GtkWindow

GtkWindow — Toplevel which can contain other widgets

Synopsis

#include <gtk/gtk.h>


                    GtkWindow;
GtkWidget*          gtk_window_new                      (GtkWindowType type);
void                gtk_window_set_title                (GtkWindow *window,
                                                         const gchar *title);
void                gtk_window_set_wmclass              (GtkWindow *window,
                                                         const gchar *wmclass_name,
                                                         const gchar *wmclass_class);
void                gtk_window_set_policy               (GtkWindow *window,
                                                         gint allow_shrink,
                                                         gint allow_grow,
                                                         gint auto_shrink);
void                gtk_window_set_resizable            (GtkWindow *window,
                                                         gboolean resizable);
gboolean            gtk_window_get_resizable            (GtkWindow *window);
void                gtk_window_add_accel_group          (GtkWindow *window,
                                                         GtkAccelGroup *accel_group);
void                gtk_window_remove_accel_group       (GtkWindow *window,
                                                         GtkAccelGroup *accel_group);
#define             gtk_window_position
gboolean            gtk_window_activate_focus           (GtkWindow *window);
gboolean            gtk_window_activate_default         (GtkWindow *window);
void                gtk_window_set_modal                (GtkWindow *window,
                                                         gboolean modal);
void                gtk_window_set_default_size         (GtkWindow *window,
                                                         gint width,
                                                         gint height);
void                gtk_window_set_geometry_hints       (GtkWindow *window,
                                                         GtkWidget *geometry_widget,
                                                         GdkGeometry *geometry,
                                                         GdkWindowHints geom_mask);
void                gtk_window_set_gravity              (GtkWindow *window,
                                                         GdkGravity gravity);
GdkGravity          gtk_window_get_gravity              (GtkWindow *window);
void                gtk_window_set_position             (GtkWindow *window,
                                                         GtkWindowPosition position);
void                gtk_window_set_transient_for        (GtkWindow *window,
                                                         GtkWindow *parent);
void                gtk_window_set_destroy_with_parent  (GtkWindow *window,
                                                         gboolean setting);
void                gtk_window_set_screen               (GtkWindow *window,
                                                         GdkScreen *screen);
GdkScreen*          gtk_window_get_screen               (GtkWindow *window);
gboolean            gtk_window_is_active                (GtkWindow *window);
gboolean            gtk_window_has_toplevel_focus       (GtkWindow *window);
GList*              gtk_window_list_toplevels           (void);
void                gtk_window_add_mnemonic             (GtkWindow *window,
                                                         guint keyval,
                                                         GtkWidget *target);
void                gtk_window_remove_mnemonic          (GtkWindow *window,
                                                         guint keyval,
                                                         GtkWidget *target);
gboolean            gtk_window_mnemonic_activate        (GtkWindow *window,
                                                         guint keyval,
                                                         GdkModifierType modifier);
gboolean            gtk_window_activate_key             (GtkWindow *window,
                                                         GdkEventKey *event);
gboolean            gtk_window_propagate_key_event      (GtkWindow *window,
                                                         GdkEventKey *event);
GtkWidget*          gtk_window_get_focus                (GtkWindow *window);
void                gtk_window_set_focus                (GtkWindow *window,
                                                         GtkWidget *focus);
void                gtk_window_set_default              (GtkWindow *window,
                                                         GtkWidget *default_widget);
void                gtk_window_present                  (GtkWindow *window);
void                gtk_window_present_with_time        (GtkWindow *window,
                                                         guint32 timestamp);
void                gtk_window_iconify                  (GtkWindow *window);
void                gtk_window_deiconify                (GtkWindow *window);
void                gtk_window_stick                    (GtkWindow *window);
void                gtk_window_unstick                  (GtkWindow *window);
void                gtk_window_maximize                 (GtkWindow *window);
void                gtk_window_unmaximize               (GtkWindow *window);
void                gtk_window_fullscreen               (GtkWindow *window);
void                gtk_window_unfullscreen             (GtkWindow *window);
void                gtk_window_set_keep_above           (GtkWindow *window,
                                                         gboolean setting);
