Details
gtk_window_new ()
Creates a new GtkWindow, which is a toplevel window that can
contain other widgets. Nearly always, the type of the window should
be GTK_WINDOW_TOPLEVEL. If you're implementing something like a
popup menu from scratch (which is a bad idea, just use GtkMenu),
you might use GTK_WINDOW_POPUP. GTK_WINDOW_POPUP is not for
dialogs, though in some other toolkits dialogs are called "popups."
In GTK+, GTK_WINDOW_POPUP means a pop-up menu or pop-up tooltip.
Popup windows are not controlled by the window manager.
If you simply want an undecorated window (no window borders), use
gtk_window_set_decorated(), don't use GTK_WINDOW_POPUP.
gtk_window_set_title ()
void gtk_window_set_title (GtkWindow *window,
const gchar *title); |
Sets the title of the GtkWindow. The title of a window will be displayed in
its title bar; on the X Window System, the title bar is rendered by the
window manager, so exactly how the title appears to users may vary according
to a user's exact configuration. The title should help a user distinguish
this window from other windows they may have open. A good title might
include the application name and current document filename, for example.
gtk_window_set_wmclass ()
void gtk_window_set_wmclass (GtkWindow *window,
const gchar *wmclass_name,
const gchar *wmclass_class); |
Don't use this function. It sets the X Window System "class" and
"name" hints for a window. According to the ICCCM, you should
always set these to the same value for all windows in an
application, and GTK sets them to that value by default, so calling
this function is sort of pointless. However, you may want to call
gtk_window_set_role() on each window in your application, for the
benefit of the session manager. Setting the role allows the window
manager to restore window positions when loading a saved session.
gtk_window_set_policy ()
void gtk_window_set_policy (GtkWindow *window,
gint allow_shrink,
gint allow_grow,
gint auto_shrink); |
Warning |
gtk_window_set_policy is deprecated and should not be used in newly-written code. |
Changes how a toplevel window deals with its size request and user resize
attempts. There are really only two reasonable ways to call this function:
gtk_window_set_policy(GTK_WINDOW(window), FALSE, TRUE, FALSE)
means that the window is user-resizable.
gtk_window_set_policy(GTK_WINDOW(window), FALSE, FALSE, TRUE)
means that the window's size is program-controlled, and should simply match
the current size request of the window's children.
The first policy is the default, that is, by default windows are designed to
be resized by users.
The basic ugly truth of this function is that it should be simply:
void gtk_window_set_user_resizeable(GtkWidget* window, gboolean setting); |
So, pretend it is like that, and only use the two policies mentioned above.
GTK+ 1.4 may replace
gtk_window_set_policy() with a nicer function like
gtk_window_set_user_resizeable().
If set to TRUE, the allow_grow parameter allows the user to expand the window
beyond the size request of its child widgets. If allow_grow is TRUE, be sure to
check that your child widgets work properly as the window is resized.
A toplevel window will always change size to ensure its child widgets receive
their requested size. This means that if you add child widgets, the toplevel
window will expand to contain them. However, normally the toplevel will not
shrink to fit the size request of its children if it's too large; the
auto_shrink parameter causes the window to shrink when child widgets have too
much space. auto_shrink is normally used with the second of the two window
policies mentioned above. That is, set auto_shrink to TRUE if you want the
window to have a fixed, always-optimal size determined by your program.
Note that auto_shrink doesn't do anything if allow_shrink and allow_grow are
both set to FALSE.
Neither of the two suggested window policies set the allow_shrink paramter to
TRUE. If allow_shrink is TRUE, the user can shrink the window so that its
children do not receive their full size request; this is basically a bad thing,
because most widgets will look wrong if this happens. Furthermore GTK+ has a
tendency to re-expand the window if size is recalculated for any reason. The
upshot is that allow_shrink should always be set to FALSE.
Sometimes when you think you want to use allow_shrink, the real problem is that
some specific child widget is requesting too much space, so the user can't
shrink the window sufficiently. Perhaps you are calling gtk_widget_set_usize()
on a child widget, and forcing its size request to be too large. Instead of
setting the child's usize, consider using gtk_window_set_default_size() so that
the child gets a larger allocation than it requests.
gtk_window_set_resizeable ()
void gtk_window_set_resizeable (GtkWindow *window,
gboolean resizeable); |
Sets whether the user can resize a window. Windows are user resizeable
by default.
gtk_window_add_accel_group ()
gtk_window_remove_accel_group ()
gtk_window_position
#define gtk_window_position gtk_window_set_position |
gtk_window_activate_focus ()
gboolean gtk_window_activate_focus (GtkWindow *window); |
gtk_window_activate_default ()
gboolean gtk_window_activate_default (GtkWindow *window); |
gtk_window_set_modal ()
void gtk_window_set_modal (GtkWindow *window,
gboolean modal); |
Sets a window modal or non-modal. Modal windows prevent interaction
with other windows in the same application. To keep modal dialogs
on top of main application windows, use
gtk_window_set_transient_for() to make the dialog transient for the
parent; most window managers will then disallow lowering the dialog
below the parent.
gtk_window_set_default_size ()
void gtk_window_set_default_size (GtkWindow *window,
gint width,
gint height); |
Sets the default size of a window. If the window's "natural" size
(its size request) is larger than the default, the default will be
ignored. So the default size is a minimum initial size. Unlike
gtk_widget_set_usize(), which sets a size request for a widget and
thus would keep users from shrinking the window, this function only
sets the initial size, just as if the user had resized the window
themselves. Users can still shrink the window again as they
normally would. Setting a default size of 0 means to use the
"natural" default size (the size request of the window).
For more control over a window's initial size and how resizing works,
investigate gtk_window_set_geometry_hints().
A useful feature: if you set the "geometry widget" via
gtk_window_set_geometry_hints(), the default size specified by
gtk_window_set_default_size() will be the default size of that
widget, not of the entire window.
gtk_window_set_geometry_hints ()
This function sets up hints about how a window can be resized by
the user. You can set a minimum and maximum size; allowed resize
increments (e.g. for xterm, you can only resize by the size of a
character); aspect ratios; and more. See the GdkGeometry struct.
gtk_window_set_gravity ()
Window gravity defines the "reference point" to be used when
positioning or resizing a window. Calls to
gtk_widget_set_uposition() will position a different point on the
window depending on the window gravity. When the window changes size
the reference point determined by the window's gravity will stay in
a fixed location.
See GdkGravity for full details. To briefly summarize,
GDK_GRAVITY_NORTH_WEST means that the reference point is the
northwest (top left) corner of the window
frame. GDK_GRAVITY_SOUTH_EAST would be the bottom right corner of
the frame, and so on. If you want to position the window contents,
rather than the window manager's frame, GDK_GRAVITY_STATIC moves
the reference point to the northwest corner of the GtkWindow
itself.
The default window gravity is GDK_GRAVITY_NORTH_WEST.
gtk_window_set_position ()
gtk_window_set_transient_for ()
Dialog windows should be set transient for the main application
window they were spawned from. This allows window managers to
e.g. keep the dialog on top of the main window, or center the
dialog over the main window. gtk_dialog_new_with_buttons() and
other convenience functions in GTK+ will sometimes call
gtk_window_set_transient_for() on your behalf.
gtk_window_set_destroy_with_parent ()
void gtk_window_set_destroy_with_parent
(GtkWindow *window,
gboolean setting); |
If setting is TRUE, then destroying the transient parent of window
will also destroy window itself. This is useful for dialogs that
shouldn't persist beyond the lifetime of the main window they're
associated with, for example.
gtk_window_list_toplevels ()
GList* gtk_window_list_toplevels (void); |
Returns a list of all existing toplevel windows. The widgets
in the list are not individually referenced. If you want
to iterate through the list and perform actions involving
callbacks that might destroy the widgets, you MUST call
g_list_foreach (result, (GFunc)g_object_ref, NULL) first, and
then unref all the widgets afterwards.
gtk_window_add_mnemonic ()
gtk_window_remove_mnemonic ()
gtk_window_mnemonic_activate ()
gtk_window_present ()
Presents a window to the user. This may mean raising the window
in the stacking order, deiconifying it, moving it to the current
desktop, and/or giving it the keyboard focus, possibly dependent
on the user's platform, window manager, and preferences.
If window is hidden, this function calls gtk_widget_show()
as well.
This function should be used when the user tries to open a window
that's already open. Say for example the preferences dialog is
currently open, and the user chooses Preferences from the menu
a second time; use gtk_window_present() to move the already-open dialog
where the user can see it.
gtk_window_iconify ()
Asks to iconify window. Note that you shouldn't assume the window
is definitely iconified afterward, because other entities (e.g. the
user or window manager) could deiconify it again, or there may not
be a window manager in which case iconification isn't possible,
etc. But normally the window will end up iconified. Just don't write
code that crashes if not.
It's permitted to call this function before showing a window,
in which case the window will be iconified before it ever appears
onscreen.
You can track iconification via the "window_state_event" signal
on GtkWidget.
gtk_window_deiconify ()
void gtk_window_deiconify (GtkWindow *window); |
Asks to deiconify window. Note that you shouldn't assume the
window is definitely deiconified afterward, because other entities
(e.g. the user or window manager) could iconify it again before
your code which assumes deiconification gets to run.
You can track iconification via the "window_state_event" signal
on GtkWidget.
gtk_window_stick ()
Asks to stick window, which means that it will appear on all user
desktops. Note that you shouldn't assume the window is definitely
stuck afterward, because other entities (e.g. the user or window
manager) could unstick it again, and some window managers do not
support sticking windows. But normally the window will end up
stuck. Just don't write code that crashes if not.
It's permitted to call this function before showing a window.
You can track stickiness via the "window_state_event" signal
on GtkWidget.
gtk_window_unstick ()
Asks to unstick window, which means that it will appear on only
one of the user's desktops. Note that you shouldn't assume the
window is definitely unstuck afterward, because other entities
(e.g. the user or window manager) could stick it again. But
normally the window will end up stuck. Just don't write code that
crashes if not.
You can track stickiness via the "window_state_event" signal
on GtkWidget.
gtk_window_maximize ()
void gtk_window_maximize (GtkWindow *window); |
Asks to maximize window, so that it becomes full-screen. Note that
you shouldn't assume the window is definitely maximized afterward,
because other entities (e.g. the user or window manager) could
unmaximize it again, and not all window managers support
maximization. But normally the window will end up maximized. Just
don't write code that crashes if not.
It's permitted to call this function before showing a window,
in which case the window will be maximized when it appears onscreen
initially.
You can track maximization via the "window_state_event" signal
on GtkWidget.
gtk_window_unmaximize ()
void gtk_window_unmaximize (GtkWindow *window); |
Asks to unmaximize window. Note that you shouldn't assume the
window is definitely unmaximized afterward, because other entities
(e.g. the user or window manager) could maximize it again, and not
all window managers honor requests to unmaximize. But normally the
window will end up unmaximized. Just don't write code that crashes
if not.
You can track maximization via the "window_state_event" signal
on GtkWidget.
gtk_window_begin_resize_drag ()
void gtk_window_begin_resize_drag (GtkWindow *window,
GdkWindowEdge edge,
gint button,
gint root_x,
gint root_y,
guint32 timestamp); |
Starts resizing a window. This function is used if an application
has window resizing controls. When GDK can support it, the resize
will be done using the standard mechanism for the window manager or
windowing system. Otherwise, GDK will try to emulate window
resizing, potentially not all that well, depending on the windowing system.
gtk_window_begin_move_drag ()
void gtk_window_begin_move_drag (GtkWindow *window,
gint button,
gint root_x,
gint root_y,
guint32 timestamp); |
Starts moving a window. This function is used if an application
has window movement grips. When GDK can support it, the window movement
will be done using the standard mechanism for the window manager or
windowing system. Otherwise, GDK will try to emulate window
movement, potentially not all that well, depending on the windowing system.
gtk_window_set_decorated ()
void gtk_window_set_decorated (GtkWindow *window,
gboolean setting); |
By default, windows are decorated with a title bar, resize
controls, etc. Some window managers allow GTK+ to disable these
decorations, creating a borderless window. If you set the decorated
property to FALSE using this function, GTK+ will do its best to
convince the window manager not to decorate the window.
gtk_window_set_frame_dimensions ()
void gtk_window_set_frame_dimensions (GtkWindow *window,
gint left,
gint top,
gint right,
gint bottom); |
For windows with frames (see gtk_window_set_has_frame) this function
can be used to change the size of the frame border.
gtk_window_set_has_frame ()
void gtk_window_set_has_frame (GtkWindow *window); |
If this function is called on a window before it is realized
or showed it will have a "frame" window around widget-window,
accessible in window->frame. Using the signal frame_event
you can recieve all events targeted at the frame.
This function is used by the linux-fb port to implement managed
windows, but it could concievably be used by X-programs that
want to do their own window decorations.
gtk_window_set_mnemonic_modifier ()
gtk_window_set_role ()
void gtk_window_set_role (GtkWindow *window,
const gchar *role); |
In combination with the window title, the window role allows a
window manager to identify "the same" window when an application is
restarted. So for example you might set the "toolbox" role on your
app's toolbox window, so that when the user restarts their session,
the window manager can put the toolbox back in the same place.
If a window already has a unique title, you don't need to set the
role, since the WM can use the title to identify the window when
restoring the session.
gtk_window_set_type_hint ()
By setting the type hint for the window, you allow the window
manager to decorate and handle the window in a way which is
suitable to the function of the window in your application.
This function should be called before the window becomes visible.
gtk_dialog_new_with_buttons() and other convenience functions in GTK+
will sometimes call gtk_window_set_type_hint() on your behalf.
gtk_decorated_window_init ()
void gtk_decorated_window_init (GtkWindow *window); |
gtk_decorated_window_calculate_frame_size ()
void gtk_decorated_window_calculate_frame_size
(GtkWindow *window); |
gtk_decorated_window_set_title ()
void gtk_decorated_window_set_title (GtkWindow *window,
const gchar *title); |
gtk_decorated_window_move_resize_window ()
void gtk_decorated_window_move_resize_window
(GtkWindow *window,
gint x,
gint y,
gint width,
gint height); |