RE: [gtkmm] Converting from GTK+ to Gtkmm



1. With libglademm, you need to manually connect your signals after getting
the widgets from the Gnome::Glade::Xml. There is no autoconnect yet.
2. I don't think you need to get the Gnome::Glade::Xml from the widget. You
should probably just remember the Gnome::Glade::Xml that you used, as a
member variable. But I was not even aware of this function so you might want
to patch libglademm to support it.

Murray Cumming
murrayc usa net
www.murrayc.com 

> -----Original Message-----
> From: Roger Leigh [mailto:roger whinlatter uklinux net] 
> Sent: Montag, 7. Juli 2003 21:55
> To: gtkmm-list gnome org
> Subject: [gtkmm] Converting from GTK+ to Gtkmm
> 
> 
> Hello,
> 
> [Previously posted to gtk-list; I hope this is the correct list.]
> 
> 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
> _______________________________________________
> gtkmm-list mailing list
> gtkmm-list gnome org
> http://mail.gnome.org/mailman/listinfo/gtkmm-list
> 



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