Class: Gtk::Window

Inherits:
Object
  • Object
show all
Defined in:
(unknown)

Instance Method Summary collapse

Instance Method Details

#accept_focusTrueClass

Gets the value set by gtk_window_set_accept_focus().

Returns:

  • (TrueClass)

    true if window should receive the input focus

#accept_focus=(accept_focus) ⇒ TrueClass

Whether the window should receive the input focus.

Parameters:

  • accept_focus (TrueClass)

Returns:

  • (TrueClass)

    accept-focus

  • (TrueClass)

    accept-focus

#accept_focus?TrueClass

Whether the window should receive the input focus.

Returns:

  • (TrueClass)

    accept-focus

#activate_defaultTrueClass

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.

Returns:

  • (TrueClass)

    true if a widget got activated.

#activate_focusTrueClass

Activates the current focused widget within the window.

Returns:

  • (TrueClass)

    true if a widget got activated.

#activate_key(event) ⇒ TrueClass

Activates mnemonics and accelerators for this Gtk::Window. 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:

  • event (Gdk::EventKey)

    a Gdk::EventKey

Returns:

  • (TrueClass)

    true if a mnemonic or accelerator was found and activated.

#add_accel_group(accel_group) ⇒ nil

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

Parameters:

Returns:

  • (nil)

#add_mnemonic(keyval, target) ⇒ nil

Adds a mnemonic to this window.

Parameters:

  • keyval (Integer)

    the mnemonic

  • target (Gtk::Widget)

    the widget that gets activated by the mnemonic

Returns:

  • (nil)

#applicationGtk::Application

The Gtk::Application associated with the window.

The application will be kept alive for at least as long as it has any windows associated with it (see g_application_hold() for a way to keep it alive without windows).

Normally, the connection between the application and the window will remain until the window is destroyed, but you can explicitly remove it by setting the :application property to nil.

Returns:

#application=(application) ⇒ Gtk::Application

The Gtk::Application associated with the window.

The application will be kept alive for at least as long as it has any windows associated with it (see g_application_hold() for a way to keep it alive without windows).

Normally, the connection between the application and the window will remain until the window is destroyed, but you can explicitly remove it by setting the :application property to nil.

Parameters:

Returns:

#attached_toGtk::Widget

The widget to which this window is attached. See gtk_window_set_attached_to().

Examples of places where specifying this relation is useful are for instance a Gtk::Menu created by a #GtkComboBox, a completion popup window created by Gtk::Entry or a typeahead search entry created by Gtk::TreeView.

Returns:

#attached_to=(attached_to) ⇒ Gtk::Widget

The widget to which this window is attached. See gtk_window_set_attached_to().

Examples of places where specifying this relation is useful are for instance a Gtk::Menu created by a #GtkComboBox, a completion popup window created by Gtk::Entry or a typeahead search entry created by Gtk::TreeView.

Parameters:

Returns:

