[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

[Q] Ruby and XUL?

Daniel Carrera

10/29/2003 8:39:00 AM

Hi all,

I just read a neat article at IBM DeveloperWorks:

http://www-106.ibm.com/developerworks/web/library/wa-appmozx/?ca=dgr-lnxw02Mozilla...

It's about writing GUIs with Mozilla's XUL. I must say I'm very
impressed. XUL looks like a great idea. Writing GUIs is traditionally a
long and tedious process. XUL is an XML-based way of writing GUIs very
easily. For example, here is a menu bar:

<menubar id="menubar">
<menu id="File" accesskey="F" label="File">
<menupopup>
<menuitem id="f1" label="New" accesskey="L" oncommand="new()"/>
<menuitem id="f2" label="Open" accesskey="O" oncommand="open()"/>
<menuitem id="f3" label="Save" accesskey="S" oncommand="save()"/>
<menuitem id="f4" label="Print" accesskey="P" oncommand="print()"/>
</menupopup>
</menu>
</menubar>

So, defining the GUI structure is easy and clear. All the programning
logic is left for an actual programming language.

Unfortunately, it seems that the only language supported is JavaScript. =(
I don't particularly like JavaScript.

I was just wondering what it would take to be able to use Ruby for the
programming logic. I guess that one way is to convince the Mozilla
project to ship Ruby with Mozilla. But I wouldn't count on that.

Re-implementing XUL would be very difficult, I imagine.

But over-all, I think I like the idea of using XML for the GUI structure
and a programming language for the behaviour. This strikes me as a good
combination (but then again, I am not a very experienced programmer).

Cheers,
--
Daniel Carrera | OpenPGP KeyID: 9AF77A88
PhD grad student. |
Mathematics Dept. | "To understand recursion, you must first
UMD, College Park | understand recursion".

19 Answers

Pablo Lorenzzoni

10/29/2003 8:56:00 AM

0

Hello!

Em Qua, 29 Out 2003, Daniel Carrera escreveu:
| I was just wondering what it would take to be able to use Ruby for the
| programming logic. I guess that one way is to convince the Mozilla
| project to ship Ruby with Mozilla. But I wouldn't count on that.

Hm... implementing XUL in Ruby would be very easy. The problem have,
actually, two sides:

(1) Either we want Mozilla to use Ruby to draw their GUI - and I think
they'd never do that since JavaScript is the "de facto" language for
client-side applications

(2) Or we want to use XUL's scheme in our Ruby programs - which can be
more interesting... writing our GUIs using XML is, surely, much easier
than the traditional method. The problem is that Ruby doesn't have a
"standard" Graphical Toolkit... So, "our XUL" either have to be bound to
some existing Toolkit and act as "yet another layer" for the GUI
programming, or (which I think is more interesting) act as an agnostic
layer, working with just any Toolkit.

| But over-all, I think I like the idea of using XML for the GUI structure
| and a programming language for the behaviour. This strikes me as a good
| combination (but then again, I am not a very experienced programmer).

The idea is not new. I think Glade, for the Gtk, can save it's
structures in an XML format to be loaded inside the program. If we could
imagine an "agnostic" Glade that outputs XML in the XUL format, and make
it work with any toolkit Ruby support... that sounds as a good idea.

[]s

Pablo
--
Pablo Lorenzzoni (Spectra) <spectra@debian.org>
GnuPG: 0x268A084D at pgp.mit.edu/keyring.debian.org
This message is protected by DoubleROT13 encryption
Attempting to decode it violates the DMCA/WIPO acts

Daniel Carrera

10/29/2003 9:14:00 AM

0

On Wed, Oct 29, 2003 at 05:56:24PM +0900, Pablo Lorenzzoni wrote:

> | I was just wondering what it would take to be able to use Ruby for the
> | programming logic.
[snip]
> (2) Or we want to use XUL's scheme in our Ruby programs - which can be
> more interesting... writing our GUIs using XML is, surely, much easier
> than the traditional method. The problem is that Ruby doesn't have a
> "standard" Graphical Toolkit... So, "our XUL" either have to be bound to
> some existing Toolkit and act as "yet another layer" for the GUI
> programming, or (which I think is more interesting) act as an agnostic
> layer, working with just any Toolkit.

That's a very interesting idea. I hadn't thought of that. I could write
a GUI program with Ruby and (let's call it) RubyXUL. I can run it with
one toolkit and you can run it with another (because they both have a
wrapper for RubyXUL).

That would be a neat way to meet differences in platforms and personal
taste. I don't have to worry about the fact that my GtkRuby application
won't run under Mac. Or that Fox doesn't look good under KDE.

Also, we don't have to exactly copy Mozilla's XUL. If there's any place
where we feel that the Mozilla team went wrong, we can change it in ours.

Okay, XUL is XML. Ruby comes with an XML parser, so that's not a
problem.


> If we could imagine an "agnostic" Glade that outputs XML in the XUL
> format, and make it work with any toolkit Ruby support... that sounds
> as a good idea.

Indeed.

So I guess that for each toolkit we'd need a library that can interpret
read XUL and produce the GUI.

There can be an environment variable which specifies which toolkit the
user wants.

I had never thought of designing toolkit-agnostic GUIs. That's a very
neat idea.

Cheers,
--
Daniel Carrera | OpenPGP KeyID: 9AF77A88
PhD grad student. |
Mathematics Dept. | "To understand recursion, you must first
UMD, College Park | understand recursion".

Raphael Bauduin

10/29/2003 9:14:00 AM

0

It's funny, I just wondered yesterday what it would take to integrate
ruby to mozilla so I could use ruby in place of javascript.

Maybe it could be done (if the whole idea is realistic of course ;-) as
a module/extension to install so it wouldn't have to be shipped with
mozilla.

There's already an xpcom binding for ruby (not sure it's still active
though : http://rbxpcom.m... ).

Raph

Daniel Carrera wrote:
> Hi all,
>
> I just read a neat article at IBM DeveloperWorks:
>
> http://www-106.ibm.com/developerworks/web/library/wa-appmozx/?ca=dgr-lnxw02Mozilla...
>
> It's about writing GUIs with Mozilla's XUL. I must say I'm very
> impressed. XUL looks like a great idea. Writing GUIs is traditionally a
> long and tedious process. XUL is an XML-based way of writing GUIs very
> easily. For example, here is a menu bar:
>
> <menubar id="menubar">
> <menu id="File" accesskey="F" label="File">
> <menupopup>
> <menuitem id="f1" label="New" accesskey="L" oncommand="new()"/>
> <menuitem id="f2" label="Open" accesskey="O" oncommand="open()"/>
> <menuitem id="f3" label="Save" accesskey="S" oncommand="save()"/>
> <menuitem id="f4" label="Print" accesskey="P" oncommand="print()"/>
> </menupopup>
> </menu>
> </menubar>
>
> So, defining the GUI structure is easy and clear. All the programning
> logic is left for an actual programming language.
>
> Unfortunately, it seems that the only language supported is JavaScript. =(
> I don't particularly like JavaScript.
>
> I was just wondering what it would take to be able to use Ruby for the
> programming logic. I guess that one way is to convince the Mozilla
> project to ship Ruby with Mozilla. But I wouldn't count on that.
>
> Re-implementing XUL would be very difficult, I imagine.
>
> But over-all, I think I like the idea of using XML for the GUI structure
> and a programming language for the behaviour. This strikes me as a good
> combination (but then again, I am not a very experienced programmer).
>
> Cheers,

gabriele renzi

10/29/2003 11:31:00 AM

0

il Wed, 29 Oct 2003 17:56:24 +0900, Pablo Lorenzzoni
<spectra@debian.org> ha scritto::

>Hello!
>

>The idea is not new. I think Glade, for the Gtk, can save it's
>structures in an XML format to be loaded inside the program. If we could
>imagine an "agnostic" Glade that outputs XML in the XUL format, and make
>it work with any toolkit Ruby support... that sounds as a good idea.

may I point you to QTDesigner?
It outputs a .ui file wich is XML and very well documented.

The UI file is then 'compiled' in actual code (from 'uic' or Pyuic o
rbuic that I saw somewhere in the kde cvs :)

Actually, it should be quite toolkit-agnostic, cause there is a ui
compiler that outputs java AWT/Swing code..

ptkwt

10/29/2003 3:53:00 PM

0

In article <20031029085552.GA11776@eriador>,
Pablo Lorenzzoni <spectra@debian.org> wrote:
>Hello!
>
>Em Qua, 29 Out 2003, Daniel Carrera escreveu:
>| I was just wondering what it would take to be able to use Ruby for the
>| programming logic. I guess that one way is to convince the Mozilla
>| project to ship Ruby with Mozilla. But I wouldn't count on that.
>
>Hm... implementing XUL in Ruby would be very easy. The problem have,
>actually, two sides:
>
>(1) Either we want Mozilla to use Ruby to draw their GUI - and I think
>they'd never do that since JavaScript is the "de facto" language for
>client-side applications

Well, Mozilla is open source and it does have a plug-in architecture
(doesn't it?). Would it be possible to create a plug-in that allows you
to use Ruby for XUL as an alternative to JavaScript?

Alternatively, what if Ruby was used to generate the required JavaScript
code? That way you wouldn't have to touch (or even know JavaScript) to
use XUL, and it's probably a lot easier than the plug-in suggestion above.
....well, on second thought, maybe it wouldn't be that easy.

Phil

Robert Klemme

10/29/2003 4:05:00 PM

0


"Daniel Carrera" <dcarrera@math.umd.edu> schrieb im Newsbeitrag
news:20031029083840.GA775@math.umd.edu...
> Hi all,
>
> I just read a neat article at IBM DeveloperWorks:
>
>
http://www-106.ibm.com/developerworks/web/library/wa-appmozx/?ca=dgr-lnxw02Mozilla...
>
> It's about writing GUIs with Mozilla's XUL. I must say I'm very
> impressed. XUL looks like a great idea. Writing GUIs is traditionally
a
> long and tedious process. XUL is an XML-based way of writing GUIs very
> easily. For example, here is a menu bar:
>
> <menubar id="menubar">
> <menu id="File" accesskey="F" label="File">
> <menupopup>
> <menuitem id="f1" label="New" accesskey="L" oncommand="new()"/>
> <menuitem id="f2" label="Open" accesskey="O" oncommand="open()"/>
> <menuitem id="f3" label="Save" accesskey="S" oncommand="save()"/>
> <menuitem id="f4" label="Print" accesskey="P" oncommand="print()"/>
> </menupopup>
> </menu>
> </menubar>
>
> So, defining the GUI structure is easy and clear. All the programning
> logic is left for an actual programming language.

BUT: the "long and tedious" of the process does not come from setting up
the structure IOW doing the layout. That's easily done with current UI
designers.

The hard part is to connect the GUI elements with each other AND with the
model via signals. That's where most logic resides and as far as I can
see a UI structure defined in XML doesn't help you there. Interactions in
the UI can get very complex if you are trying to make things usable.

My EUR 0.02...

robert

Erik Terpstra

10/29/2003 4:37:00 PM

0

Phil Tomson wrote:
> Well, Mozilla is open source and it does have a plug-in architecture
> (doesn't it?). Would it be possible to create a plug-in that allows you
> to use Ruby for XUL as an alternative to JavaScript?
>
> Alternatively, what if Ruby was used to generate the required JavaScript
> code? That way you wouldn't have to touch (or even know JavaScript) to
> use XUL, and it's probably a lot easier than the plug-in suggestion above.
> ...well, on second thought, maybe it wouldn't be that easy.

I usually make server side generated XUL interfaces (with Ruby) and
avoid client-side scripting as much as possible.

It's exactly the same as writing CGI programs in Ruby, except that you
are generating XUL markup instead of HTML markup.

The only difference in this case is that HTML generating CGI programs
have the look and feel of a website, whereas XUL generating CGI
program's have the look and feel of a native application.

Sending form data, and dynamically refreshing trees/lists can be done
with a couple of JavaScript one-liners.

Server-side scripts are also much easier for testing and debugging.

Erik.

Eric Hodel

10/29/2003 4:45:00 PM

0



Daniel Carrera (dcarrera@math.umd.edu) wrote:

> Hi all,
>=20
> I just read a neat article at IBM DeveloperWorks:

=2E..

> So, defining the GUI structure is easy and clear. All the programning=20
> logic is left for an actual programming language.

Yes, XUL is great

> Unfortunately, it seems that the only language supported is JavaScript. =
=3D(
> I don't particularly like JavaScript.
>=20
> I was just wondering what it would take to be able to use Ruby for the=20
> programming logic. I guess that one way is to convince the Mozilla=20
> project to ship Ruby with Mozilla. But I wouldn't count on that.

In order to script XUL, you need to plug into Mozilla's XPCOM layer,
Mozilla ships with Javascript and C++ support built in, but all the
popular scripting languages are also supported:

http://rbxpcom.m... -- Ruby
http://aspn.activestate.com/ASPN/Downloads/Komod... -- Python
http://plxpcom.m... -- Perl
http://www.mozilla.org/projects/blackwoo... -- Java

Of course, you'll need to compile the component and plug it into
Mozilla.

--=20
Eric Hodel - drbrain@segment7.net - http://se...
All messages signed with fingerprint:
FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04




-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.2 (FreeBSD)

iD8DBQE/n+6KMypVHHlsnwQRAo16AJ9X9PjnF0HeAvftJOrAeRdW+MvJFgCfQFAD
RzdcUzcG9LLBWN5sj38LRkU=
=Bz+s
-----END PGP SIGNATURE-----


Pierre Baillet

10/29/2003 5:10:00 PM

0

Hi,

sorry to sound like a bad boy, but XPCOM bindings only allows you to
call mozilla XPComp components from your favortie scriting langage. So
you can, for instance, create a mqil component, make it connacts and
fetch mail via ruby but you'll never be able to ask it to draw an
alert on the user's screen.

XPCOM is the equivalent of windows' COM while XUL is the equivalent of a
higher level GDI. They only share javascript in common and the *XPCOM
bridges allows you to connect to the XPCOM world, not the xul one.

Plus the rbxpcom is, IIRC, a bit outdated thoug I don't think i've
managed to build it back when mozilla 1.0 went out.

hth,

On Wed, Oct 29, 2003, Eric Hodel wrote:
>
> In order to script XUL, you need to plug into Mozilla's XPCOM layer,
> Mozilla ships with Javascript and C++ support built in, but all the
> popular scripting languages are also supported:
>
> http://rbxpcom.m... -- Ruby
> http://aspn.activestate.com/ASPN/Downloads/Komod... -- Python
> http://plxpcom.m... -- Perl
> http://www.mozilla.org/projects/blackwoo... -- Java
>
> Of course, you'll need to compile the component and plug it into
> Mozilla.

Pierre.
--
Pierre Baillet
Je pompe donc je suis.
Devise Shadok

Robert Feldt

10/29/2003 5:34:00 PM

0

Daniel Carrera wrote:

>I just read a neat article at IBM DeveloperWorks:
>
>http://www-106.ibm.com/developerworks/web/library/wa-appmozx/?ca=dgr-lnxw02Mozilla...
>
>It's about writing GUIs with Mozilla's XUL. I must say I'm very
>impressed. XUL looks like a great idea.
>
I've also looked at XUL and think its promising (especially since I
found that both Firebird and Thunderbird's GUI's are done in XUL). My
idea on making it kind-of-work with Ruby would be to simply serve XUL
xml etc from a Ruby app. Could it work as long as you stay with the
default components? I understand that to make new components/widgets
you'd need to use rbxpcom or revert to javascript for the wdiget code.

I guess instead of writing it in XML we could do a YAML layer and output
the XUL XML from the objects created by the YAML loader.

Regards,

Robert