Dialog

Dialog boxes are a convenient way to prompt the user for a small amount of input, e.g. to display a message, ask a question, or anything else that does not require extensive effort on the user's part.

GTK+ treats a dialog as a window split vertically. The top section is a GtkVBox, and is where widgets such as a GtkLabel or a GtkEntry should be packed. The bottom area is known as the action_area. This is generally used for packing buttons into the dialog which may perform functions such as cancel, ok, or apply.

GtkDialog boxes are created with a call to gtk_dialog_new() or gtk_dialog_new_with_buttons(). gtk_dialog_new_with_buttons() is recommended; it allows you to set the dialog title, some convenient flags, and add simple buttons.

If 'dialog' is a newly created dialog, the two primary areas of the window can be accessed through gtk_dialog_get_content_area() and gtk_dialog_get_action_area(), as can be seen from the example below.

A 'modal' dialog (that is, one which freezes the rest of the application from user input), can be created by calling gtk_window_set_modal() on the dialog. Use the GTK_WINDOW() macro to cast the widget returned from gtk_dialog_new() into a GtkWindow. When using gtk_dialog_new_with_buttons() you can also pass the GTK_DIALOG_MODAL flag to make a dialog modal.

If you add buttons to GtkDialog using gtk_dialog_new_with_buttons(), gtk_dialog_add_button(), gtk_dialog_add_buttons(), or gtk_dialog_add_action_widget(), clicking the button will emit a signal called "response" with a response ID that you specified. GTK+ will never assign a meaning to positive response IDs; these are entirely user-defined. But for convenience, you can use the response IDs in the GtkResponseType enumeration (these all have values less than zero). If a dialog receives a delete event, the "response" signal will be emitted with a response ID of GTK_RESPONSE_DELETE_EVENT.

If you want to block waiting for a dialog to return before returning control flow to your code, you can call gtk_dialog_run(). This function enters a recursive main loop and waits for the user to respond to the dialog, returning the response ID corresponding to the button the user clicked.

For the simple dialog in the following example, in reality you'd probably use GtkMessageDialog to save yourself some effort. But you'd need to create the dialog contents manually if you had more than a simple message in the dialog.

GtkDialog as GtkBuildable

The GtkDialog implementation of the GtkBuildable interface exposes the vbox and action_area as internal children with the names "vbox" and "action_area".

GtkDialog supports a custom <action-widgets> element, which can contain multiple <action-widget> elements. The "response" attribute specifies a numeric response, and the content of the element is the id of widget (which should be a child of the dialogs action_area).

Constructors

this
this(GtkDialog* gtkDialog)

Sets our main struct and passes it to the parent class

this
this(string title, Window parent, GtkDialogFlags flags, string[] buttonsText, ResponseType[] responses)
this(string title, Window parent, GtkDialogFlags flags, StockID[] stockIDs, ResponseType[] responses)

Both title and parent can be null.

this
this()

Creates a new dialog box. Widgets should not be packed into this GtkWindow directly, but into the vbox and action_area, as described above.

Members

Functions

addActionWidget
void addActionWidget(Widget child, int responseId)

Adds an activatable widget to the action area of a GtkDialog, connecting a signal handler that will emit the "response" signal on the dialog when the widget is activated. The widget is appended to the end of the dialog's action area. If you want to add a non-activatable widget, simply pack it into the action_area field of the GtkDialog struct.

addButton
Button addButton(StockID stockID, int responseId)
addButton
Widget addButton(string buttonText, int responseId)

Adds a button with the given text and sets things up so that clicking the button will emit the "response" signal with the given response_id. The button is appended to the end of the dialog's action area. The button widget is returned, but usually you don't need it.

addButtons
void addButtons(string[] buttonsText, ResponseType[] responses)
addButtons
void addButtons(StockID[] stockIDs, ResponseType[] responses)
addOnClose
void addOnClose(void delegate(Dialog) dlg, ConnectFlags connectFlags)

The ::close signal is a keybinding signal which gets emitted when the user uses a keybinding to close the dialog. The default binding for this signal is the Escape key.

addOnResponse
void addOnResponse(void delegate(gint, Dialog) dlg, ConnectFlags connectFlags)