#begin_move_drag(button, root_x, root_y, timestamp) ⇒ nil

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][gtk-X11-arch

or windowing

system. Otherwise, GDK will try to emulate window movement, potentially not all that well, depending on the windowing system.

Parameters:

  • button (Integer)

    mouse button that initiated the drag

  • root_x (Integer)

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

  • root_y (Integer)

    Y position where the user clicked to initiate the drag

  • timestamp (Integer)

    timestamp from the click event that initiated the drag

Returns:

  • (nil)

#begin_resize_drag(edge, button, root_x, root_y, timestamp) ⇒ nil

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][gtk-X11-arch

or windowing

system. Otherwise, GDK will try to emulate window resizing, potentially not all that well, depending on the windowing system.

Parameters:

  • edge (Gdk::WindowEdge)

    position of the resize control

  • button (Integer)

    mouse button that initiated the drag

  • root_x (Integer)

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

  • root_y (Integer)

    Y position where the user clicked to initiate the drag

  • timestamp (Integer)

    timestamp from the click event that initiated the drag

Returns:

  • (nil)

#closenil

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.

Returns:

  • (nil)

#decoratedTrueClass

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

Returns:

  • (TrueClass)

    true if the window has been set to have decorations

#decorated=(decorated) ⇒ TrueClass

Whether the window should be decorated by the window manager.

Parameters:

  • decorated (TrueClass)

Returns:

  • (TrueClass)

    decorated

  • (TrueClass)

    decorated

#decorated?TrueClass

Whether the window should be decorated by the window manager.

Returns:

  • (TrueClass)

    decorated

#default=(default_widget) ⇒ nil

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 Gtk::Window. 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:

  • default_widget (Gtk::Widget)

    widget to be the default, or nil to unset the default widget for the toplevel

Returns:

  • (nil)

#default_heightInteger

Returns default-height.

Returns:

  • (Integer)

    default-height

#default_height=(default_height) ⇒ Integer

Parameters:

  • default_height (Integer)

Returns:

  • (Integer)

    default-height

  • (Integer)

    default-height

#default_widgetGtk::Widget

Returns the default widget for window. See gtk_window_set_default() for more details. if there is none.

Returns:

#default_widthInteger

Returns default-width.

Returns:

  • (Integer)

    default-width

#default_width=(default_width) ⇒ Integer

Parameters:

  • default_width (Integer)

Returns:

  • (Integer)

    default-width

  • (Integer)

    default-width

#deiconifynil

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 Gtk::Widget.

Returns:

  • (nil)

#deletableTrueClass

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

Returns:

  • (TrueClass)

    true if the window has been set to have a close button

#deletable=(deletable) ⇒ TrueClass

Whether the window frame should have a close button.

Parameters:

  • deletable (TrueClass)

Returns:

  • (TrueClass)

    deletable

  • (TrueClass)

    deletable

#deletable?TrueClass

Whether the window frame should have a close button.

Returns:

  • (TrueClass)

    deletable

#destroy_with_parentTrueClass

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

Returns:

  • (TrueClass)

    true if the window will be destroyed with its transient parent.

#destroy_with_parent=(destroy_with_parent) ⇒ TrueClass

Parameters:

  • destroy_with_parent (TrueClass)

Returns:

  • (TrueClass)

    destroy-with-parent

  • (TrueClass)

    destroy-with-parent

#destroy_with_parent?TrueClass

Returns destroy-with-parent.

Returns:

  • (TrueClass)

    destroy-with-parent

#focusGtk::Widget

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. or nil if there is none.

Returns:

#focus=(focus) ⇒ nil

If focus is not the current focus widget, and is focusable, sets it as the focus widget for the window. If focus is nil, unsets the focus widget for this window. To set the focus to a particular widget in the toplevel, it is usually more convenient to use gtk_widget_grab_focus() instead of this function.

Parameters:

  • focus (Gtk::Widget)

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

Returns:

  • (nil)

#focus_on_mapTrueClass

Gets the value set by gtk_window_set_focus_on_map(). mapped.

Returns:

  • (TrueClass)

    true if window should receive the input focus when

#focus_on_map=(focus_on_map) ⇒ TrueClass

Whether the window should receive the input focus when mapped.

Parameters:

  • focus_on_map (TrueClass)

Returns:

  • (TrueClass)

    focus-on-map

  • (TrueClass)

    focus-on-map

#focus_on_map?TrueClass

Whether the window should receive the input focus when mapped.

Returns:

  • (TrueClass)

    focus-on-map

#focus_visibleTrueClass

Gets the value of the Gtk::Window:focus-visible property.

Returns:

  • (TrueClass)

    true if “focus rectangles” are supposed to be visible in this window.

#focus_visible=(focus_visible) ⇒ TrueClass

Whether ‘focus rectangles’ are currently visible in this window.

This property is maintained by GTK+ based on user input and should not be set by applications.

Parameters:

  • focus_visible (TrueClass)

Returns:

  • (TrueClass)

    focus-visible

  • (TrueClass)

    focus-visible

#focus_visible?TrueClass

Whether ‘focus rectangles’ are currently visible in this window.

This property is maintained by GTK+ based on user input and should not be set by applications.

Returns:

  • (TrueClass)

    focus-visible

#fullscreennil

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 Gtk::Widget.

Returns:

  • (nil)

#fullscreen_on_monitor(screen, monitor) ⇒ nil

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 Gtk::Widget.

Parameters:

  • screen (Gdk::Screen)

    a Gdk::Screen to draw to

  • monitor (Integer)

    which monitor to go fullscreen on

Returns:

  • (nil)

#get_default_size(width, height) ⇒ nil

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:

  • width (Integer)

    location to store the default width, or nil

  • height (Integer)

    location to store the default height, or nil

Returns:

  • (nil)

#get_position(root_x, root_y) ⇒ nil

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:

  • root_x (Integer)

    return location for X coordinate of gravity-determined reference point, or nil

  • root_y (Integer)

    return location for Y coordinate of gravity-determined reference point, or nil

Returns:

  • (nil)

#get_resize_grip_area(rect) ⇒ TrueClass

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

Parameters:

  • rect (Gdk::Rectangle)

    a pointer to a Gdk::Rectangle which we should store the resize grip area

Returns:

  • (TrueClass)

    true if the resize grip’s area was retrieved

#get_size(width, height) ⇒ nil

Obtains the current size of window.

If window is not visible on screen, this function return the size GTK+ will suggest to the [window manager] for the initial window size (but this is not reliably the same as the size the window manager will actually select). See: gtk_window_set_default_size().

Depending on the windowing system and the window manager constraints, the size returned by this function may not match the size set using gtk_window_resize(); additionally, since gtk_window_resize() may be implemented as an asynchronous operation, GTK+ cannot guarantee in any way that this code:

static void
on_size_allocate (GtkWidget *widget, GtkAllocation *allocation)
{
  int new_width, new_height;

  gtk_window_get_size (GTK_WINDOW (widget), &new_width, &new_height);

  ...
}

Note that, if you connect to the Gtk::Widget::size-allocate signal, you should not use the dimensions of the Gtk::Allocation passed to the signal handler, as the allocation may contain client side decorations added by GTK+, depending on the windowing system in use.

If you are getting a window size in order to position the window on the screen, you should, instead, simply set the window’s semantic type with gtk_window_set_type_hint(), which allows the window manager to e.g. center dialogs. Also, if you set the transient parent of dialogs with gtk_window_set_transient_for() window managers will often center the dialog over its parent window. It’s much preferred to let the window manager handle these cases rather than doing it yourself, because all apps will behave consistently and according to user or system preferences, if the window manager handles it. Also, the window manager can take into account the size of the window decorations and border that it may add, and of which GTK+ has no knowledge. Additionally, positioning windows in global screen coordinates may not be allowed by the windowing system. For more information, see: gtk_window_set_position().

Parameters:

  • width (Integer)

    return location for width, or nil

  • height (Integer)

    return location for height, or nil

Returns:

  • (nil)

#gravityGdk::Gravity

The window gravity of the window. See gtk_window_move() and Gdk::Gravity for more details about window gravity.

Returns:

#gravity=(gravity) ⇒ Gdk::Gravity

The window gravity of the window. See gtk_window_move() and Gdk::Gravity for more details about window gravity.

Parameters:

Returns:

#groupGtk::WindowGroup

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

Returns:

#has_groupTrueClass

Returns whether window has an explicit window group. Since 2.22

Returns:

  • (TrueClass)

    true if window has an explicit window group.

#has_resize_gripTrueClass

Determines whether the window may have a resize grip.

Returns:

  • (TrueClass)

    true if the window has a resize grip

#has_resize_grip=(has_resize_grip) ⇒ TrueClass

Whether the window has a corner resize grip.

Note that the resize grip is only shown if the window is actually resizable and not maximized. Use Gtk::Window:resize-grip-visible to find out if the resize grip is currently shown.

Parameters:

  • has_resize_grip (TrueClass)

Returns:

  • (TrueClass)

    has-resize-grip

  • (TrueClass)

    has-resize-grip

#has_resize_grip?TrueClass

Whether the window has a corner resize grip.

Note that the resize grip is only shown if the window is actually resizable and not maximized. Use Gtk::Window:resize-grip-visible to find out if the resize grip is currently shown.

Returns:

  • (TrueClass)

    has-resize-grip

#has_toplevel_focusTrueClass

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 Gtk::Plug, the results will differ.

Returns:

  • (TrueClass)

    true if the input focus is within this GtkWindow

#has_toplevel_focus=(has_toplevel_focus) ⇒ TrueClass

Parameters:

  • has_toplevel_focus (TrueClass)

Returns:

  • (TrueClass)

    has-toplevel-focus

  • (TrueClass)

    has-toplevel-focus

#has_toplevel_focus?TrueClass

Returns has-toplevel-focus.

Returns:

  • (TrueClass)

    has-toplevel-focus

#has_user_ref_count=(setting) ⇒ nil

Tells GTK+ whether to drop its extra reference to the window when gtk_widget_destroy() is called.

This function is only exported for the benefit of language bindings which may need to keep the window alive until their wrapper object is garbage collected. There is no justification for ever calling this function in an application.

Parameters:

  • setting (TrueClass)

    the new value

Returns:

  • (nil)

#hide_titlebar_when_maximizedTrueClass

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

Returns:

  • (TrueClass)

    true if the window has requested to have its titlebar hidden when maximized

#hide_titlebar_when_maximized=(hide_titlebar_when_maximized) ⇒ TrueClass

Whether the titlebar should be hidden during maximization.

Parameters:

  • hide_titlebar_when_maximized (TrueClass)

Returns:

  • (TrueClass)

    hide-titlebar-when-maximized

  • (TrueClass)

    hide-titlebar-when-maximized

#hide_titlebar_when_maximized?TrueClass

Whether the titlebar should be hidden during maximization.

Returns:

  • (TrueClass)

    hide-titlebar-when-maximized

#iconGdkPixbuf::Pixbuf

Returns icon.

Returns:

#icon=(icon) ⇒ GdkPixbuf::Pixbuf

Parameters:

Returns:

#icon_from_file=(filename) ⇒ TrueClass

Sets the icon for window. Warns on failure if err is nil.

This function is equivalent to calling gtk_window_set_icon() with a pixbuf created by loading the image from filename.

Parameters:

  • filename (Gtk::filename)

    location of icon file

Returns:

  • (TrueClass)

    true if setting the icon succeeded.

#icon_listGLib::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.

Returns:

  • (GLib::List)

    copy of window’s icon list

#icon_list=(list) ⇒ nil

Sets up the icon representing a Gtk::Window. The icon is used when the window is minimized (also known as iconified). Some window managers or desktop environments may also place it in the window frame, or display it in other contexts. On others, the icon is not used at all, so your mileage may vary.

gtk_window_set_icon_list() allows you to pass in the same icon in several hand-drawn sizes. The list should contain the natural sizes your icon is available in; that is, don’t scale the image before passing it to GTK+. Scaling is postponed until the last minute, when the desired final size is known, to allow best quality.

By passing several sizes, you may improve the final image quality of the icon, by reducing or eliminating automatic image scaling.

Recommended sizes to provide: 16x16, 32x32, 48x48 at minimum, and larger images (64x64, 128x128) if you have them.

See also gtk_window_set_default_icon_list() to set the icon for all windows in your application in one go.

Note that transient windows (those who have been set transient for another window using gtk_window_set_transient_for()) will inherit their icon from their transient parent. So there’s no need to explicitly set the icon on transient windows.

Parameters:

  • list (GLib::List)

    list of Gdk::Pixbuf

Returns:

  • (nil)

#icon_nameString

The :icon-name property specifies the name of the themed icon to use as the window icon. See Gtk::IconTheme for more details.

Returns:

  • (String)

    icon-name

#icon_name=(icon_name) ⇒ String

The :icon-name property specifies the name of the themed icon to use as the window icon. See Gtk::IconTheme for more details.

Parameters:

  • icon_name (String)

Returns:

  • (String)

    icon-name

  • (String)

    icon-name

#iconifynil

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 Gtk::Widget.

Returns:

  • (nil)

#is_activeTrueClass

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 Gtk::Plug 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()

Returns:

  • (TrueClass)

    true if the window part of the current active window.

#is_active=(is_active) ⇒ TrueClass

Parameters:

  • is_active (TrueClass)

Returns:

  • (TrueClass)

    is-active

  • (TrueClass)

    is-active

#is_active?TrueClass

Returns is-active.

Returns:

  • (TrueClass)

    is-active

#is_maximizedTrueClass

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

Returns:

  • (TrueClass)

    whether the window has a maximized state.

#is_maximized=(is_maximized) ⇒ TrueClass

Parameters:

  • is_maximized (TrueClass)

Returns:

  • (TrueClass)

    is-maximized

  • (TrueClass)

    is-maximized

#is_maximized?TrueClass

Returns is-maximized.

Returns:

  • (TrueClass)

    is-maximized

#keep_above=(setting) ⇒ nil

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 Gtk::Widget.

Note that, according to the [Extended Window Manager Hints Specification](www.freedesktop.org/Standards/wm-spec), 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:

  • setting (TrueClass)

    whether to keep window above other windows

Returns:

  • (nil)

#keep_below=(setting) ⇒ nil

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 Gtk::Widget.

Note that, according to the [Extended Window Manager Hints Specification](www.freedesktop.org/Standards/wm-spec), 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:

  • setting (TrueClass)

    whether to keep window below other windows

Returns:

  • (nil)

#maximizenil

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 Gtk::Widget, or by listening to notifications on the Gtk::Window:is-maximized property.

Returns:

  • (nil)

#mnemonic_activate(keyval, modifier) ⇒ TrueClass

Activates the targets associated with the mnemonic.

Parameters:

Returns:

  • (TrueClass)

    true if the activation is done.

#mnemonic_modifierGdk::ModifierType

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

Returns:

  • (Gdk::ModifierType)

    the modifier mask used to activate mnemonics on this window.

#mnemonic_modifier=(modifier) ⇒ nil

Sets the mnemonic modifier for this window.

Parameters:

  • modifier (Gdk::ModifierType)

    the modifier mask used to activate mnemonics on this window.

Returns:

  • (nil)

#mnemonics_visibleTrueClass

Gets the value of the Gtk::Window:mnemonics-visible property. in this window.

Returns:

  • (TrueClass)

    true if mnemonics are supposed to be visible

#mnemonics_visible=(mnemonics_visible) ⇒ TrueClass

Whether mnemonics are currently visible in this window.

This property is maintained by GTK+ based on user input, and should not be set by applications.

Parameters:

  • mnemonics_visible (TrueClass)

Returns:

  • (TrueClass)

    mnemonics-visible

  • (TrueClass)

    mnemonics-visible

#mnemonics_visible?TrueClass

Whether mnemonics are currently visible in this window.

This property is maintained by GTK+ based on user input, and should not be set by applications.

Returns:

  • (TrueClass)

    mnemonics-visible

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

Returns:

  • (TrueClass)

    true if the window is set to be modal and establishes a grab when shown

#modal=(modal) ⇒ TrueClass

Parameters:

  • modal (TrueClass)

Returns:

  • (TrueClass)

    modal

  • (TrueClass)

    modal

#modal?TrueClass

Returns modal.

Returns:

  • (TrueClass)

    modal

#move(x, y) ⇒ nil

Asks the [window manager] to move window to the given position. Window managers are free to ignore this; most window managers ignore requests for initial window positions (instead using a user-defined placement algorithm) and honor requests after the window has already been shown.

Note: the position is the position of the gravity-determined reference point for the window. The gravity determines two things: first, the location of the reference point in root window coordinates; and second, which point on the window is positioned at the reference point.

By default the gravity is #GDK_GRAVITY_NORTH_WEST, so the reference point is simply the x, y supplied to gtk_window_move(). The top-left corner of the window decorations (aka window frame or border) will be placed at x, y. Therefore, to position a window at the top left of the screen, you want to use the default gravity (which is #GDK_GRAVITY_NORTH_WEST) and move the window to 0,0.

To position a window at the bottom right corner of the screen, you would set #GDK_GRAVITY_SOUTH_EAST, which means that the reference point is at x + the window width and y + the window height, and the bottom-right corner of the window border will be placed at that reference point. So, to place a window in the bottom right corner you would first set gravity to south east, then write: ‘gtk_window_move (window, gdk_screen_width () - window_width, gdk_screen_height () - window_height)` (note that this example does not take multi-head scenarios into account).

The [Extended Window Manager Hints Specification](www.freedesktop.org/Standards/wm-spec) has a nice table of gravities in the “implementation notes” section.

The gtk_window_get_position() documentation may also be relevant.

Parameters:

  • x (Integer)

    X coordinate to move window to

  • y (Integer)

    Y coordinate to move window to

Returns:

  • (nil)

#new(type) ⇒ Gtk::Widget

Creates a new Gtk::Window, 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 Gtk::Menu), 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.

