- how to close GTK window with C
- 2 Answers 2
- Gtk windows on closed
- Functions
- Properties
- Style Properties
- Signals
- Types and Values
- Object Hierarchy
- Implemented Interfaces
- Includes
- Description
- GtkWindow as GtkBuildable
- CSS nodes
- Functions
- gtk_window_new ()
- Parameters
- Returns
- gtk_window_set_title ()
- Parameters
- gtk_window_set_wmclass ()
- Parameters
- gtk_window_set_resizable ()
- Parameters
- gtk_window_get_resizable ()
- Parameters
- Returns
- gtk_window_add_accel_group ()
- Parameters
- gtk_window_remove_accel_group ()
- Parameters
- gtk_window_activate_focus ()
- Parameters
- Returns
- gtk_window_activate_default ()
- Parameters
- Returns
- gtk_window_set_modal ()
- Parameters
- gtk_window_set_default_size ()
- Parameters
- gtk_window_set_default_geometry ()
- Parameters
- gtk_window_set_geometry_hints ()
- Parameters
- gtk_window_set_gravity ()
- Parameters
- gtk_window_get_gravity ()
- Parameters
- Returns
- gtk_window_set_position ()
- Parameters
- gtk_window_set_transient_for ()
- Parameters
- gtk_window_set_attached_to ()
- Parameters
- gtk_window_set_destroy_with_parent ()
- Parameters
- gtk_window_set_hide_titlebar_when_maximized ()
- Parameters
- gtk_window_set_screen ()
- Parameters
- gtk_window_get_screen ()
- Parameters
- Returns
- gtk_window_is_active ()
- Parameters
- Returns
- gtk_window_is_maximized ()
- Parameters
- Returns
- gtk_window_has_toplevel_focus ()
- Parameters
- Returns
- gtk_window_list_toplevels ()
- Returns
- gtk_window_add_mnemonic ()
- Parameters
- gtk_window_remove_mnemonic ()
- Parameters
- gtk_window_mnemonic_activate ()
- Parameters
- Returns
- gtk_window_activate_key ()
- Parameters
- Returns
- gtk_window_propagate_key_event ()
- Parameters
- Returns
- gtk_window_get_focus ()
- Parameters
- Returns
- gtk_window_set_focus ()
- Parameters
- gtk_window_get_default_widget ()
- Parameters
- Returns
- gtk_window_set_default ()
- Parameters
- gtk_window_present ()
- Parameters
- gtk_window_present_with_time ()
- Parameters
- gtk_window_close ()
- Parameters
- gtk_window_iconify ()
- Parameters
- gtk_window_deiconify ()
- Parameters
- gtk_window_stick ()
- Parameters
- gtk_window_unstick ()
- Parameters
- gtk_window_maximize ()
- Parameters
- gtk_window_unmaximize ()
- Parameters
- gtk_window_fullscreen ()
- Parameters
- gtk_window_fullscreen_on_monitor ()
- Parameters
- gtk_window_unfullscreen ()
- Parameters
- gtk_window_set_keep_above ()
- Parameters
- gtk_window_set_keep_below ()
- Parameters
- gtk_window_begin_resize_drag ()
- Parameters
- gtk_window_begin_move_drag ()
- Parameters
- gtk_window_set_decorated ()
- Parameters
- gtk_window_set_deletable ()
- Parameters
- gtk_window_set_mnemonic_modifier ()
- Parameters
- gtk_window_set_type_hint ()
- Parameters
- gtk_window_set_skip_taskbar_hint ()
- Parameters
- gtk_window_set_skip_pager_hint ()
- Parameters
- gtk_window_set_urgency_hint ()
- Parameters
- gtk_window_set_accept_focus ()
- Parameters
- gtk_window_set_focus_on_map ()
- Parameters
- gtk_window_set_startup_id ()
- Parameters
- gtk_window_set_role ()
- Parameters
- gtk_window_get_decorated ()
- Parameters
- Returns
- gtk_window_get_deletable ()
- Parameters
- Returns
- gtk_window_get_default_icon_list ()
- Returns
- gtk_window_get_default_icon_name ()
- Returns
- gtk_window_get_default_size ()
- Parameters
- gtk_window_get_destroy_with_parent ()
- Parameters
- Returns
- gtk_window_get_hide_titlebar_when_maximized ()
- Parameters
- Returns
- gtk_window_get_icon ()
- Parameters
- Returns
- gtk_window_get_icon_list ()
- Parameters
- Returns
- gtk_window_get_icon_name ()
- Parameters
- Returns
- gtk_window_get_mnemonic_modifier ()
- Parameters
- Returns
- gtk_window_get_modal ()
- Parameters
- Returns
- gtk_window_get_position ()
- Parameters
how to close GTK window with C
i was doing a small project where i had a a fullscreen GUI (Glade, GTK and C) and needed to give the user a way to close the screen (obviously the window manager was not available due to the window being fullscreen).
problem rices when i attempt to compile this piece of code
i receive the following error
I tried to follow the documentation here, but seem to have failed badly
Does anyone have any ideas?
here is the full main.c if someone is intrested. Its my first attempt at C with gtk, so dont be too harsh, Thank you (=
2 Answers 2
You probably should call
But that window should come from somewhere.
(you may use a Gtk closure with a connection, or a callback with a client data, etc. or store somehow that window in a global variable, etc. )
Read more about C programming, then read a bit about callbacks and closures, then read more about GTK, and the signal mechanism of Gobject.
(your code shows a lot of confusion; I suggest to read the Getting started with GTK chapter after having read a good C programming book; BTW, I suggest to first write something which is not fullscreen, and only later improve it)
Don’t forget to enable all warnings and debug info when compiling, that is compile with
gcc -Wall -Wextra -g (and other arguments, perhaps using $(pkg-config —cflags gtk+-3.0) and also $(pkg-config —libs gtk+-3.0) for linking).
Gtk windows on closed
GtkWindow — Toplevel which can contain other widgets
Functions
GtkWidget * | gtk_window_new () |
void | gtk_window_set_title () |
void | gtk_window_set_wmclass () |
void | gtk_window_set_resizable () |
gboolean | gtk_window_get_resizable () |
void | gtk_window_add_accel_group () |
void | gtk_window_remove_accel_group () |
gboolean | gtk_window_activate_focus () |
gboolean | gtk_window_activate_default () |
void | gtk_window_set_modal () |
void | gtk_window_set_default_size () |
void | gtk_window_set_default_geometry () |
void | gtk_window_set_geometry_hints () |
void | gtk_window_set_gravity () |
GdkGravity | gtk_window_get_gravity () |
void | gtk_window_set_position () |
void | gtk_window_set_transient_for () |
void | gtk_window_set_attached_to () |
void | gtk_window_set_destroy_with_parent () |
void | gtk_window_set_hide_titlebar_when_maximized () |
void | gtk_window_set_screen () |
GdkScreen * | gtk_window_get_screen () |
gboolean | gtk_window_is_active () |
gboolean | gtk_window_is_maximized () |
gboolean | gtk_window_has_toplevel_focus () |
GList * | gtk_window_list_toplevels () |
void | gtk_window_add_mnemonic () |
void | gtk_window_remove_mnemonic () |
gboolean | gtk_window_mnemonic_activate () |
gboolean | gtk_window_activate_key () |
gboolean | gtk_window_propagate_key_event () |
GtkWidget * | gtk_window_get_focus () |
void | gtk_window_set_focus () |
GtkWidget * | gtk_window_get_default_widget () |
void | gtk_window_set_default () |
void | gtk_window_present () |
void | gtk_window_present_with_time () |
void | gtk_window_close () |
void | gtk_window_iconify () |
void | gtk_window_deiconify () |
void | gtk_window_stick () |
void | gtk_window_unstick () |
void | gtk_window_maximize () |
void | gtk_window_unmaximize () |
void | gtk_window_fullscreen () |
void | gtk_window_fullscreen_on_monitor () |
void | gtk_window_unfullscreen () |
void | gtk_window_set_keep_above () |
void | gtk_window_set_keep_below () |
void | gtk_window_begin_resize_drag () |
void | gtk_window_begin_move_drag () |
void | gtk_window_set_decorated () |
void | gtk_window_set_deletable () |
void | gtk_window_set_mnemonic_modifier () |
void | gtk_window_set_type_hint () |
void | gtk_window_set_skip_taskbar_hint () |
void | gtk_window_set_skip_pager_hint () |
void | gtk_window_set_urgency_hint () |
void | gtk_window_set_accept_focus () |
void | gtk_window_set_focus_on_map () |
void | gtk_window_set_startup_id () |
void | gtk_window_set_role () |
gboolean | gtk_window_get_decorated () |
gboolean | gtk_window_get_deletable () |
GList * | gtk_window_get_default_icon_list () |
const gchar * | gtk_window_get_default_icon_name () |
void | gtk_window_get_default_size () |
gboolean | gtk_window_get_destroy_with_parent () |
gboolean | gtk_window_get_hide_titlebar_when_maximized () |
GdkPixbuf * | gtk_window_get_icon () |
GList * | gtk_window_get_icon_list () |
const gchar * | gtk_window_get_icon_name () |
GdkModifierType | gtk_window_get_mnemonic_modifier () |
gboolean | gtk_window_get_modal () |
void | gtk_window_get_position () |
const gchar * | gtk_window_get_role () |
void | gtk_window_get_size () |
const gchar * | gtk_window_get_title () |
GtkWindow * | gtk_window_get_transient_for () |
GtkWidget * | gtk_window_get_attached_to () |
GdkWindowTypeHint | gtk_window_get_type_hint () |
gboolean | gtk_window_get_skip_taskbar_hint () |
gboolean | gtk_window_get_skip_pager_hint () |
gboolean | gtk_window_get_urgency_hint () |
gboolean | gtk_window_get_accept_focus () |
gboolean | gtk_window_get_focus_on_map () |
GtkWindowGroup * | gtk_window_get_group () |
gboolean | gtk_window_has_group () |
GtkWindowType | gtk_window_get_window_type () |
void | gtk_window_move () |
gboolean | gtk_window_parse_geometry () |
void | gtk_window_reshow_with_initial_size () |
void | gtk_window_resize () |
void | gtk_window_resize_to_geometry () |
void | gtk_window_set_default_icon_list () |
void | gtk_window_set_default_icon () |
gboolean | gtk_window_set_default_icon_from_file () |
void | gtk_window_set_default_icon_name () |
void | gtk_window_set_icon () |
void | gtk_window_set_icon_list () |
gboolean | gtk_window_set_icon_from_file () |
void | gtk_window_set_icon_name () |
void | gtk_window_set_auto_startup_notification () |
gdouble | gtk_window_get_opacity () |
void | gtk_window_set_opacity () |
gboolean | gtk_window_get_mnemonics_visible () |
void | gtk_window_set_mnemonics_visible () |
gboolean | gtk_window_get_focus_visible () |
void | gtk_window_set_focus_visible () |
void | gtk_window_set_has_resize_grip () |
gboolean | gtk_window_get_has_resize_grip () |
gboolean | gtk_window_resize_grip_is_visible () |
gboolean | gtk_window_get_resize_grip_area () |
GtkApplication * | gtk_window_get_application () |
void | gtk_window_set_application () |
void | gtk_window_set_has_user_ref_count () |
void | gtk_window_set_titlebar () |
GtkWidget * | gtk_window_get_titlebar () |
void | gtk_window_set_interactive_debugging () |
Properties
gboolean | accept-focus | Read / Write |
GtkApplication * | application | Read / Write |
GtkWidget * | attached-to | Read / Write / Construct |
gboolean | decorated | Read / Write |
int | default-height | Read / Write |
int | default-width | Read / Write |
gboolean | deletable | Read / Write |
gboolean | destroy-with-parent | Read / Write |
gboolean | focus-on-map | Read / Write |
gboolean | focus-visible | Read / Write |
GdkGravity | gravity | Read / Write |
gboolean | has-resize-grip | Read / Write |
gboolean | has-toplevel-focus | Read |
gboolean | hide-titlebar-when-maximized | Read / Write |
GdkPixbuf * | icon | Read / Write |
char * | icon-name | Read / Write |
gboolean | is-active | Read |
gboolean | is-maximized | Read |
gboolean | mnemonics-visible | Read / Write |
gboolean | modal | Read / Write |
gboolean | resizable | Read / Write |
gboolean | resize-grip-visible | Read |
char * | role | Read / Write |
GdkScreen * | screen | Read / Write |
gboolean | skip-pager-hint | Read / Write |
gboolean | skip-taskbar-hint | Read / Write |
char * | startup-id | Write |
char * | title | Read / Write |
GtkWindow * | transient-for | Read / Write / Construct |
GtkWindowType | type | Read / Write / Construct Only |
GdkWindowTypeHint | type-hint | Read / Write |
gboolean | urgency-hint | Read / Write |
GtkWindowPosition | window-position | Read / Write |
Style Properties
char * | decoration-button-layout | Read |
int | decoration-resize-handle | Read / Write |
Signals
void | activate-default | Action |
void | activate-focus | Action |
gboolean | enable-debugging | Action |
void | keys-changed | Run First |
void | set-focus | Run Last |
Types and Values
Object Hierarchy
Implemented Interfaces
GtkWindow implements AtkImplementorIface and GtkBuildable.
Includes
Description
A GtkWindow is a toplevel window which can contain other widgets. Windows normally have decorations that are under the control of the windowing system and allow the user to manipulate the window (resize it, move it, close it. ).
GtkWindow as GtkBuildable
The GtkWindow implementation of the GtkBuildable interface supports a custom element, which supports any number of elements representing the GtkAccelGroup objects you want to add to your window (synonymous with gtk_window_add_accel_group() .
It also supports the element, whose name property names the widget to receive the focus when the window is mapped.
An example of a UI definition fragment with accel groups:
The GtkWindow implementation of the GtkBuildable interface supports setting a child as the titlebar by specifying “titlebar” as the “type” attribute of a element.
CSS nodes
GtkWindow has a main CSS node with name window and style class .background, and a subnode with name decoration.
Style classes that are typically used with the main CSS node are .csd (when client-side decorations are in use), .solid-csd (for client-side decorations without invisible borders), .ssd (used by mutter when rendering server-side decorations). GtkWindow also represents window states with the following style classes on the main node: .tiled, .maximized, .fullscreen. Specialized types of window often add their own discriminating style classes, such as .popup or .tooltip.
GtkWindow adds the .titlebar and .default-decoration style classes to the widget that is added as a titlebar child.
Functions
gtk_window_new ()
Creates a new GtkWindow , which is a toplevel window that can contain other widgets. Nearly always, the type of the window should be GTK_WINDOW_TOPLEVEL . If you’re implementing something like a popup menu from scratch (which is a bad idea, just use GtkMenu ), you might use GTK_WINDOW_POPUP . GTK_WINDOW_POPUP is not for dialogs, though in some other toolkits dialogs are called “popups”. In GTK+, GTK_WINDOW_POPUP means a pop-up menu or pop-up tooltip. On X11, popup windows are not controlled by the window manager.
If you simply want an undecorated window (no window borders), use gtk_window_set_decorated() , don’t use GTK_WINDOW_POPUP .
All top-level windows created by gtk_window_new() are stored in an internal top-level window list. This list can be obtained from gtk_window_list_toplevels() . Due to Gtk+ keeping a reference to the window internally, gtk_window_new() does not return a reference to the caller.
Parameters
Returns
gtk_window_set_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.
Parameters
title of the window
gtk_window_set_wmclass ()
gtk_window_set_wmclass has been deprecated since version 3.22 and should not be used in newly-written code.
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.
Parameters
window name hint
window class hint
gtk_window_set_resizable ()
Sets whether the user can resize a window. Windows are user resizable by default.
Parameters
TRUE if the user can resize this window
gtk_window_get_resizable ()
Parameters
Returns
TRUE if the user can resize the window
gtk_window_add_accel_group ()
Associate accel_group with window , such that calling gtk_accel_groups_activate() on window will activate accelerators in accel_group .
Parameters
window to attach accelerator group to
gtk_window_remove_accel_group ()
Parameters
gtk_window_activate_focus ()
Activates the current focused widget within the window.
Parameters
Returns
TRUE if a widget got activated.
gtk_window_activate_default ()
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.
Parameters
Returns
TRUE if a widget got activated.
gtk_window_set_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.
Parameters
whether the window is modal
gtk_window_set_default_size ()
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 1×1, but passing 0 for width and height is OK, resulting in a 1×1 default size.
If you use this function to reestablish a previously saved window size, note that the appropriate size to save is the one returned by gtk_window_get_size() . Using the window allocation directly will not work in all circumstances and can lead to growing or shrinking windows.
Parameters
width in pixels, or -1 to unset the default width
height in pixels, or -1 to unset the default height
gtk_window_set_default_geometry ()
gtk_window_set_default_geometry has been deprecated since version 3.20 and should not be used in newly-written code.
This function does nothing. If you want to set a default size, use gtk_window_set_default_size() instead.
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.
Parameters
width in resize increments, or -1 to unset the default width
height in resize increments, or -1 to unset the default height
gtk_window_set_geometry_hints ()
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.
Parameters
widget the geometry hints used to be applied to or NULL . Since 3.20 this argument is ignored and GTK behaves as if NULL was set.
struct containing geometry information or NULL .
mask indicating which struct fields should be paid attention to
gtk_window_set_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.”
Parameters
gtk_window_get_gravity ()
Parameters
Returns
gtk_window_set_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.
Parameters
a position constraint.
gtk_window_set_transient_for ()
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 Wayland, this function can also be used to attach a new GTK_WINDOW_POPUP to a GTK_WINDOW_TOPLEVEL parent already mapped on screen so that the GTK_WINDOW_POPUP will be created as a subsurface-based window GDK_WINDOW_SUBSURFACE which can be positioned at will relatively to the GTK_WINDOW_TOPLEVEL surface.
On Windows, this function puts the child window on top of the parent, much as the window manager would have done on X.
Parameters
parent window, or NULL .
gtk_window_set_attached_to ()
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.
Parameters
gtk_window_set_destroy_with_parent ()
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.
Parameters
whether to destroy window with its transient parent
gtk_window_set_hide_titlebar_when_maximized ()
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.
Note that custom titlebars set with gtk_window_set_titlebar() are not affected by this. The application is in full control of their content and visibility anyway.
Parameters
whether to hide the titlebar when window is maximized
gtk_window_set_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.
Parameters
gtk_window_get_screen ()
Returns the GdkScreen associated with window .
Parameters
Returns
gtk_window_is_active ()
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()
Parameters
Returns
TRUE if the window part of the current active window.
gtk_window_is_maximized ()
Retrieves the current maximized state of window .
Note that since maximization is ultimately handled by the window manager and happens asynchronously to an application request, you shouldn’t assume the return value of this function changing immediately (or at all), as an effect of calling gtk_window_maximize() or gtk_window_unmaximize() .
Parameters
Returns
whether the window has a maximized state.
gtk_window_has_toplevel_focus ()
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.
Parameters
Returns
TRUE if the input focus is within this GtkWindow
gtk_window_list_toplevels ()
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.
Returns
list of toplevel widgets.
gtk_window_add_mnemonic ()
Adds a mnemonic to this window.
Parameters
the widget that gets activated by the mnemonic
gtk_window_remove_mnemonic ()
Removes a mnemonic from this window.
Parameters
the widget that gets activated by the mnemonic
gtk_window_mnemonic_activate ()
Activates the targets associated with the mnemonic.
Parameters
Returns
TRUE if the activation is done.
gtk_window_activate_key ()
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.
Parameters
Returns
TRUE if a mnemonic or accelerator was found and activated.
gtk_window_propagate_key_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.
Parameters
Returns
TRUE if a widget in the focus chain handled the event.
gtk_window_get_focus ()
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.
Parameters
Returns
the currently focused widget, or NULL if there is none.
gtk_window_set_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.
Parameters
widget to be the new focus widget, or NULL to unset any focus widget for the toplevel window.
gtk_window_get_default_widget ()
Returns the default widget for window . See gtk_window_set_default() for more details.
Parameters
Returns
the default widget, or NULL if there is none.
gtk_window_set_default ()
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 . When setting (rather than unsetting) the default widget it’s generally easier to call gtk_widget_grab_default() 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.
Parameters
widget to be the default, or NULL to unset the default widget for the toplevel.
gtk_window_present ()
Presents a window to the user. This function should not be used as when it is called, it is too late to gather a valid timestamp to allow focus stealing prevention to work correctly.
Parameters
gtk_window_present_with_time ()
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.
Presents a window to the user in response to a user interaction. The timestamp should be gathered when the window was requested to be shown (when clicking a link for example), rather than once the window is ready to be shown.
Parameters
the timestamp of the user interaction (typically a button or key press event) which triggered this call
gtk_window_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.
Parameters
gtk_window_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 .
Parameters
gtk_window_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 .
Parameters
gtk_window_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 .
Parameters
gtk_window_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 .
Parameters
gtk_window_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 , or by listening to notifications on the “is-maximized” property.
Parameters
gtk_window_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 .
Parameters
gtk_window_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 .
Parameters
gtk_window_fullscreen_on_monitor ()
Asks to place window in the fullscreen state. Note that you shouldn’t assume the window is definitely full screen afterward.
You can track the fullscreen state via the «window-state-event» signal on GtkWidget .
Parameters
a GdkScreen to draw to
which monitor to go fullscreen on
gtk_window_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 .
Parameters
gtk_window_set_keep_above ()
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.
Parameters
whether to keep window above other windows
gtk_window_set_keep_below ()
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.
Parameters
whether to keep window below other windows
gtk_window_begin_resize_drag ()
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.
Parameters
mouse button that initiated the drag
position of the resize control
X position where the user clicked to initiate the drag, in root window coordinates
Y position where the user clicked to initiate the drag
timestamp from the click event that initiated the drag
gtk_window_begin_move_drag ()
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.
Parameters
mouse button that initiated the drag
X position where the user clicked to initiate the drag, in root window coordinates
Y position where the user clicked to initiate the drag
timestamp from the click event that initiated the drag
gtk_window_set_decorated ()
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.
Parameters
TRUE to decorate the window
gtk_window_set_deletable ()
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.
Parameters
TRUE to decorate the window as deletable
gtk_window_set_mnemonic_modifier ()
Sets the mnemonic modifier for this window.
Parameters
the modifier mask used to activate mnemonics on this window.
gtk_window_set_type_hint ()
By setting the type hint for the window, you allow the window manager to decorate and handle the window in a way which is suitable to the function of the window in your application.
This function should be called before the window becomes visible.
gtk_dialog_new_with_buttons() and other convenience functions in GTK+ will sometimes call gtk_window_set_type_hint() on your behalf.
Parameters
the window type
gtk_window_set_skip_taskbar_hint ()
Windows may set a hint asking the desktop environment not to display the window in the task bar. This function sets this hint.
Parameters
TRUE to keep this window from appearing in the task bar
gtk_window_set_skip_pager_hint ()
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.)
Parameters
TRUE to keep this window from appearing in the pager
gtk_window_set_urgency_hint ()
Windows may set a hint asking the desktop environment to draw the users attention to the window. This function sets this hint.
Parameters
TRUE to mark this window as urgent
gtk_window_set_accept_focus ()
Windows may set a hint asking the desktop environment not to receive the input focus. This function sets this hint.
Parameters
TRUE to let this window receive input focus
gtk_window_set_focus_on_map ()
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.
Parameters
TRUE to let this window receive input focus on map
gtk_window_set_startup_id ()
Startup notification identifiers are used by desktop environment to track application startup, to provide user feedback and other features. This function changes the corresponding property on the underlying GdkWindow. Normally, startup identifier is managed automatically and you should only use this function in special cases like transferring focus from other processes. You should use this function before calling gtk_window_present() or any equivalent function generating a window map event.
This function is only useful on X11, not with other GTK+ targets.
Parameters
a string with startup-notification identifier
gtk_window_set_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.
Parameters
unique identifier for the window to be used when restoring a session
gtk_window_get_decorated ()
Returns whether the window has been set to have decorations such as a title bar via gtk_window_set_decorated() .
Parameters
Returns
TRUE if the window has been set to have decorations
gtk_window_get_deletable ()
Returns whether the window has been set to have a close button via gtk_window_set_deletable() .
Parameters
Returns
TRUE if the window has been set to have a close button
gtk_window_get_default_icon_list ()
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.
Returns
copy of default icon list.
gtk_window_get_default_icon_name ()
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() .
Returns
the fallback icon name for windows
gtk_window_get_default_size ()
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.
Parameters
location to store the default width, or NULL .
location to store the default height, or NULL .
gtk_window_get_destroy_with_parent ()
Returns whether the window will be destroyed with its transient parent. See gtk_window_set_destroy_with_parent() .
Parameters
Returns
TRUE if the window will be destroyed with its transient parent.
gtk_window_get_hide_titlebar_when_maximized ()
Returns whether the window has requested to have its titlebar hidden when maximized. See gtk_window_set_hide_titlebar_when_maximized() .
Parameters
Returns
TRUE if the window has requested to have its titlebar hidden when maximized
gtk_window_get_icon ()
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).
Parameters
Returns
icon for window or NULL if none.
gtk_window_get_icon_list ()
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.
Parameters
Returns
copy of window’s icon list.
gtk_window_get_icon_name ()
Returns the name of the themed icon for the window, see gtk_window_set_icon_name() .
Parameters
Returns
the icon name or NULL if the window has no themed icon.
gtk_window_get_mnemonic_modifier ()
Returns the mnemonic modifier for this window. See gtk_window_set_mnemonic_modifier() .
Parameters
Returns
the modifier mask used to activate mnemonics on this window.
gtk_window_get_modal ()
Returns whether the window is modal. See gtk_window_set_modal() .
Parameters
Returns
TRUE if the window is set to be modal and establishes a grab when shown
gtk_window_get_position ()
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.
The reliability of this function depends on the windowing system currently in use. Some windowing systems, such as Wayland, do not support a global coordinate system, and thus the position of the window will always be (0, 0). Others, like X11, do not have a reliable way to obtain the geometry of the decorations of a window if they are provided by the window manager. Additionally, on X11, window manager have been known to mismanage window gravity, which result in windows moving even if you use the coordinates of the current position as returned by this function.
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.
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.
Ideally, this function should return appropriate values if the window has client side decorations, assuming that the windowing system supports global coordinates.
In practice, saving the window position should not be left to applications, as they lack enough knowledge of the windowing system and the window manager state to effectively do so. The appropriate way to implement saving the window position is to use a platform-specific protocol, wherever that is available.
Parameters
return location for X coordinate of gravity-determined reference point, or NULL .