Converting from GTK+ to Gtkmm

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

 



Hello,

I have written a program in C using GTK+ and libglade.  Its callbacks
do things like this:

void cb_reset( GtkWidget *widget,
               gpointer   data )
{
  GladeXML *xml;
  GtkWidget *pg_val;
  GtkWidget *ri_val;
  GtkWidget *cf_val;
  GtkWidget *og_result;
  GtkWidget *abv_result;

  xml = glade_get_widget_tree (GTK_WIDGET (widget));
  pg_val = glade_xml_get_widget (xml, "pg_entry");
  ri_val = glade_xml_get_widget (xml, "ri_entry");
  cf_val = glade_xml_get_widget (xml, "cf_entry");
  og_result = glade_xml_get_widget (xml, "og_result");
  abv_result = glade_xml_get_widget (xml, "abv_result");

  gtk_spin_button_set_value (GTK_SPIN_BUTTON(pg_val), 0.0);
[...]
  gtk_label_set_text (GTK_LABEL(abv_result), "");
  gtk_widget_grab_focus (pg_val);
}

The callbacks have two parts:
1. Getting the XML tree and getting the widgets required from the
   tree.
2. Performing some actions using those widgets.

This means that all of the interface construction is done entirely
with Glade, and only the callbacks are in the C source file (no need
to bung the widgets in a structure and pass them in as "gpointer data"
like I did before).

Looking at Glademm, it seems can do this, but I'm not sure how to get
the XML tree (Gnome::Glade::Xml) from within the callback.  Is it
possible?  The example callbacks I've seen didn't usually take
arguments.  In an ideal world, I'd like the callbacks to be set-up
automatically by libglademm, like I get with
glade_xml_signal_autoconnect().  Could this be done?

Should using gtkmm/libglademm result in cleaner code than
libgtk/libglade?  From the little I've seen of it so far, things like
signals actually look more complex, but I'm not yet as experienced
with C++ as I am with C.


Thanks,
Roger

-- 
Roger Leigh

                Printing on GNU/Linux?  http://gimp-print.sourceforge.net/
                GPG Public Key: 0x25BFB848 available on public keyservers


[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux