On Tue, 2014-03-11 at 14:01 +0000, Richard Shann wrote: > On Tue, 2014-03-11 at 13:18 +0100, Joël Krähemann wrote: > > On Tue, 2014-03-11 at 08:12 +0000, Richard Shann wrote: > > > On Tue, 2014-03-11 at 04:43 +0100, Joël Krähemann wrote: > > > > On Mon, 2014-03-10 at 09:52 +0000, Richard Shann wrote: > > > > > On Mon, 2014-03-10 at 09:29 +0100, Joël Krähemann wrote: > > > > > > On Mon, 2014-03-10 at 09:26 +0100, Joël Krähemann wrote: > > > > > > > On Sun, 2014-03-09 at 14:03 +0000, Richard Shann wrote: > > > > > > > > > From: Jo?l Kr?hemann <j...@weedlight.ch> > > > > > > > > > To: gtk-app-devel-list@gnome.org > > > > > > > > > Subject: Re: Help replacing GtkDrawingArea with GtkLayout > > > > > > > > > Message-ID: <1394327737.3369.3.camel@debian> > > > > > > > > > Content-Type: text/plain; charset="us-ascii" > > > > > > > > > > > > > > > > > > Hi, > > > > > > > > > > > > > > > > > > Didn't before but may be check the following: > > > > > > > > > > > > > > > > > > g_object_set(G_OBJECT(layout), > > > > > > > > > "app-paintable\0", TRUE, > > > > > > > > > NULL); > > > > > > > > > > > > > > > > Hmm, I hadn't noticed that property. It is presumably set ok > > > > > > > > since I can > > > > > > > > draw and place widgets on the GtkLayout. It was the configure > > > > > > > > and scroll > > > > > > > > events that I didn't receive. > > > > > > > > BTW why do you have two NULL bytes at the end of the property > > > > > > > > name > > > > > > > > (AFAIK only one is needed)? > > > > > > > > > > > > > > > > Richard > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Assumed you get annoyed by warnings, you can slightly disable it. > > > > > > > It's > > > > > > > distribution depend what flags are per default on. For further > > > > > > > reading: > > > > > > > > > > > > > > http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html > > > > > > > > > > > > > > regards > > > > > > > Joël > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > gtk-app-devel-list mailing list > > > > > > > gtk-app-devel-list@gnome.org > > > > > > > https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list > > > > > > > > > > > > You should ask why I forget to add GDK_SCROLL_MASK > > > > > > > > > > Well, I didn't ask because I already tried it. The GtkLayout didn't > > > > > receive that nor the configure signal even with setting > > > > > GDK_ALL_EVENTS_MASK. What *did* work is receiving the events on the > > > > > parent. > > > > > But I am still curious why you have two NULL bytes termination your > > > > > signal name strings, the extra one must surely get ignored... > > > > > > > > > > Richard > > > > > > > > > > > > > > > > > > > > > > gtk_widget_set_events (GTK_WIDGET (layout), > > > > > > GDK_EXPOSURE_MASK > > > > > > | GDK_LEAVE_NOTIFY_MASK > > > > > > | GDK_BUTTON_PRESS_MASK > > > > > > | GDK_BUTTON_RELEASE_MASK > > > > > > | GDK_POINTER_MOTION_MASK > > > > > > | GDK_POINTER_MOTION_HINT_MASK > > > > > > | GDK_SCROLL_MASK > > > > > > ); > > > > > > > > > > > > then you have to > > > > > > > > > > > > g_signal_connect(G_OBJECT(layout), "scroll-event\0", > > > > > > G_CALLBACK(layout_callback), NULL); > > > > > > > > > > > > > > > > > > gboolean > > > > > > layout_callback(GtkWidget *widget, GdkEvent *event, gpointer > > > > > > user_data) > > > > > > { > > > > > > /* do your thing */ > > > > > > > > > > > > return(FALSE); > > > > > > } > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Is your code somewhere online? Are you using > > > > gtk_widget_set_size_request()? > > > > > > > > > > I gave a minimal example earlier in the thread: > > > > > > https://mail.gnome.org/archives/gtk-app-devel-list/2014-March/msg00007.html > > > > > > > > > Richard > > > > > > > > Much better! As someone told you before the widget is realized you have > > to set the appropriate flags. > > The widget is not realized before the flags are set. Indeed gtk_main() > has not even been called, so no signals have been emitted when the flags > are set. > Here is the code with the sequence altered as you suggest: > > 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8>< > #include <gtk/gtk.h> > static gboolean > configure_event () > { > fprintf (stderr, "configure-event\n"); > gtk_main_quit (); > return FALSE; > } > > int main(int argc, char *argv[]) > { > GtkWidget *window; > GtkWidget *layout; > GtkWidget *label1; > > gtk_init (&argc, &argv); > > window = gtk_window_new (GTK_WINDOW_TOPLEVEL); > > layout = gtk_layout_new (NULL, NULL); > gtk_widget_add_events (layout, GDK_ALL_EVENTS_MASK); > gtk_container_add (GTK_CONTAINER (window), layout); > > > label1 = gtk_label_new ("label 1"); > > gtk_layout_put (GTK_LAYOUT (layout), label1, 10, 50); > > > gtk_widget_show_all (window); > > GdkWindow *win = gtk_widget_get_window(layout); > g_print("win is %p initial mask 0x%x\n", win, gdk_window_get_events > (win)); > gdk_window_set_events (win, gdk_window_get_events (win) | > GDK_STRUCTURE_MASK); > g_print("After adding GDK_STRUCTURE_MASK mask 0x%x\n", > gdk_window_get_events (win)); > > g_signal_connect (layout, "configure-event", G_CALLBACK > (configure_event), NULL); > > gtk_main (); > > return 0; > } > > 8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8><8>< > > As you can verify, it makes no difference - it would be very bizarre if > it did. > > > > > layout = gtk_layout_new (NULL, NULL); > > > > /* SET FLAGS HERE */ > > > > gtk_container_add (GTK_CONTAINER (window), layout); > > > > > > and don't forget to add the missing parameters. > > The parameters in the definition of the callback function > configure_event(void) are not missing, it is deliberately declared not > to have them. It is not a good idea to declare the callback with > parameters if they are not going to be used. > > Richard > > > > > > gboolean > > configure_event(GtkWidget *widget, GdkEventConfigure *event, gpointer > > user_data){ > > /* YOUR CODE HERE */ > > } > > > > >
Please consider the documentation of gtk_widget_set_app_paintable() don't believe GtkLayout can do your job. You could try id with a GtkDrawingArea with a cairo surface. I do some drawing in C take a look at http://sourceforge.net/p/ags/code/HEAD/tree/src/ags/X/ags_editor.c regards Joël _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org https://mail.gnome.org/mailman/listinfo/gtk-app-devel-list