It's possible to manually override GTK+'s geometry
management. This is a bad idea 95% of the time, because
GTK+'s geometry is essentially the user's preferred
geometry, determined by the theme, and resizing toplevel
windows. If you find yourself wanting to do things
manually, it's probably because you're using the wrong
layout container, or you really should be writing a
custom container widget.
You can force a size or position on a widget with the
functions shown in
Figure 19. However, it is rarely a good idea to use
them. In particular,
gtk_widget_set_usize() should not be used to set a
toplevel window's default size. Usually you want to set
window size because you've saved the application's state
and you're restoring it, or because the user specified a
window geometry on the command line. Unfortunately, if
you use gtk_widget_set_usize()
the user will be unable to shrink the window, and you'll
get hate mail. Rather than force a size, you want to
specify an initial size with
gtk_window_set_default_size(), shown in Figure 20. gtk_widget_set_usize() is almost
never a good idea for non-toplevel widgets either; most
of the time, you can get better results using the proper
layout widget.
gtk_widget_set_uposition() is
only useful for toplevel windows; it borders on
nonsensical for other widgets, and will most likely cause
bad things to happen. It's primarily used to honor a --geometry command line
argument.
All three of these functions can accept -1 for the
x, y, width, or
height argument. The functions ignore any -1 argument; this allows you to
set only one of the two arguments, leaving the default
value for the other.