Trait gtk4::prelude::GtkWindowExt[][src]

pub trait GtkWindowExt: 'static {
Show 92 methods fn close(&self);
fn destroy(&self);
fn fullscreen(&self);
fn fullscreen_on_monitor(&self, monitor: &Monitor);
fn application(&self) -> Option<Application>;
fn child(&self) -> Option<Widget>;
fn is_decorated(&self) -> bool;
fn default_size(&self) -> (i32, i32);
fn default_widget(&self) -> Option<Widget>;
fn is_deletable(&self) -> bool;
fn must_destroy_with_parent(&self) -> bool;
fn gets_focus_visible(&self) -> bool;
fn group(&self) -> WindowGroup;
fn is_handle_menubar_accel(&self) -> bool;
fn hides_on_close(&self) -> bool;
fn icon_name(&self) -> Option<GString>;
fn is_mnemonics_visible(&self) -> bool;
fn is_modal(&self) -> bool;
fn is_resizable(&self) -> bool;
fn title(&self) -> Option<GString>;
fn titlebar(&self) -> Option<Widget>;
fn transient_for(&self) -> Option<Window>;
fn has_group(&self) -> bool;
fn is_active(&self) -> bool;
fn is_fullscreen(&self) -> bool;
fn is_maximized(&self) -> bool;
fn maximize(&self);
fn minimize(&self);
fn present(&self);
fn present_with_time(&self, timestamp: u32);
fn set_application(&self, application: Option<&impl IsA<Application>>);
fn set_child(&self, child: Option<&impl IsA<Widget>>);
fn set_decorated(&self, setting: bool);
fn set_default_size(&self, width: i32, height: i32);
fn set_default_widget(&self, default_widget: Option<&impl IsA<Widget>>);
fn set_deletable(&self, setting: bool);
fn set_destroy_with_parent(&self, setting: bool);
fn set_display(&self, display: &impl IsA<Display>);
fn set_focus_visible(&self, setting: bool);
fn set_handle_menubar_accel(&self, handle_menubar_accel: bool);
fn set_hide_on_close(&self, setting: bool);
fn set_icon_name(&self, name: Option<&str>);
fn set_mnemonics_visible(&self, setting: bool);
fn set_modal(&self, modal: bool);
fn set_resizable(&self, resizable: bool);
fn set_startup_id(&self, startup_id: &str);
fn set_title(&self, title: Option<&str>);
fn set_titlebar(&self, titlebar: Option<&impl IsA<Widget>>);
fn set_transient_for(&self, parent: Option<&impl IsA<Window>>);
fn unfullscreen(&self);
fn unmaximize(&self);
fn unminimize(&self);
fn default_height(&self) -> i32;
fn set_default_height(&self, default_height: i32);
fn default_width(&self) -> i32;
fn set_default_width(&self, default_width: i32);
fn focus_widget(&self) -> Option<Widget>;
fn set_focus_widget<P: IsA<Widget>>(&self, focus_widget: Option<&P>);
fn is_fullscreened(&self) -> bool;
fn set_fullscreened(&self, fullscreened: bool);
fn set_maximized(&self, maximized: bool);
fn connect_activate_default<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn emit_activate_default(&self);
fn connect_activate_focus<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn emit_activate_focus(&self);
fn connect_close_request<F: Fn(&Self) -> Inhibit + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_enable_debugging<F: Fn(&Self, bool) -> bool + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn emit_enable_debugging(&self, toggle: bool) -> bool;
fn connect_keys_changed<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_application_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_child_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_decorated_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_default_height_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_default_widget_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_default_width_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_deletable_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_destroy_with_parent_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_display_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_focus_visible_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_focus_widget_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_fullscreened_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_handle_menubar_accel_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_hide_on_close_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_icon_name_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_is_active_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_maximized_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_mnemonics_visible_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_modal_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_resizable_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_startup_id_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_title_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_transient_for_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
}
Expand description

Required methods

Requests that the window is closed.

This is similar to what happens when a window manager close button is clicked.

This function can be used with close buttons in custom titlebars.

Drop the internal reference GTK holds on toplevel windows.

Asks to place self in the fullscreen state.

