Window
Object Hierarchy:
Description:
A GtkWindow is a toplevel window which can contain other widgets.
Windows normally have decorations that are under the control of the windowing system and allow the user to manipulate the window (resize it, move it, close it,...).
GtkWindow as GtkBuildable
The GtkWindow implementation of the Buildable interface supports a custom `< accel-groups>` element, which supports any number of `<group>` elements representing the AccelGroup objects you want to add to your window (synonymous with add_accel_group.
It also supports the `<initial-focus>` element, whose name property names the widget to receive the focus when the window is mapped.
An example of a UI definition fragment with accel groups:
<object class="GtkWindow">
<accel-groups>
<group name="accelgroup1"/>
</accel-groups>
<initial-focus name="thunderclap"/>
</object>
...
<object class="GtkAccelGroup" id="accelgroup1"/>
The GtkWindow implementation of the Buildable interface supports setting a child as the titlebar by specifying “titlebar” as the “type” attribute of a `<child>` element.
CSS nodes
window.background
├── decoration
├── <titlebar child>.titlebar [.default-decoration]
╰── <child>
main CSS node with name window and style class .background, and a subnode with name decoration.
Style classes that are typically used with the main CSS node are .csd (when client-side decorations are in use), .solid-csd (for client-side decorations without invisible borders), .ssd (used by mutter when rendering server-side decorations). GtkWindow also represents window states with the following style classes on the main node: .tiled, .maximized, .fullscreen. Specialized types of window often add their own discriminating style classes, such as .popup or .tooltip.
GtkWindow adds the .titlebar and .default-decoration style classes to the widget that is added as a titlebar child.
Example: Window:
public class Application : Gtk.Window {
public Application () {
// Sets the title of the Window:
this.title = "My Gtk.Window";
// Center window at startup:
this.window_position = Gtk.WindowPosition.CENTER;
// Sets the default size of a window:
this.set_default_size (350, 70);
// Whether the titlebar should be hidden during maximization.
this.hide_titlebar_when_maximized = false;
// Method called on pressing [X]
this.destroy.connect (() => {
// Print "Bye!" to our console:
print ("Bye!\n");
// Terminate the mainloop: (main returns 0)
Gtk.main_quit ();
});
// Widget content:
this.add (new Gtk.Label ("Hello, world!"));
}
public static int main (string[] args) {
Gtk.init (ref args);
Application app = new Application ();
app.show_all ();
Gtk.main ();
return 0;
}
}
valac --pkg gtk+-3.0 Gtk.Window.vala
Content:
Properties:
- public bool accept_focus { get; set; }
Whether the window should receive the input focus.
- public Application application { get; set; }
The Application associated with the window.
- public Widget attached_to { get; set construct; }
The widget to which this window is attached.
- public bool decorated { get; set; }
Whether the window should be decorated by the window manager.
- public int default_height { get; set; }
- public int default_width { get; set; }
- public bool deletable { get; set; }
Whether the window frame should have a close button.
- public bool destroy_with_parent { get; set; }
- public bool focus_on_map { get; set; }
Whether the window should receive the input focus when mapped.
- public bool focus_visible { get; set; }
Whether 'focus rectangles' are currently visible in this window.
- public Gravity gravity { get; set; }
The window gravity of the window.
- public bool has_resize_grip { get; set; }
Whether the window has a corner resize grip.
- public bool has_toplevel_focus { get; }
- public bool hide_titlebar_when_maximized { get; set; }
Whether the titlebar should be hidden during maximization.
- public Pixbuf icon { get; set; }
- public string icon_name { get; set; }
The icon_name property specifies the name of the themed icon to use as the window icon.
- public bool is_active { get; }
- public bool is_maximized { get; }
- public bool mnemonics_visible { get; set; }
Whether mnemonics are currently visible in this window.
- public bool modal { get; set; }
- public bool resizable { get; set; }
- public bool resize_grip_visible { get; }
Whether a corner resize grip is currently shown.
- public string role { get; set; }
- public Screen screen { get; set; }
- public bool skip_pager_hint { get; set; }
- public bool skip_taskbar_hint { get; set; }
- public string startup_id { set; }
The startup_id is a write-only property for setting window's startup notification identifier.
- public string title { get; set; }
- public Window transient_for { get; set construct; }
The transient parent of the window.
- public WindowType type { get; construct; }
- public WindowTypeHint type_hint { get; set; }
- public bool urgency_hint { get; set; }
- public WindowPosition window_position { get; set; }
Static methods:
- public static List<unowned Pixbuf> get_default_icon_list ()
Gets the value set by set_default_icon_list.
- public static unowned string get_default_icon_name ()
Returns the fallback icon name for windows that has been set with set_default_icon_name.
- public static List<unowned Window> list_toplevels ()
Returns a list of all existing toplevel windows.
- public static void set_auto_startup_notification (bool setting)
By default, after showing the first Window, GTK+ calls notify_startup_complete.
- public static void set_default_icon (Pixbuf icon)
Sets an icon to be used as fallback for windows that haven't had set_icon called on them from a pixbuf.
- public static bool set_default_icon_from_file (string filename) throws Error
Sets an icon to be used as fallback for windows that haven't had set_icon_list called on them from a file on disk.
- public static void set_default_icon_list (owned List<unowned Pixbuf> list)
Sets an icon list to be used as fallback for windows that haven't had set_icon_list called on them to set up a window-specific icon list.
- public static void set_default_icon_name (string name)
Sets an icon to be used as fallback for windows that haven't had set_icon_list called on them from a named themed icon, see set_icon_name.
- public static void set_interactive_debugging (bool enable)
Opens or closes the interactive debugger, which offers access to the widget hierarchy of the application and to useful debugging tools.
Creation methods:
- public Window (WindowType type = TOPLEVEL)
Creates a new Window, which is a toplevel window that can contain other widgets.
Methods:
- public bool activate_key (EventKey event)
Activates mnemonics and accelerators for this Window .
- public void add_accel_group (AccelGroup accel_group)
Associate
accel_group
with this , such that calling accel_groups_activate on this will activate accelerators inaccel_group
. - public void add_mnemonic (uint keyval, Widget target)
Adds a mnemonic to this window.
- public void begin_move_drag (int button, int root_x, int root_y, uint32 timestamp)
Starts moving a window.
- public void begin_resize_drag (WindowEdge edge, int button, int root_x, int root_y, uint32 timestamp)
Starts resizing a window.
- public void close ()
Requests that the window is closed, similar to what happens when a window manager close button is clicked.
- public void deiconify ()
Asks to deiconify (i.
- public void fullscreen ()
Asks to place this in the fullscreen state.
- public void fullscreen_on_monitor (Screen screen, int monitor)
Asks to place this in the fullscreen state.
- public bool get_accept_focus ()
Gets the value set by set_accept_focus.
- public unowned Application? get_application ()
Gets the Application associated with the window (if any).
- public unowned Widget? get_attached_to ()
Fetches the attach widget for this window.
- public bool get_decorated ()
Returns whether the window has been set to have decorations such as a title bar via set_decorated.
- public void get_default_size (out int width, out int height)
Gets the default size of the window.
- public unowned Widget? get_default_widget ()
Returns the default widget for this.
- public bool get_deletable ()
Returns whether the window has been set to have a close button via set_deletable.
- public bool get_destroy_with_parent ()
Returns whether the window will be destroyed with its transient parent.
- public unowned Widget? get_focus ()
Retrieves the current focused widget within the window.
- public bool get_focus_on_map ()
Gets the value set by set_focus_on_map.
- public bool get_focus_visible ()
Gets the value of the focus_visible property.
- public Gravity get_gravity ()
Gets the value set by set_gravity.
- public unowned WindowGroup get_group ()
Returns the group for this or the default group, if this is null or if this does not have an explicit window group.
- public bool get_has_resize_grip ()
Determines whether the window may have a resize grip.
- public bool get_hide_titlebar_when_maximized ()
Returns whether the window has requested to have its titlebar hidden when maximized.
- public unowned Pixbuf? get_icon ()
Gets the value set by set_icon (or if you've called set_icon_list, gets the first icon in the icon list).
- public List<unowned Pixbuf> get_icon_list ()
Retrieves the list of icons set by set_icon_list.
- public unowned string? get_icon_name ()
Returns the name of the themed icon for the window, see set_icon_name.
- public ModifierType get_mnemonic_modifier ()
Returns the mnemonic modifier for this window.
- public bool get_mnemonics_visible ()
Gets the value of the mnemonics_visible property.
- public bool get_modal ()
Returns whether the window is modal.
- public double get_opacity ()
Fetches the requested opacity for this window.
- public void get_position (out int root_x, out int root_y)
This function returns the position you need to pass to move to keep this in its current position.
- public bool get_resizable ()
Gets the value set by set_resizable.
- public bool get_resize_grip_area (out Rectangle rect)
If a window has a resize grip, this will retrieve the grip position, width and height into the specified Rectangle.
- public unowned string? get_role ()
Returns the role of the window.
- public unowned Screen get_screen ()
Returns the Screen associated with this.
- public void get_size (out int width, out int height)
Obtains the current size of this.
- public bool get_skip_pager_hint ()
Gets the value set by set_skip_pager_hint.
- public bool get_skip_taskbar_hint ()
Gets the value set by set_skip_taskbar_hint
- public unowned string? get_title ()
Retrieves the title of the window.
- public unowned Widget? get_titlebar ()
Returns the custom titlebar that has been set with set_titlebar.
- public unowned Window? get_transient_for ()
Fetches the transient parent for this window.
- public WindowTypeHint get_type_hint ()
Gets the type hint for this window.
- public bool get_urgency_hint ()
Gets the value set by set_urgency_hint
- public WindowType get_window_type ()
Gets the type of the window.
- public bool has_group ()
Returns whether this has an explicit window group.
- public void iconify ()
Asks to iconify (i.
- public void maximize ()
Asks to maximize this, so that it becomes full-screen.
- public bool mnemonic_activate (uint keyval, ModifierType modifier)
Activates the targets associated with the mnemonic.
- public void move (int x, int y)
Asks the window manager to move this to the given position.
- public bool parse_geometry (string geometry)
Parses a standard X Window System geometry string - see the manual page for X (type “man X”) for details on this.
- public void present ()
Presents a window to the user.
- public void present_with_time (uint32 timestamp)
Presents a window to the user.
- public bool propagate_key_event (EventKey event)
Propagate a key press or release event to the focus widget and up the focus container chain until a widget handles
event
. - public void remove_accel_group (AccelGroup accel_group)
Reverses the effects of add_accel_group.
- public void remove_mnemonic (uint keyval, Widget target)
Removes a mnemonic from this window.
- public void reshow_with_initial_size ()
Hides this, then reshows it, resetting the default size and position of the window.
- public void resize (int width, int height)
Resizes the window as if the user had done so, obeying geometry constraints.
- public bool resize_grip_is_visible ()
Determines whether a resize grip is visible for the specified window.
- public void resize_to_geometry (int width, int height)
Like resize, but
width
andheight
are interpreted in terms of the base size and increment set with gtk_window_set_geometry_hints. - public void set_accept_focus (bool setting)
Windows may set a hint asking the desktop environment not to receive the input focus.
- public void set_application (Application? application)
Sets or unsets the Application associated with the window.
- public void set_attached_to (Widget? attach_widget)
Marks this as attached to
attach_widget
. - public void set_decorated (bool setting)
By default, windows are decorated with a title bar, resize controls, etc.
- public void set_default (Widget? default_widget)
The default widget is the widget that’s activated when the user presses Enter in a dialog (for example).
- public void set_default_geometry (int width, int height)
Like set_default_size, but
width
andheight
are interpreted in terms of the base size and increment set with gtk_window_set_geometry_hints. - public void set_default_size (int width, int height)
Sets the default size of a window.
- public void set_deletable (bool setting)
By default, windows have a close button in the window frame.
- public void set_destroy_with_parent (bool setting)
If
setting
is true, then destroying the transient parent of this will also destroy this itself. - public void set_focus_on_map (bool setting)
Windows may set a hint asking the desktop environment not to receive the input focus when the window is mapped.
- public void set_focus_visible (bool setting)
Sets the focus_visible property.
- public void set_geometry_hints (Widget? geometry_widget, Geometry? geometry, WindowHints geom_mask)
This function sets up hints about how a window can be resized by the user.
- public void set_gravity (Gravity gravity)
Window gravity defines the meaning of coordinates passed to move.
- public void set_has_resize_grip (bool value)
Sets whether this has a corner resize grip.
- public void set_has_user_ref_count (bool setting)
Tells GTK+ whether to drop its extra reference to the window when destroy is called.
- public void set_hide_titlebar_when_maximized (bool setting)
If
setting
is true, then this will request that it’s titlebar should be hidden when maximized. - public void set_icon (Pixbuf? icon)
Sets up the icon representing a Window.
- public bool set_icon_from_file (string filename) throws Error
Sets the icon for this.
- public void set_icon_list (List<Pixbuf> list)
Sets up the icon representing a Window.
- public void set_icon_name (string? name)
Sets the icon for the window from a named themed icon.
- public void set_keep_above (bool setting)
Asks to keep this above, so that it stays on top.
- public void set_keep_below (bool setting)
Asks to keep this below, so that it stays in bottom.
- public void set_mnemonic_modifier (ModifierType modifier)
Sets the mnemonic modifier for this window.
- public void set_mnemonics_visible (bool setting)
Sets the mnemonics_visible property.
- public void set_modal (bool modal)
Sets a window modal or non-modal.
- public void set_opacity (double opacity)
Request the windowing system to make this partially transparent, with opacity 0 being fully transparent and 1 fully opaque.
- public void set_position (WindowPosition position)
Sets a position constraint for this window.
- public void set_resizable (bool resizable)
Sets whether the user can resize a window.
- public void set_role (string role)
This function is only useful on X11, not with other GTK+ targets.
- public void set_screen (Screen screen)
Sets the Screen where the this is displayed; if the window is already mapped, it will be unmapped, and then remapped on the new screen.
- public void set_skip_pager_hint (bool setting)
Windows may set a hint asking the desktop environment not to display the window in the pager.
- public void set_skip_taskbar_hint (bool setting)
Windows may set a hint asking the desktop environment not to display the window in the task bar.
- public void set_startup_id (string startup_id)
Startup notification identifiers are used by desktop environment to track application startup, to provide user feedback and other features.
- public void set_title (string title)
Sets the title of the Window.
- public void set_titlebar (Widget? titlebar)
Sets a custom titlebar for this.
- public void set_transient_for (Window? parent)
Dialog windows should be set transient for the main application window they were spawned from.
- public void set_type_hint (WindowTypeHint hint)
By setting the type hint for the window, you allow the window manager to decorate and handle the window in a way which is suitable to the function of the window in your application.
- public void set_urgency_hint (bool setting)
Windows may set a hint asking the desktop environment to draw the users attention to the window.
- public void set_wmclass (string wmclass_name, string wmclass_class)
Don’t use this function.
- public void stick ()
Asks to stick this, which means that it will appear on all user desktops.
- public bool try_activate_default ()
- public bool try_activate_focus ()
- public void unfullscreen ()
Asks to toggle off the fullscreen state for this .
- public void unmaximize ()
Asks to unmaximize this.
- public void unstick ()
Asks to unstick this, which means that it will appear on only one of the user’s desktops.
Signals:
- public virtual signal void activate_default ()
The activate_default signal is a keybinding signal which gets emitted when the user activates the default widget of
window
. - public virtual signal void activate_focus ()
The activate_focus signal is a keybinding signal which gets emitted when the user activates the currently focused widget of
window
. - public virtual signal bool enable_debugging (bool toggle)
The enable_debugging signal is a keybinding signal which gets emitted when the user enables or disables interactive debugging.
- public virtual signal void keys_changed ()
The keys_changed signal gets emitted when the set of accelerators or mnemonics that are associated with
window
changes. - public virtual signal void set_focus (Widget? focus)
This signal is emitted whenever the currently focused widget in this window changes.
Inherited Members:
- accel_closures_changed
- activate
- add_accelerator
- add_device_events
- add_events
- add_mnemonic_label
- add_tick_callback
- adjust_baseline_allocation
- adjust_baseline_request
- adjust_size_allocation
- adjust_size_request
- app_paintable
- bind_template_callback_full
- bind_template_child_full
- button_press_event
- button_release_event
- can_activate_accel
- can_default
- can_focus
- child_focus
- child_notify
- class_path
- composite_child
- composited_changed
- compute_expand
- compute_expand_internal
- configure_event
- create_pango_context
- create_pango_layout
- damage_event
- delete_event
- destroy
- destroy_event
- destroyed
- device_is_shadowed
- direction_changed
- dispatch_child_properties_changed
- double_buffered
- drag_begin
- drag_data_delete
- drag_data_get
- drag_data_received
- drag_drop
- drag_end
- drag_failed
- drag_leave
- drag_motion
- draw
- draw_to_cairo_context
- ensure_style
- enter_notify_event
- error_bell
- event
- event_after
- events
- expand
- find_style_property
- focus
- focus_in_event
- focus_on_click
- focus_out_event
- freeze_child_notify
- get_accessible
- get_action_group
- get_allocated_baseline
- get_allocated_height
- get_allocated_size
- get_allocated_width
- get_allocation
- get_ancestor
- get_app_paintable
- get_can_default
- get_can_focus
- get_child_requisition
- get_child_visible
- get_clip
- get_clipboard
- get_composite_name
- get_css_name
- get_default_direction
- get_default_style
- get_device_enabled
- get_device_events
- get_direction
- get_display
- get_double_buffered
- get_events
- get_focus_on_click
- get_font_map
- get_font_options
- get_frame_clock
- get_halign
- get_has_tooltip
- get_has_window
- get_hexpand
- get_hexpand_set
- get_mapped
- get_margin_bottom
- get_margin_end
- get_margin_left
- get_margin_right
- get_margin_start
- get_margin_top
- get_modifier_mask
- get_modifier_style
- get_no_show_all
- get_opacity
- get_pango_context
- get_parent
- get_parent_window
- get_path
- get_pointer
- get_preferred_height
- get_preferred_height_and_baseline_for_width
- get_preferred_height_for_width
- get_preferred_height_for_width_internal
- get_preferred_height_internal
- get_preferred_size
- get_preferred_width
- get_preferred_width_for_height
- get_preferred_width_for_height_internal
- get_preferred_width_internal
- get_realized
- get_receives_default
- get_request_mode
- get_requisition
- get_root_window
- get_scale_factor
- get_screen
- get_sensitive
- get_settings
- get_size_request
- get_state
- get_state_flags
- get_style
- get_style_context
- get_support_multidevice
- get_template_child
- get_tooltip_markup
- get_tooltip_text
- get_tooltip_window
- get_toplevel
- get_valign
- get_valign_with_baseline
- get_vexpand
- get_vexpand_set
- get_visible
- get_visual
- get_window
- grab_broken_event
- grab_default
- grab_focus
- grab_notify
- halign
- has_default
- has_focus
- has_grab
- has_rc_style
- has_screen
- has_tooltip
- has_visible_focus
- height_request
- hexpand
- hexpand_set
- hide
- hide_on_delete
- hierarchy_changed
- in_destruction
- init_template
- input_shape_combine_region
- insert_action_group
- install_style_property
- install_style_property_parser
- intersect
- is_ancestor
- is_composited
- is_drawable
- is_focus
- is_sensitive
- is_toplevel
- is_visible
- key_press_event
- key_release_event
- keynav_failed
- leave_notify_event
- list_accel_closures
- list_action_prefixes
- list_mnemonic_labels
- list_style_properties
- map
- map_event
- margin
- margin_bottom
- margin_end
- margin_left
- margin_right
- margin_start
- margin_top
- mnemonic_activate
- modify_base
- modify_bg
- modify_cursor
- modify_fg
- modify_font
- modify_style
- modify_text
- motion_notify_event
- move_focus
- name
- no_show_all
- opacity
- override_background_color
- override_color
- override_cursor
- override_font
- override_symbolic_color
- parent
- parent_set
- path
- pop_composite_child
- popup_menu
- property_notify_event
- proximity_in_event
- proximity_out_event
- push_composite_child
- query_tooltip
- queue_allocate
- queue_compute_expand
- queue_draw
- queue_draw_area
- queue_draw_region
- queue_resize
- queue_resize_no_redraw
- realize
- receives_default
- region_intersect
- register_window
- remove_accelerator
- remove_mnemonic_label
- remove_tick_callback
- render_icon
- render_icon_pixbuf
- reparent
- reset_rc_styles
- reset_style
- scale_factor
- screen_changed
- scroll_event
- selection_clear_event
- selection_get
- selection_notify_event
- selection_received
- selection_request_event
- send_expose
- send_focus_change
- sensitive
- set_accel_path
- set_accessible_role
- set_accessible_type
- set_allocation
- set_app_paintable
- set_can_default
- set_can_focus
- set_child_visible
- set_clip
- set_composite_name
- set_connect_func
- set_css_name
- set_default_direction
- set_device_enabled
- set_device_events
- set_direction
- set_double_buffered
- set_events
- set_focus_on_click
- set_font_map
- set_font_options
- set_halign
- set_has_tooltip
- set_has_window
- set_hexpand
- set_hexpand_set
- set_mapped
- set_margin_bottom
- set_margin_end
- set_margin_left
- set_margin_right
- set_margin_start
- set_margin_top
- set_no_show_all
- set_opacity
- set_parent
- set_parent_window
- set_realized
- set_receives_default
- set_redraw_on_allocate
- set_sensitive
- set_size_request
- set_state
- set_state_flags
- set_style
- set_support_multidevice
- set_template
- set_template_from_resource
- set_tooltip_markup
- set_tooltip_text
- set_tooltip_window
- set_valign
- set_vexpand
- set_vexpand_set
- set_visible
- set_visual
- set_window
- shape_combine_region
- show
- show_all
- show_help
- show_now
- size_allocate
- size_allocate_with_baseline
- size_request
- state_changed
- state_flags_changed
- style
- style_attach
- style_get
- style_get_property
- style_get_valist
- style_set
- style_updated
- thaw_child_notify
- tooltip_markup
- tooltip_text
- touch_event
- translate_coordinates
- trigger_tooltip_query
- unmap
- unmap_event
- unparent
- unrealize
- unregister_window
- unset_state_flags
- valign
- vexpand
- vexpand_set
- visibility_notify_event
- visible
- width_request
- window_state_event