void                gtk_window_set_keep_below           (GtkWindow *window,
                                                         gboolean setting);
void                gtk_window_begin_resize_drag        (GtkWindow *window,
                                                         GdkWindowEdge edge,
                                                         gint button,
                                                         gint root_x,
                                                         gint root_y,
                                                         guint32 timestamp);
void                gtk_window_begin_move_drag          (GtkWindow *window,
                                                         gint button,
                                                         gint root_x,
                                                         gint root_y,
                                                         guint32 timestamp);
void                gtk_window_set_decorated            (GtkWindow *window,
                                                         gboolean setting);
void                gtk_window_set_deletable            (GtkWindow *window,
                                                         gboolean setting);
void                gtk_window_set_frame_dimensions     (GtkWindow *window,
                                                         gint left,
                                                         gint top,
                                                         gint right,
                                                         gint bottom);
void                gtk_window_set_has_frame            (GtkWindow *window,
                                                         gboolean setting);
void                gtk_window_set_mnemonic_modifier    (GtkWindow *window,
                                                         GdkModifierType modifier);
void                gtk_window_set_role                 (GtkWindow *window,
                                                         const gchar *role);
void                gtk_window_set_type_hint            (GtkWindow *window,
                                                         GdkWindowTypeHint hint);
void                gtk_window_set_skip_taskbar_hint    (GtkWindow *window,
                                                         gboolean setting);
void                gtk_window_set_skip_pager_hint      (GtkWindow *window,
                                                         gboolean setting);
void                gtk_window_set_urgency_hint         (GtkWindow *window,
                                                         gboolean setting);
void                gtk_window_set_accept_focus         (GtkWindow *window,
                                                         gboolean setting);
void                gtk_window_set_focus_on_map         (GtkWindow *window,
                                                         gboolean setting);
void                gtk_window_set_startup_id           (GtkWindow *window,
                                                         const gchar *startup_id);
void                gtk_window_set_role                 (GtkWindow *window,
                                                         const gchar *role);
gboolean            gtk_window_get_decorated            (GtkWindow *window);
gboolean            gtk_window_get_deletable            (GtkWindow *window);
GList*              gtk_window_get_default_icon_list    (void);
void                gtk_window_get_default_size         (GtkWindow *window,
                                                         gint *width,
                                                         gint *height);
gboolean            gtk_window_get_destroy_with_parent  (GtkWindow *window);
void                gtk_window_get_frame_dimensions     (GtkWindow *window,
                                                         gint *left,
                                                         gint *top,
                                                         gint *right,
                                                         gint *bottom);
gboolean            gtk_window_get_has_frame            (GtkWindow *window);
GdkPixbuf*          gtk_window_get_icon                 (GtkWindow *window);
GList*              gtk_window_get_icon_list            (GtkWindow *window);
gchar*              gtk_window_get_icon_name            (GtkWindow *window);
GdkModifierType     gtk_window_get_mnemonic_modifier    (GtkWindow *window);
gboolean            gtk_window_get_modal                (GtkWindow *window);
void                gtk_window_get_position             (GtkWindow *window,
                                                         gint *root_x,
                                                         gint *root_y);
const gchar*        gtk_window_get_role                 (GtkWindow *window);
void                gtk_window_get_size                 (GtkWindow *window,
                                                         gint *width,
                                                         gint *height);
const gchar*        gtk_window_get_title                (GtkWindow *window);
GtkWindow*          gtk_window_get_transient_for        (GtkWindow *window);
GdkWindowTypeHint   gtk_window_get_type_hint            (GtkWindow *window);
gboolean            gtk_window_get_skip_taskbar_hint    (GtkWindow *window);
gboolean            gtk_window_get_skip_pager_hint      (GtkWindow *window);
gboolean            gtk_window_get_urgency_hint         (GtkWindow *window);
gboolean            gtk_window_get_accept_focus         (GtkWindow *window);
gboolean            gtk_window_get_focus_on_map         (GtkWindow *window);
GtkWindowGroup*     gtk_window_get_group                (GtkWindow *window);
void                gtk_window_move                     (GtkWindow *window,
                                                         gint x,
                                                         gint y);
