On 12/08/05, Michal Porzuczek <[EMAIL PROTECTED]> wrote: > On 8/12/05, Yiannis <[EMAIL PROTECTED]> wrote: > > Hi, > > > > my callback on the button press event seems not to be called... in > > fact I am not sure if a button press event occurs. Find below a simple > > program (using glade/libglade) that makes a drawing area and a 2 > > callbacks... The expose event and the button press event callback. > > > > Hi, > > I'm not 100% sure since I've never used Glade before and I'm not sure > if it takes care of it, but I know with GTK you have to include: > > gtk_widget_set_events (Drawing_Area, GDK_EXPOSURE_MASK > | GDK_LEAVE_NOTIFY_MASK > | GDK_BUTTON_PRESS_MASK); >
Cheers, this missing bit on my code seems to be the problem, as if you take it out from the original scribble tutorial program there are no "responses" to button press events. However, firstly I never understood what is meant by the following (taken from the gtk tutorial) "As for other signals, to determine what happens when an event occurs we call gtk_signal_connect(). But we also need let GTK know which events we want to be notified about. To do this, we call the function: gtk_widget_set_events" Doesn't gtk sends these events??? And what these have to do with the button press event? Anyway including this on my code gives me the following error: (md:9727): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed which if I recall well it has to do with when you call gtk_widget_set_events, I think it has to go before showing the toplevel widget.... but in my case the only thing I can do is hide the window and gtk_widget_show after setting the events... which I tried and still gives the same error. > > Michal > > > > > > -------------------------------------------------------------------------------------------------- > > > > <?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="window1"> > > <property name="visible">True</property> > > <property name="title" translatable="yes">window1</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> > > <property name="decorated">True</property> > > <property name="skip_taskbar_hint">False</property> > > <property name="skip_pager_hint">False</property> > > <property name="type_hint">GDK_WINDOW_TYPE_HINT_NORMAL</property> > > <property name="gravity">GDK_GRAVITY_NORTH_WEST</property> > > <property name="focus_on_map">True</property> > > > > <child> > > <widget class="GtkDrawingArea" id="drawingarea1"> > > <property name="visible">True</property> > > <signal name="button_press_event" > > handler="on_drawingarea1_button_press_event" > > last_modification_time="Fri, 12 Aug 2005 13:45:43 GMT"/> > > <signal name="expose_event" > > handler="on_drawingarea1_expose_event" last_modification_time="Fri, 12 > > Aug 2005 13:45:53 GMT"/> > > </widget> > > </child> > > </widget> > > > > </glade-interface> > > > > > > ---------------------------------------------------------------------------------------------------------------- > > > > > > #include <stdlib.h> > > #include <gtk/gtk.h> > > #include <glade/glade.h> > > > > GladeXML *Xml; > > > > void > > on_drawingarea1_expose_event(GtkWidget *widget, GdkEventExpose *event, > > gpointer data); > > > > void > > button_press_event(GtkWidget *widget, GdkEventButton *event, gpointer data); > > > > void > > on_drawingarea1_expose_event(GtkWidget *widget, GdkEventExpose *event, > > gpointer data) > > { > > g_print("expose event\n"); > > } > > > > void > > on_drawingarea1_button_press_event(GtkWidget *widget, GdkEventButton > > *event, gpointer data) > > { > > g_print("button press event %d %d\n", event->x, event->y); > > } > > > > > > gint > > main(int argc, char *argv[]) > > { > > GtkWidget *drawing_area; > > > > gtk_init(&argc, &argv); > > glade_init(); > > > > /* load the interface */ > > Xml = glade_xml_new("test_button_press.glade", NULL, NULL); > > > > /* > > drawing_area = glade_xml_get_widget(Xml, "drawingarea1"); > > gtk_signal_connect (GTK_OBJECT (drawing_area), "expose_event", > > (GtkSignalFunc) on_drawingarea1_expose_event, NULL); > > gtk_signal_connect (GTK_OBJECT (drawing_area), "button_press_event", > > (GtkSignalFunc) on_drawingarea1_button_press_event, > > NULL); > > */ > > > > /* connect the signals in the interface */ > > glade_xml_signal_autoconnect(Xml); > > > > /* start the event loop */ > > gtk_main(); > > > > return 0; > > } > > > > > > > > > > > > > > -- > > -- Yiannis > > _______________________________________________ > > gtk-app-devel-list mailing list > > gtk-app-devel-list@gnome.org > > http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > -- -- Yiannis _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list