To delete a Gtk::Window, call gtk_widget_destroy().

Parameters:

Returns:

#opacityFloat

Fetches the requested opacity for this window. See gtk_window_set_opacity().

Returns:

  • (Float)

    the requested opacity for this window.

#opacity=(opacity) ⇒ nil

Request the windowing system to make window partially transparent, with opacity 0 being fully transparent and 1 fully opaque. (Values of the opacity parameter are clamped to the [0,1] range.) On X11 this has any effect only on X screens with a compositing manager running. See gtk_widget_is_composited(). On Windows it should work always.

Note that setting a window’s opacity after the window has been shown causes it to flicker once on Windows.

Parameters:

  • opacity (Float)

    desired opacity, between 0 and 1

Returns:

  • (nil)

#parse_geometry(geometry) ⇒ TrueClass

Parses a standard X Window System geometry string - see the manual page for X (type “man X”) for details on this. gtk_window_parse_geometry() does work on all GTK+ ports including Win32 but is primarily intended for an X environment.

If either a size or a position can be extracted from the geometry string, gtk_window_parse_geometry() returns true and calls gtk_window_set_default_size() and/or gtk_window_move() to resize/move the window.

If gtk_window_parse_geometry() returns true, it will also set the #GDK_HINT_USER_POS and/or #GDK_HINT_USER_SIZE hints indicating to the window manager that the size/position of the window was user-specified. This causes most window managers to honor the geometry.