gboolean            gtk_window_parse_geometry           (GtkWindow *window,
                                                         const gchar *geometry);
void                gtk_window_reshow_with_initial_size (GtkWindow *window);
void                gtk_window_resize                   (GtkWindow *window,
                                                         gint width,
                                                         gint height);
void                gtk_window_set_default_icon_list    (GList *list);
void                gtk_window_set_default_icon         (GdkPixbuf *icon);
gboolean            gtk_window_set_default_icon_from_file
                                                        (const gchar *filename,
                                                         GError **err);
void                gtk_window_set_default_icon_name    (const gchar *name);
void                gtk_window_set_icon                 (GtkWindow *window,
                                                         GdkPixbuf *icon);
void                gtk_window_set_icon_list            (GtkWindow *window,
                                                         GList *list);
gboolean            gtk_window_set_icon_from_file       (GtkWindow *window,
                                                         const gchar *filename,
                                                         GError **err);
void                gtk_window_set_icon_name            (GtkWindow *window,
                                                         const gchar *name);
void                gtk_window_set_auto_startup_notification
                                                        (gboolean setting);
gdouble             gtk_window_get_opacity              (GtkWindow *window);
void                gtk_window_set_opacity              (GtkWindow *window,
                                                         gdouble opacity);


Object Hierarchy

  GObject
   +----GInitiallyUnowned
         +----GtkObject
               +----GtkWidget
                     +----GtkContainer
                           +----GtkBin
                                 +----GtkWindow
                                       +----GtkDialog
                                       +----GtkAssistant
                                       +----GtkPlug

Implemented Interfaces

GtkWindow implements AtkImplementorIface and GtkBuildable.

Properties

  "accept-focus"             gboolean              : Read / Write
  "allow-grow"               gboolean              : Read / Write
  "allow-shrink"             gboolean              : Read / Write
  "decorated"                gboolean              : Read / Write
  "default-height"           gint                  : Read / Write
  "default-width"            gint                  : Read / Write
  "deletable"                gboolean              : Read / Write
  "destroy-with-parent"      gboolean              : Read / Write
  "focus-on-map"             gboolean              : Read / Write
  "gravity"                  GdkGravity            : Read / Write
  "has-toplevel-focus"       gboolean              : Read
  "icon"                     GdkPixbuf             : Read / Write
  "icon-name"                gchararray            : Read / Write
  "is-active"                gboolean              : Read
  "modal"                    gboolean              : Read / Write
  "opacity"                  gdouble               : Read / Write
  "resizable"                gboolean              : Read / Write
  "role"                     gchararray            : Read / Write
  "screen"                   GdkScreen             : Read / Write
  "skip-pager-hint"          gboolean              : Read / Write
  "skip-taskbar-hint"        gboolean              : Read / Write
  "startup-id"               gchararray            : Write
  "title"                    gchararray            : Read / Write
  "transient-for"            GtkWindow             : Read / Write / Construct
  "type"                     GtkWindowType         : Read / Write / Construct Only
  "type-hint"                GdkWindowTypeHint     : Read / Write
  "urgency-hint"             gboolean              : Read / Write
  "window-position"          GtkWindowPosition     : Read / Write

Signals

  "activate-default"                               : Run Last / Action
  "activate-focus"                                 : Run Last / Action
  "frame-event"                                    : Run Last
  "keys-changed"                                   : Run First
  "set-focus"                                      : Run Last

Description

Details

GtkWindow

typedef struct _GtkWindow GtkWindow;


gtk_window_new ()

GtkWidget*          gtk_window_new                      (GtkWindowType type);

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.

type :

type of window

Returns :

a new GtkWindow.

gtk_window_set_title ()

