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<P: IsA<Application>>(&self, application: Option<&P>);
fn set_child<P: IsA<Widget>>(&self, child: Option<&P>);
fn set_decorated(&self, setting: bool);
fn set_default_size(&self, width: i32, height: i32);
fn set_default_widget<P: IsA<Widget>>(&self, default_widget: Option<&P>);
fn set_deletable(&self, setting: bool);
fn set_destroy_with_parent(&self, setting: bool);
fn set_display<P: IsA<Display>>(&self, display: &P);
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<P: IsA<Widget>>(&self, titlebar: Option<&P>);
fn set_transient_for<P: IsA<Window>>(&self, parent: Option<&P>);
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
Trait containing all Window
methods.
Implementors
AboutDialog
, ApplicationWindow
, Assistant
, Dialog
, ShortcutsWindow
, Window
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.
fn fullscreen(&self)
fn fullscreen(&self)
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.
fn fullscreen_on_monitor(&self, monitor: &Monitor)
fn fullscreen_on_monitor(&self, monitor: &Monitor)
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
fn application(&self) -> Option<Application>
fn application(&self) -> Option<Application>
fn is_decorated(&self) -> bool
fn is_decorated(&self) -> bool
fn default_widget(&self) -> Option<Widget>
fn default_widget(&self) -> Option<Widget>
fn is_deletable(&self) -> bool
fn is_deletable(&self) -> bool
fn must_destroy_with_parent(&self) -> bool
fn must_destroy_with_parent(&self) -> bool
fn gets_focus_visible(&self) -> bool
fn gets_focus_visible(&self) -> bool
fn group(&self) -> WindowGroup
fn group(&self) -> WindowGroup
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
v4_2
only.fn hides_on_close(&self) -> bool
fn hides_on_close(&self) -> bool
fn is_mnemonics_visible(&self) -> bool
fn is_mnemonics_visible(&self) -> bool
fn is_resizable(&self) -> bool
fn is_resizable(&self) -> bool
fn transient_for(&self) -> Option<Window>
fn transient_for(&self) -> Option<Window>
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.
fn is_fullscreen(&self) -> bool
fn is_fullscreen(&self) -> bool
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.
fn is_maximized(&self) -> bool
fn is_maximized(&self) -> bool
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.
fn present_with_time(&self, timestamp: u32)
fn present_with_time(&self, timestamp: u32)
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
fn set_application<P: IsA<Application>>(&self, application: Option<&P>)
fn set_application<P: IsA<Application>>(&self, application: Option<&P>)
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
fn set_decorated(&self, setting: bool)
fn set_decorated(&self, setting: bool)
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
fn set_default_size(&self, width: i32, height: i32)
fn set_default_size(&self, width: i32, height: i32)
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
fn set_deletable(&self, setting: bool)
fn set_deletable(&self, setting: bool)
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
fn set_destroy_with_parent(&self, setting: bool)
fn set_destroy_with_parent(&self, setting: bool)
fn set_display<P: IsA<Display>>(&self, display: &P)
fn set_display<P: IsA<Display>>(&self, display: &P)
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
fn set_focus_visible(&self, setting: bool)
fn set_focus_visible(&self, setting: bool)
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
fn set_hide_on_close(&self, setting: bool)
fn set_hide_on_close(&self, setting: bool)
fn set_icon_name(&self, name: Option<&str>)
fn set_icon_name(&self, name: Option<&str>)
fn set_mnemonics_visible(&self, setting: bool)
fn set_mnemonics_visible(&self, setting: bool)
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.
modal
whether the window is modal
fn set_resizable(&self, resizable: bool)
fn set_resizable(&self, resizable: bool)
fn set_startup_id(&self, startup_id: &str)
fn set_startup_id(&self, startup_id: &str)
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
fn unfullscreen(&self)
fn unfullscreen(&self)
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.
fn unmaximize(&self)
fn unmaximize(&self)
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.
fn unminimize(&self)
fn unminimize(&self)
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.
fn default_height(&self) -> i32
fn default_height(&self) -> i32
The default height of the window.
fn set_default_height(&self, default_height: i32)
fn set_default_height(&self, default_height: i32)
The default height of the window.
fn default_width(&self) -> i32
fn default_width(&self) -> i32
The default width of the window.
fn set_default_width(&self, default_width: i32)
fn set_default_width(&self, default_width: i32)
The default width of the window.
fn focus_widget(&self) -> Option<Widget>
fn focus_widget(&self) -> Option<Widget>
The focus widget.
fn is_fullscreened(&self) -> bool
fn is_fullscreened(&self) -> bool
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.
fn set_fullscreened(&self, fullscreened: bool)
fn set_fullscreened(&self, fullscreened: bool)
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.
fn set_maximized(&self, maximized: bool)
fn set_maximized(&self, maximized: bool)
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.
fn connect_activate_default<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_activate_default<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
Emitted when the user activates the default widget
of window
.
This is a keybinding signal.
fn emit_activate_default(&self)
fn connect_activate_focus<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
fn connect_activate_focus<F: Fn(&Self) + 'static>(
&self,
f: F
) -> SignalHandlerId
Emitted when the user activates the currently focused
widget of window
.
This is a keybinding signal.
fn emit_activate_focus(&self)
fn connect_close_request<F: Fn(&Self) -> Inhibit + 'static>(
&self,
f: F
) -> SignalHandlerId
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 connect_enable_debugging<F: Fn(&Self, bool) -> bool + 'static>(
&self,
f: F
) -> SignalHandlerId
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
fn emit_enable_debugging(&self, toggle: bool) -> bool
fn connect_keys_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
fn connect_keys_changed<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId
emitted when the set of accelerators or mnemonics that
are associated with window
changes.
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
v4_2
only.