Note that for gtk_window_parse_geometry() to work as expected, it has to be called when the window has its “final” size, i.e. after calling gtk_widget_show_all() on the contents and gtk_window_set_geometry_hints() on the window.

#include <gtk/gtk.h>

static void
fill_with_content (GtkWidget *vbox)
{
  // fill with content...
}

int
main (int argc, char *argv[])
{
  GtkWidget *window, *vbox;
  GdkGeometry size_hints = {
    100, 50, 0, 0, 100, 50, 10,
    10, 0.0, 0.0, GDK_GRAVITY_NORTH_WEST
  };

  gtk_init (&argc, &argv);

  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);

  gtk_container_add (GTK_CONTAINER (window), vbox);
  fill_with_content (vbox);
  gtk_widget_show_all (vbox);

  gtk_window_set_geometry_hints (GTK_WINDOW (window),
	  			    NULL,
				    &size_hints,
				    GDK_HINT_MIN_SIZE |
				    GDK_HINT_BASE_SIZE |
				    GDK_HINT_RESIZE_INC);

  if (argc > 1)
    {
      gboolean res;
      res = gtk_window_parse_geometry (GTK_WINDOW (window),
                                       argv[1]);
      if (! res)
        fprintf (stderr,
                 "Failed to parse “%s”\n",
                 argv[1]);
    }

  gtk_widget_show_all (window);
  gtk_main ();

  return 0;
}

