Re: Getting a GDK_CONFIGURE event from a GtkImage
On 6/26/07, Jim George [EMAIL PROTECTED] wrote: [...] caused an infinite loop, because I'm trying to do the following: gboolean solar_cal_pixbuf_resize(GtkWidget *widget, GtkAllocation *alloc, gpointer user_data) { GtkImage *img_widget = user_data; GdkPixbuf *pixbuf = gtk_image_get_pixbuf(img_widget); if (pixbuf) g_object_unref(pixbuf); pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, alloc-width, alloc-height); gtk_image_set_from_pixbuf(img_widget, pixbuf); } The call to gtk_image_set_from_pixbuf causes a size-alloc to be emitted, leading to the infinite loop. I don't see why the size-request signal is not being emitted. Just put a call to g_signal_handlers_block_by_func() before gtk_Image_set_from_pixbuf(), and then after, a call to g_signal_handlers_unblock_by_func(). There may be a more elegant way of handling that, but this'll work. -brian Thanks, Brian, it works now. I'll take that back, the handler keeps getting called even if I block it before calling gtk_image_set_from_pixbuf. If I disconnect it, it doesn't get called again. Seems like the allocate-event occurs with some delay after gtk_image_set_from_pixbuf is called. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Getting a GDK_CONFIGURE event from a GtkImage
On Tue, Jun 26, 2007 at 11:28:48AM -0600, Jim George wrote: I'll take that back, the handler keeps getting called even if I block it before calling gtk_image_set_from_pixbuf. If I disconnect it, it doesn't get called again. Seems like the allocate-event occurs with some delay after gtk_image_set_from_pixbuf is called. It does a round-trip through the X server, so the allocation is performed after you return from the signal handler. I do not follow this thread, but can't you just compare the new allocation to the current one and do nothing when they are equal? Yeti -- http://gwyddion.net/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Getting a GDK_CONFIGURE event from a GtkImage
I do not follow this thread, but can't you just compare the new allocation to the current one and do nothing when they are equal? That doesn't work, they seem to always be equal. I'm comparing the allocation being passed to the alloc-event handler in the second parameter and the allocation of the widget itself using something like GTK_WIDGET(object)-allocation.width. Seems like alloc-event gets called after the widget is allocated space, so that's the correct behaviour. -Jim ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Getting a GDK_CONFIGURE event from a GtkImage
Is there some way I can obtain a GDK_CONFIGURE event from a GtkImage widget? I tried putting the GtkImage inside a GtkEventBox and connecting a handler to configure-event, without success. I also manually enabled GDK_STRUCTURE_MASK, even though GTK is supposed to do that by default. I would like to know when the image size has changed, so that I can assign a new GdkPixbuf to the GtkImage and draw to the GdkPixbuf. TIA -Jim ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Getting a GDK_CONFIGURE event from a GtkImage
On 6/25/07, Brian J. Tarricone [EMAIL PROTECTED] wrote: On Mon, 25 Jun 2007 15:13:30 -0600 Jim George wrote: Is there some way I can obtain a GDK_CONFIGURE event from a GtkImage widget? I tried putting the GtkImage inside a GtkEventBox and connecting a handler to configure-event, without success. I also manually enabled GDK_STRUCTURE_MASK, even though GTK is supposed to do that by default. I would like to know when the image size has changed, so that I can assign a new GdkPixbuf to the GtkImage and draw to the GdkPixbuf. AFAIR, configure events are only useful for toplevel windows. You'll probably want to look at the size-request and/or size-allocate signals (on GtkWidget). -brian That's true (although GtkDrawingArea will emit it too). I tried using size-request, and nothing happened (callback never got called). size-allocate, however, caused an infinite loop, because I'm trying to do the following: gboolean solar_cal_pixbuf_resize(GtkWidget *widget, GtkAllocation *alloc, gpointer user_data) { GtkImage *img_widget = user_data; GdkPixbuf *pixbuf = gtk_image_get_pixbuf(img_widget); if (pixbuf) g_object_unref(pixbuf); pixbuf = gdk_pixbuf_new(GDK_COLORSPACE_RGB, TRUE, 8, alloc-width, alloc-height); gtk_image_set_from_pixbuf(img_widget, pixbuf); } The call to gtk_image_set_from_pixbuf causes a size-alloc to be emitted, leading to the infinite loop. I don't see why the size-request signal is not being emitted. Baah, maybe I should just stick to using a GtkDrawingArea instead... -Jim ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list