GNOME Bugzilla – Bug 444755
some widgets do not update dimensions after changes in the window
Last modified: 2007-06-06 16:14:12 UTC
Please describe the problem: I have an image viewer window which has a filechooser widget embedded which is shown on key/button press. Of course, the filechooser then takes up space (it is not shown normally) and the other elements in the window are reduced in size. In order to keep the image shown at the right size, I poll my Eventbox containing an image widget for its dimensions as follows and then scale the image accordingly: FileChooser.is_visible() ? FileChooser.hide() : FileChooser.show(); //while(Gtk::Main::events_pending()) Gtk::Main::iteration(); ImageBox.ScaleImage(ImageScroller.get_width(),ImageScroller.get_height(),&scalefactor); When I don't perform the iteration, the dimensions of both the filechooser and the eventbox are not updated in time and the image is scaled to the old dimensions. (filechooser remains 1,1 and the eventbox remains x,y, while I would expect the filechooser to return x,b and the eventbox x,y-b) If this is intended behaviour, disregard the bug, but I find it quite counterintuitive that I have to first iterate to get the dimensions of widgets updated after they have been changed. Steps to reproduce: Actual results: Expected results: Does this happen every time? Other information:
If you look at the source for gtk_widget_hide() [1], you'll notice that when you hide a widget, it emits the 'hide' signal for that widget, and then queues a resize of the widget. In other words, the resize doesn't actually happen immediately, it happens when the queued resize request is handled. This is by design and not a bug. What you most likely want to do in your application is connect to a filechooser signal that is emitted after the resize actually takes place (perhaps the 'hide' and 'show' signals would work, you could also look into 'configure-event', which will be emitted every time the filechooser is resized, not just hidden or shown) and then update your dimensions inside the signal handler. I'm going to close this bug. If you need further help with your application, you might try asking on gtkmm-list. [1] http://svn.gnome.org/viewcvs/gtk%2B/trunk/gtk/gtkwidget.c?revision=18025&view=markup