Superclass: bin atk-implementor-iface buildable
Subclasses: plug assistant dialog
gtk-window is a toplevel window that can contain other widgets. Nearly always, the type of the window should be :toplevel
. If you're implementing something like a popup menu from scratch (which is a bad idea, just use menu), you might use :popup
. :popup
is not for dialogs, though in some other toolkits dialogs are called "popups". In GTK+, :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-decorated, don't use :popup
.
Slots:
boolean
. Accessor: gtk-window-accept-focus
.
Windows may set a hint asking the desktop environment not to receive the input focus. True if the window should receive the input focus.
Default value: True
boolean
. Accessor: gtk-window-allow-grow
.
If True, users can expand the window beyond its minimum size.
Default value: True
boolean
. Accessor: gtk-window-allow-shrink
.
If True, the window has no mimimum size. Setting this to True is 99% of the time a bad idea.
Default value: False
boolean
. Accessor: gtk-window-decorated
.
Whether the window should be decorated by the window manager.
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. 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 calling widget-show.
On Windows, this always works, since there's no window manager policy involved.
Default value: True
integer
. Accessor: gtk-window-default-height
.
The default height of the window, used when initially showing the 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 widget-width-request and widget-height-request, that set 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, see 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.
Default value: -1
gtk-window-default-widget
.
The default widget is the widget that's activated when the user presses Enter in a dialog (for example). When setting (rather than unsetting) the default widget it's generally easier to call gtk_widget_grab_focus() on the widget. Before making a widget the default widget, you must set the widget-can-default on the widget you'd like to make the default.
integer
. Accessor: gtk-window-default-width
.
The default width of the window, used when initially showing the window.
See gtk-window-default-height for explanation.
Default value: -1
boolean
. Accessor: gtk-window-deletable
.
Whether the window frame should have a close button.
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 False 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 calling widget-show.
On Windows, this always works, since there's no window manager policy involved.
Default value: True
boolean
. Accessor: gtk-window-destroy-with-parent
.
If this window should be destroyed when the parent is destroyed.
Default value: False
gtk-window-focus
.
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-focus will not be True for the widget.
Settings this works the following way. If focus is not the current focus widget, and is focusable, sets it as the focus widget for the window. If focus is NIL, unsets the focus widget for this window. To set the focus to a particular widget in the toplevel, it is usually more convenient to use widget-grab-focus instead of this function.
boolean
. Accessor: gtk-window-focus-on-map
.
Windows may set a hint asking the desktop environment not to receive the input focus when the window is mapped. True if the window should receive the input focus when mapped.
Default value: True
gtk-window-group
. Read-only.
Returns the group for window or the default group, if window does not have an explicit window group.
gtk-window-gravity
.
The window gravity of the window. See gtk-window-move and gravity for more details about window gravity.
Default value: :north-west
boolean
. Accessor: gtk-window-has-frame
.
(Note: this is a special-purpose property for the framebuffer port that causes GTK+ to draw its own window border. For most applications you want gtk-window-decorated instead, which tells the window manager whether to draw the window border.)
If this property is set to True on a window, then before it is realized or showed, it will have a "frame" window around widget-window. Using the signal gtk-window::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.
boolean
. Accessor: gtk-window-has-toplevel-focus
. Read-only.
Whether the input focus is within this GtkWindow.
Default value: False
gtk-window-icon
.
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.
Icon for this window.
gtk-window-icon-list
.
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.
This property 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-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-transient-for) will inherit their icon from their transient parent. So there's no need to explicitly set the icon on transient windows.
string
. Accessor: gtk-window-icon-name
.
The icon-name property specifies the name of the themed icon to use as the window icon. See icon-theme for more details.
Note that this has nothing to do with the WM_ICON_NAME property which is mentioned in the ICCCM.
Default value: NIL
boolean
. Accessor: gtk-window-is-active
. Read-only.
Whether the toplevel is the current active window.
Default value: False
boolean
. Accessor: gtk-window-keep-above
. Write-only.
Setting this to True 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 set this property 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 widget::window-state-event signal.
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.
boolean
. Accessor: gtk-window-keep-below
. Write-only.
Setting this to True 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 set this property 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 widget::window-state-event signal.
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.
gtk-window-mnemonic-modifier
.
The modifier mask used to activate mnemonics on this window.
boolean
. Accessor: gtk-window-modal
.
If True, the window is modal (other windows are not usable while this one is up).
Default value: False
double-float
. Accessor: gtk-window-opacity
.
The requested opacity of the window.
Setting opacity requests the windowing system to make window partially transparent, with opacity 0 being fully transparent and 1 fully opaque. (Values of the opacity parameter are clamped to the [0,1] range.) On X11 this has any effect only on X screens with a compositing manager running. See screen-composited-p. On Windows it should work always.
Note that setting a window's opacity after the window has been shown causes it to flicker once on Windows.
Allowed values: [0,1]
Default value: 1
boolean
. Accessor: gtk-window-resizable
.
If True, users can resize the window.
Default value: True
string
. Accessor: gtk-window-role
.
Unique identifier for the window to be used when restoring a session.
This 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.
Default value: NIL
gtk-window-screen
.
The screen where this window will be displayed.
boolean
. Accessor: gtk-window-skip-pager-hint
.
Windows may set a hint asking the desktop environment not to display the window in the pager. (A "pager" is any desktop navigation tool such as a workspace switcher that displays a thumbnail representation of the windows on the screen.) True if the window should not be in the pager.
Default value: False
boolean
. Accessor: gtk-window-skip-taskbar-hint
.
Windows may set a hint asking the desktop environment not to display the window in the task bar. True if the window should not be in the task bar.
Default value: False
string
. Accessor: gtk-window-startup-id
. Write-only.
The startup-id is a write-only property for setting window's startup notification identifier.
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 gdk-window. Normally, startup identifier is managed automatically and you should only use this function in special cases like transferring focus from other processes. You should set this before calling gtk-window-present or any equivalent function generating a window map event.
This is only useful on X11, not with other GTK+ targets.
Default value: NIL
string
. Accessor: gtk-window-title
.
The title of the window.
Default value: NIL
gtk-window-transient-for
.
The transient parent of the 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.
On Windows, this puts the child window on top of the parent, much as the window manager would have done on X.
gtk-window-type
.
The type of the window.
Default value: :toplevel
gtk-window-type-hint
.
Hint to help the desktop environment understand what kind of window this is and how to treat it.
This should be set before the window becomes visible.
Default value: :normal
boolean
. Accessor: gtk-window-urgency-hint
.
Windows may set a hint asking the desktop environment to draw the users attention to the window. True if the window should be brought to the user's attention.
Default value: False
gtk-window-window-position
.
The initial position of the window.
Default value: :none
Signals:
The activate-default signal is a keybinding signal which gets emitted when the user activates the default widget of window.
The activate-default signal is a keybinding signal which gets emitted when the user activates the currently focused widget of window.
boolean
. Options: run-last.
The keys-changed signal gets emitted when the set of accelerators or mnemonics that are associated with window changes.
(gtk-window-add-accel-group window accel-group)
Associate accel-group (an accel-group) with window (an gtk-window).
(gtk-window-remove-accel-group window accel-group)
Reverses the effect of gtk-window-add-accel-group.
(gtk-window-activate-focus window)
Activates the current focused widget within the window (an gtk-window).
(gtk-window-activate-default window) => activated-p
Activates the default widget for the window (an gtk-window), unless the current focused widget has been configured to receive the default action (see widget-receives-default), in which case the focused widget is activated.
Returns True if a widget got activated.
(gtk-window-set-geometry-hints window geometry-widget geometry geometry-mask)
This function sets up hints about how a window (an gtk-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 geometry struct.
geometry-widget: a widget - widget the geometry hints will be applied to
geometry: a geometry - struct containing geometry information
geometry-mask: a window-hints - mask indicating which struct fields should be paid attention to
(gtk-window-list-toplevels) => windows
Returns a list of all existing toplevel windows. The widgets in the list are not individually referenced.
windows: fresh list of gtk-window
(window-add-mnemonic window keyval target)
Adds a mnemonic to this window (a gtk-window).
keyval: mnemonic keyval
target: the widget that gets activated by the mnemonic
(gtk-window-remove-mnemonic window keyval target)
Removes a mnemonic from this window (a gtk-window).
keyval: mnemonic keyval
target: the widget that gets activated by the mnemonic
(gtk-window-activate-mnemonic window keyval modifier)
Activates the targets associated with the mnemonic.
keyval: mnemonic keyval
modifier: a modifier-type - modifiers
(gtk-window-activate-key window event) => activated-p
Activates mnemonics and accelerators for this gtk-window. This is normally called by the default widget::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.
Returns True if a mnemonic or accelerator was found and activated.
event: a event-key
(gtk-window-propagate-key-event window event) => handled-p
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 widget::key-press-event and widget::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.
Returns True if a widget in the focus chain handled the event.
event: a event-key
(gtk-window-present window)
Presents a window (a gtk-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 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.
(gtk-window-present-with-time window timestamp)
Presents a window (a gtk-window) to the user in response to a user interaction. If you need to present a window without a timestamp, use gtk-window-present. See gtk-window-present for details.
timestamp: the timestamp of the user interaction (typically a button or key press event) which triggered this call
(gtk-window-iconify window)
Asks to iconify (i.e. minimize) the specified window (a gtk-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 widget::window-state-event signal on GtkWidget.
(gtk-window-deiconify 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 widget::window-state-event.
(gtk-window-stick window)
Asks to stick window (a gtk-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 widget::window-state-event signal.
(gtk-window-unstick window)
Asks to unstick window (a gtk-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 widget::window-state-event signal.
(gtk-window-maximize window)
Asks to maximize window (a gtk-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 widget::window-state-event signal.
(gtk-window-unmaximize window)
Asks to unmaximize window (a gtk-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 widget::window-state-event signal on GtkWidget.
(gtk-window-fullscreen window)
Asks to place window (a gtk-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 widget::window-state-event signal.
(gtk-window-unfullscreen window)
Asks to toggle off the fullscreen state for window (a gtk-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 widget::window-state-event signal.
(gtk-window-begin-resize-drag window edge button root-x root-y timestamp)
Starts resizing a window (a gtk-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.
edge: a window-edge; position of the resize control
button: an integer; mouse button that initiated the drag
root-x: an integer; X position where the user clicked to initiate the drag, in root window coordinates
root-y: an integer; Y position where the user clicked to initiate the drag
timestamp: timestamp from the click event that initiated the drag
(gtk-window-begin-move-drag window button root-x root-y 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.
edge: a window-edge; position of the resize control
button: an integer; mouse button that initiated the drag
root-x: an integer; X position where the user clicked to initiate the drag, in root window coordinates
root-y: an integer; Y position where the user clicked to initiate the drag
timestamp: timestamp from the click event that initiated the drag
(gtk-window-set-frame-dimensions window left top right bottom)
(Note: this is a special-purpose function intended for the framebuffer port; see gtk-window-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 this function can be used to change the size of the frame border.
window: a gtk-window
left, top, right, bottom - integers; sizes of left, top, right, bottom borders
(gtk-window-default-icon-list) => icons (setf (gtk-window-default-icon-list) icons)
An icon list to be used as fallback for windows that haven't had gtk-window-icon-list set 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.
icons: a list of pixbufs.
(setf (gtk-window-default-icon) icon)
Sets an icon (a pixbuf) to be used as fallback for windows that haven't had gtk-window-icon set on them from a pixbuf.
(setf (gtk-window-default-icon-name) name)
Sets an icon (a string
- the name of the themed icon) to be used as fallback for windows.
(gtk-window-move window x y)
Asks the window manager to move window (a gtk-window) to the given position (defined by integers x, y). 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 :north-west
, so the reference point is simply the x, y supplied. 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 :north-west
) and move the window to 0,0.
To position a window at the bottom right corner of the screen, you would set :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.
(gtk-window-resize window width height)
Resizes the window (a gtk-window) to width pixels by height pixels 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 (see widget-width-request, widget-height-request).
If gtk-window-resize is called before showing a window for the first time, it overrides any default size set with gtk-window-default-width, gtk-window-default-height.
Windows may not be resized smaller than 1 by 1 pixels.