[][src]Trait gtk::GtkApplicationExt

pub trait GtkApplicationExt: 'static {
    fn add_window<P: IsA<Window>>(&self, window: &P);
fn get_accels_for_action(&self, detailed_action_name: &str) -> Vec<GString>;
fn get_actions_for_accel(&self, accel: &str) -> Vec<GString>;
fn get_active_window(&self) -> Option<Window>;
fn get_app_menu(&self) -> Option<MenuModel>;
fn get_menu_by_id(&self, id: &str) -> Option<Menu>;
fn get_menubar(&self) -> Option<MenuModel>;
fn get_window_by_id(&self, id: u32) -> Option<Window>;
fn get_windows(&self) -> Vec<Window>;
fn inhibit<P: IsA<Window>>(
        &self,
        window: Option<&P>,
        flags: ApplicationInhibitFlags,
        reason: Option<&str>
    ) -> u32;
fn is_inhibited(&self, flags: ApplicationInhibitFlags) -> bool;
fn list_action_descriptions(&self) -> Vec<GString>;
fn prefers_app_menu(&self) -> bool;
fn remove_window<P: IsA<Window>>(&self, window: &P);
fn set_accels_for_action(&self, detailed_action_name: &str, accels: &[&str]);
fn set_app_menu<P: IsA<MenuModel>>(&self, app_menu: Option<&P>);
fn set_menubar<P: IsA<MenuModel>>(&self, menubar: Option<&P>);
fn uninhibit(&self, cookie: u32);
fn get_property_register_session(&self) -> bool;
fn set_property_register_session(&self, register_session: bool);
fn get_property_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_property_active_window_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_app_menu_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_menubar_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_register_session_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId;
fn connect_property_screensaver_active_notify<F: Fn(&Self) + 'static>(
        &self,
        f: F
    ) -> SignalHandlerId; }

Trait containing all Application methods.

Implementors

Application

Required methods

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

Adds a window to self.

This call can only happen after the self has started; typically, you should add new application windows in response to the emission of the gio::Application::activate signal.

This call is equivalent to setting the Window:application property of 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 GtkApplicationExt::remove_window.

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

window

a Window

fn get_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, as a None-terminated array. Free with g_strfreev when no longer needed

fn get_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. None is never returned.

It is a programmer error to pass an invalid accelerator string. If you are unsure, check it with gtk_accelerator_parse first.

accel

an accelerator that can be parsed by gtk_accelerator_parse

Returns

a None-terminated array of actions for accel

fn get_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, or None if there isn't one.

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

Returns the menu model that has been set with GtkApplicationExt::set_app_menu.

Returns

the application menu of self or None if no application menu has been set.

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

Gets a menu from automatically loaded resources. See [Automatic resources][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

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

Returns the menu model that has been set with GtkApplicationExt::set_menubar.

Returns

the menubar for windows of self

fn get_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::get_id.

id

an identifier number

Returns

the window with ID id, or None if there is no window with this ID

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

Gets a list of the GtkWindows associated with self.

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 glib::List of Window

fn inhibit<P: IsA<Window>>(
    &self,
    window: Option<&P>,
    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 GtkApplicationExt::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.

Reasons 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, or None

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 GtkApplicationExt::uninhibit in order to remove the request. If the platform does not support inhibiting or the request failed for some reason, 0 is returned.

fn is_inhibited(&self, flags: ApplicationInhibitFlags) -> bool

Determines if any of the actions specified in flags are currently inhibited (possibly by another application).

Note that this information may not be available (for example when the application is running in a sandbox).

flags

what types of actions should be queried

Returns

true if any of the actions specified in flags are inhibited

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

Lists the detailed action names which have associated accelerators. See GtkApplicationExt::set_accels_for_action.

Returns

a None-terminated array of strings, free with g_strfreev when done

fn prefers_app_menu(&self) -> bool

Determines if the desktop environment in which the application is running would prefer an application menu be shown.

If this function returns true then the application should call GtkApplicationExt::set_app_menu with the contents of an application menu, which will be shown by the desktop environment. If it returns false then you should consider using an alternate approach, such as a menubar.

The value returned by this function is purely advisory and you are free to ignore it. If you call GtkApplicationExt::set_app_menu even if the desktop environment doesn't support app menus, then a fallback will be provided.

Applications are similarly free not to set an app menu even if the desktop environment wants to show one. In that case, a fallback will also be created by the desktop environment (GNOME, for example, uses a menu with only a "Quit" item in it).

The value returned by this function never changes. Once it returns a particular value, it is guaranteed to always return the same value.

You may only call this function after the application has been registered and after the base startup handler has run. You're most likely to want to use this from your own startup handler. It may also make sense to consult this function while constructing UI (in activate, open or an action activation handler) in order to determine if you should show a gear menu or not.

This function will return false on Mac OS and a default app menu will be created automatically with the "usual" contents of that menu typical to most Mac OS applications. If you call GtkApplicationExt::set_app_menu anyway, then this menu will be replaced with your own.

Returns

true if you should set an app menu

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

Remove a window from self.

If window belongs to self then this call is equivalent to setting the Window:application property of window to None.

The application may stop running as a result of a call to this function.

window

a Window

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 gtk_accelerator_parse

fn set_app_menu<P: IsA<MenuModel>>(&self, app_menu: Option<&P>)

Sets or unsets the application menu for self.

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

The application menu is a single menu containing items that typically impact the application as a whole, rather than acting on a specific window or document. For example, you would expect to see “Preferences” or “Quit” in an application menu, but not “Save” or “Print”.

If supported, the application menu will be rendered by the desktop environment.

Use the base gio::ActionMap interface to add actions, to respond to the user selecting these menu items.

app_menu

a gio::MenuModel, or None

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

Sets or unsets the menubar for windows of self.

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. 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 gio::ActionMap interface to add actions, to respond to the user selecting these menu items.

a gio::MenuModel, or None

fn uninhibit(&self, cookie: u32)

Removes an inhibitor that has been established with GtkApplicationExt::inhibit. Inhibitors are also cleared when the application exits.

a cookie that was returned by GtkApplicationExt::inhibit

fn get_property_register_session(&self) -> bool

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

fn set_property_register_session(&self, register_session: bool)

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

fn get_property_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 Application::register-session is set to true.

Tracking the screensaver state is supported on Linux.

Feature: v3_24

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

Emitted when the session manager is about to end the session, only if Application::register-session is true. Applications can connect to this signal and call GtkApplicationExt::inhibit with ApplicationInhibitFlags::Logout to delay the end of the session until state has been saved.

Feature: v3_24_8

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

Emitted when a Window is added to application through GtkApplicationExt::add_window.

window

the newly-added Window

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

Emitted when a Window is removed from application, either as a side-effect of being destroyed or explicitly through GtkApplicationExt::remove_window.

window

the Window that is being removed

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

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

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

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

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

Loading content...

Implementors

impl<O: IsA<Application>> GtkApplicationExt for O[src]

Loading content...