Parameters:

  • geometry (String)

    geometry string

Returns:

  • (TrueClass)

    true if string was parsed successfully

#position=(position) ⇒ nil

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:

Returns:

  • (nil)

#presentnil

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.

Returns:

  • (nil)

#present_with_time(timestamp) ⇒ nil

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:

  • timestamp (Integer)

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

Returns:

  • (nil)

#propagate_key_event(event) ⇒ TrueClass

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:

  • event (Gdk::EventKey)

    a Gdk::EventKey

Returns:

  • (TrueClass)

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

#remove_accel_group(accel_group) ⇒ nil

Reverses the effects of gtk_window_add_accel_group().

Parameters:

Returns:

  • (nil)

#remove_mnemonic(keyval, target) ⇒ nil

Removes a mnemonic from this window.

Parameters:

  • keyval (Integer)

    the mnemonic

  • target (Gtk::Widget)

    the widget that gets activated by the mnemonic

Returns:

  • (nil)

#reshow_with_initial_sizenil

Hides window, then reshows it, resetting the default size and position of the window. Used by GUI builders only.

Returns:

  • (nil)

#resizableTrueClass

Gets the value set by gtk_window_set_resizable().

Returns:

  • (TrueClass)

    true if the user can resize the window

#resizable=(resizable) ⇒ TrueClass