void                gtk_window_set_title                (GtkWindow *window,
                                                         const gchar *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.

window :

a GtkWindow

title :

title of the window

gtk_window_set_wmclass ()

void                gtk_window_set_wmclass              (GtkWindow *window,
                                                         const gchar *wmclass_name,
                                                         const gchar *wmclass_class);

Don't use this function. It sets the X Window System "class" and "name" hints for a window. According to the ICCCM, you should always set these to the same value for all windows in an application, and GTK+ sets them to that value by default, so calling this function is sort of pointless. However, you may want to call gtk_window_set_role() on each window in your application, for the benefit of the session manager. Setting the role allows the window manager to restore window positions when loading a saved session.

window :

a GtkWindow

wmclass_name :

window name hint

wmclass_class :

window class hint

gtk_window_set_policy ()

void                gtk_window_set_policy               (GtkWindow *window,
                                                         gint allow_shrink,
                                                         gint allow_grow,
                                                         gint auto_shrink);

Warning

gtk_window_set_policy is deprecated and should not be used in newly-written code. Use gtk_window_set_resizable() instead.

Changes how a toplevel window deals with its size request and user resize attempts. There are really only two reasonable ways to call this function:

  1. gtk_window_set_policy (GTK_WINDOW (window), FALSE, TRUE, FALSE) means that the window is user-resizable.

  2. gtk_window_set_policy (GTK_WINDOW (window), FALSE, FALSE, TRUE) means that the window's size is program-controlled, and should simply match the current size request of the window's children.

The first policy is the default, that is, by default windows are designed to be resized by users.

The basic ugly truth of this function is that it should be simply: void gtk_window_set_resizable (GtkWindow* window, gboolean setting); ...which is why GTK+ 2.0 introduces gtk_window_set_resizable(), which you should use instead of gtk_window_set_policy().

If set to TRUE, the allow_grow parameter allows the user to expand the window beyond the size request of its child widgets. If allow_grow is TRUE, be sure to check that your child widgets work properly as the window is resized.

A toplevel window will always change size to ensure its child widgets receive their requested size. This means that if you add child widgets, the toplevel window will expand to contain them. However, normally the toplevel will not shrink to fit the size request of its children if it's too large; the auto_shrink parameter causes the window to shrink when child widgets have too much space. auto_shrink is normally used with the second of the two window policies mentioned above. That is, set auto_shrink to TRUE if you want the window to have a fixed, always-optimal size determined by your program.

Note that auto_shrink doesn't do anything if allow_shrink and allow_grow are both set to FALSE.

Neither of the two suggested window policies set the allow_shrink parameter to TRUE. If allow_shrink is TRUE, the user can shrink the window so that its children do not receive their full size request; this is basically a bad thing, because most widgets will look wrong if this happens. Furthermore GTK+ has a tendency to re-expand the window if size is recalculated for any reason. The upshot is that allow_shrink should always be set to FALSE.

Sometimes when you think you want to use allow_shrink, the real problem is that some specific child widget is requesting too much space, so the user can't shrink the window sufficiently. Perhaps you are calling gtk_widget_set_size_request() on a child widget, and forcing its size request to be too large. Instead of setting the child's usize, consider using gtk_window_set_default_size() so that the child gets a larger allocation than it requests.

window :

the window

allow_shrink :

whether the user can shrink the window below its size request

allow_grow :

whether the user can grow the window larger than its size request

auto_shrink :

whether the window automatically snaps back to its size request if it's larger

gtk_window_set_resizable ()

void                gtk_window_set_resizable            (GtkWindow *window,
                                                         gboolean resizable);

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

window :

a GtkWindow

resizable :

TRUE if the user can resize this window

gtk_window_get_resizable ()

gboolean            gtk_window_get_resizable            (GtkWindow *window);

Gets the value set by gtk_window_set_resizable().

window :

a GtkWindow

Returns :

TRUE if the user can resize the window

gtk_window_add_accel_group ()

void                gtk_window_add_accel_group          (GtkWindow *window,
                                                         GtkAccelGroup *accel_group);

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

window :

window to attach accelerator group to

accel_group :

a GtkAccelGroup

gtk_window_remove_accel_group ()

void                gtk_window_remove_accel_group       (GtkWindow *window,
                                                         GtkAccelGroup *accel_group);

Reverses the effects of gtk_window_add_accel_group().

window :

a GtkWindow

accel_group :

a GtkAccelGroup

gtk_window_position

#define	gtk_window_position			gtk_window_set_position

Warning

gtk_window_position is deprecated and should not be used in newly-written code.

Deprecated alias for gtk_window_set_position().


gtk_window_activate_focus ()

gboolean            gtk_window_activate_focus           (GtkWindow *window);

Activates the current focused widget within the window.

window :

a GtkWindow

Returns :

TRUE if a widget got activated.

gtk_window_activate_default ()

gboolean            gtk_window_activate_default         (GtkWindow *window);

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

window :

a GtkWindow

Returns :

TRUE if a widget got activated.

gtk_window_set_modal ()

void                gtk_window_set_modal                (GtkWindow *window,
                                                         gboolean 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.

window :

a GtkWindow

modal :

whether the window is modal

gtk_window_set_default_size ()

void                gtk_window_set_default_size         (GtkWindow *window,
                                                         gint width,
                                                         gint 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.

window :

a GtkWindow

width :

width in pixels, or -1 to unset the default width

height :

height in pixels, or -1 to unset the default height

gtk_window_set_geometry_hints ()

void                gtk_window_set_geometry_hints       (GtkWindow *window,
                                                         GtkWidget *geometry_widget,
                                                         GdkGeometry *geometry,
                                                         GdkWindowHints geom_mask);

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.

window :

a GtkWindow

geometry_widget :

widget the geometry hints will be applied to

geometry :

struct containing geometry information

geom_mask :

mask indicating which struct fields should be paid attention to

gtk_window_set_gravity ()

void                gtk_window_set_gravity              (GtkWindow *window,
                                                         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."

window :

a GtkWindow

gravity :

window gravity

gtk_window_get_gravity ()

GdkGravity          gtk_window_get_gravity              (GtkWindow *window);

Gets the value set by gtk_window_set_gravity().

window :

a GtkWindow

Returns :

window gravity

gtk_window_set_position ()

void                gtk_window_set_position             (GtkWindow *window,
                                                         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.

window :

a GtkWindow.

position :

a position constraint.

gtk_window_set_transient_for ()

void                gtk_window_set_transient_for        (GtkWindow *window,
                                                         GtkWindow *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.

On Windows, this function puts the child window on top of the parent, much as the window manager would have done on X.

window :

a GtkWindow

parent :

parent window

gtk_window_set_destroy_with_parent ()

void                gtk_window_set_destroy_with_parent  (GtkWindow *window,
                                                         gboolean 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.

window :

a GtkWindow

setting :

whether to destroy window with its transient parent

gtk_window_set_screen ()

void                gtk_window_set_screen               (GtkWindow *window,
                                                         GdkScreen *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.

window :

a GtkWindow.

screen :

a GdkScreen.

Since 2.2


gtk_window_get_screen ()

GdkScreen*          gtk_window_get_screen               (GtkWindow *window);

Returns the GdkScreen associated with window.

window :

a GtkWindow.

Returns :

a GdkScreen.

Since 2.2


gtk_window_is_active ()

gboolean            gtk_window_is_active                (GtkWindow *window);

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

window :

a GtkWindow

Returns :

TRUE if the window part of the current active window.

Since 2.4


gtk_window_has_toplevel_focus ()

gboolean            gtk_window_has_toplevel_focus       (GtkWindow *window);

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.

window :

a GtkWindow

Returns :

TRUE if the input focus is within this GtkWindow

Since 2.4


gtk_window_list_toplevels ()

GList*              gtk_window_list_toplevels           (void);

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

void                gtk_window_add_mnemonic             (GtkWindow *window,
                                                         guint keyval,
                                                         GtkWidget *target);

Adds a mnemonic to this window.

window :

a GtkWindow

keyval :

the mnemonic

target :

the widget that gets activated by the mnemonic

gtk_window_remove_mnemonic ()

void                gtk_window_remove_mnemonic          (GtkWindow *window,
                                                         guint keyval,
                                                         GtkWidget *target);

Removes a mnemonic from this window.

window :

a GtkWindow

keyval :

the mnemonic

target :

the widget that gets activated by the mnemonic

gtk_window_mnemonic_activate ()

gboolean            gtk_window_mnemonic_activate        (GtkWindow *window,
                                                         guint keyval,
                                                         GdkModifierType modifier);

Activates the targets associated with the mnemonic.

window :

a GtkWindow

keyval :

the mnemonic

modifier :

the modifiers

Returns :

TRUE if the activation is done.

gtk_window_activate_key ()

gboolean            gtk_window_activate_key             (GtkWindow *window,
                                                         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.

window :

a GtkWindow

event :

a GdkEventKey

Returns :

TRUE if a mnemonic or accelerator was found and activated.

gtk_window_propagate_key_event ()

gboolean            gtk_window_propagate_key_event      (GtkWindow *window,
                                                         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.

window :

a GtkWindow

event :

a GdkEventKey

Returns :

TRUE if a widget in the focus chain handled the event.

gtk_window_get_focus ()

GtkWidget*          gtk_window_get_focus                (GtkWindow *window);

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.

window :

a GtkWindow

Returns :

the currently focused widget, or NULL if there is none.

gtk_window_set_focus ()

void                gtk_window_set_focus                (GtkWindow *window,
                                                         GtkWidget *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.

window :

a GtkWindow

focus :

widget to be the new focus widget, or NULL to unset any focus widget for the toplevel window.

gtk_window_set_default ()

void                gtk_window_set_default              (GtkWindow *window,
                                                         GtkWidget *default_widget);

The default widget is the widget that's activated when the user presses Enter in a dialog (for example). This function sets or unsets the default widget for a 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 set the GTK_CAN_DEFAULT flag on the widget you'd like to make the default using GTK_WIDGET_SET_FLAGS().

window :

a GtkWindow

default_widget :

widget to be the default, or NULL to unset the default widget for the toplevel.

gtk_window_present ()

void                gtk_window_present                  (GtkWindow *window);

Presents a window to the user. This may mean raising the window in the stacking order, deiconifying it, moving it to the current desktop, and/or giving it the keyboard focus, possibly dependent on the user's platform, window manager, and preferences.

If window is hidden, this function calls gtk_widget_show() as well.

This function should be used when the user tries to open a window that's already open. Say for example the preferences dialog is currently open, and the user chooses Preferences from the menu a second time; use gtk_window_present() to move the already-open dialog where the user can see it.

If you are calling this function in response to a user interaction, it is preferable to use gtk_window_present_with_time().

window :

a GtkWindow

gtk_window_present_with_time ()

void                gtk_window_present_with_time        (GtkWindow *window,
                                                         guint32 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.

window :

a GtkWindow

timestamp :

the timestamp of the user interaction (typically a button or key press event) which triggered this call

Since 2.8


gtk_window_iconify ()

void                gtk_window_iconify                  (GtkWindow *window);

Asks to iconify (i.e. minimize) the specified window. Note that you shouldn't assume the window is definitely iconified afterward, because other entities (e.g. the user or window manager) could deiconify it again, or there may not be a window manager in which case iconification isn't possible, etc. But normally the window will end up iconified. Just don't write code that crashes if not.

It's permitted to call this function before showing a window, in which case the window will be iconified before it ever appears onscreen.

You can track iconification via the "window_state_event" signal on GtkWidget.

window :

a GtkWindow

gtk_window_deiconify ()

void                gtk_window_deiconify                (GtkWindow *window);

Asks to deiconify (i.e. unminimize) the specified window. Note that you shouldn't assume the window is definitely deiconified afterward, because other entities (e.g. the user or window manager) could iconify it again before your code which assumes deiconification gets to run.

You can track iconification via the "window_state_event" signal on GtkWidget.

window :

a GtkWindow

gtk_window_stick ()

void                gtk_window_stick                    (GtkWindow *window);

Asks to stick window, which means that it will appear on all user desktops. Note that you shouldn't assume the window is definitely stuck afterward, because other entities (e.g. the user or window manager) could unstick it again, and some window managers do not support sticking windows. But normally the window will end up stuck. Just don't write code that crashes if not.

It's permitted to call this function before showing a window.

You can track stickiness via the "window_state_event" signal on GtkWidget.

window :

a GtkWindow

gtk_window_unstick ()

void                gtk_window_unstick                  (GtkWindow *window);

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

You can track stickiness via the "window_state_event" signal on GtkWidget.

window :

a GtkWindow

gtk_window_maximize ()

void                gtk_window_maximize                 (GtkWindow *window);

Asks to maximize window, so that it becomes full-screen. Note that you shouldn't assume the window is definitely maximized afterward, because other entities (e.g. the user or window manager) could unmaximize it again, and not all window managers support maximization. But normally the window will end up maximized. Just don't write code that crashes if not.

It's permitted to call this function before showing a window, in which case the window will be maximized when it appears onscreen initially.

You can track maximization via the "window_state_event" signal on GtkWidget.

window :

a GtkWindow

gtk_window_unmaximize ()

void                gtk_window_unmaximize               (GtkWindow *window);

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

You can track maximization via the "window_state_event" signal on GtkWidget.

window :

a GtkWindow

gtk_window_fullscreen ()

void                gtk_window_fullscreen               (GtkWindow *window);

Asks to place window in the fullscreen state. Note that you shouldn't assume the window is definitely full screen afterward, because other entities (e.g. the user or window manager) could unfullscreen it again, and not all window managers honor requests to fullscreen windows. But normally the window will end up fullscreen. Just don't write code that crashes if not.

You can track the fullscreen state via the "window_state_event" signal on GtkWidget.

window :

a GtkWindow

Since 2.2


gtk_window_unfullscreen ()

void                gtk_window_unfullscreen             (GtkWindow *window);

Asks to toggle off the fullscreen state for window. Note that you shouldn't assume the window is definitely not full screen afterward, because other entities (e.g. the user or window manager) could fullscreen it again, and not all window managers honor requests to unfullscreen windows. But normally the window will end up restored to its normal state. Just don't write code that crashes if not.

You can track the fullscreen state via the "window_state_event" signal on GtkWidget.

window :

a GtkWindow

Since 2.2


gtk_window_set_keep_above ()

void                gtk_window_set_keep_above           (GtkWindow *window,
                                                         gboolean 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.

window :

a GtkWindow

setting :

whether to keep window above other windows

Since 2.4


gtk_window_set_keep_below ()

void                gtk_window_set_keep_below           (GtkWindow *window,
                                                         gboolean 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.

window :

a GtkWindow

setting :

whether to keep window below other windows

Since 2.4


gtk_window_begin_resize_drag ()

void                gtk_window_begin_resize_drag        (GtkWindow *window,
                                                         GdkWindowEdge edge,
                                                         gint button,
                                                         gint root_x,
                                                         gint root_y,
                                                         guint32 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.

window :

a GtkWindow

edge :

position of the resize control

button :

mouse button that initiated the drag

root_x :

X position where the user clicked to initiate the drag, in root window coordinates

root_y :

Y position where the user clicked to initiate the drag

timestamp :

timestamp from the click event that initiated the drag

gtk_window_begin_move_drag ()

void                gtk_window_begin_move_drag          (GtkWindow *window,
                                                         gint button,
                                                         gint root_x,
                                                         gint root_y,
                                                         guint32 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.

window :

a GtkWindow

button :

mouse button that initiated the drag

root_x :

X position where the user clicked to initiate the drag, in root window coordinates

root_y :

Y position where the user clicked to initiate the drag

timestamp :

timestamp from the click event that initiated the drag

gtk_window_set_decorated ()

void                gtk_window_set_decorated            (GtkWindow *window,
                                                         gboolean 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