Trait gtk4::prelude::GtkApplicationExt

source ·
pub trait GtkApplicationExt: IsA<Application> + Sealed + 'static {
Show 24 methods // Provided methods fn add_window(&self, window: &impl IsA<Window>) { ... } 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 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 is_register_session(&self) -> bool { ... } fn set_register_session(&self, register_session: bool) { ... } fn is_screensaver_active(&self) -> bool { ... } fn connect_query_end<F: Fn(&Self) + '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_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 { ... }
}
Expand description

Trait containing all Application methods.

§Implementors

Application

Provided Methods§

source

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

Adds a window to 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 GApplication::activate signal.

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

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 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 accel 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

a None-terminated array of 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 that has been set with set_menubar().

§Returns

the menubar for windows of application

source

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

Returns the ApplicationWindow 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 instances associated with 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

a GList of Window instances

source

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

Inform 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 window is given, the session manager may point the user to this window to find out more about why the action is inhibited.

§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 request. It should be used as an argument to uninhibit() in order to remove the request. If the platform does not support inhibiting or the request failed for some reason, 0 is returned.

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 application.

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

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

§window

a Window

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 g_action_parse_detailed_name() and g_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 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. GApplication::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 GMenuModel

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 is_register_session(&self) -> bool

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).

source

fn set_register_session(&self, register_session: bool)

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).

source

fn is_screensaver_active(&self) -> bool

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

GTK only tracks session state (including this) when register-session is set to true.

Tracking the screensaver state is currently only supported on Linux.

source

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

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

This signal is only emitted if register-session is TRUE. Applications can connect to this signal and call inhibit() with GTK_APPLICATION_INHIBIT_LOGOUT to delay the end of the session until state has been saved.

source

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

Emitted when a Window is added to application through 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 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_menubar_notify<F: Fn(&Self) + 'static>( &self, f: F ) -> SignalHandlerId

source

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

source

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

Object Safety§

This trait is not object safe.

Implementors§