Note that you shouldn’t assume the window is definitely fullscreen afterward, because other entities (e.g. the user or window manager unfullscreen it again, and not all window managers honor requests to fullscreen windows.

You can track the result of this operation via the property::Gdk::Toplevel::state property, or by listening to notifications of the property::Window::fullscreened property.

Asks to place self in the fullscreen state on the given monitor.

Note that you shouldn’t assume the window is definitely fullscreen afterward, or that the windowing system allows fullscreen windows on any given monitor.

You can track the result of this operation via the property::Gdk::Toplevel::state property, or by listening to notifications of the property::Window::fullscreened property.

monitor

which monitor to go fullscreen on

Gets the Application associated with the window.

Returns

a Application

Gets the child widget of self.

Returns

the child widget of self

Returns whether the window has been set to have decorations.

Returns

true if the window has been set to have decorations

Gets the default size of the window.

A value of 0 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.

Returns
width

location to store the default width

height

location to store the default height

Returns the default widget for self.

Returns

the default widget

Returns whether the window has been set to have a close button.

Returns

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

Returns whether the window will be destroyed with its transient parent.

Returns

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

Gets whether “focus rectangles” are supposed to be visible.

Returns

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

Returns the group for self.

If the window has no group, then the default group is returned.

Returns

the WindowGroup for a window or the default group

This is supported on crate feature v4_2 only.

Returns whether this window reacts to F10 key presses by activating a menubar it contains.

Returns

true if the window handles F10

Returns whether the window will be hidden when the close button is clicked.

Returns

true if the window will be hidden

Returns the name of the themed icon for the window.

Returns

the icon name

Gets whether mnemonics are supposed to be visible.

Returns

true if mnemonics are supposed to be visible in this window.

Returns whether the window is modal.

Returns

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

Gets the value set by set_resizable().

Returns

true if the user can resize the window

Retrieves the title of the window.

Returns

the title of the window

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

Returns

the custom titlebar

Fetches the transient parent for this window.

Returns

the transient parent for this window

Returns whether self has an explicit window group.

Returns

true if self has an explicit window group.

Returns whether the window is part of the current active toplevel.

The active toplevel is the window receiving keystrokes.

The return value is true if the window is active toplevel itself. You might use this function if you wanted to draw a widget differently in an active window from a widget in an inactive window.

Returns

true if the window part of the current active window.

Retrieves the current fullscreen state of self.

Note that since fullscreening 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 fullscreen() or unfullscreen().

If the window isn’t yet mapped, the value returned will whether the initial requested state is fullscreen.

Returns

whether the window has a fullscreen state.

Retrieves the current maximized state of self.

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 maximize() or unmaximize().

If the window isn’t yet mapped, the value returned will whether the initial requested state is maximized.

Returns

whether the window has a maximized state.

Asks to maximize self, so that it fills the 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.

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 the result of this operation via the property::Gdk::Toplevel::state property, or by listening to notifications on the property::Window::maximized property.

Asks to minimize the specified self.

Note that you shouldn’t assume the window is definitely minimized afterward, because the windowing system might not support this functionality; other entities (e.g. the user or the window manager could unminimize it again, or there may not be a window manager in which case minimization isn’t possible, etc.

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

You can track result of this operation via the property::Gdk::Toplevel::state property.

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.

Presents a window to the user.

This may mean raising the window in the stacking order, unminimizing 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 self is hidden, this function calls WidgetExt::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 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.

timestamp

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

Sets or unsets the 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 to None.

This is equivalent to calling GtkApplicationExt::remove_window() and/or GtkApplicationExt::add_window() on the old/new applications as relevant.

application

a Application, or None to unset

Sets the child widget of self.

child

the child widget

Sets whether the window should be decorated.

By default, windows are decorated with a title bar, resize controls, etc. Some window managers allow GTK to disable these decorations, creating a borderless window. If you set the decorated property to false using this function, GTK will do its best to convince the window manager not to decorate the window. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before calling WidgetExt::show().

On Windows, this function always works, since there’s no window manager policy involved.

setting

true to decorate the window

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.

Unlike WidgetExt::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).

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 default_size(). Using the window allocation directly will not work in all circumstances and can lead to growing or shrinking windows.

width

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

height

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

Sets the default widget.

The default widget is the widget that is activated when the user presses Enter in a dialog (for example).

default_widget

widget to be the default to unset the default widget for the toplevel

Sets whether the window should be deletable.

By default, windows have a close button in the window frame. Some window managers allow GTK to disable this button. If you set the deletable property to false using this function, GTK will do its best to convince the window manager not to show a close button. Depending on the system, this function may not have any effect when called on a window that is already visible, so you should call it before calling WidgetExt::show().

On Windows, this function always works, since there’s no window manager policy involved.

setting

true to decorate the window as deletable

If setting is true, then destroying the transient parent of self will also destroy self itself.

This is useful for dialogs that shouldn’t persist beyond the lifetime of the main window they are associated with, for example.

setting

whether to destroy self with its transient parent

Sets the gdk::Display where the self is displayed.

If the window is already mapped, it will be unmapped, and then remapped on the new display.

display

a gdk::Display

Sets whether “focus rectangles” are supposed to be visible.

setting

the new value

This is supported on crate feature v4_2 only.

Sets whether this window should react to F10 key presses by activating a menubar it contains.

handle_menubar_accel

true to make self handle F10

If setting is true, then clicking the close button on the window will not destroy it, but only hide it.

setting

whether to hide the window when it is closed

Sets the icon for the window from a named themed icon.

See the docs for IconTheme for more details. On some platforms, the window icon is not used at all.

Note that this has nothing to do with the WM_ICON_NAME property which is mentioned in the ICCCM.

name

the name of the themed icon

Sets whether mnemonics are supposed to be visible.

setting

the new value

Sets a window modal or non-modal.

Modal windows prevent interaction with other windows in the same application. To keep modal dialogs on top of main application windows, use set_transient_for() to make the dialog transient for the parent; most window managers will then disallow lowering the dialog below the parent.

whether the window is modal

Sets whether the user can resize a window.

Windows are user resizable by default.

resizable

true if the user can resize this window

Sets the startup notification ID.

Startup notification identifiers are used by desktop environment to track application startup, to provide user feedback and other features. This function changes the corresponding property on the underlying gdk::Surface.

Normally, startup identifier is managed automatically and you should only use this function in special cases like transferring focus from other processes. You should use this function before calling present() or any equivalent function generating a window map event.

This function is only useful on X11, not with other GTK targets.

startup_id

a string with startup-notification identifier

Sets the title of the Window.

The title of a window will be displayed in its title bar; on the X Window System, the title bar is rendered by the window manager so exactly how the title appears to users may vary according to a user’s exact configuration. The title should help a user distinguish this window from other windows they may have open. A good title might include the application name and current document filename, for example.

Passing None does the same as setting the title to an empty string.

title

title of the window

Sets a custom titlebar for self.

A typical widget used here is 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 WidgetExt::show().

titlebar

the widget to use as titlebar

Dialog windows should be set transient for the main application window they were spawned from. This allows window managers to e.g. keep the dialog on top of the main window, or center the dialog over the main window. Dialog::with_buttons() and other convenience functions in GTK will sometimes call set_transient_for() on your behalf.

Passing None for parent unsets the current transient window.

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

parent

parent window

Asks to remove the fullscreen state for self, and return to its previous state.

Note that you shouldn’t assume the window is definitely not fullscreen 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; normally the window will end up restored to its normal state. Just don’t write code that crashes if not.

You can track the result of this operation via the property::Gdk::Toplevel::state property, or by listening to notifications of the property::Window::fullscreened property.

Asks to unmaximize self.

Note that you shouldn’t assume the window is definitely unmaximized afterward, because other entities (e.g. the user or window manager maximize it again, and not all window managers honor requests to unmaximize.

You can track the result of this operation via the property::Gdk::Toplevel::state property, or by listening to notifications on the property::Window::maximized property.

Asks to unminimize the specified self.

Note that you shouldn’t assume the window is definitely unminimized afterward, because the windowing system might not support this functionality; other entities (e.g. the user or the window manager could minimize it again, or there may not be a window manager in which case minimization isn’t possible, etc.

You can track result of this operation via the property::Gdk::Toplevel::state property.

The default height of the window.

The default height of the window.

The default width of the window.

The default width of the window.

The focus widget.

The focus widget.

Whether the window is fullscreen.

Setting this property is the equivalent of calling fullscreen() or unfullscreen(); either operation is asynchronous, which means you will need to connect to the ::notify signal in order to know whether the operation was successful.

Whether the window is fullscreen.

Setting this property is the equivalent of calling fullscreen() or unfullscreen(); either operation is asynchronous, which means you will need to connect to the ::notify signal in order to know whether the operation was successful.

Whether the window is maximized.

Setting this property is the equivalent of calling maximize() or unmaximize(); either operation is asynchronous, which means you will need to connect to the ::notify signal in order to know whether the operation was successful.

Emitted when the user activates the default widget of window.

This is a keybinding signal.

Emitted when the user activates the currently focused widget of window.

This is a keybinding signal.

Emitted when the user clicks on the close button of the window.

Returns

true to stop other handlers from being invoked for the signal

Emitted when the user enables or disables interactive debugging.

When toggle is true, interactive debugging is toggled on or off, when it is false, the debugger will be pointed at the widget under the pointer.

This is a keybinding signal.

The default bindings for this signal are Ctrl-Shift-I and Ctrl-Shift-D.

toggle

toggle the debugger

Returns

true if the key binding was handled

emitted when the set of accelerators or mnemonics that are associated with window changes.

This is supported on crate feature v4_2 only.

Implementors