Re: Gtk2::Table widget alignment



-- Gavin Brown <gavin brown uk com> wrote
(on Friday, 15 August 2003, 03:07 PM +0100):
in such situations i've made a habit of rearranging things so that i can
vectorize the creation of the table rows.  this has the added benefit of
decoulpling things so that you can rearrange and replace them quite easily. 
perl is great for this sort of thing.

  # declare the row relationships as data rather than code
  @rows = (
     { label => 'foo', type => 'entry', var => \$foo_val }
     { label => 'bar', type => 'bool', var => \$bar_val }
     { label => 'baz', type => 'entry', var => \$baz_val }
  );
  foreach my $r (@rows) {
     # write the logic to create a row once
     # with different cases for different row types
  }

I always thought there was was a space for a module that might be called
Gtk2::Form, that basically did all that stuff for you. Would probably
make the creation of preferences dialogs a *lot* easier.

Actually, I was about to reply to the parent mail in this thread, but I
think this might be a better spot for it...

Those who've been monitoring the list the last couple weeks have
probably seen a few questions from me. I use a file manager called
ROX-Filer; it's a nice Gtk2 (as of version 2.0.0) app that also can
provide a pinboard with icons and panels. The author has made it very
easy for other Gtk2 processes to interact with it, and built a python
library called ROX-Lib2 to provide an easy way to build applets for the
panel and simple-to-complex applications that interact with the filer.

The interesting thing is that the way in which they interact is fairly
universal (uses DND, SOAP-RPC, and Gtk Socket/Plug pairs), and also that
they utilize a concept called 'AppDir's. These application directories
contain an executable (called AppRun) and an information file (called
AppInfo.xml), and an optional icon (.DirIcon); simply double-click on
the directory, and the program springs to life. 

But I digress.

I wanted to write apps to utilize with the filer, but didn't want to
learn python. So I took the long route, and started creating
'librox-perl', a python->perl translation of ROX-Lib2. The reason I
bring it up is that it's doing a lot of what muppet and Gavin are
talking about. One module, ROX::OptionsBox, takes an XML file, grabs
nodes out of it, and creates a dialog; different 'sections' are
represented as notebooks, and these are separated into frames and
whatnot. It then has ways to build checkbox, radio, and entry widgets
and store the values. I've tried to make it subclassable, too, so that
an author could add custom widgets that can utilize the same
architecture for saving the data (which is saved in an XML doc).

It's intended for a ROX-Filer using/developing audience, but it doesn't
necessarily need to be confined to that arena; an application developed
with these perl modules could work in any environment, really. I've
documented fairly heavily with POD, so if you choose to look at it, you
should be able to pick things up. You might want to take a short look at
http://freedesktop.org and look at their specs on the Choices system,
too, as the options created with these modules are intended to be saved
using that spec (a design decision I decided to utilize from ROX-Lib2).

You can find what I've done at:
    http://sourceforge.net/projects/librox-perl/ 

I just finished the OptionsBox stuff last night, and need to test one
more thing before making a new release; you might want to check stuff
out from CVS, or wait until this evening or tomorrow morning (US eastern
time) if you're interested in the form stuff. I hope to add some more
widgets to it eventually -- a file selection dialog would be nice, for
instance -- and if you're interested in contributing...

Just one of the many things I've never got round to doing :-/

It's amazing what unemployment can do for one's OSS productivity...
Fortunately, or unfortunately, depending on how you look at it, I start
a new job next week.

-- 
Matthew Weier O'Phinney
http://weierophinney.net/matthew/



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]