deprecated: 3.20 

Declaration [src]

gtk_window_parse_geometry (
  GtkWindow* window,
  const gchar* geometry

Description [src]

Parses a standard X Window System geometry string - see the manual page for X (type “man X”) for details on this. gtk_window_parse_geometry() does work on all GTK+ ports including Win32 but is primarily intended for an X environment.

If either a size or a position can be extracted from the geometry string, gtk_window_parse_geometry() returns TRUE and calls gtk_window_set_default_size() and/or gtk_window_move() to resize/move the window.

If gtk_window_parse_geometry() returns TRUE, it will also set the #GDK_HINT_USER_POS and/or #GDK_HINT_USER_SIZE hints indicating to the window manager that the size/position of the window was user-specified. This causes most window managers to honor the geometry.

Note that for gtk_window_parse_geometry() to work as expected, it has to be called when the window has its “final” size, i.e. after calling gtk_widget_show_all() on the contents and gtk_window_set_geometry_hints() on the window.

#include <gtk/gtk.h>

static void
fill_with_content (GtkWidget *vbox)
  // fill with content...

main (int argc, char *argv[])
  GtkWidget *window, *vbox;
  GdkGeometry size_hints = {
    100, 50, 0, 0, 100, 50, 10,
    10, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

  gtk_container_add (GTK_CONTAINER (window), vbox);
  fill_with_content (vbox);
  gtk_widget_show_all (vbox);

  gtk_window_set_geometry_hints (GTK_WINDOW (window),
                    GDK_HINT_MIN_SIZE |
                    GDK_HINT_BASE_SIZE |

  if (argc > 1)
      gboolean res;
      res = gtk_window_parse_geometry (GTK_WINDOW (window),
      if (! res)
        fprintf (stderr,
                 "Failed to parse “%s”\n",

  gtk_widget_show_all (window);
  gtk_main ();

  return 0;

Deprecated since: 3.20

Geometry handling in GTK is deprecated.



Type: const gchar*

Geometry string.

The data is owned by the caller of the method.
The value is a NUL terminated UTF-8 string.

Return value

Type: gboolean

TRUE if string was parsed successfully.