Passing objects to libglade callbacks



Hi,
I put a button on a glade-2.0 window. In the properties form,
i selected the "clicked" signal. For the handler, i entered
"on_button_clicked". For the object, i entered "1" (without
the quotes).

In the following gtk+2 program, when i click the button, the
on_button_clicked callback prints a very large integer instead
of "1". Why?

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

void on_button_clicked(GtkWidget *widget, gpointer user_data) {
        g_print("Butt=%d\n",GPOINTER_TO_INT(user_data));
//      g_print("Butt=%d\n",*((gint*)user_data));
}

int main(int argc, char *argv[])
{
    GladeXML *xml;

    gtk_init(&argc, &argv);
    glade_init();

    /* load the interface */
    xml = glade_xml_new("keypad.glade",NULL,NULL);
    /* connect the signals in the interface */
    glade_xml_signal_autoconnect(xml);
    /* start the event loop */
    gtk_main();
    return 0;
}




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