Emitted when an action widget is clicked, the dialog receives a delete event, or the application programmer calls gtk_dialog_response(). On a delete event, the response ID is GTK_RESPONSE_DELETE_EVENT. Otherwise, it depends on which action widget was clicked. See Also GtkVBox, GtkWindow, GtkButton

getActionArea
HButtonBox getActionArea()

Returns the action area of dialog. Since 2.14

getContentArea
VBox getContentArea()

Returns the content area of dialog. Since 2.14

getDialogStruct
GtkDialog* getDialogStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getResponseForWidget
int getResponseForWidget(Widget widget)

Gets the response id of a widget in the action area of a dialog. Since 2.8

getStruct
void* getStruct()

the main Gtk struct as a void*

getWidgetForResponse
Widget getWidgetForResponse(int responseId)

Gets the widget button that uses the given response ID in the action area of a dialog. Since 2.20

response
void response(int responseId)

Emits the "response" signal with the given response ID. Used to indicate that the user has responded to the dialog in some way; typically either you or gtk_dialog_run() will be monitoring the ::response signal and take appropriate action.

run
int run()

Blocks in a recursive main loop until the dialog either emits the "response" signal, or is destroyed. If the dialog is destroyed during the call to gtk_dialog_run(), gtk_dialog_run() returns GTK_RESPONSE_NONE. Otherwise, it returns the response ID from the ::response signal emission. Before entering the recursive main loop, gtk_dialog_run() calls gtk_widget_show() on the dialog for you. Note that you still need to show any children of the dialog yourself. During gtk_dialog_run(), the default behavior of "delete-event" is disabled; if the dialog receives ::delete_event, it will not be destroyed as windows usually are, and gtk_dialog_run() will return GTK_RESPONSE_DELETE_EVENT. Also, during gtk_dialog_run() the dialog will be modal. You can force gtk_dialog_run() to return at any time by calling gtk_dialog_response() to emit the ::response signal. Destroying the dialog during gtk_dialog_run() is a very bad idea, because your post-run code won't know whether the dialog was destroyed or not. After gtk_dialog_run() returns, you are responsible for hiding or destroying the dialog if you wish to do so.

setAlternativeButtonOrder
void setAlternativeButtonOrder(int[] newOrder)

Sets an alternative button order. If the "gtk-alternative-button-order" setting is set to TRUE, the dialog buttons are reordered according to the order of the response ids in new_order. See gtk_dialog_set_alternative_button_order() for more information. This function is for use by language bindings. Since 2.6 Style Property Details The "action-area-border" style property "action-area-border" gint : Read Width of border around the button area at the bottom of the dialog. Allowed values: >= 0 Default value: 5

setDefaultResponse
void setDefaultResponse(int responseId)

Sets the last widget in the dialog's action area with the given response_id as the default widget for the dialog. Pressing "Enter" normally activates the default widget.

setResponseSensitive
void setResponseSensitive(int responseId, int setting)

Calls gtk_widget_set_sensitive (widget, setting) for each widget in the dialog's action area with the given response_id. A convenient way to sensitize/desensitize dialog buttons.

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.

Static functions

alternativeDialogButtonOrder
int alternativeDialogButtonOrder(Screen screen)

Returns TRUE if dialogs are expected to use an alternative button order on the screen screen. See gtk_dialog_set_alternative_button_order() for more details about alternative button order. If you need to use this function, you should probably connect to the ::notify:gtk-alternative-button-order signal on the GtkSettings object associated to screen, in order to be notified if the button order setting changes. Since 2.6

callBackClose
void callBackClose(GtkDialog* arg0Struct, Dialog _dialog)
Undocumented in source. Be warned that the author may not have intended to support it.
callBackResponse
void callBackResponse(GtkDialog* dialogStruct, gint responseId, Dialog _dialog)
Undocumented in source. Be warned that the author may not have intended to support it.

Variables

connectedSignals
int[string] connectedSignals;
gtkDialog
GtkDialog* gtkDialog;

the main Gtk struct

onCloseListeners
void delegate(Dialog)[] onCloseListeners;
Undocumented in source.
onResponseListeners
void delegate(gint, Dialog)[] onResponseListeners;
Undocumented in source.

