GtkApplicationExt

Trait GtkApplicationExt 

Source
pub trait GtkApplicationExt: IsA<Application> + 'static {
Show 35 methods // Provided methods fn add_window(&self, window: &impl IsA<Window>) { ... } fn forget(&self) { ... } fn accels_for_action(&self, detailed_action_name: &str) -> Vec<GString> { ... } fn actions_for_accel(&self, accel: &str) -> Vec<GString> { ... } fn active_window(&self) -> Option<Window> { ... } fn menu_by_id(&self, id: &str) -> Option<Menu> { ... } fn menubar(&self) -> Option<MenuModel> { ... } fn window_by_id(&self, id: u32) -> Option<Window> { ... } fn windows(&self) -> Vec<Window> { ... } fn inhibit( &self, window: Option<&impl IsA<Window>>, flags: ApplicationInhibitFlags, reason: Option<&str>, ) -> u32 { ... } fn list_action_descriptions(&self) -> Vec<GString> { ... } fn remove_window(&self, window: &impl IsA<Window>) { ... } fn save(&self) { ... } fn set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str]) { ... } fn set_menubar(&self, menubar: Option<&impl IsA<MenuModel>>) { ... } fn uninhibit(&self, cookie: u32) { ... } fn autosave_interval(&self) -> u32 { ... } fn set_autosave_interval(&self, autosave_interval: u32) { ... } fn is_register_session(&self) -> bool { ... } fn set_register_session(&self, register_session: bool) { ... } fn is_screensaver_active(&self) -> bool { ... } fn supports_save(&self) -> bool { ... } fn set_support_save(&self, support_save: bool) { ... } fn connect_query_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId { ... } fn connect_restore_state<F: Fn(&Self, RestoreReason, &Variant) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_restore_window<F: Fn(&Self, RestoreReason, &Variant) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_save_state<F: Fn(&Self, &VariantDict) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_window_added<F: Fn(&Self, &Window) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_window_removed<F: Fn(&Self, &Window) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_active_window_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_autosave_interval_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_menubar_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_register_session_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_screensaver_active_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... } fn connect_support_save_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId { ... }
}
Expand description

Trait containing all Application methods.

§Implementors

Application

Provided Methods§

Source

fn add_window(&self, window: &impl IsA<Window>)

Adds a window to the application.

