Warn when calling gtk_window_parse_geometry() on an empty window

gtk_window_parse_geometry() gets the size of the window in order
to interpret the position of the window; calling it before, say,
calling gtk_widget_show_all() on a window is a subtle trap, so
add a warning in the case we can easily detect.

https://bugzilla.gnome.org/show_bug.cgi?id=631794
This commit is contained in:
Owen W. Taylor 2010-10-09 22:29:20 -04:00
parent 88cf547029
commit 519d758711

View File

@ -8820,6 +8820,7 @@ gtk_window_parse_geometry (GtkWindow *window,
{
gint result, x = 0, y = 0;
guint w, h;
GtkWidget *child;
GdkGravity grav;
gboolean size_set, pos_set;
GdkScreen *screen;
@ -8827,6 +8828,12 @@ gtk_window_parse_geometry (GtkWindow *window,
g_return_val_if_fail (GTK_IS_WINDOW (window), FALSE);
g_return_val_if_fail (geometry != NULL, FALSE);
child = gtk_bin_get_child (GTK_BIN (window));
if (!child || !gtk_widget_get_visible (child))
g_warning ("gtk_window_parse_geometry() called on a window with no "
"visible children; the window should be set up before "
"gtk_window_parse_geometry() is called.");
screen = gtk_window_check_screen (window);
result = gtk_XParseGeometry (geometry, &x, &y, &w, &h);