Inherited Members

From Window

gtkWindow
GtkWindow* gtkWindow;

the main Gtk struct

getWindowStruct
GtkWindow* getWindowStruct()
Undocumented in source. Be warned that the author may not have intended to support it.
getStruct
void* getStruct()

the main Gtk struct as a void*

setStruct
void setStruct(GObject* obj)
Undocumented in source. Be warned that the author may not have intended to support it.
move
void move(double x, double y)

Move the window to an absolute position. just calls move(int, int). convinience because GdkEvent structs return the position coords as doubles

connectedSignals
int[string] connectedSignals;
onActivateDefaultListeners
void delegate(Window)[] onActivateDefaultListeners;
Undocumented in source.
addOnActivateDefault
void addOnActivateDefault(void delegate(Window) dlg, ConnectFlags connectFlags)

The ::activate-default signal is a keybinding signal which gets emitted when the user activates the default widget of window.

callBackActivateDefault
void callBackActivateDefault(GtkWindow* windowStruct, Window _window)
Undocumented in source. Be warned that the author may not have intended to support it.
onActivateFocusListeners
void delegate(Window)[] onActivateFocusListeners;
Undocumented in source.
addOnActivateFocus
void addOnActivateFocus(void delegate(Window) dlg, ConnectFlags connectFlags)

The ::activate-focus signal is a keybinding signal which gets emitted when the user activates the currently focused widget of window.

callBackActivateFocus
void callBackActivateFocus(GtkWindow* windowStruct, Window _window)
Undocumented in source. Be warned that the author may not have intended to support it.
onKeysChangedListeners
void delegate(Window)[] onKeysChangedListeners;
Undocumented in source.
addOnKeysChanged
void addOnKeysChanged(void delegate(Window) dlg, ConnectFlags connectFlags)

The ::keys-changed signal gets emitted when the set of accelerators or mnemonics that are associated with window changes.