Parameters:

  • resizable (TrueClass)

Returns:

  • (TrueClass)

    resizable

  • (TrueClass)

    resizable

#resizable?TrueClass

Returns resizable.

Returns:

  • (TrueClass)

    resizable

#resize(width, height) ⇒ nil

Resizes the window as if the user had done so, obeying geometry constraints. The default geometry constraint is that windows may not be smaller than their size request; to override this constraint, call gtk_widget_set_size_request() to set the window’s request to a smaller value.

If gtk_window_resize() is called before showing a window for the first time, it overrides any default size set with gtk_window_set_default_size().

Windows may not be resized smaller than 1 by 1 pixels.

When using client side decorations, GTK+ will do its best to adjust the given size so that the resulting window size matches the requested size without the title bar, borders and shadows added for the client side decorations, but there is no guarantee that the result will be totally accurate because these widgets added for client side decorations depend on the theme and may not be realized or visible at the time gtk_window_resize() is issued.

If the GtkWindow has a titlebar widget (see gtk_window_set_titlebar()), then typically, gtk_window_resize() will compensate for the height of the titlebar widget only if the height is known when the resulting GtkWindow configuration is issued. For example, if new widgets are added after the GtkWindow configuration and cause the titlebar widget to grow in height, this will result in a window content smaller that specified by gtk_window_resize() and not a larger window.