This call can only happen after the application has started; typically, you should add new application windows in response to the emission of the [activate][struct@crate::GIO::Application#activate] signal.

This call is equivalent to setting the application property of the window to @self.

Normally, the connection between the application and the window will remain until the window is destroyed, but you can explicitly remove it with remove_window().

GTK will keep the application running as long as it has any windows.

§window

a window

Source

fn forget(&self)

Available on crate feature v4_22 only.

Forget state that has been previously saved and prevent further automatic state saving.

In order to reenable state saving, call save().

Source

fn accels_for_action(&self, detailed_action_name: &str) -> Vec<GString>

Gets the accelerators that are currently associated with the given action.

§detailed_action_name

a detailed action name, specifying an action and target to obtain accelerators for

§Returns

accelerators for @detailed_action_name

Source

fn actions_for_accel(&self, accel: &str) -> Vec<GString>

Returns the list of actions (possibly empty) that the accelerator maps to.

Each item in the list is a detailed action name in the usual form.

This might be useful to discover if an accel already exists in order to prevent installation of a conflicting accelerator (from an accelerator editor or a plugin system, for example). Note that having more than one action per accelerator may not be a bad thing and might make sense in cases where the actions never appear in the same context.

In case there are no actions for a given accelerator, an empty array is returned. NULL is never returned.

It is a programmer error to pass an invalid accelerator string.

If you are unsure, check it with accelerator_parse() first.

§accel

an accelerator that can be parsed by accelerator_parse()

§Returns

actions for @accel

Source

fn active_window(&self) -> Option<Window>

Gets the “active” window for the application.

The active window is the one that was most recently focused (within the application). This window may not have the focus at the moment if another application has it — this is just the most recently-focused window within this application.

§Returns

the active window

Source

fn menu_by_id(&self, id: &str) -> Option<Menu>

Gets a menu from automatically loaded resources.

See the section on Automatic resources for more information.

§id

the ID of the menu to look up

§Returns

Gets the menu with the given ID from the automatically loaded resources

Source

fn menubar(&self) -> Option<MenuModel>

Returns the menu model for the menu bar of the application.

§Returns

the menubar for windows of the application

Source

fn window_by_id(&self, id: u32) -> Option<Window>

Returns the window with the given ID.

The ID of a ApplicationWindow can be retrieved with ApplicationWindowExt::id().

§id

an identifier number

§Returns

the window for the given ID

Source

fn windows(&self) -> Vec<Window>

Gets a list of the window associated with the application.

The list is sorted by most recently focused window, such that the first element is the currently focused window. (Useful for choosing a parent for a transient window.)

The list that is returned should not be modified in any way. It will only remain valid until the next focus change or window creation or deletion.

§Returns

the list of windows

Source

fn inhibit( &self, window: Option<&impl IsA<Window>>, flags: ApplicationInhibitFlags, reason: Option<&str>, ) -> u32

Informs the session manager that certain types of actions should be inhibited.

This is not guaranteed to work on all platforms and for all types of actions.

Applications should invoke this method when they begin an operation that should not be interrupted, such as creating a CD or DVD. The types of actions that may be blocked are specified by the @flags parameter. When the application completes the operation it should call uninhibit() to remove the inhibitor. Note that an application can have multiple inhibitors, and all of them must be individually removed. Inhibitors are also cleared when the application exits.

Applications should not expect that they will always be able to block the action. In most cases, users will be given the option to force the action to take place.

The @reason message should be short and to the point.

If a window is given, the session manager may point the user to this window to find out more about why the action is inhibited.

The cookie that is returned by this function should be used as an argument to uninhibit() in order to remove the request.

§window

a window

§flags

what types of actions should be inhibited

§reason

a short, human-readable string that explains why these operations are inhibited

§Returns

A non-zero cookie that is used to uniquely identify this, or 0 if the platform does not support inhibiting or the request failed for some reason

Source

fn list_action_descriptions(&self) -> Vec<GString>

Lists the detailed action names which have associated accelerators.

See set_accels_for_action().

§Returns

the detailed action names

Source

fn remove_window(&self, window: &impl IsA<Window>)

Remove a window from the application.

If the window belongs to the application then this call is equivalent to setting the application property of the window to NULL.

The application may stop running as a result of a call to this function, if the window was the last window of the application.

§window

a window

Source

fn save(&self)

Available on crate feature v4_22 only.

Saves the state of application.

See forget() for a way to forget the state.

If register-session is set, Application calls this function automatically when the application is closed or the session ends.

Source

fn set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str])

Sets zero or more keyboard accelerators that will trigger the given action.

The first item in @accels will be the primary accelerator, which may be displayed in the UI.

To remove all accelerators for an action, use an empty, zero-terminated array for @accels.

For the @detailed_action_name, see gio::Action::parse_detailed_name() and [Gio.Action.print_detailed_name].

§detailed_action_name

a detailed action name, specifying an action and target to associate accelerators with

§accels

a list of accelerators in the format understood by accelerator_parse()

Source

fn set_menubar(&self, menubar: Option<&impl IsA<MenuModel>>)

Sets or unsets the menubar for windows of the application.

This is a menubar in the traditional sense.

This can only be done in the primary instance of the application, after it has been registered. vfunc::GIO::Application::startup is a good place to call this.

Depending on the desktop environment, this may appear at the top of each window, or at the top of the screen. In some environments, if both the application menu and the menubar are set, the application menu will be presented as if it were the first item of the menubar. Other environments treat the two as completely separate — for example, the application menu may be rendered by the desktop shell while the menubar (if set) remains in each individual window.

Use the base GActionMap interface to add actions, to respond to the user selecting these menu items.

a menu model

Source

fn uninhibit(&self, cookie: u32)

Removes an inhibitor that has been previously established.

See inhibit().

Inhibitors are also cleared when the application exits.

a cookie that was returned by inhibit()

Source

fn autosave_interval(&self) -> u32

Available on crate feature v4_22 only.

The number of seconds between automatic state saves. Defaults to 15. A value of 0 will opt out of automatic state saving.

