Synopsis#include <gtk/gtk.h> GtkWindow; GtkWidget* gtk_window_new (GtkWindowType type); void gtk_window_set_title (GtkWindow *window, const gchar *title); void gtk_window_set_wmclass (GtkWindow *window, const gchar *wmclass_name, const gchar *wmclass_class); void gtk_window_set_policy (GtkWindow *window, gint allow_shrink, gint allow_grow, gint auto_shrink); void gtk_window_set_resizable (GtkWindow *window, gboolean resizable); gboolean gtk_window_get_resizable (GtkWindow *window); void gtk_window_add_accel_group (GtkWindow *window, GtkAccelGroup *accel_group); void gtk_window_remove_accel_group (GtkWindow *window, GtkAccelGroup *accel_group); #define gtk_window_position gboolean gtk_window_activate_focus (GtkWindow *window); gboolean gtk_window_activate_default (GtkWindow *window); void gtk_window_set_modal (GtkWindow *window, gboolean modal); void gtk_window_set_default_size (GtkWindow *window, gint width, gint height); void gtk_window_set_geometry_hints (GtkWindow *window, GtkWidget *geometry_widget, GdkGeometry *geometry, GdkWindowHints geom_mask); void gtk_window_set_gravity (GtkWindow *window, GdkGravity gravity); GdkGravity gtk_window_get_gravity (GtkWindow *window); void gtk_window_set_position (GtkWindow *window, GtkWindowPosition position); void gtk_window_set_transient_for (GtkWindow *window, GtkWindow *parent); void gtk_window_set_destroy_with_parent (GtkWindow *window, gboolean setting); void gtk_window_set_screen (GtkWindow *window, GdkScreen *screen); GdkScreen* gtk_window_get_screen (GtkWindow *window); gboolean gtk_window_is_active (GtkWindow *window); gboolean gtk_window_has_toplevel_focus (GtkWindow *window); GList* gtk_window_list_toplevels (void); void gtk_window_add_mnemonic (GtkWindow *window, guint keyval, GtkWidget *target); void gtk_window_remove_mnemonic (GtkWindow *window, guint keyval, GtkWidget *target); gboolean gtk_window_mnemonic_activate (GtkWindow *window, guint keyval, GdkModifierType modifier); gboolean gtk_window_activate_key (GtkWindow *window, GdkEventKey *event); gboolean gtk_window_propagate_key_event (GtkWindow *window, GdkEventKey *event); GtkWidget* gtk_window_get_focus (GtkWindow *window); void gtk_window_set_focus (GtkWindow *window, GtkWidget *focus); GtkWidget* gtk_window_get_default_widget (GtkWindow *window); void gtk_window_set_default (GtkWindow *window, GtkWidget *default_widget); void gtk_window_present (GtkWindow *window); void gtk_window_present_with_time (GtkWindow *window, guint32 timestamp); void gtk_window_iconify (GtkWindow *window); void gtk_window_deiconify (GtkWindow *window); void gtk_window_stick (GtkWindow *window); void gtk_window_unstick (GtkWindow *window); void gtk_window_maximize (GtkWindow *window); void gtk_window_unmaximize (GtkWindow *window); void gtk_window_fullscreen (GtkWindow *window); void gtk_window_unfullscreen (GtkWindow *window); void gtk_window_set_keep_above (GtkWindow *window, gboolean setting); void gtk_window_set_keep_below (GtkWindow *window, gboolean setting); void gtk_window_begin_resize_drag (GtkWindow *window, GdkWindowEdge edge, gint button, gint root_x, gint root_y, guint32 timestamp); void gtk_window_begin_move_drag (GtkWindow *window, gint button, gint root_x, gint root_y, guint32 timestamp); void gtk_window_set_decorated (GtkWindow *window, gboolean setting); void gtk_window_set_deletable (GtkWindow *window, gboolean setting); void gtk_window_set_frame_dimensions (GtkWindow *window, gint left, gint top, gint right, gint bottom); void gtk_window_set_has_frame (GtkWindow *window, gboolean setting); void gtk_window_set_mnemonic_modifier (GtkWindow *window, GdkModifierType modifier); void gtk_window_set_role (GtkWindow *window, const gchar *role); void gtk_window_set_type_hint (GtkWindow *window, GdkWindowTypeHint hint); void gtk_window_set_skip_taskbar_hint (GtkWindow *window, gboolean setting); void gtk_window_set_skip_pager_hint (GtkWindow *window, gboolean setting); void gtk_window_set_urgency_hint (GtkWindow *window, gboolean setting); void gtk_window_set_accept_focus (GtkWindow *window, gboolean setting); void gtk_window_set_focus_on_map (GtkWindow *window, gboolean setting); void gtk_window_set_startup_id (GtkWindow *window, const gchar *startup_id); void gtk_window_set_role (GtkWindow *window, const gchar *role); gboolean gtk_window_get_decorated (GtkWindow *window); gboolean gtk_window_get_deletable (GtkWindow *window); GList* gtk_window_get_default_icon_list (void); void gtk_window_get_default_size (GtkWindow *window, gint *width, gint *height); gboolean gtk_window_get_destroy_with_parent (GtkWindow *window); void gtk_window_get_frame_dimensions (GtkWindow *window, gint *left, gint *top, gint *right, gint *bottom); gboolean gtk_window_get_has_frame (GtkWindow *window); GdkPixbuf* gtk_window_get_icon (GtkWindow *window); GList* gtk_window_get_icon_list (GtkWindow *window); gchar* gtk_window_get_icon_name (GtkWindow *window); GdkModifierType gtk_window_get_mnemonic_modifier (GtkWindow *window); gboolean gtk_window_get_modal (GtkWindow *window); void gtk_window_get_position (GtkWindow *window, gint *root_x, gint *root_y); const gchar* gtk_window_get_role (GtkWindow *window); void gtk_window_get_size (GtkWindow *window, gint *width, gint *height); const gchar* gtk_window_get_title (GtkWindow *window); GtkWindow* gtk_window_get_transient_for (GtkWindow *window); GdkWindowTypeHint gtk_window_get_type_hint (GtkWindow *window); gboolean gtk_window_get_skip_taskbar_hint (GtkWindow *window); gboolean gtk_window_get_skip_pager_hint (GtkWindow *window); gboolean gtk_window_get_urgency_hint (GtkWindow *window); gboolean gtk_window_get_accept_focus (GtkWindow *window); gboolean gtk_window_get_focus_on_map (GtkWindow *window); GtkWindowGroup* gtk_window_get_group (GtkWindow *window); void gtk_window_move (GtkWindow *window, gint x, gint y); gboolean gtk_window_parse_geometry (GtkWindow *window, const gchar *geometry); void gtk_window_reshow_with_initial_size (GtkWindow *window); void gtk_window_resize (GtkWindow *window, gint width, gint height); void gtk_window_set_default_icon_list (GList *list); void gtk_window_set_default_icon (GdkPixbuf *icon); gboolean gtk_window_set_default_icon_from_file (const gchar *filename, GError **err); void gtk_window_set_default_icon_name (const gchar *name); void gtk_window_set_icon (GtkWindow *window, GdkPixbuf *icon); void gtk_window_set_icon_list (GtkWindow *window, GList *list); gboolean gtk_window_set_icon_from_file (GtkWindow *window, const gchar *filename, GError **err); void gtk_window_set_icon_name (GtkWindow *window, const gchar *name); void gtk_window_set_auto_startup_notification (gboolean setting); gdouble gtk_window_get_opacity (GtkWindow *window); void gtk_window_set_opacity (GtkWindow *window, gdouble opacity); Object HierarchyGObject +----GInitiallyUnowned +----GtkObject +----GtkWidget +----GtkContainer +----GtkBin +----GtkWindow +----GtkDialog +----GtkAssistant +----GtkPlug Properties"accept-focus" gboolean : Read / Write "allow-grow" gboolean : Read / Write "allow-shrink" gboolean : Read / Write "decorated" gboolean : Read / Write "default-height" gint : Read / Write "default-width" gint : Read / Write "deletable" gboolean : Read / Write "destroy-with-parent" gboolean : Read / Write "focus-on-map" gboolean : Read / Write "gravity" GdkGravity : Read / Write "has-toplevel-focus" gboolean : Read "icon" GdkPixbuf* : Read / Write "icon-name" gchar* : Read / Write "is-active" gboolean : Read "modal" gboolean : Read / Write "opacity" gdouble : Read / Write "resizable" gboolean : Read / Write "role" gchar* : Read / Write "screen" GdkScreen* : Read / Write "skip-pager-hint" gboolean : Read / Write "skip-taskbar-hint" gboolean : Read / Write "startup-id" gchar* : Write "title" gchar* : Read / Write "transient-for" GtkWindow* : Read / Write / Construct "type" GtkWindowType : Read / Write / Construct Only "type-hint" GdkWindowTypeHint : Read / Write "urgency-hint" gboolean : Read / Write "window-position" GtkWindowPosition : Read / Write Signals"activate-default" : Run Last / Action "activate-focus" : Run Last / Action "frame-event" : Run Last "keys-changed" : Run First "set-focus" : Run Last Detailsgtk_window_new ()GtkWidget* gtk_window_new (GtkWindowType type); 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. On X11, popup windows are not controlled by the window manager.
If you simply want an undecorated window (no window borders), use
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_policy ()void gtk_window_set_policy (GtkWindow *window, gint allow_shrink, gint allow_grow, gint auto_shrink); Warning
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:
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:
If set to
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
Note that
Neither of the two suggested window policies set the
Sometimes when you think you want to use
gtk_window_set_resizable ()void gtk_window_set_resizable (GtkWindow *window, gboolean resizable); Sets whether the user can resize a window. Windows are user resizable by default.
gtk_window_get_resizable ()gboolean gtk_window_get_resizable (GtkWindow *window);
Gets the value set by
gtk_window_add_accel_group ()void gtk_window_add_accel_group (GtkWindow *window, GtkAccelGroup *accel_group);
Associate
gtk_window_remove_accel_group ()void gtk_window_remove_accel_group (GtkWindow *window, GtkAccelGroup *accel_group);
Reverses the effects of
gtk_window_position#define gtk_window_position gtk_window_set_position Warning
Deprecated alias for gtk_window_activate_focus ()gboolean gtk_window_activate_focus (GtkWindow *window); Activates the current focused widget within the window.
gtk_window_activate_default ()gboolean gtk_window_activate_default (GtkWindow *window); Activates the default widget for the window, unless the current focused widget has been configured to receive the default action (see GTK_RECEIVES_DEFAULT in GtkWidgetFlags), in which case the focused widget is activated.
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_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. More generally, if the default size does not obey the
geometry hints for the window (
Unlike
For more control over a window's initial size and how resizing works,
investigate
For some uses, The default size of a window only affects the first time a window is shown; if a window is hidden and re-shown, it will remember the size it had prior to hiding, rather than using the default size.
Windows can't actually be 0x0 in size, they must be at least 1x1, but
passing 0 for
gtk_window_set_geometry_hints ()void gtk_window_set_geometry_hints (GtkWindow *window, GtkWidget *geometry_widget, GdkGeometry *geometry, GdkWindowHints geom_mask); 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 ()void gtk_window_set_gravity (GtkWindow *window, GdkGravity gravity);
Window gravity defines the meaning of coordinates passed to
The default window gravity is GDK_GRAVITY_NORTH_WEST which will typically "do what you mean."
gtk_window_get_gravity ()GdkGravity gtk_window_get_gravity (GtkWindow *window);
Gets the value set by
gtk_window_set_position ()void gtk_window_set_position (GtkWindow *window, GtkWindowPosition position);
Sets a position constraint for this window. If the old or new
constraint is
gtk_window_set_transient_for ()void gtk_window_set_transient_for (GtkWindow *window, GtkWindow *parent);
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. On Windows, this function puts the child window on top of the parent, much as the window manager would have done on X.
gtk_window_set_destroy_with_parent ()void gtk_window_set_destroy_with_parent (GtkWindow *window, gboolean setting);
If
gtk_window_set_screen ()void gtk_window_set_screen (GtkWindow *window, GdkScreen *screen);
Sets the GdkScreen where the
Since 2.2 gtk_window_get_screen ()GdkScreen* gtk_window_get_screen (GtkWindow *window);
Returns the GdkScreen associated with
Since 2.2 gtk_window_is_active ()gboolean gtk_window_is_active (GtkWindow *window);
Returns whether the window is part of the current active toplevel.
(That is, the toplevel window receiving keystrokes.)
The return value is
Since 2.4 gtk_window_has_toplevel_focus ()gboolean gtk_window_has_toplevel_focus (GtkWindow *window);
Returns whether the input focus is within this GtkWindow.
For real toplevel windows, this is identical to
Since 2.4 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
gtk_window_add_mnemonic ()void gtk_window_add_mnemonic (GtkWindow *window, guint keyval, GtkWidget *target); Adds a mnemonic to this window.
gtk_window_remove_mnemonic ()void gtk_window_remove_mnemonic (GtkWindow *window, guint keyval, GtkWidget *target); Removes a mnemonic from this window.
gtk_window_mnemonic_activate ()gboolean gtk_window_mnemonic_activate (GtkWindow *window, guint keyval, GdkModifierType modifier); Activates the targets associated with the mnemonic.
gtk_window_activate_key ()gboolean gtk_window_activate_key (GtkWindow *window, GdkEventKey *event); Activates mnemonics and accelerators for this GtkWindow. This is normally called by the default ::key_press_event handler for toplevel windows, however in some cases it may be useful to call this directly when overriding the standard key handling for a toplevel window.
gtk_window_propagate_key_event ()gboolean gtk_window_propagate_key_event (GtkWindow *window, GdkEventKey *event);
Propagate a key press or release event to the focus widget and
up the focus container chain until a widget handles
gtk_window_get_focus ()GtkWidget* gtk_window_get_focus (GtkWindow *window);
Retrieves the current focused widget within the window.
Note that this is the widget that would have the focus
if the toplevel window focused; if the toplevel window
is not focused then
gtk_window_set_focus ()void gtk_window_set_focus (GtkWindow *window, GtkWidget *focus);
If
gtk_window_get_default_widget ()GtkWidget* gtk_window_get_default_widget (GtkWindow *window);
Returns the default widget for
Since 2.14 gtk_window_set_default ()void gtk_window_set_default (GtkWindow *window, GtkWidget *default_widget);
The default widget is the widget that's activated when the user
presses Enter in a dialog (for example). This function sets or
unsets the default widget for a GtkWindow about. When setting
(rather than unsetting) the default widget it's generally easier to
call
gtk_window_present ()void gtk_window_present (GtkWindow *window); 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
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
If you are calling this function in response to a user interaction,
it is preferable to use
gtk_window_present_with_time ()void gtk_window_present_with_time (GtkWindow *window, guint32 timestamp);
Presents a window to the user in response to a user interaction.
If you need to present a window without a timestamp, use
Since 2.8 gtk_window_iconify ()void gtk_window_iconify (GtkWindow *window);
Asks to iconify (i.e. minimize) the specified 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 (i.e. unminimize) the specified You can track iconification via the "window-state-event" signal on GtkWidget.
gtk_window_stick ()void gtk_window_stick (GtkWindow *window);
Asks to stick 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 ()void gtk_window_unstick (GtkWindow *window);
Asks to unstick You can track stickiness via the "window-state-event" signal on GtkWidget.
gtk_window_maximize ()void gtk_window_maximize (GtkWindow *window);
Asks to maximize 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 You can track maximization via the "window-state-event" signal on GtkWidget.
gtk_window_fullscreen ()void gtk_window_fullscreen (GtkWindow *window);
Asks to place You can track the fullscreen state via the "window-state-event" signal on GtkWidget.
Since 2.2 gtk_window_unfullscreen ()void gtk_window_unfullscreen (GtkWindow *window);
Asks to toggle off the fullscreen state for You can track the fullscreen state via the "window-state-event" signal on GtkWidget.
Since 2.2 gtk_window_set_keep_above ()void gtk_window_set_keep_above (GtkWindow *window, gboolean setting);
Asks to keep It's permitted to call this function before showing a window, in which case the window will be kept above when it appears onscreen initially. You can track the above state via the "window-state-event" signal on GtkWidget. Note that, according to the Extended Window Manager Hints specification, the above state is mainly meant for user preferences and should not be used by applications e.g. for drawing attention to their dialogs.
Since 2.4 gtk_window_set_keep_below ()void gtk_window_set_keep_below (GtkWindow *window, gboolean setting);
Asks to keep It's permitted to call this function before showing a window, in which case the window will be kept below when it appears onscreen initially. You can track the below state via the "window-state-event" signal on GtkWidget. Note that, according to the Extended Window Manager Hints specification, the above state is mainly meant for user preferences and should not be used by applications e.g. for drawing attention to their dialogs.
Since 2.4 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 On Windows, this function always works, since there's no window manager policy involved.
gtk_window_set_deletable ()void gtk_window_set_deletable (GtkWindow *window, gboolean setting);
By default, windows have a close button in the window frame. Some
window managers allow GTK+ to
disable this button. If you set the deletable property to On Windows, this function always works, since there's no window manager policy involved.
Since 2.10 gtk_window_set_frame_dimensions ()void gtk_window_set_frame_dimensions (GtkWindow *window, gint left, gint top, gint right, gint bottom);
(Note: this is a special-purpose function intended for the framebuffer
port; see
For windows with frames (see
gtk_window_set_has_frame ()void gtk_window_set_has_frame (GtkWindow *window, gboolean setting);
(Note: this is a special-purpose function for the framebuffer port,
that causes GTK+ to draw its own window border. For most applications,
you want
If this function is called on a window with setting of This function is used by the linux-fb port to implement managed windows, but it could conceivably be used by X-programs that want to do their own window decorations.
gtk_window_set_mnemonic_modifier ()void gtk_window_set_mnemonic_modifier (GtkWindow *window, GdkModifierType modifier); Sets the mnemonic modifier for this window.
gtk_window_set_role ()void gtk_window_set_role (GtkWindow *window, const gchar *role); This function is only useful on X11, not with other GTK+ targets. 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 ()void gtk_window_set_type_hint (GtkWindow *window, GdkWindowTypeHint 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_window_set_skip_taskbar_hint ()void gtk_window_set_skip_taskbar_hint (GtkWindow *window, gboolean setting); Windows may set a hint asking the desktop environment not to display the window in the task bar. This function sets this hint.
Since 2.2 gtk_window_set_skip_pager_hint ()void gtk_window_set_skip_pager_hint (GtkWindow *window, gboolean setting); Windows may set a hint asking the desktop environment not to display the window in the pager. This function sets this hint. (A "pager" is any desktop navigation tool such as a workspace switcher that displays a thumbnail representation of the windows on the screen.)
Since 2.2 gtk_window_set_urgency_hint ()void gtk_window_set_urgency_hint (GtkWindow *window, gboolean setting); Windows may set a hint asking the desktop environment to draw the users attention to the window. This function sets this hint.
Since 2.8 gtk_window_set_accept_focus ()void gtk_window_set_accept_focus (GtkWindow *window, gboolean setting); Windows may set a hint asking the desktop environment not to receive the input focus. This function sets this hint.
Since 2.4 gtk_window_set_focus_on_map ()void gtk_window_set_focus_on_map (GtkWindow *window, gboolean setting); Windows may set a hint asking the desktop environment not to receive the input focus when the window is mapped. This function sets this hint.
Since 2.6 gtk_window_set_startup_id ()void gtk_window_set_startup_id (GtkWindow *window, const gchar *startup_id);
Startup notification identifiers are used by desktop environment to
track application startup, to provide user feedback and other
features. This function changes the corresponding property on the
underlying GdkWindow. Normally, startup identifier is managed
automatically and you should only use this function in special cases
like transferring focus from other processes. You should use this
function before calling This function is only useful on X11, not with other GTK+ targets.
Since 2.12 gtk_window_set_role ()void gtk_window_set_role (GtkWindow *window, const gchar *role); This function is only useful on X11, not with other GTK+ targets. 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_get_decorated ()gboolean gtk_window_get_decorated (GtkWindow *window);
Returns whether the window has been set to have decorations
such as a title bar via
gtk_window_get_deletable ()gboolean gtk_window_get_deletable (GtkWindow *window);
Returns whether the window has been set to have a close button
via
Since 2.10 gtk_window_get_default_icon_list ()GList* gtk_window_get_default_icon_list (void);
Gets the value set by
gtk_window_get_default_size ()void gtk_window_get_default_size (GtkWindow *window, gint *width, gint *height); Gets the default size of the window. A value of -1 for the width or height indicates that a default size has not been explicitly set for that dimension, so the "natural" size of the window will be used.
gtk_window_get_destroy_with_parent ()gboolean gtk_window_get_destroy_with_parent (GtkWindow *window);
Returns whether the window will be destroyed with its transient parent. See
gtk_window_get_frame_dimensions ()void gtk_window_get_frame_dimensions (GtkWindow *window, gint *left, gint *top, gint *right, gint *bottom);
(Note: this is a special-purpose function intended for the
framebuffer port; see
Retrieves the dimensions of the frame window for this toplevel.
See
gtk_window_get_has_frame ()gboolean gtk_window_get_has_frame (GtkWindow *window);
Accessor for whether the window has a frame window exterior to
gtk_window_get_icon ()GdkPixbuf* gtk_window_get_icon (GtkWindow *window);
Gets the value set by
gtk_window_get_icon_list ()GList* gtk_window_get_icon_list (GtkWindow *window);
Retrieves the list of icons set by
gtk_window_get_icon_name ()gchar* gtk_window_get_icon_name (GtkWindow *window);
Returns the name of the themed icon for the window,
see
Since 2.6 gtk_window_get_mnemonic_modifier ()GdkModifierType gtk_window_get_mnemonic_modifier (GtkWindow *window);
Returns the mnemonic modifier for this window. See
gtk_window_get_modal ()gboolean gtk_window_get_modal (GtkWindow *window);
Returns whether the window is modal. See
gtk_window_get_position ()void gtk_window_get_position (GtkWindow *window, gint *root_x, gint *root_y);
This function returns the position you need to pass to
If you haven't changed the window gravity, its gravity will be
GDK_GRAVITY_NORTH_WEST. This means that
Moreover, nearly all window managers are historically broken with
respect to their handling of window gravity. So moving a window to
its current position as returned by
If a window has gravity GDK_GRAVITY_STATIC the window manager
frame is not relevant, and thus If you are saving and restoring your application's window positions, you should know that it's impossible for applications to do this without getting it somewhat wrong because applications do not have sufficient knowledge of window manager state. The Correct Mechanism is to support the session management protocol (see the "GnomeClient" object in the GNOME libraries for example) and allow the window manager to save your window sizes and positions.
gtk_window_get_role ()const gchar* gtk_window_get_role (GtkWindow *window);
Returns the role of the window. See
gtk_window_get_size ()void gtk_window_get_size (GtkWindow *window, gint *width, gint *height);
Obtains the current size of Note 1: Nearly any use of this function creates a race condition, because the size of the window may change between the time that you get the size and the time that you perform some action assuming that size is the current size. To avoid race conditions, connect to "configure-event" on the window and adjust your size-dependent state to match the size delivered in the GdkEventConfigure. Note 2: The returned size does not include the size of the window manager decorations (aka the window frame or border). Those are not drawn by GTK+ and GTK+ has no reliable method of determining their size.
Note 3: If you are getting a window size in order to position
the window onscreen, there may be a better way. The preferred
way is to simply set the window's semantic type with
In any case, if you insist on application-specified window
positioning, there's still a better way than
doing it yourself -
gtk_window_get_title ()const gchar* gtk_window_get_title (GtkWindow *window);
Retrieves the title of the window. See
gtk_window_get_transient_for ()GtkWindow* gtk_window_get_transient_for (GtkWindow *window);
Fetches the transient parent for this window. See
gtk_window_get_type_hint ()GdkWindowTypeHint gtk_window_get_type_hint (GtkWindow *window);
Gets the type hint for this window. See
gtk_window_get_skip_taskbar_hint ()gboolean gtk_window_get_skip_taskbar_hint (GtkWindow *window);
Gets the value set by
Since 2.2 gtk_window_get_skip_pager_hint ()gboolean gtk_window_get_skip_pager_hint (GtkWindow *window);
Gets the value set by
Since 2.2 gtk_window_get_urgency_hint ()gboolean gtk_window_get_urgency_hint (GtkWindow *window);
Gets the value set by
Since 2.8 gtk_window_get_accept_focus ()gboolean gtk_window_get_accept_focus (GtkWindow *window);
Gets the value set by
Since 2.4 gtk_window_get_focus_on_map ()gboolean gtk_window_get_focus_on_map (GtkWindow *window);
Gets the value set by
Since 2.6 gtk_window_get_group ()GtkWindowGroup* gtk_window_get_group (GtkWindow *window);
Returns the group for
Since 2.10 gtk_window_move ()void gtk_window_move (GtkWindow *window, gint x, gint y);
Asks the window manager to move
Note: the position is the position of the gravity-determined reference point for the window. The gravity determines two things: first, the location of the reference point in root window coordinates; and second, which point on the window is positioned at the reference point.
By default the gravity is GDK_GRAVITY_NORTH_WEST, so the reference
point is simply the
To position a window at the bottom right corner of the screen, you
would set GDK_GRAVITY_SOUTH_EAST, which means that the reference
point is at The Extended Window Manager Hints specification at http://www.freedesktop.org/Standards/wm-spec has a nice table of gravities in the "implementation notes" section.
The
gtk_window_parse_geometry ()gboolean gtk_window_parse_geometry (GtkWindow *window, const gchar *geometry);
Parses a standard X Window System geometry string - see the
manual page for X (type 'man X') for details on this.
If either a size or a position can be extracted from the
geometry string,
If
Note that for #include <gtk/gtk.h> static void fill_with_content (GtkWidget *vbox) { /* fill with content... */ } int 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_vbox_new (FALSE, 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), window, &size_hints, GDK_HINT_MIN_SIZE | GDK_HINT_BASE_SIZE | GDK_HINT_RESIZE_INC); if (argc > 1) { if (!gtk_window_parse_geometry (GTK_WINDOW (window), argv[1])) fprintf (stderr, "Failed to parse '%s'\n", argv[1]); } gtk_widget_show_all (window); gtk_main (); return 0; }
gtk_window_reshow_with_initial_size ()void gtk_window_reshow_with_initial_size (GtkWindow *window);
Hides
gtk_window_resize ()void gtk_window_resize (GtkWindow *window, gint width, gint height);
Resizes the window as if the user had done so, obeying geometry
constraints. The default geometry constraint is that windows may
not be smaller than their size request; to override this
constraint, call
If Windows may not be resized smaller than 1 by 1 pixels.
gtk_window_set_default_icon_list ()void gtk_window_set_default_icon_list (GList *list);
Sets an icon list to be used as fallback for windows that haven't
had
See
gtk_window_set_default_icon ()void gtk_window_set_default_icon (GdkPixbuf *icon);
Sets an icon to be used as fallback for windows that haven't
had
Since 2.4 gtk_window_set_default_icon_from_file ()gboolean gtk_window_set_default_icon_from_file (const gchar *filename, GError **err);
Sets an icon to be used as fallback for windows that haven't
had
Since 2.2 gtk_window_set_default_icon_name ()void gtk_window_set_default_icon_name (const gchar *name);
Sets an icon to be used as fallback for windows that haven't
had
Since 2.6 gtk_window_set_icon ()void gtk_window_set_icon (GtkWindow *window, GdkPixbuf *icon); Sets up the icon representing a GtkWindow. This icon is used when the window is minimized (also known as iconified). Some window managers or desktop environments may also place it in the window frame, or display it in other contexts. The icon should be provided in whatever size it was naturally drawn; that is, don't scale the image before passing it to GTK+. Scaling is postponed until the last minute, when the desired final size is known, to allow best quality.
If you have your icon hand-drawn in multiple sizes, use
This function is equivalent to calling
See also
gtk_window_set_icon_list ()void gtk_window_set_icon_list (GtkWindow *window, GList *list); Sets up the icon representing a GtkWindow. The icon is used when the window is minimized (also known as iconified). Some window managers or desktop environments may also place it in the window frame, or display it in other contexts.
By passing several sizes, you may improve the final image quality of the icon, by reducing or eliminating automatic image scaling. Recommended sizes to provide: 16x16, 32x32, 48x48 at minimum, and larger images (64x64, 128x128) if you have them.
See also
Note that transient windows (those who have been set transient for another
window using
gtk_window_set_icon_from_file ()gboolean gtk_window_set_icon_from_file (GtkWindow *window, const gchar *filename, GError **err);
Sets the icon for
This function is equivalent to calling
Since 2.2 gtk_window_set_icon_name ()void gtk_window_set_icon_name (GtkWindow *window, const gchar *name); Sets the icon for the window from a named themed icon. See the docs for GtkIconTheme for more details. Note that this has nothing to do with the WM_ICON_NAME property which is mentioned in the ICCCM.
Since 2.6 gtk_window_set_auto_startup_notification ()void gtk_window_set_auto_startup_notification (gboolean setting);
By default, after showing the first GtkWindow, GTK+ calls
In that example, you would disable startup notification temporarily, show your splash screen, then re-enable it so that showing the main window would automatically result in notification.
Since 2.2 gtk_window_get_opacity ()gdouble gtk_window_get_opacity (GtkWindow *window);
Fetches the requested opacity for this window. See
Since 2.12 gtk_window_set_opacity ()void gtk_window_set_opacity (GtkWindow *window, gdouble opacity);
Request the windowing system to make Note that setting a window's opacity after the window has been shown causes it to flicker once on Windows.
Since 2.12 Property DetailsThe
|
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"activate-focus"
signalvoid user_function (GtkWindow *window, gpointer user_data) : Run Last / Action
|
the object which received the signal. |
|
user data set when the signal handler was connected. |
"frame-event"
signalgboolean user_function (GtkWindow *window, GdkEvent *event, gpointer user_data) : Run Last
|
the object which received the signal. |
|
|
|
user data set when the signal handler was connected. |
Returns : |
"keys-changed"
signalvoid user_function (GtkWindow *window, gpointer user_data) : Run First
|
the object which received the signal. |
|
user data set when the signal handler was connected. |