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

Rapid program development tools



I've been playing around with Glade and libglade from the GNOME project
over the last week, and I've been amazed by what it can do.  Glade is a
Gtk GUI builder, and libglade is a library that allows run-time creation
of the GUI from the XML file spat out by Glade.

What this means is that a basic application with a quit button looks like
this:

#include <gtk/gtk.h>
#include <glade/glade.h>

int main(int argc, char *argv[]) {
  gtk_init(&argc, &argv);
  glade_init();
  glade_xml_signal_autoconnect(glade_xml_new("gui.xml",NULL));
  gtk_main();
  return 0;
}

void on_Quit_clicked(GtkWidget *widget,GdkEvent *event,gpointer data) {
  gtk_main_quit();
}

You then use Glade to build a GUI that has a quit button, and connect the
'clicked' signal to on_Quit_clicked.  The magic here is
glade_xml_signal_autoconnect, which does gmodule_open(NULL) to look up
functions by name in the current program (as opposed to loading an
external .so).  When it hits a <signal> definition in the source XML, it
looks up the appropriate signal and connects it.  Piece of cake.

It seems that if anyone has been wanting to start writing any kind of
reasonably simply program, this removes one of the very last reasons to
procrastinate.  It's truly a piece of cake to get something functional.

I'm working with a friend of mine on a series of tutorials on programming
in the GNOME environment (using lib* as provided by GNOME and friends),
and the first thing I'm writing is the section on Glade.  It'll be
available on my site as soon as I get it presentable, and you can browse
through it and see what I mean.

BTW, there are bindings for this in several languages, including Perl,
C++, Ada95, and Python.  I'm going to try doing something with Perl to see
how well it works, as soon as the webpage for the thing comes back up
again.

Oh yeah... If you want to start playing around with this stuff, you can
snag snapshot RPMs from anakin.cse.ogi.edu in /pub/gnome/cvssnap/.  Make
sure you get the 990425 or later snapshots, as there are some bugs in
previous ones.

TTYL,
    Omega

         Erik Walthinsen <omega@cse.ogi.edu> - Staff Programmer @ OGI
        Quasar project - http://www.cse.ogi.edu/DISC/projects/quasar/
   Video4Linux Two drivers and stuff - http://www.cse.ogi.edu/~omega/v4l2/
        __
       /  \             SEUL: Simple End-User Linux - http://www.seul.org/
      |    | M E G A           Helping Linux become THE choice
      _\  /_                          for the home or office user