[Glade-users] libglade, GtkDrawingArea, GdkEvents ?
e98cuenc@free.fr
e98cuenc@free.fr
Tue, 12 Aug 2003 18:13:30 +0200
In addition of adding the callback in glade, you should also connect to the
callback on your code using glade_xml_signal_connect, or connect at the same
time all the callbacks using glade_xml_signal_autoconnect (if you want to use
autoconnect, you should export the symbols of your executable. Using the -
export-dynamic option of libtool should do the trick in a portable way).
Cheers,
Selon goth goth <oogothoo@yahoo.fr>:
> Hello,
>
> I realise a simple application using libglade 2, Gtk
> 2.2 : a GtkDrawingArea in a GtkWindow.
>
> window : signal destroy connect to gtk_main_quit
> drawingarea : signals button_release_event and
> motion_notify_event on two function who g_print event.
>
> drawingarea use the string "00000000001000000100" to
> the GdkEvent (activate GDK_MOTION_NOTIFY_MASK and
> GDK_BUTTON_RELEASE_MASK).
>
> Events are not send : no error message but no action
> What is the problem ?
>
> This is the code :
>
> ----------------------------------
>
> #include <gtk/gtk.h>
> #include <glade/glade.h>
>
> gboolean
> on_drawingarea_motion_notify_event(GtkWidget *widget,
> GdkEventMotion *event)
> {
> g_print("%f %f.\n", event->x, event->y);
> return TRUE;
> }
>
>
>
> gboolean
> on_drawingarea_button_release_event(GtkWidget *widget,
> GdkEventButton *event)
> {
> g_print("bouton = %d.\n", event->button);
> return TRUE;
> }
>
>
> int
> main(int argc, char **argv)
> {
> GladeXML *xml;
>
> gtk_init(&argc, &argv);
> glade_init();
>
> xml = glade_xml_new("test.glade", NULL, NULL);
>
> if(!xml)
> {
> g_warning("error loading gtk.glade");
> return 1;
> } else {
> glade_xml_signal_autoconnect(xml);
> gtk_main();
> return 0;
> }
> }
>
> -------------------------------
>
> This is the test.glade :
>
> <?xml version="1.0" standalone="no"?> <!--*- mode: xml
> -*-->
> <!DOCTYPE glade-interface SYSTEM
> "http://glade.gnome.org/glade-2.0.dtd">
>
> <glade-interface>
>
> <widget class="GtkWindow" id="window">
> <property name="visible">True</property>
> <property name="title"
> translatable="yes">window</property>
> <property name="type">GTK_WINDOW_TOPLEVEL</property>
> <property
> name="window_position">GTK_WIN_POS_NONE</property>
> <property name="modal">False</property>
> <property name="resizable">True</property>
> <property
> name="destroy_with_parent">False</property>
> <signal name="destroy" handler="gtk_main_quit"
> last_modification_time="Mon, 11 Aug 2003 22:50:33
> GMT"/>
>
> <child>
> <widget class="GtkDrawingArea" id="drawingarea">
> <property name="visible">True</property>
> <property name="can_default">True</property>
> <property name="can_focus">True</property>
> <property name="events">GDK_POINTER_MOTION_MASK
> | GDK_BUTTON_RELEASE_MASK</property>
> <property
> name="extension_events">GDK_EXTENSION_EVENTS_CURSOR</property>
> <signal name="motion_notify_event"
> handler="on_drawingarea_motion_notify_event"
> last_modification_time="Mon, 11 Aug 2003 22:57:56
> GMT"/>
> <signal name="button_release_event"
> handler="on_drawingarea_button_release_event"
> last_modification_time="Mon, 11 Aug 2003 22:58:03
> GMT"/>
> </widget>
> </child>
> </widget>
>
> </glade-interface>
>
>
>
>
>
> ___________________________________________________________
> Do You Yahoo!? -- Une adresse @yahoo.fr gratuite et en français !
> Yahoo! Mail : http://fr.mail.yahoo.com
> _______________________________________________
> Glade-users maillist - Glade-users@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/glade-users
>