Source

fn set_autosave_interval(&self, autosave_interval: u32)

Available on crate feature v4_22 only.

The number of seconds between automatic state saves. Defaults to 15. A value of 0 will opt out of automatic state saving.

Source

fn is_register_session(&self) -> bool

👎Deprecated: Since 4.22

Set this property to true to register with the session manager.

This will make GTK track the session state (such as the screensaver-active property).

§Deprecated since 4.22

This property is ignored. GTK always registers with the session manager

Source

fn set_register_session(&self, register_session: bool)

👎Deprecated: Since 4.22

Set this property to true to register with the session manager.

This will make GTK track the session state (such as the screensaver-active property).

§Deprecated since 4.22

This property is ignored. GTK always registers with the session manager

Source

fn is_screensaver_active(&self) -> bool

This property is true if GTK believes that the screensaver is currently active.

Tracking the screensaver state is currently only supported on Linux.

Source

fn supports_save(&self) -> bool

Available on crate feature v4_22 only.

Set this property to true if the application supports state saving and restoring.

Source

fn set_support_save(&self, support_save: bool)

Available on crate feature v4_22 only.

Set this property to true if the application supports state saving and restoring.

Source

fn connect_query_end<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId

Emitted when the session manager is about to end the session.

Applications can connect to this signal and call inhibit() with [flags@Gtk.ApplicationInhibitFlags.logout] to delay the end of the session until state has been saved.

Source

fn connect_restore_state<F: Fn(&Self, RestoreReason, &Variant) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId

Available on crate feature v4_22 only.

Emitted when application global state is restored.

The handler for this signal should do the opposite of what the corresponding handler for save-state does.

§reason

the reason for restoring state

§state

an “a{sv}” GVariant with state to restore

§Returns

true to stop stop further handlers from running

Source

fn connect_restore_window<F: Fn(&Self, RestoreReason, &Variant) + 'static>( &self, f: F, ) -> SignalHandlerId

Available on crate feature v4_22 only.

Emitted when an application’s per-window state is restored.

In response to this signal, you should create a new application window, add it to @application, apply the provided @state, and present it. The application can use the @reason to determine how much of the state should be restored.

You must be careful to be robust in the face of app upgrades and downgrades: the @state might have been created by a previous or occasionally even a future version of your app. Do not assume that a given key exists in the state. Apps must try to restore state saved by a previous version, but are free to discard state if it was written by a future version.

GTK will remember which window the user was using most recently, and will emit this signal for that window first. Thus, if you decide that the provided @reason means that only one window should be restored, you can reliably ignore emissions if a window already exists

Note that this signal is not emitted only during the app’s initial launch. If all windows are closed but the app keeps running, the signal will be emitted the next time a new window is opened.

§reason

the reason this window is restored

§state

an “a{sv}” GVariant with state to restore, as saved by a save-state handler

Source

fn connect_save_state<F: Fn(&Self, &VariantDict) -> bool + 'static>( &self, f: F, ) -> SignalHandlerId

Available on crate feature v4_22 only.

Emitted when the application is saving global state.

The handler for this signal should persist any global state of @application into @dict.

See restore-state for how to restore global state, and save-state and restore-window for handling per-window state.

§dict

a GVariantDict

§Returns

true to stop stop further handlers from running

Source

fn connect_window_added<F: Fn(&Self, &Window) + 'static>( &self, f: F, ) -> SignalHandlerId

Emitted when a window is added to an application.

See add_window().

§window

the newly-added window

Source

fn connect_window_removed<F: Fn(&Self, &Window) + 'static>( &self, f: F, ) -> SignalHandlerId

Emitted when a window is removed from an application.

This can happen as a side-effect of the window being destroyed or explicitly through remove_window().

§window

the window that is being removed

Source

fn connect_active_window_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_autosave_interval_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Available on crate feature v4_22 only.
Source

fn connect_menubar_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_register_session_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

👎Deprecated: Since 4.22
Source

fn connect_screensaver_active_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Source

fn connect_support_save_notify<F: Fn(&Self) + 'static>( &self, f: F, ) -> SignalHandlerId

Available on crate feature v4_22 only.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§