On Mon, 2006-07-10 at 21:55 +0200, Atanas Atanasov wrote: > I have a fragment of code similar to this: > > gtk_widget_show_all (window); > gtk_window_resize (window, ...); > > The problem is that sometimes the specified window starts with the > size I set and sometimes it doesn't. This problem occurs in both debug > & release versions, and it seems to be completely random. What I know > is that before a window is shown the resize function acts differently. > It seems that it works well after the window is shown so as such it is > a timing issue. If for example I delay for a second between these two > lines with g_usleep(1000000); everything would be fine. How can I > solve the problem without introducing any artificial solutions such as > delays and the similar?
Try something like this: gboolean resize_window_on_idle (gpointer data) { gtk_window_resize (GTK_WINDOW(data), ... , ...); return FALSE; } // ... gtk_widget_show_all (window); g_idle_add (resize_window_on_idle, (gpointer) window); The window may flicker a bit ( I mean the size change will be visible by the user ) but it will work. You can also pass a composite structure with the window, width and height to g_idle_add if you want. > Should I try to purge the message queue > running gtk_main_iteration while gtk_main_events_pending? This may do the trick as well. > Would it > make a difference if I use functions like gtk_widget_request_size and > the alike requests? If you mean gtk_widget_size_request yes there will be differences but not what you want. This will set the preferred size of your window so you won't be able to shrink it. -- Iago Rubio _______________________________________________ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list