callBackKeysChanged
void callBackKeysChanged(GtkWindow* windowStruct, Window _window)
Undocumented in source. Be warned that the author may not have intended to support it.
onSetFocusListeners
void delegate(Widget, Window)[] onSetFocusListeners;
Undocumented in source.
addOnSetFocus
void addOnSetFocus(void delegate(Widget, Window) dlg, ConnectFlags connectFlags)
callBackSetFocus
void callBackSetFocus(GtkWindow* windowStruct, GtkWidget* widget, Window _window)
Undocumented in source. Be warned that the author may not have intended to support it.
setTitle
void setTitle(string 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.

setWmclass
void setWmclass(string wmclassName, string wmclassClass)

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.

setResizable
void setResizable(int resizable)

Sets whether the user can resize a window. Windows are user resizable by default.

getResizable
int getResizable()

Gets the value set by gtk_window_set_resizable().

addAccelGroup
void addAccelGroup(AccelGroup accelGroup)

Associate accel_group with window, such that calling gtk_accel_groups_activate() on window will activate accelerators in accel_group.

removeAccelGroup
void removeAccelGroup(AccelGroup accelGroup)

Reverses the effects of gtk_window_add_accel_group().

activateFocus
int activateFocus()

Activates the current focused widget within the window.

activateDefault
int activateDefault()

Activates the default widget for the window, unless the current focused widget has been configured to receive the default action (see gtk_widget_set_receives_default()), in which case the focused widget is activated.

setModal
void setModal(int modal)

Sets a window modal or non-modal. Modal windows prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use gtk_window_set_transient_for() to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.

setDefaultSize
void setDefaultSize(int width, int 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 (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.

setDefaultGeometry
void setDefaultGeometry(int width, int height)

Like gtk_window_set_default_size(), but width and height are interpreted in terms of the base size and increment set with gtk_window_set_geometry_hints.

setGeometryHints
void setGeometryHints(Widget geometryWidget, GdkGeometry geometry, GdkWindowHints geomMask)

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.

setGravity
void setGravity(GdkGravity gravity)

Window gravity defines the meaning of coordinates passed to gtk_window_move(). See gtk_window_move() and GdkGravity for more details. The default window gravity is GDK_GRAVITY_NORTH_WEST which will typically "do what you mean."

getGravity
GdkGravity getGravity()

Gets the value set by gtk_window_set_gravity().

setPosition
void setPosition(GtkWindowPosition 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.

setTransientFor
void setTransientFor(Window 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. gtk_dialog_new_with_buttons() and other convenience functions in GTK+ will sometimes call gtk_window_set_transient_for() on your behalf. Passing NULL for parent unsets the current transient window. On Windows, this function puts the child window on top of the parent, much as the window manager would have done on X.

setAttachedTo
void setAttachedTo(Widget attachWidget)

Marks window as attached to attach_widget. This creates a logical binding between the window and the widget it belongs to, which is used by GTK+ to propagate information such as styling or accessibility to window as if it was a children of attach_widget. Examples of places where specifying this relation is useful are for instance a GtkMenu created by a GtkComboBox, a completion popup window created by GtkEntry or a typeahead search entry created by GtkTreeView. Note that this function should not be confused with gtk_window_set_transient_for(), which specifies a window manager relation between two toplevels instead. Passing NULL for attach_widget detaches the window.

setDestroyWithParent
void setDestroyWithParent(int setting)

If setting is TRUE, then destroying the transient parent of window will also destroy window itself. This is useful for dialogs that shouldn't persist beyond the lifetime of the main window they're associated with, for example.

setHideTitlebarWhenMaximized
void setHideTitlebarWhenMaximized(int setting)

If setting is TRUE, then window will request that it's titlebar should be hidden when maximized. This is useful for windows that don't convey any information other than the application name in the titlebar, to put the available screen space to better use. If the underlying window system does not support the request, the setting will not have any effect.

setScreen
void setScreen(Screen screen)

Sets the GdkScreen where the window is displayed; if the window is already mapped, it will be unmapped, and then remapped on the new screen. Since 2.2

getScreen
Screen getScreen()

Returns the GdkScreen associated with window. Since 2.2

isActive
int isActive()

Returns whether the window is part of the current active toplevel. (That is, the toplevel window receiving keystrokes.) The return value is TRUE if the window is active toplevel itself, but also if it is, say, a GtkPlug 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. See gtk_window_has_toplevel_focus() Since 2.4

hasToplevelFocus
int hasToplevelFocus()

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 GtkPlug, the results will differ. Since 2.4

listToplevels
ListG listToplevels()

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.

addMnemonic
void addMnemonic(uint keyval, Widget target)

Adds a mnemonic to this window.

removeMnemonic
void removeMnemonic(uint keyval, Widget target)

Removes a mnemonic from this window.

mnemonicActivate
int mnemonicActivate(uint keyval, GdkModifierType modifier)

Activates the targets associated with the mnemonic.

activateKey
int activateKey(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. Since 2.4

propagateKeyEvent
int propagateKeyEvent(GdkEventKey* event)

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. Since 2.4

getFocus
Widget getFocus()

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 TRUE for the widget.

setFocus
void setFocus(Widget focus)

If focus is not the current focus widget, and is focusable, sets it as the focus widget for the window. If focus is NULL, 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 gtk_widget_grab_focus() instead of this function.

getDefaultWidget
Widget getDefaultWidget()

Returns the default widget for window. See gtk_window_set_default() for more details. Since 2.14

setDefault
void setDefault(Widget defaultWidget)

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_widget_grab_focus() on the widget. Before making a widget the default widget, you must call gtk_widget_set_can_default() on the widget you'd like to make the default.

present
void present()

Presents a window to the user. This may mean raising the window in the stacking order, deiconifying it, moving it to the current desktop, and/or giving it the keyboard focus, possibly dependent on the user's platform, window manager, and preferences. If window is hidden, this function calls gtk_widget_show() as well. This function should be used when the user tries to open a window that's already open. Say for example the preferences dialog is currently open, and the user chooses Preferences from the menu a second time; use gtk_window_present() to move the already-open dialog where the user can see it. If you are calling this function in response to a user interaction, it is preferable to use gtk_window_present_with_time().

presentWithTime
void presentWithTime(uint timestamp)

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(). See gtk_window_present() for details. Since 2.8

close
void close()

Requests that the window is closed, similar to what happens when a window manager close button is clicked. This function can be used with close buttons in custom titlebars.

iconify
void iconify()

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 GtkWidget.

deiconify
void deiconify()

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 GtkWidget.

stick
void stick()

Asks to stick window, which means that it will appear on all user desktops. Note that you shouldn't assume the window is definitely stuck afterward, because other entities (e.g. the user or window manager) could unstick it again, and some window managers do not support sticking windows. But normally the window will end up stuck. Just don't write code that crashes if not. It's permitted to call this function before showing a window. You can track stickiness via the "window-state-event" signal on GtkWidget.

unstick
void unstick()

Asks to unstick window, which means that it will appear on only one of the user's desktops. Note that you shouldn't assume the window is definitely unstuck afterward, because other entities (e.g. the user or window manager) could stick it again. But normally the window will end up stuck. Just don't write code that crashes if not. You can track stickiness via the "window-state-event" signal on GtkWidget.

maximize
void maximize()

Asks to maximize window, so that it becomes full-screen. Note that you shouldn't assume the window is definitely maximized afterward, because other entities (e.g. the user or window manager) could unmaximize it again, and not all window managers support maximization. But normally the window will end up maximized. Just don't write code that crashes if not. It's permitted to call this function before showing a window, in which case the window will be maximized when it appears onscreen initially. You can track maximization via the "window-state-event" signal on GtkWidget.

unmaximize
void unmaximize()

Asks to unmaximize window. Note that you shouldn't assume the window is definitely unmaximized afterward, because other entities (e.g. the user or window manager) could maximize it again, and not all window managers honor requests to unmaximize. But normally the window will end up unmaximized. Just don't write code that crashes if not. You can track maximization via the "window-state-event" signal on GtkWidget.

fullscreen
void fullscreen()

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 GtkWidget. Since 2.2

unfullscreen
void unfullscreen()

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 GtkWidget. Since 2.2

setKeepAbove
void setKeepAbove(int setting)

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 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

setKeepBelow
void setKeepBelow(int setting)

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 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

beginResizeDrag
void beginResizeDrag(GdkWindowEdge edge, int button, int rootX, int rootY, uint 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.

beginMoveDrag
void beginMoveDrag(int button, int rootX, int rootY, uint 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.

setDecorated
void setDecorated(int setting)

By default, windows are decorated with a title bar, resize controls, etc. Some window managers allow GTK+ to disable these decorations, creating a borderless window. If you set the decorated property to FALSE using this function, GTK+ will do its best to convince the window manager not to decorate the window. 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 gtk_widget_show(). On Windows, this function always works, since there's no window manager policy involved.

setDeletable
void setDeletable(int 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 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 gtk_widget_show(). On Windows, this function always works, since there's no window manager policy involved. Since 2.10

setMnemonicModifier
void setMnemonicModifier(GdkModifierType modifier)

Sets the mnemonic modifier for this window.

setTypeHint
void setTypeHint(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_dialog_new_with_buttons() and other convenience functions in GTK+ will sometimes call gtk_window_set_type_hint() on your behalf.

setSkipTaskbarHint
void setSkipTaskbarHint(int 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

setSkipPagerHint
void setSkipPagerHint(int 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

setUrgencyHint
void setUrgencyHint(int 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

setAcceptFocus
void setAcceptFocus(int setting)

Windows may set a hint asking the desktop environment not to receive the input focus. This function sets this hint. Since 2.4

setFocusOnMap
void setFocusOnMap(int 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

setStartupId
void setStartupId(string startupId)

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 gtk_window_present() or any equivalent function generating a window map event. This function is only useful on X11, not with other GTK+ targets. Since 2.12

setRole
void setRole(string 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.

getDecorated
int getDecorated()

Returns whether the window has been set to have decorations such as a title bar via gtk_window_set_decorated().

getDeletable
int getDeletable()

Returns whether the window has been set to have a close button via gtk_window_set_deletable(). Since 2.10

getDefaultIconList
ListG getDefaultIconList()

Gets the value set by gtk_window_set_default_icon_list(). The list is a copy and should be freed with g_list_free(), but the pixbufs in the list have not had their reference count incremented.

getDefaultIconName
string getDefaultIconName()

Returns the fallback icon name for windows that has been set with gtk_window_set_default_icon_name(). The returned string is owned by GTK+ and should not be modified. It is only valid until the next call to gtk_window_set_default_icon_name(). Since 2.16

getDefaultSize
void getDefaultSize(int width, int 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.

getDestroyWithParent
int getDestroyWithParent()

Returns whether the window will be destroyed with its transient parent. See gtk_window_set_destroy_with_parent().

getHideTitlebarWhenMaximized
int getHideTitlebarWhenMaximized()

Returns whether the window has requested to have its titlebar hidden when maximized. See gtk_window_set_hide_titlebar_when_maximized().

getIcon
Pixbuf getIcon()

Gets the value set by gtk_window_set_icon() (or if you've called gtk_window_set_icon_list(), gets the first icon in the icon list).

getIconList
ListG getIconList()

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.

getIconName
string getIconName()

Returns the name of the themed icon for the window, see gtk_window_set_icon_name(). Since 2.6

getMnemonicModifier
GdkModifierType getMnemonicModifier()

Returns the mnemonic modifier for this window. See gtk_window_set_mnemonic_modifier().

getModal
int getModal()

Returns whether the window is modal. See gtk_window_set_modal().

getPosition
void getPosition(int rootX, int rootY)

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. See gtk_window_move() for more details. If you haven't changed the window gravity, its gravity will be GDK_GRAVITY_NORTH_WEST. This means that gtk_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 thus gtk_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.

getRole
string getRole()

Returns the role of the window. See gtk_window_set_role() for further explanation.

getSize
void getSize(int width, int height)

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 GdkEventConfigure, that is, GTK+ uses its locally-stored size, rather than querying the X server for the size. As a result, if you call gtk_window_resize() then immediately call gtk_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 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 gtk_window_set_type_hint(), which allows the window manager to e.g. center dialogs. Also, if you set the transient parent of dialogs with gtk_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.

getTitle
string getTitle()

Retrieves the title of the window. See gtk_window_set_title().

getTransientFor
Window getTransientFor()

Fetches the transient parent for this window. See gtk_window_set_transient_for().

getAttachedTo
Widget getAttachedTo()

Fetches the attach widget for this window. See gtk_window_set_attached_to().

getTypeHint
GdkWindowTypeHint getTypeHint()

Gets the type hint for this window. See gtk_window_set_type_hint().

getSkipTaskbarHint
int getSkipTaskbarHint()

Gets the value set by gtk_window_set_skip_taskbar_hint() Since 2.2

getSkipPagerHint
int getSkipPagerHint()

Gets the value set by gtk_window_set_skip_pager_hint(). Since 2.2

getUrgencyHint
int getUrgencyHint()

Gets the value set by gtk_window_set_urgency_hint() Since 2.8

getAcceptFocus
int getAcceptFocus()

Gets the value set by gtk_window_set_accept_focus(). Since 2.4

getFocusOnMap
int getFocusOnMap()

Gets the value set by gtk_window_set_focus_on_map(). Since 2.6

getGroup
WindowGroup getGroup()

Returns the group for window or the default group, if window is NULL or if window does not have an explicit window group. Since 2.10

hasGroup
int hasGroup()

Returns whether window has an explicit window group. Since 2.22

getWindowType
GtkWindowType getWindowType()

Gets the type of the window. See GtkWindowType. Since 2.20

move
void move(int x, int y)

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

parseGeometry
int parseGeometry(string geometry)

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 TRUE and calls gtk_window_set_default_size() and/or gtk_window_move() to resize/move the window. If gtk_window_parse_geometry() returns TRUE, 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 calling gtk_widget_show_all() on the contents and gtk_window_set_geometry_hints() on the window.

reshowWithInitialSize
void reshowWithInitialSize()

Warning gtk_window_reshow_with_initial_size has been deprecated since version 3.10 and should not be used in newly-written code. GUI builders can call gtk_widget_hide(), gtk_widget_unrealize() and then gtk_widget_show() on window themselves, if they still need this functionality. Hides window, then reshows it, resetting the default size and position of the window. Used by GUI builders only.

resize
void resize(int width, int 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 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 with gtk_window_set_default_size(). Windows may not be resized smaller than 1 by 1 pixels.

resizeToGeometry
void resizeToGeometry(int width, int height)

Like gtk_window_resize(), but width and height are interpreted in terms of the base size and increment set with gtk_window_set_geometry_hints.

setDefaultIconList
void setDefaultIconList(ListG list)

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.

setDefaultIcon
void setDefaultIcon(Pixbuf icon)

Sets an icon to be used as fallback for windows that haven't had gtk_window_set_icon() called on them from a pixbuf. Since 2.4

setDefaultIconFromFile
int setDefaultIconFromFile(string filename)

Sets an icon to be used as fallback for windows that haven't had gtk_window_set_icon_list() called on them from a file on disk. Warns on failure if err is NULL. Since 2.2

setDefaultIconName
void setDefaultIconName(string name)

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, see gtk_window_set_icon_name(). Since 2.6

setIcon
void setIcon(Pixbuf 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 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.

setIconList
void setIconList(ListG 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. 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.

setIconFromFile
int setIconFromFile(string filename)

Sets the icon for window. Warns on failure if err is NULL. This function is equivalent to calling gtk_window_set_icon() with a pixbuf created by loading the image from filename. Since 2.2

setIconName
void setIconName(string 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

setAutoStartupNotification
void setAutoStartupNotification(int setting)

By default, after showing the first GtkWindow, GTK+ calls gdk_notify_startup_complete(). Call this function to disable the automatic startup notification. You might do this if your first window is a splash screen, and you want to delay notification until after your real main window has been shown, for example. 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

getOpacity
double getOpacity()

Warning gtk_window_get_opacity has been deprecated since version 3.8 and should not be used in newly-written code. Use gtk_widget_get_opacity instead. Fetches the requested opacity for this window. See gtk_window_set_opacity(). Since 2.12

setOpacity
void setOpacity(double opacity)

Warning gtk_window_set_opacity has been deprecated since version 3.8 and should not be used in newly-written code. Use gtk_widget_set_opacity instead. Request 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 gtk_widget_is_composited(). 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. Since 2.12

getMnemonicsVisible
int getMnemonicsVisible()

Gets the value of the "mnemonics-visible" property. Since 2.20

setMnemonicsVisible
void setMnemonicsVisible(int setting)

Sets the "mnemonics-visible" property. Since 2.20

getFocusVisible
int getFocusVisible()

Gets the value of the "focus-visible" property.

setFocusVisible
void setFocusVisible(int setting)

Sets the "focus-visible" property.

setHasResizeGrip
void setHasResizeGrip(int value)

Sets whether window has a corner resize grip. Note that the resize grip is only shown if the window is actually resizable and not maximized. Use gtk_window_resize_grip_is_visible() to find out if the resize grip is currently shown.

getHasResizeGrip
int getHasResizeGrip()

Determines whether the window may have a resize grip.

resizeGripIsVisible
int resizeGripIsVisible()

Determines whether a resize grip is visible for the specified window.

getResizeGripArea
int getResizeGripArea(Rectangle rect)

If a window has a resize grip, this will retrieve the grip position, width and height into the specified GdkRectangle.

getApplication
Application getApplication()

Gets the GtkApplication associated with the window (if any).

setApplication
void setApplication(Application application)

Sets or unsets the GtkApplication associated with the window. The application will be kept alive for at least as long as the window is open.

setHasUserRefCount
void setHasUserRefCount(int setting)

Tells GTK+ whether to drop its extra reference to the window when gtk_widget_destroy() is called. This function is only exported for the benefit of language bindings which may need to keep the window alive until their wrapper object is garbage collected. There is no justification for ever calling this function in an application.

setTitlebar
void setTitlebar(Widget titlebar)

Sets a custom titlebar for window. If you set a custom titlebar, GTK+ will do its best to convince the window manager not to put its own titlebar on the window. Depending on the system, this function may not work for a window that is already visible, so you set the titlebar before calling gtk_widget_show().

Meta