Class: Gtk::Window
- Inherits:
-
Object
- Object
- Gtk::Window
- Defined in:
- (unknown)
Instance Method Summary collapse
-
#accept_focus ⇒ TrueClass
Gets the value set by gtk_window_set_accept_focus().
-
#accept_focus=(accept_focus) ⇒ TrueClass
Whether the window should receive the input focus.
-
#accept_focus? ⇒ TrueClass
Whether the window should receive the input focus.
-
#activate_default ⇒ TrueClass
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.
-
#activate_focus ⇒ TrueClass
Activates the current focused widget within the window.
-
#activate_key(event) ⇒ TrueClass
Activates mnemonics and accelerators for this Gtk::Window.
-
#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.
-
#add_mnemonic(keyval, target) ⇒ nil
Adds a mnemonic to this window.
-
#application ⇒ Gtk::Application
The Gtk::Application associated with the window.
-
#application=(application) ⇒ Gtk::Application
The Gtk::Application associated with the window.
-
#attached_to ⇒ Gtk::Widget
The widget to which this window is attached.
-
#attached_to=(attached_to) ⇒ Gtk::Widget
The widget to which this window is attached.
-
#begin_move_drag(button, root_x, root_y, timestamp) ⇒ nil
Starts moving a window.
-
#begin_resize_drag(edge, button, root_x, root_y, timestamp) ⇒ nil
Starts resizing a window.
-
#close ⇒ nil
Requests that the window is closed, similar to what happens when a window manager close button is clicked.
-
#decorated ⇒ TrueClass
Returns whether the window has been set to have decorations such as a title bar via gtk_window_set_decorated().
-
#decorated=(decorated) ⇒ TrueClass
Whether the window should be decorated by the window manager.
-
#decorated? ⇒ TrueClass
Whether the window should be decorated by the window manager.
-
#default=(default_widget) ⇒ nil
The default widget is the widget that’s activated when the user presses Enter in a dialog (for example).
-
#default_height ⇒ Integer
Default-height.
- #default_height=(default_height) ⇒ Integer
-
#default_widget ⇒ Gtk::Widget
Returns the default widget for window.
-
#default_width ⇒ Integer
Default-width.
- #default_width=(default_width) ⇒ Integer
-
#deiconify ⇒ nil
Asks to deiconify (i.e. unminimize) the specified window.
-
#deletable ⇒ TrueClass
Returns whether the window has been set to have a close button via gtk_window_set_deletable().
-
#deletable=(deletable) ⇒ TrueClass
Whether the window frame should have a close button.
-
#deletable? ⇒ TrueClass
Whether the window frame should have a close button.
-
#destroy_with_parent ⇒ TrueClass
Returns whether the window will be destroyed with its transient parent.
- #destroy_with_parent=(destroy_with_parent) ⇒ TrueClass
-
#destroy_with_parent? ⇒ TrueClass
Destroy-with-parent.
-
#focus ⇒ Gtk::Widget
Retrieves the current focused widget within the window.
-
#focus=(focus) ⇒ nil
If focus is not the current focus widget, and is focusable, sets it as the focus widget for the window.
-
#focus_on_map ⇒ TrueClass
Gets the value set by gtk_window_set_focus_on_map().
-
#focus_on_map=(focus_on_map) ⇒ TrueClass
Whether the window should receive the input focus when mapped.
-
#focus_on_map? ⇒ TrueClass
Whether the window should receive the input focus when mapped.
-
#focus_visible ⇒ TrueClass
Gets the value of the Gtk::Window:focus-visible property.
-
#focus_visible=(focus_visible) ⇒ TrueClass
Whether ‘focus rectangles’ are currently visible in this window.
-
#focus_visible? ⇒ TrueClass
Whether ‘focus rectangles’ are currently visible in this window.
-
#fullscreen ⇒ nil
Asks to place window in the fullscreen state.
-
#fullscreen_on_monitor(screen, monitor) ⇒ nil
Asks to place window in the fullscreen state.
-
#get_default_size(width, height) ⇒ nil
Gets the default size of the window.
-
#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.
-
#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.
-
#get_size(width, height) ⇒ nil
Obtains the current size of window.
-
#gravity ⇒ Gdk::Gravity
The window gravity of the window.
-
#gravity=(gravity) ⇒ Gdk::Gravity
The window gravity of the window.
-
#group ⇒ Gtk::WindowGroup
Returns the group for window or the default group, if window is nil or if window does not have an explicit window group.
-
#has_group ⇒ TrueClass
Returns whether window has an explicit window group.
-
#has_resize_grip ⇒ TrueClass
Determines whether the window may have a resize grip.
-
#has_resize_grip=(has_resize_grip) ⇒ TrueClass
Whether the window has a corner resize grip.
-
#has_resize_grip? ⇒ TrueClass
Whether the window has a corner resize grip.
-
#has_toplevel_focus ⇒ TrueClass
Returns whether the input focus is within this GtkWindow.
- #has_toplevel_focus=(has_toplevel_focus) ⇒ TrueClass
-
#has_toplevel_focus? ⇒ 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.
-
#hide_titlebar_when_maximized ⇒ TrueClass
Returns whether 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.
-
#hide_titlebar_when_maximized? ⇒ TrueClass
Whether the titlebar should be hidden during maximization.
-
#icon ⇒ GdkPixbuf::Pixbuf
Icon.
- #icon=(icon) ⇒ GdkPixbuf::Pixbuf
-
#icon_from_file=(filename) ⇒ TrueClass
Sets the icon for window.
-
#icon_list ⇒ GLib::List
Retrieves the list of icons set by gtk_window_set_icon_list().
-
#icon_list=(list) ⇒ nil
Sets up the icon representing a Gtk::Window.
-
#icon_name ⇒ String
The :icon-name property specifies the name of the themed icon to use as the window icon.
-
#icon_name=(icon_name) ⇒ String
The :icon-name property specifies the name of the themed icon to use as the window icon.
-
#iconify ⇒ nil
Asks to iconify (i.e. minimize) the specified window.
-
#is_active ⇒ TrueClass
Returns whether the window is part of the current active toplevel.
- #is_active=(is_active) ⇒ TrueClass
-
#is_active? ⇒ TrueClass
Is-active.
-
#is_maximized ⇒ TrueClass
Retrieves the current maximized state of window.
- #is_maximized=(is_maximized) ⇒ TrueClass
-
#is_maximized? ⇒ TrueClass
Is-maximized.
-
#keep_above=(setting) ⇒ nil
Asks to keep window above, so that it stays on top.
-
#keep_below=(setting) ⇒ nil
Asks to keep window below, so that it stays in bottom.
-
#maximize ⇒ nil
Asks to maximize window, so that it becomes full-screen.
-
#mnemonic_activate(keyval, modifier) ⇒ TrueClass
Activates the targets associated with the mnemonic.
-
#mnemonic_modifier ⇒ Gdk::ModifierType
Returns the mnemonic modifier for this window.
-
#mnemonic_modifier=(modifier) ⇒ nil
Sets the mnemonic modifier for this window.
-
#mnemonics_visible ⇒ TrueClass
Gets the value of the Gtk::Window:mnemonics-visible property.
-
#mnemonics_visible=(mnemonics_visible) ⇒ TrueClass
Whether mnemonics are currently visible in this window.
-
#mnemonics_visible? ⇒ TrueClass
Whether mnemonics are currently visible in this window.
-
#modal ⇒ TrueClass
Returns whether the window is modal.
- #modal=(modal) ⇒ TrueClass
-
#modal? ⇒ TrueClass
Modal.
-
#move(x, y) ⇒ nil
Asks the [window manager] to move window to the given position.
-
#new(type) ⇒ Gtk::Widget
Creates a new Gtk::Window, which is a toplevel window that can contain other widgets.
-
#opacity ⇒ Float
Fetches 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.
-
#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.
-
#position=(position) ⇒ nil
Sets a position constraint for this window.
-
#present ⇒ nil
Presents a window to the user.
-
#present_with_time(timestamp) ⇒ nil
Presents a window to the user.
-
#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.
-
#remove_accel_group(accel_group) ⇒ nil
Reverses the effects of gtk_window_add_accel_group().
-
#remove_mnemonic(keyval, target) ⇒ nil
Removes a mnemonic from this window.
-
#reshow_with_initial_size ⇒ nil
Hides window, then reshows it, resetting the default size and position of the window.
-
#resizable ⇒ TrueClass
Gets the value set by gtk_window_set_resizable().
- #resizable=(resizable) ⇒ TrueClass
-
#resizable? ⇒ TrueClass
Resizable.
-
#resize(width, height) ⇒ nil
Resizes the window as if the user had done so, obeying geometry constraints.
-
#resize_grip_is_visible ⇒ TrueClass
Determines whether a resize grip is visible for the specified window.
-
#resize_grip_visible=(resize_grip_visible) ⇒ TrueClass
Whether a corner resize grip is currently shown.
-
#resize_grip_visible? ⇒ TrueClass
Whether a corner resize grip is currently shown.
-
#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.
-
#role ⇒ String
Role.
- #role=(role) ⇒ String
-
#screen ⇒ Gdk::Screen
Screen.
- #screen=(screen) ⇒ Gdk::Screen
-
#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.
-
#set_default_size(width, height) ⇒ nil
Sets the default size of a window.
-
#set_geometry_hints(geometry_widget, geometry, geom_mask) ⇒ nil
This function sets up hints about how a window can be resized by the user.
-
#set_wmclass(wmclass_name, wmclass_class) ⇒ nil
Don’t use this function.
-
#skip_pager_hint ⇒ TrueClass
Gets the value set by gtk_window_set_skip_pager_hint().
- #skip_pager_hint=(skip_pager_hint) ⇒ TrueClass
-
#skip_pager_hint? ⇒ TrueClass
Skip-pager-hint.
-
#skip_taskbar_hint ⇒ TrueClass
Gets the value set by gtk_window_set_skip_taskbar_hint().
- #skip_taskbar_hint=(skip_taskbar_hint) ⇒ TrueClass
-
#skip_taskbar_hint? ⇒ TrueClass
Skip-taskbar-hint.
-
#startup_id=(startup_id) ⇒ String
The :startup-id is a write-only property for setting window’s startup notification identifier.
-
#stick ⇒ nil
Asks to stick window, which means that it will appear on all user desktops.
-
#title ⇒ String
Title.
- #title=(title) ⇒ String
-
#titlebar ⇒ Gtk::Widget
Returns the custom titlebar that has been set with gtk_window_set_titlebar().
-
#titlebar=(titlebar) ⇒ nil
Sets a custom titlebar for window.
-
#transient_for ⇒ Gtk::Window
The transient parent of the window.
-
#transient_for=(transient_for) ⇒ Gtk::Window
The transient parent of the window.
-
#type ⇒ Gtk::WindowType
Type.
- #type=(type) ⇒ Gtk::WindowType
-
#type_hint ⇒ Gdk::WindowTypeHint
Type-hint.
- #type_hint=(type_hint) ⇒ Gdk::WindowTypeHint
-
#unfullscreen ⇒ nil
Asks to toggle off the fullscreen state for window.
-
#unmaximize ⇒ nil
Asks to unmaximize window.
-
#unstick ⇒ nil
Asks to unstick window, which means that it will appear on only one of the user’s desktops.
-
#urgency_hint ⇒ TrueClass
Gets the value set by gtk_window_set_urgency_hint().
- #urgency_hint=(urgency_hint) ⇒ TrueClass
-
#urgency_hint? ⇒ TrueClass
Urgency-hint.
-
#window_position ⇒ Gtk::WindowPosition
Window-position.
- #window_position=(window_position) ⇒ Gtk::WindowPosition
-
#window_type ⇒ Gtk::WindowType
Gets the type of the window.
Instance Method Details
#accept_focus ⇒ TrueClass
Gets the value set by gtk_window_set_accept_focus().
#accept_focus=(accept_focus) ⇒ TrueClass
Whether the window should receive the input focus.
#accept_focus? ⇒ TrueClass
Whether the window should receive the input focus.
#activate_default ⇒ TrueClass
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.
#activate_focus ⇒ TrueClass
Activates the current focused widget within the window.
#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.
#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.
#add_mnemonic(keyval, target) ⇒ nil
Adds a mnemonic to this window.
#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.
#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.
#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.
#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.
#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.
#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.
#close ⇒ nil
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.
#decorated ⇒ TrueClass
Returns whether the window has been set to have decorations such as a title bar via gtk_window_set_decorated().
#decorated=(decorated) ⇒ TrueClass
Whether the window should be decorated by the window manager.
#decorated? ⇒ TrueClass
Whether the window should be decorated by the window manager.
#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.
#default_height ⇒ Integer
Returns default-height.
#default_height=(default_height) ⇒ Integer
#default_widget ⇒ Gtk::Widget
Returns the default widget for window. See gtk_window_set_default() for more details. if there is none.
#default_width ⇒ Integer
Returns default-width.
#default_width=(default_width) ⇒ Integer
#deiconify ⇒ nil
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.
#deletable ⇒ TrueClass
Returns whether the window has been set to have a close button via gtk_window_set_deletable().
#deletable=(deletable) ⇒ TrueClass
Whether the window frame should have a close button.
#deletable? ⇒ TrueClass
Whether the window frame should have a close button.
#destroy_with_parent ⇒ TrueClass
Returns whether the window will be destroyed with its transient parent. See gtk_window_set_destroy_with_parent ().
#destroy_with_parent=(destroy_with_parent) ⇒ TrueClass
#destroy_with_parent? ⇒ TrueClass
Returns destroy-with-parent.
#focus ⇒ Gtk::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.
#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.
#focus_on_map ⇒ TrueClass
Gets the value set by gtk_window_set_focus_on_map(). mapped.
#focus_on_map=(focus_on_map) ⇒ TrueClass
Whether the window should receive the input focus when mapped.
#focus_on_map? ⇒ TrueClass
Whether the window should receive the input focus when mapped.
#focus_visible ⇒ TrueClass
Gets the value of the Gtk::Window:focus-visible property.
#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.
#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.
#fullscreen ⇒ nil
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.
#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.
#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.
#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.
#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.
#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().
#gravity ⇒ Gdk::Gravity
The window gravity of the window. See gtk_window_move() and Gdk::Gravity for more details about window gravity.
#gravity=(gravity) ⇒ Gdk::Gravity
The window gravity of the window. See gtk_window_move() and Gdk::Gravity for more details about window gravity.
#group ⇒ Gtk::WindowGroup
Returns the group for window or the default group, if window is nil or if window does not have an explicit window group.
#has_group ⇒ TrueClass
Returns whether window has an explicit window group. Since 2.22
#has_resize_grip ⇒ TrueClass
Determines whether the window may have 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.
#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.
#has_toplevel_focus ⇒ TrueClass
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.
#has_toplevel_focus=(has_toplevel_focus) ⇒ TrueClass
#has_toplevel_focus? ⇒ TrueClass
Returns 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.
#hide_titlebar_when_maximized ⇒ TrueClass
Returns whether the window has requested to have its titlebar hidden when maximized. See gtk_window_set_hide_titlebar_when_maximized ().
#hide_titlebar_when_maximized=(hide_titlebar_when_maximized) ⇒ TrueClass
Whether the titlebar should be hidden during maximization.
#hide_titlebar_when_maximized? ⇒ TrueClass
Whether the titlebar should be hidden during maximization.
#icon ⇒ GdkPixbuf::Pixbuf
Returns icon.
#icon=(icon) ⇒ GdkPixbuf::Pixbuf
#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.
#icon_list ⇒ GLib::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.
#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.
#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.
#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.
#iconify ⇒ nil
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.
#is_active ⇒ TrueClass
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()
#is_active=(is_active) ⇒ TrueClass
#is_active? ⇒ TrueClass
Returns is-active.
#is_maximized ⇒ TrueClass
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().
#is_maximized=(is_maximized) ⇒ TrueClass
#is_maximized? ⇒ TrueClass
Returns 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.
#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.
#maximize ⇒ nil
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.
#mnemonic_activate(keyval, modifier) ⇒ TrueClass
Activates the targets associated with the mnemonic.
#mnemonic_modifier ⇒ Gdk::ModifierType
Returns the mnemonic modifier for this window. See gtk_window_set_mnemonic_modifier().
#mnemonic_modifier=(modifier) ⇒ nil
Sets the mnemonic modifier for this window.
#mnemonics_visible ⇒ TrueClass
Gets the value of the Gtk::Window:mnemonics-visible property. in this window.
#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.
#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.
#modal ⇒ TrueClass
Returns whether the window is modal. See gtk_window_set_modal().
#modal=(modal) ⇒ TrueClass
#modal? ⇒ TrueClass
Returns 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.
#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().
#opacity ⇒ Float
Fetches the requested opacity for this window. See gtk_window_set_opacity().
#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.
#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;
}
#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.
#present ⇒ nil
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.
#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.
#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.
#remove_accel_group(accel_group) ⇒ nil
Reverses the effects of gtk_window_add_accel_group().
#remove_mnemonic(keyval, target) ⇒ nil
Removes a mnemonic from this window.
#reshow_with_initial_size ⇒ nil
Hides window, then reshows it, resetting the default size and position of the window. Used by GUI builders only.
#resizable ⇒ TrueClass
Gets the value set by gtk_window_set_resizable().
#resizable=(resizable) ⇒ TrueClass
#resizable? ⇒ TrueClass
Returns 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.
#resize_grip_is_visible ⇒ TrueClass
Determines whether a resize grip is visible for the specified window.
#resize_grip_visible=(resize_grip_visible) ⇒ TrueClass
Whether a corner resize grip is currently shown.
#resize_grip_visible? ⇒ TrueClass
Whether a corner resize grip is currently shown.
#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.
#role ⇒ String
Returns role.
#role=(role) ⇒ String
#screen ⇒ Gdk::Screen
Returns screen.
#screen=(screen) ⇒ Gdk::Screen
#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.
#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.
#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.
#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.
#skip_pager_hint ⇒ TrueClass
Gets the value set by gtk_window_set_skip_pager_hint().
#skip_pager_hint=(skip_pager_hint) ⇒ TrueClass
#skip_pager_hint? ⇒ TrueClass
Returns skip-pager-hint.
#skip_taskbar_hint ⇒ TrueClass
Gets the value set by gtk_window_set_skip_taskbar_hint()
#skip_taskbar_hint=(skip_taskbar_hint) ⇒ TrueClass
#skip_taskbar_hint? ⇒ TrueClass
Returns 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.
#stick ⇒ nil
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.
#title ⇒ String
Returns title.
#title=(title) ⇒ String
#titlebar ⇒ Gtk::Widget
Returns the custom titlebar that has been set with gtk_window_set_titlebar().
#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().
#transient_for ⇒ Gtk::Window
The transient parent of the window. See gtk_window_set_transient_for() for more details about transient windows.
#transient_for=(transient_for) ⇒ Gtk::Window
The transient parent of the window. See gtk_window_set_transient_for() for more details about transient windows.
#type ⇒ Gtk::WindowType
Returns type.
#type=(type) ⇒ Gtk::WindowType
#type_hint ⇒ Gdk::WindowTypeHint
Returns type-hint.
#type_hint=(type_hint) ⇒ Gdk::WindowTypeHint
#unfullscreen ⇒ nil
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.
#unmaximize ⇒ nil
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.
#unstick ⇒ nil
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.
#urgency_hint ⇒ TrueClass
Gets the value set by gtk_window_set_urgency_hint()
#urgency_hint=(urgency_hint) ⇒ TrueClass
#urgency_hint? ⇒ TrueClass
Returns urgency-hint.
#window_position ⇒ Gtk::WindowPosition
Returns window-position.
#window_position=(window_position) ⇒ Gtk::WindowPosition
#window_type ⇒ Gtk::WindowType
Gets the type of the window. See Gtk::WindowType.