[Glade-users] Strange differences with gtk and libglade
Damon Chaplin
damon@karuna.uklinux.net
Wed, 06 Oct 2004 17:39:57 +0100
On Wed, 2004-10-06 at 19:25, antongiulio wrote:
> Hi,
> (sorry for my bad english)
> (for my mistake this mail sent gtk-list too:( sorry)
>
> I'm learning to use gtk and libglade libraries.
>
> I have made a simple GtkWindow manually and with glade-2.6.0 program (just .glade file to use with libglade).
> In manual-window I have added a 'close-button' with this signal:
>
> g_signal_connect (G_OBJECT (button_close), "clicked",
> G_CALLBACK (do_things_and_exit), (gpointer) window);
>
> and relative callback handler:
>
> void
> do_things_and_exit (GtkButton * button, gpointer user_data)
> {
> /* various things */
> .................
>
> gtk_widget_destroy (GTK_WIDGET (user_data));
>
> }
>
> This code works properly (press close button: do various things and close window).
>
> With glade program I have edited a window.glade file and added to 'close-button' property this signal:
>
> signal: clicked
> handler: do_things_and_exit
> object: window
>
> launch signals with:
>
> glade_xml_signal_autoconnect(window_xml_glade);
>
> but when I press close-button, just close-button is deleted and window is on again... WHY???
If you set the 'object:' field, that object becomes the first argument
to the callback.
So if you did this it would work:
gtk_widget_destroy (GTK_WIDGET (button));
Lots of people are confused by the 'object:' field, so it is best to
just not use it.
> Last question:
>
> How is it possibile pass a constant value with libglade?
>
> In manual-gtk I have:
>
> g_signal_connect (G_OBJECT (my_button_widget), "clicked",
> G_CALLBACK (my_handler), GINT_TO_POINTER (1000));
>
> and with libglade???
You can use glade_xml_signal_connect_data(). See:
http://developer.gnome.org/doc/API/2.0/libglade/GladeXML.html#glade-xml-signal-connect-data
Damon