Parameters:

  • width (Integer)

    width in pixels to resize the window to

  • height (Integer)

    height in pixels to resize the window to

Returns:

  • (nil)

#resize_grip_is_visibleTrueClass

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

Returns:

  • (TrueClass)

    true if a resize grip exists and is visible

#resize_grip_visible=(resize_grip_visible) ⇒ TrueClass

Whether a corner resize grip is currently shown.

Parameters:

  • resize_grip_visible (TrueClass)

Returns:

  • (TrueClass)

    resize-grip-visible

  • (TrueClass)

    resize-grip-visible

#resize_grip_visible?TrueClass

Whether a corner resize grip is currently shown.

Returns:

  • (TrueClass)

    resize-grip-visible

#resize_to_geometry(width, height) ⇒ nil

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

Parameters:

  • width (Integer)

    width in resize increments to resize the window to

  • height (Integer)

    height in resize increments to resize the window to

Returns:

  • (nil)

#roleString

Returns role.

Returns:

  • (String)

    role

#role=(role) ⇒ String

Parameters:

  • role (String)

Returns:

  • (String)

    role

  • (String)

    role

#screenGdk::Screen

Returns screen.

Returns:

#screen=(screen) ⇒ Gdk::Screen

Parameters:

Returns:

#set_default_geometry(width, height) ⇒ nil

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

    width in resize increments, or -1 to unset the default width

  • height (Integer)

    height in resize increments, or -1 to unset the default height

Returns:

  • (nil)

#set_default_size(width, height) ⇒ nil

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.

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

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

  • height (Integer)

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

Returns:

  • (nil)

#set_geometry_hints(geometry_widget, geometry, geom_mask) ⇒ nil

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 Gdk::Geometry struct.

Parameters:

  • geometry_widget (Gtk::Widget)

    widget the geometry hints used to be applied to or nil. Since 3.20 this argument is ignored and GTK behaves as if nil was set.

  • geometry (Gdk::Geometry)

    struct containing geometry information or nil

  • geom_mask (Gdk::WindowHints)

    mask indicating which struct fields should be paid attention to

