Toplevel which can contain other widgets
Derives from
<gtk-bin>
.This class defines the following slots:
type
- The type of the window
title
- The title of the window
startup-id
- Unique startup identifier for the window used by startup-notification
role
- Unique identifier for the window to be used when restoring a session
allow-shrink
- If TRUE, the window has no mimimum size. Setting this to TRUE is 99% of the time a bad idea
allow-grow
- If TRUE, users can expand the window beyond its minimum size
resizable
- If TRUE, users can resize the window
modal
- If TRUE, the window is modal (other windows are not usable while this one is up)
window-position
- The initial position of the window
default-width
- The default width of the window, used when initially showing the window
default-height
- The default height of the window, used when initially showing the window
destroy-with-parent
- If this window should be destroyed when the parent is destroyed
icon
- Icon for this window
icon-name
- Name of the themed icon for this window
screen
- The screen where this window will be displayed
type-hint
- Hint to help the desktop environment understand what kind of window this is and how to treat it.
skip-taskbar-hint
- TRUE if the window should not be in the task bar.
skip-pager-hint
- TRUE if the window should not be in the pager.
urgency-hint
- TRUE if the window should be brought to the user's attention.
accept-focus
- TRUE if the window should receive the input focus.
focus-on-map
- TRUE if the window should receive the input focus when mapped.
decorated
- Whether the window should be decorated by the window manager
deletable
- Whether the window frame should have a close button
gravity
- The window gravity of the window
transient-for
- The transient parent of the dialog
opacity
- The opacity of the window, from 0 to 1
is-active
- Whether the toplevel is the current active window
has-toplevel-focus
- Whether the input focus is within this GtkWindow
<gtk-window-type>
) ⇒ (ret <gtk-widget>
)Creates a new
<gtk-window>
, 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<gtk-menu>
), 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-decorated
, don't use<gtk-window-popup>
.
- type
- type of window
- ret
- a new
<gtk-window>
.
<gtk-window>
) (title mchars
)Sets the title of the
<gtk-window>
. 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.
- window
- a
<gtk-window>
- title
- title of the window
<gtk-window>
) (wmclass_name mchars
) (wmclass_class mchars
)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.
- window
- a
<gtk-window>
- wmclass-name
- window name hint
- wmclass-class
- window class hint
<gtk-window>
) (resizable bool
)Sets whether the user can resize a window. Windows are user resizable by default.
- window
- a
<gtk-window>
- resizable
- ‘
#t
’ if the user can resize this window
<gtk-window>
) ⇒ (ret bool
)Gets the value set by
gtk-window-set-resizable
.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if the user can resize the window
<gtk-window>
) (accel_group <gtk-accel-group>
)Associate accel-group with window, such that calling
gtk-accel-groups-activate
on window will activate accelerators in accel-group.
- window
- window to attach accelerator group to
- accel-group
- a
<gtk-accel-group>
<gtk-window>
) (accel_group <gtk-accel-group>
)Reverses the effects of
gtk-window-add-accel-group
.
- window
- a
<gtk-window>
- accel-group
- a
<gtk-accel-group>
<gtk-window>
) ⇒ (ret bool
)Activates the current focused widget within the window.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if a widget got activated.
<gtk-window>
) ⇒ (ret bool
)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<gtk-widget-flags>
), in which case the focused widget is activated.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if a widget got activated.
<gtk-window>
) (modal bool
)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.
- window
- a
<gtk-window>
- modal
- whether the window is modal
<gtk-window>
) (width int
) (height int
)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 (
gtk-window-set-geometry-hints
can be used to set these explicitly), the default size will be clamped to the nearest permitted size.Unlike
gtk-widget-set-size-request
, 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 -1 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
.For some uses,
gtk-window-resize
is a more appropriate function.gtk-window-resize
changes the current size of the window, rather than the size to be used on initial display.gtk-window-resize
always affects the window itself, not the geometry widget.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 width and height is OK, resulting in a 1x1 default size.
- window
- a
<gtk-window>
- width
- width in pixels, or -1 to unset the default width
- height
- height in pixels, or -1 to unset the default height
<gtk-window>
) (gravity <gdk-gravity>
)Window gravity defines the meaning of coordinates passed to
gtk-window-move
. Seegtk-window-move
and<gdk-gravity>
for more details.The default window gravity is
<gdk-gravity-north-west>
which will typically "do what you mean."
- window
- a
<gtk-window>
- gravity
- window gravity
<gtk-window>
) ⇒ (ret <gdk-gravity>
)Gets the value set by
gtk-window-set-gravity
.
- window
- a
<gtk-window>
- ret
- window gravity
<gtk-window>
) (position <gtk-window-position>
)Sets a position constraint for this window. If the old or new constraint is ‘GTK_WIN_POS_CENTER_ALWAYS’, this will also cause the window to be repositioned to satisfy the new constraint.
- window
- a
<gtk-window>
.- position
- a position constraint.
<gtk-window>
) (parent <gtk-window>
)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 callgtk-window-set-transient-for
on your behalf.On Windows, this function will and put the child window on top of the parent, much as the window manager would have done on X.
- window
- a
<gtk-window>
- parent
- parent window
<gtk-window>
) (setting bool
)If setting is ‘
#t
’, 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.
- window
- a
<gtk-window>
- setting
- whether to destroy window with its transient parent
<gtk-window>
) (screen <gdk-screen>
)Sets the
<gdk-screen>
where the window is displayed; if the window is already mapped, it will be unmapped, and then remapped on the new screen.
- window
- a
<gtk-window>
.- screen
- a
<gdk-screen>
.Since 2.2
<gtk-window>
) ⇒ (ret <gdk-screen>
)Returns the
<gdk-screen>
associated with window.
- window
- a
<gtk-window>
.- ret
- a
<gdk-screen>
.Since 2.2
<gtk-window>
) ⇒ (ret bool
)Returns whether the window is part of the current active toplevel. (That is, the toplevel window receiving keystrokes.) The return value is ‘
#t
’ if the window is active toplevel itself, but also if it is, say, a<gtk-plug>
embedded in the active toplevel. You might use this function if you wanted to draw a widget differently in an active window from a widget in an inactive window. Seegtk-window-has-toplevel-focus
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if the window part of the current active window.Since 2.4
<gtk-window>
) ⇒ (ret bool
)Returns whether the input focus is within this GtkWindow. For real toplevel windows, this is identical to
gtk-window-is-active
, but for embedded windows, like<gtk-plug>
, the results will differ.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if the input focus is within this GtkWindowSince 2.4
glist-of
)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.
- ret
- list of toplevel widgets
<gtk-window>
) (keyval unsigned-int
) (target <gtk-widget>
)Adds a mnemonic to this window.
- window
- a
<gtk-window>
- keyval
- the mnemonic
- target
- the widget that gets activated by the mnemonic
<gtk-window>
) (keyval unsigned-int
) (target <gtk-widget>
)Removes a mnemonic from this window.
- window
- a
<gtk-window>
- keyval
- the mnemonic
- target
- the widget that gets activated by the mnemonic
<gtk-window>
) (keyval unsigned-int
) (modifier <gdk-modifier-type>
) ⇒ (ret bool
)Activates the targets associated with the mnemonic.
- window
- a
<gtk-window>
- keyval
- the mnemonic
- modifier
- the modifiers
- ret
- ‘
#t
’ if the activation is done.
<gtk-window>
) (event <gdk-event-key>
) ⇒ (ret bool
)Activates mnemonics and accelerators for this
<gtk-window>
. 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.
- window
- a
<gtk-window>
- event
- a
<gdk-event-key>
- ret
- ‘
#t
’ if a mnemonic or accelerator was found and activated.
<gtk-window>
) (event <gdk-event-key>
) ⇒ (ret bool
)Propagate a key press or release event to the focus widget and up the focus container chain until a widget handles event. This is normally called by the default ::key_press_event and ::key_release_event handlers 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.
- window
- a
<gtk-window>
- event
- a
<gdk-event-key>
- ret
- ‘
#t
’ if a widget in the focus chain handled the event.
<gtk-window>
) ⇒ (ret <gtk-widget>
)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_WIDGET_HAS_FOCUS (widget)’ will not be ‘
#t
’ for the widget.
- window
- a
<gtk-window>
- ret
- the currently focused widget, or ‘
#f
’ if there is none.
<gtk-window>
) (focus <gtk-widget>
)If focus is not the current focus widget, and is focusable, sets it as the focus widget for the window. If focus is ‘
#f
’, unsets the focus widget for this window. To set the focus to a particular widget in the toplevel, it is usually more convenient to usegtk-widget-grab-focus
instead of this function.
- window
- a
<gtk-window>
- focus
- widget to be the new focus widget, or ‘
#f
’ to unset any focus widget for the toplevel window.
<gtk-window>
) (default_widget <gtk-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
<gtk-window>
about. When setting (rather than unsetting) the default widget it's generally easier to callgtk-widget-grab-focus
on the widget. Before making a widget the default widget, you must set the<gtk-can-default>
flag on the widget you'd like to make the default usinggtk-widget-set-flags
.
- window
- a
<gtk-window>
- default-widget
- widget to be the default, or ‘
#f
’ to unset the default widget for the toplevel.
<gtk-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 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.If you are calling this function in response to a user interaction, it is preferable to use
gtk-window-present-with-time
.
- window
- a
<gtk-window>
<gtk-window>
) (timestamp unsigned-int32
)Presents a window to the user in response to a user interaction. If you need to present a window without a timestamp, use
gtk-window-present
. Seegtk-window-present
for details.
- window
- a
<gtk-window>
- timestamp
- the timestamp of the user interaction (typically a button or key press event) which triggered this call
Since 2.8
<gtk-window>
)Asks to iconify (i.e. minimize) the specified 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
<gtk-widget>
.
- window
- a
<gtk-window>
<gtk-window>
)Asks to deiconify (i.e. unminimize) the specified 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
<gtk-widget>
.
- window
- a
<gtk-window>
<gtk-window>
)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
<gtk-widget>
.
- window
- a
<gtk-window>
<gtk-window>
)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
<gtk-widget>
.
- window
- a
<gtk-window>
<gtk-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
<gtk-widget>
.
- window
- a
<gtk-window>
<gtk-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
<gtk-widget>
.
- window
- a
<gtk-window>
<gtk-window>
)Asks to place window in the fullscreen state. Note that you shouldn't assume the window is definitely full screen afterward, because other entities (e.g. the user or window manager) could unfullscreen it again, and not all window managers honor requests to fullscreen windows. But normally the window will end up fullscreen. Just don't write code that crashes if not.
You can track the fullscreen state via the "window_state_event" signal on
<gtk-widget>
.
- window
- a
<gtk-window>
Since 2.2
<gtk-window>
)Asks to toggle off the fullscreen state for window. Note that you shouldn't assume the window is definitely not full screen afterward, because other entities (e.g. the user or window manager) could fullscreen it again, and not all window managers honor requests to unfullscreen windows. But normally the window will end up restored to its normal state. Just don't write code that crashes if not.
You can track the fullscreen state via the "window_state_event" signal on
<gtk-widget>
.
- window
- a
<gtk-window>
Since 2.2
<gtk-window>
) (setting bool
)Asks to keep window above, so that it stays on top. Note that you shouldn't assume the window is definitely above afterward, because other entities (e.g. the user or window manager) could not keep it above, and not all window managers support keeping windows above. But normally the window will end kept above. 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 kept above when it appears onscreen initially.
You can track the above state via the "window_state_event" signal on
<gtk-widget>
.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.
- window
- a
<gtk-window>
- setting
- whether to keep window above other windows
Since 2.4
<gtk-window>
) (setting bool
)Asks to keep window below, so that it stays in bottom. Note that you shouldn't assume the window is definitely below afterward, because other entities (e.g. the user or window manager) could not keep it below, and not all window managers support putting windows below. But normally the window will be kept below. 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 kept below when it appears onscreen initially.
You can track the below state via the "window_state_event" signal on
<gtk-widget>
.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.
- window
- a
<gtk-window>
- setting
- whether to keep window below other windows
Since 2.4
<gtk-window>
) (edge <gdk-window-edge>
) (button int
) (root_x int
) (root_y int
) (timestamp unsigned-int32
)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.
- window
- a
<gtk-window>
- edge
- position of the resize control
- button
- mouse button that initiated the drag
- root-x
- X position where the user clicked to initiate the drag, in root window coordinates
- root-y
- Y position where the user clicked to initiate the drag
- timestamp
- timestamp from the click event that initiated the drag
<gtk-window>
) (button int
) (root_x int
) (root_y int
) (timestamp unsigned-int32
)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.
- window
- a
<gtk-window>
- button
- mouse button that initiated the drag
- root-x
- X position where the user clicked to initiate the drag, in root window coordinates
- root-y
- Y position where the user clicked to initiate the drag
- timestamp
- timestamp from the click event that initiated the drag
<gtk-window>
) (setting bool
)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 ‘
#f
’ using this function, GTK+ will do its best to convince the window manager not to decorate the window. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before callinggtk-window-show
.On Windows, this function always works, since there's no window manager policy involved.
- window
- a
<gtk-window>
- setting
- ‘
#t
’ to decorate the window
<gtk-window>
) (setting bool
)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 ‘
#f
’ using this function, GTK+ will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before callinggtk-window-show
.On Windows, this function always works, since there's no window manager policy involved.
- window
- a
<gtk-window>
- setting
- ‘
#t
’ to decorate the window as deletableSince 2.10
<gtk-window>
) (left int
) (top int
) (right int
) (bottom int
)(Note: this is a special-purpose function intended for the framebuffer port; see
gtk-window-set-has-frame
. It will have no effect on the window border drawn by the window manager, which is the normal case when using the X Window system.)For windows with frames (see
gtk-window-set-has-frame
) this function can be used to change the size of the frame border.
- window
- a
<gtk-window>
that has a frame- left
- The width of the left border
- top
- The height of the top border
- right
- The width of the right border
- bottom
- The height of the bottom border
<gtk-window>
) (setting bool
)(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
gtk-window-set-decorated
instead, which tells the window manager whether to draw the window border.)If this function is called on a window with setting of ‘
#t
’, before it is realized or showed, it will have a "frame" window around window->window, accessible in window->frame. Using the signal frame_event you can receive all events targeted at the frame.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.
- window
- a
<gtk-window>
- setting
- a boolean
<gtk-window>
) (modifier <gdk-modifier-type>
)Sets the mnemonic modifier for this window.
- window
- a
<gtk-window>
- modifier
- the modifier mask used to activate mnemonics on this window.
<gtk-window>
) (role mchars
)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.
- window
- a
<gtk-window>
- role
- unique identifier for the window to be used when restoring a session
<gtk-window>
) (hint <gdk-window-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 callgtk-window-set-type-hint
on your behalf.
- window
- a
<gtk-window>
- hint
- the window type
<gtk-window>
) (setting bool
)Windows may set a hint asking the desktop environment not to display the window in the task bar. This function sets this hint.
- window
- a
<gtk-window>
- setting
- ‘
#t
’ to keep this window from appearing in the task barSince 2.2
<gtk-window>
) (setting bool
)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.)
- window
- a
<gtk-window>
- setting
- ‘
#t
’ to keep this window from appearing in the pagerSince 2.2
<gtk-window>
) (setting bool
)Windows may set a hint asking the desktop environment to draw the users attention to the window. This function sets this hint.
- window
- a
<gtk-window>
- setting
- ‘
#t
’ to mark this window as urgentSince 2.8
<gtk-window>
) (setting bool
)Windows may set a hint asking the desktop environment not to receive the input focus. This function sets this hint.
- window
- a
<gtk-window>
- setting
- ‘
#t
’ to let this window receive input focusSince 2.4
<gtk-window>
) (setting bool
)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.
- window
- a
<gtk-window>
- setting
- ‘
#t
’ to let this window receive input focus on mapSince 2.6
<gtk-window>
) ⇒ (ret bool
)Returns whether the window has been set to have decorations such as a title bar via
gtk-window-set-decorated
.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if the window has been set to have decorations
<gtk-window>
) ⇒ (ret bool
)Returns whether the window has been set to have a close button via
gtk-window-set-deletable
.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if the window has been set to have a close buttonSince 2.10
glist-of
)Gets the value set by
gtk-window-set-default-icon-list
. The list is a copy and should be freed withg-list-free
, but the pixbufs in the list have not had their reference count incremented.
- ret
- copy of default icon list
<gtk-window>
) ⇒ (width int
) (height int
)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.
- window
- a
<gtk-window>
- width
- location to store the default width, or ‘
#f
’- height
- location to store the default height, or ‘
#f
’
<gtk-window>
) ⇒ (ret bool
)Returns whether the window will be destroyed with its transient parent. See
gtk-window-set-destroy-with-parent
.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if the window will be destroyed with its transient parent.
<gtk-window>
) ⇒ (left int
) (top int
) (right int
) (bottom int
)(Note: this is a special-purpose function intended for the framebuffer port; see
gtk-window-set-has-frame
. It will not return the size of the window border drawn by the window manager, which is the normal case when using a windowing system. Seegdk-window-get-frame-extents
to get the standard window border extents.)Retrieves the dimensions of the frame window for this toplevel. See
gtk-window-set-has-frame
,gtk-window-set-frame-dimensions
.
- window
- a
<gtk-window>
- left
- location to store the width of the frame at the left, or ‘
#f
’- top
- location to store the height of the frame at the top, or ‘
#f
’- right
- location to store the width of the frame at the returns, or ‘
#f
’- bottom
- location to store the height of the frame at the bottom, or ‘
#f
’
<gtk-window>
) ⇒ (ret bool
)Accessor for whether the window has a frame window exterior to window->window. Gets the value set by
gtk-window-set-has-frame
.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if a frame has been added to the window viagtk-window-set-has-frame
.
<gtk-window>
) ⇒ (ret <gdk-pixbuf>
)Gets the value set by
gtk-window-set-icon
(or if you've calledgtk-window-set-icon-list
, gets the first icon in the icon list).
- window
- a
<gtk-window>
- ret
- icon for window
<gtk-window>
) ⇒ (ret glist-of
)Retrieves the list of icons set by
gtk-window-set-icon-list
. The list is copied, but the reference count on each member won't be incremented.
- window
- a
<gtk-window>
- ret
- copy of window's icon list
<gtk-window>
) ⇒ (ret mchars
)Returns the name of the themed icon for the window, see
gtk-window-set-icon-name
.
- window
- a
<gtk-window>
- ret
- the icon name or ‘
#f
’ if the window has no themed iconSince 2.6
<gtk-window>
) ⇒ (ret <gdk-modifier-type>
)Returns the mnemonic modifier for this window. See
gtk-window-set-mnemonic-modifier
.
- window
- a
<gtk-window>
- ret
- the modifier mask used to activate mnemonics on this window.
<gtk-window>
) ⇒ (ret bool
)Returns whether the window is modal. See
gtk-window-set-modal
.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if the window is set to be modal and establishes a grab when shown
<gtk-window>
) ⇒ (root_x int
) (root_y int
)This function returns the position you need to pass to
gtk-window-move
to keep window in its current position. This means that the meaning of the returned value varies with window gravity. Seegtk-window-move
for more details.If you haven't changed the window gravity, its gravity will be
<gdk-gravity-north-west>
. This means thatgtk-window-get-position
gets the position of the top-left corner of the window manager frame for the window.gtk-window-move
sets the position of this same top-left corner.
gtk-window-get-position
is not 100% reliable because the X Window System does not specify a way to obtain the geometry of the decorations placed on a window by the window manager. Thus GTK+ is using a "best guess" that works with most window managers.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
gtk-window-get-position
tends to result in moving the window slightly. Window managers are slowly getting better over time.If a window has gravity
<gdk-gravity-static>
the window manager frame is not relevant, and thusgtk-window-get-position
will always produce accurate results. However you can't use static gravity to do things like place a window in a corner of the screen, because static gravity ignores the window manager decorations.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.
- window
- a
<gtk-window>
- root-x
- return location for X coordinate of gravity-determined reference p\oint
- root-y
- return location for Y coordinate of gravity-determined reference p\oint
<gtk-window>
) ⇒ (ret mchars
)Returns the role of the window. See
gtk-window-set-role
for further explanation.
- window
- a
<gtk-window>
- ret
- the role of the window if set, or ‘
#f
’. The returned is owned by the widget and must not be modified or freed.
<gtk-window>
) ⇒ (width int
) (height int
)Obtains the current size of window. If window is not onscreen, it returns the size GTK+ will suggest to the window manager for the initial window size (but this is not reliably the same as the size the window manager will actually select). The size obtained by
gtk-window-get-size
is the last size received in a<gdk-event-configure>
, that is, GTK+ uses its locally-stored size, rather than querying the X server for the size. As a result, if you callgtk-window-resize
then immediately callgtk-window-get-size
, the size won't have taken effect yet. After the window manager processes the resize request, GTK+ receives notification that the size has changed via a configure event, and the size of the window gets updated.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
<gdk-event-configure>
.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
gtk-window-set-type-hint
, which allows the window manager to e.g. center dialogs. Also, if you set the transient parent of dialogs withgtk-window-set-transient-for
window managers will often center the dialog over its parent window. It's much preferred to let the window manager handle these things rather than doing it yourself, because all apps will behave consistently and according to user prefs if the window manager handles it. Also, the window manager can take the size of the window decorations/border into account, while your application cannot.In any case, if you insist on application-specified window positioning, there's still a better way than doing it yourself -
gtk-window-set-position
will frequently handle the details for you.
- window
- a
<gtk-window>
- width
- return location for width, or ‘
#f
’- height
- return location for height, or ‘
#f
’
<gtk-window>
) ⇒ (ret mchars
)Retrieves the title of the window. See
gtk-window-set-title
.
- window
- a
<gtk-window>
- ret
- the title of the window, or ‘
#f
’ if none has been set explicitely. The returned string is owned by the widget and must not be modified or freed.
<gtk-window>
) ⇒ (ret <gtk-window>
)Fetches the transient parent for this window. See
gtk-window-set-transient-for
.
- window
- a
<gtk-window>
- ret
- the transient parent for this window, or ‘
#f
’ if no transient parent has been set.
<gtk-window>
) ⇒ (ret <gdk-window-type-hint>
)Gets the type hint for this window. See
gtk-window-set-type-hint
.
- window
- a
<gtk-window>
- ret
- the type hint for window.
<gtk-window>
) ⇒ (ret bool
)Gets the value set by
gtk-window-set-skip-taskbar-hint
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if window shouldn't be in taskbarSince 2.2
<gtk-window>
) ⇒ (ret bool
)Gets the value set by
gtk-window-set-skip-pager-hint
.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if window shouldn't be in pagerSince 2.2
<gtk-window>
) ⇒ (ret bool
)Gets the value set by
gtk-window-set-urgency-hint
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if window is urgentSince 2.8
<gtk-window>
) ⇒ (ret bool
)Gets the value set by
gtk-window-set-accept-focus
.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if window should receive the input focusSince 2.4
<gtk-window>
) ⇒ (ret bool
)Gets the value set by
gtk-window-set-focus-on-map
.
- window
- a
<gtk-window>
- ret
- ‘
#t
’ if window should receive the input focus when mapped.Since 2.6
<gtk-window>
) ⇒ (ret <gtk-window-group>
)Returns the group for window or the default group, if window is ‘
#f
’ or if window does not have an explicit window group.
- window
- a
<gtk-window>
, or ‘#f
’- ret
- the
<gtk-window-group>
for a window or the default groupSince 2.10
<gtk-window>
) (x int
) (y int
)Asks the window manager to move window to the given position. Window managers are free to ignore this; most window managers ignore requests for initial window positions (instead using a user-defined placement algorithm) and honor requests after the window has already been shown.
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 x, y supplied togtk-window-move
. The top-left corner of the window decorations (aka window frame or border) will be placed at x, y. Therefore, to position a window at the top left of the screen, you want to use the default gravity (which is<gdk-gravity-north-west>
) and move the window to 0,0.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 x + the window width and y + the window height, and the bottom-right corner of the window border will be placed at that reference point. So, to place a window in the bottom right corner you would first set gravity to south east, then write: ‘gtk_window_move (window,gdk-screen-width
- window_width,gdk-screen-height
- window_height)’ (note that this example does not take multi-head scenarios into account).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-get-position
documentation may also be relevant.
- window
- a
<gtk-window>
- x
- X coordinate to move window to
- y
- Y coordinate to move window to
<gtk-window>
) (geometry mchars
) ⇒ (ret bool
)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 ‘#t
’ and callsgtk-window-set-default-size
and/orgtk-window-move
to resize/move the window.If
gtk-window-parse-geometry
returns ‘#t
’, 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 callinggtk-widget-show-all
on the contents andgtk-window-set-geometry-hints
on the window.#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; }
- window
- a
<gtk-window>
- geometry
- geometry string
- ret
- ‘
#t
’ if string was parsed successfully
<gtk-window>
)Hides window, then reshows it, resetting the default size and position of the window. Used by GUI builders only.
- window
- a
<gtk-window>
<gtk-window>
) (width int
) (height int
)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
gtk-widget-set-size-request
to set the window's request to a smaller value.If
gtk-window-resize
is called before showing a window for the first time, it overrides any default size set withgtk-window-set-default-size
.Windows may not be resized smaller than 1 by 1 pixels.
- window
- a
<gtk-window>
- width
- width in pixels to resize the window to
- height
- height in pixels to resize the window to
glist-of
)Sets an icon list to be used as fallback for windows that haven't had
gtk-window-set-icon-list
called on them to set up a window-specific icon list. This function allows you to set up the icon for all windows in your app at once.See
gtk-window-set-icon-list
for more details.
- list
- a list of
<gdk-pixbuf>
<gdk-pixbuf>
)Sets an icon to be used as fallback for windows that haven't had
gtk-window-set-icon
called on them from a pixbuf.
- icon
- the icon
Since 2.4
mchars
)Sets an icon to be used as fallback for windows that haven't had
gtk-window-set-icon-list
called on them from a named themed icon, seegtk-window-set-icon-name
.
- name
- the name of the themed icon
Since 2.6
<gtk-window>
) (icon <gdk-pixbuf>
)Sets up the icon representing a
<gtk-window>
. 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
gtk-window-set-icon-list
. Then the best size will be used.This function is equivalent to calling
gtk-window-set-icon-list
with a 1-element list.See also
gtk-window-set-default-icon-list
to set the icon for all windows in your application in one go.
- window
- a
<gtk-window>
- icon
- icon image, or ‘
#f
’
<gtk-window>
) (list glist-of
)Sets up the icon representing a
<gtk-window>
. 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.
gtk-window-set-icon-list
allows you to pass in the same icon in several hand-drawn sizes. The list should contain the natural sizes your icon is available in; 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.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
gtk-window-set-default-icon-list
to set the icon for all windows in your application in one go.Note that transient windows (those who have been set transient for another window using
gtk-window-set-transient-for
) will inherit their icon from their transient parent. So there's no need to explicitly set the icon on transient windows.
- window
- a
<gtk-window>
- list
- list of
<gdk-pixbuf>
<gtk-window>
) (filename mchars
) ⇒ (ret bool
)Sets the icon for window. Warns on failure if err is ‘
#f
’.This function is equivalent to calling
gtk-window-set-icon
with a pixbuf created by loading the image from filename.
- window
- a
<gtk-window>
- filename
- location of icon file
- err
- location to store error, or ‘
#f
’.- ret
- ‘
#t
’ if setting the icon succeeded.Since 2.2
<gtk-window>
) (name mchars
)Sets the icon for the window from a named themed icon. See the docs for
<gtk-icon-theme>
for more details.Note that this has nothing to do with the WM_ICON_NAME property which is mentioned in the ICCCM.
- window
- a
<gtk-window>
- name
- the name of the themed icon
Since 2.6