Next: , Previous: gamma-curve, Up: Widgets


6.2.36 gtk-window

— Class: gtk-window

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:

Signals:

— Method: gtk-window-add-accel-group
     (gtk-window-add-accel-group window accel-group)

Associate accel-group (an accel-group) with window (an gtk-window).

— Method: gtk-window-remove-accel-group
     (gtk-window-remove-accel-group window accel-group)

Reverses the effect of gtk-window-add-accel-group.

— Method: gtk-window-activate-focus
     (gtk-window-activate-focus window)

Activates the current focused widget within the window (an gtk-window).

— Method: gtk-window-activate-default
     (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.

— Method: gtk-window-set-geometry-hints
     (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

— Function: gtk-window-list-toplevels
     (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

— Method: gtk-window-add-mnemonic
     (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

— Method: gtk-window-remove-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

— Method: gtk-window-activate-mnemonic
     (gtk-window-activate-mnemonic window keyval modifier)

Activates the targets associated with the mnemonic.

keyval: mnemonic keyval

modifier: a modifier-type - modifiers

— Method: gtk-window-activate-key
     (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

— Method: gtk-window-propagate-key-event
     (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

— Method: gtk-window-present
     (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.

— Method: 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

— Method: gtk-window-iconify
     (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.

— Method: gtk-window-deiconify
     (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.

— Method: gtk-window-stick
     (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.

— Method: gtk-window-unstick
     (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.

— Method: gtk-window-maximize
     (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.

— Method: gtk-window-unmaximize
     (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.

— Method: gtk-window-fullscreen
     (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.

— Method: gtk-window-unfullscreen
     (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.

— Method: gtk-window-begin-resize-drag
     (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

— Method: gtk-window-begin-move-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

— Method: gtk-window-set-frame-dimensions
     (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

— Function: gtk-window-default-icon-list
     (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.

— Function: gtk-window-default-icon
     (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.

— Function: gtk-window-default-icon-name
     (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.

— Method: gtk-window-move
     (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.

— Method: gtk-window-resize
     (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.