Returns:

  • (nil)

#set_wmclass(wmclass_name, wmclass_class) ⇒ nil

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:

  • wmclass_name (String)

    window name hint

  • wmclass_class (String)

    window class hint

Returns:

  • (nil)

#skip_pager_hintTrueClass

Gets the value set by gtk_window_set_skip_pager_hint().

Returns:

  • (TrueClass)

    true if window shouldn’t be in pager

#skip_pager_hint=(skip_pager_hint) ⇒ TrueClass

Parameters:

  • skip_pager_hint (TrueClass)

Returns:

  • (TrueClass)

    skip-pager-hint

  • (TrueClass)

    skip-pager-hint

#skip_pager_hint?TrueClass

Returns skip-pager-hint.

Returns:

  • (TrueClass)

    skip-pager-hint

#skip_taskbar_hintTrueClass

Gets the value set by gtk_window_set_skip_taskbar_hint()

Returns:

  • (TrueClass)

    true if window shouldn’t be in taskbar

#skip_taskbar_hint=(skip_taskbar_hint) ⇒ TrueClass

Parameters:

  • skip_taskbar_hint (TrueClass)

Returns:

  • (TrueClass)

    skip-taskbar-hint

  • (TrueClass)

    skip-taskbar-hint

#skip_taskbar_hint?TrueClass

Returns skip-taskbar-hint.

Returns:

  • (TrueClass)

    skip-taskbar-hint

#startup_id=(startup_id) ⇒ String

The :startup-id is a write-only property for setting window’s startup notification identifier. See gtk_window_set_startup_id() for more details.

Parameters:

  • startup_id (String)

Returns:

  • (String)

    startup-id

#sticknil

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][gtk-X11-arch

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 Gtk::Widget.

Returns:

  • (nil)

#titleString

Returns title.

Returns:

  • (String)

    title

#title=(title) ⇒ String

Parameters:

  • title (String)

Returns:

  • (String)

    title

  • (String)

    title

#titlebarGtk::Widget

Returns the custom titlebar that has been set with gtk_window_set_titlebar().

Returns:

#titlebar=(titlebar) ⇒ nil

Sets a custom titlebar for window.

A typical widget used here is Gtk::HeaderBar, as it provides various features expected of a titlebar while allowing the addition of child widgets to it.

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

Parameters:

  • titlebar (Gtk::Widget)

    the widget to use as titlebar

Returns:

  • (nil)

#transient_forGtk::Window

The transient parent of the window. See gtk_window_set_transient_for() for more details about transient windows.

Returns:

#transient_for=(transient_for) ⇒ Gtk::Window

The transient parent of the window. See gtk_window_set_transient_for() for more details about transient windows.

Parameters:

Returns:

#typeGtk::WindowType

Returns type.

Returns:

#type=(type) ⇒ Gtk::WindowType

Parameters:

Returns:

#type_hintGdk::WindowTypeHint

Returns type-hint.

Returns:

#type_hint=(type_hint) ⇒ Gdk::WindowTypeHint

Parameters:

Returns:

#unfullscreennil

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 Gtk::Widget.

Returns:

  • (nil)

#unmaximizenil

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 Gtk::Widget.

Returns:

  • (nil)

#unsticknil

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 Gtk::Widget.

Returns:

  • (nil)

#urgency_hintTrueClass

Gets the value set by gtk_window_set_urgency_hint()

Returns:

  • (TrueClass)

    true if window is urgent

#urgency_hint=(urgency_hint) ⇒ TrueClass

Parameters:

  • urgency_hint (TrueClass)

Returns:

  • (TrueClass)

    urgency-hint

  • (TrueClass)

    urgency-hint

#urgency_hint?TrueClass

Returns urgency-hint.

Returns:

  • (TrueClass)

    urgency-hint

#window_positionGtk::WindowPosition

Returns window-position.

Returns:

#window_position=(window_position) ⇒ Gtk::WindowPosition

Parameters:

Returns:

#window_typeGtk::WindowType

Gets the type of the window. See Gtk::WindowType.

Returns: