Ruby,XUL and toolkit agnostic GUIs

Looking back in ruby-talk for ‘Ruby’ and ‘XUL’ shows a discussion from
November of last year about creating an XML/XUL based scheme for creating
toolkit-agnostic GUIs. There was some discussion of this as a project,
I’m just wondering if anyone starting putting anything together.

I’m currently deveoping a Ruby/FLTK GUI, but there is some talk about
moving to a Mozilla-based solution and it would be nice if I could just
code up the GUI in XML/XUL and then either generate the FLTK code or take
the XUL directly to Mozilla.

I’m wondering how callbacks would work though. I suspect that you could
have some classes that define callback methods in a similar manner for all
supported toolkits.

Anyway, just wondering if anyone has started working on something like
this.

Phil

ptkwt@aracnet.com (Phil Tomson) wrote in message news:c3tr3a0187b@enews3.newsguy.com

toolkit-agnostic GUIs. There was some discussion of this as a project,
I’m just wondering if anyone starting putting anything together.

Yeah, I’ve got some basic code working using FOX as a backend, but it
is going slowly. Not because it is difficult, but because of time
constraints. I can already generate UIs with the core widget set from
XUL. Basically, it is usable – in a limited way – for application
development, but it isn’t very complete.

I need to do some documentation, some packaging, and I wanted to get a
couple of other back-ends working as proof-of-concept before I
released it, but if you want a copy, I’ll tar it up for you.

I’m currently deveoping a Ruby/FLTK GUI, but there is some talk about
moving to a Mozilla-based solution and it would be nice if I could just
code up the GUI in XML/XUL and then either generate the FLTK code or take
the XUL directly to Mozilla.

I decided not to use FLTK because FLTK doesn’t provide layout
managers, and I’m not about to write them myself. XUL uses high-level
layout mechanisms, so I’ve been focusing on toolkits (backends) that
provide these.

You can’t use Mozilla, currently, because there’s no Mozilla->Ruby
binding that would allow the Mozilla-generated events to call Ruby
code.

— SER

Sean Russell wrote:

ptkwt@aracnet.com (Phil Tomson) wrote in message
news:c3tr3a0187b@enews3.newsguy.com

toolkit-agnostic GUIs. There was some discussion of this as a project,
I’m just wondering if anyone starting putting anything together.

Yeah, I’ve got some basic code working using FOX as a backend, but it
is going slowly. Not because it is difficult, but because of time
constraints. I can already generate UIs with the core widget set from
XUL. Basically, it is usable – in a limited way – for application
development, but it isn’t very complete.

I need to do some documentation, some packaging, and I wanted to get a
couple of other back-ends working as proof-of-concept before I
released it, but if you want a copy, I’ll tar it up for you.

Very cool! Please consider wxRuby as a backend.

[snip]

You can’t use Mozilla, currently, because there’s no Mozilla->Ruby
binding that would allow the Mozilla-generated events to call Ruby
code.

I keep hoping I can get someone interested in doing this. Mozilla would be a
fantastic platform for internet enabled and html enabled Ruby applications.

I’d like to do it myself, but I’m already involved in too many things. But
I’ll take this opportunity to (once again) to offer guidance and advice to
anyone who wants to undertake this (in a past life I did a lot of Mozilla
based development).

Curt

···

Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.610 / Virus Database: 390 - Release Date: 3/3/2004

In article 83173408.0403250954.60fa32f7@posting.google.com,

ptkwt@aracnet.com (Phil Tomson) wrote in message
news:c3tr3a0187b@enews3.newsguy.com

toolkit-agnostic GUIs. There was some discussion of this as a project,
I’m just wondering if anyone starting putting anything together.

Yeah, I’ve got some basic code working using FOX as a backend, but it
is going slowly. Not because it is difficult, but because of time
constraints. I can already generate UIs with the core widget set from
XUL. Basically, it is usable – in a limited way – for application
development, but it isn’t very complete.

I need to do some documentation, some packaging, and I wanted to get a
couple of other back-ends working as proof-of-concept before I
released it, but if you want a copy, I’ll tar it up for you.

I’m currently deveoping a Ruby/FLTK GUI, but there is some talk about
moving to a Mozilla-based solution and it would be nice if I could just
code up the GUI in XML/XUL and then either generate the FLTK code or take
the XUL directly to Mozilla.

I decided not to use FLTK because FLTK doesn’t provide layout
managers, and I’m not about to write them myself. XUL uses high-level
layout mechanisms, so I’ve been focusing on toolkits (backends) that
provide these.

You can’t use Mozilla, currently, because there’s no Mozilla->Ruby
binding that would allow the Mozilla-generated events to call Ruby
code.

I’m thinking that we would just use Ruby to generate Mozilla XUL. We
would be able to transform our GUI XML descriptions into XUL as one of
thee targets. In that case we’re generating JavaScript code to handle
events.

The question is how do we describe event handling code in a toolkit
neutral way (is it even possible)? I know that in Ruby/FLTK we currently
make heavy use of blocks in a very Ruby-ish way:

Fl_Button.new(200,310,45,25, “Finish”){|o|
o.callback(“”){|o,ud|
#rubycode here:
#that’s all folks
cleanup
file << report_time
file.close
exit
}
}

In XUL:

So how do we describe differnt types of code, maybe:

…just thinking out loud.

Phil

···

Sean Russell ser@germane-software.com wrote:

ptkwt@aracnet.com (Phil Tomson) wrote in message news:c3v8j502j6k@enews4.newsguy.com

I’m thinking that we would just use Ruby to generate Mozilla XUL. We
would be able to transform our GUI XML descriptions into XUL as one of
thee targets. In that case we’re generating JavaScript code to handle
events.

It doesn’t do anything for me if I can’t write my application in Ruby.
I suppose we could set up some sort of socket-communication between
the Ruby application and Mozilla process, but this seems fragile and
cobbled together.

The question is how do we describe event handling code in a toolkit
neutral way (is it even possible)? I know that in Ruby/FLTK we currently
make heavy use of blocks in a very Ruby-ish way:

I’ve come to the conclusion that sockets and signals are the best way
of binding applications to GUIs. It is the only way that I know of
that separates the control from the view. Otherwise, you end up with
GUI code in your application, or application code in your GUI, and
neither is very attractive.

Fl_Button.new(200,310,45,25, “Finish”){|o|
o.callback(“”){|o,ud|
#rubycode here:
#that’s all folks
cleanup
file << report_time
file.close
exit
}
}

In XUL:

I’d prefer:

The view (XUL):

<button id='quit' label='_Quit'/>
<button id='save' label='_Save'/>

The control (Ruby):

gui.bind( 'quit', app.method( :quit ) )
gui.bind( 'save' ) { app.save }          # Alternative

So how do we describe differnt types of code, maybe:

I would really, really rather not embed code in the XUL, or in any
GUI code whatsoever. That defeats the whole purpose of XUL, and you
might as well just use a regular embedded GUI API in your application.

Seriously, though… there are (IMO) only two reasons to use XUL:

  1. You can run Ruby from Mozilla, so Mozilla is your application
    deployment platform, or
  2. You can have a clean separation between the model/view/controller.

— SER