[]Struct gtk::Application

pub struct Application(_, _);

Application is a class that handles many important aspects of a GTK+ application in a convenient fashion, without enforcing a one-size-fits-all application model.

Currently, Application handles GTK+ initialization, application uniqueness, session management, provides some basic scriptability and desktop shell integration by exporting actions and menus and manages a list of toplevel windows whose life-cycle is automatically tied to the life-cycle of your application.

While Application works fine with plain GtkWindows, it is recommended to use it together with ApplicationWindow.

When GDK threads are enabled, Application will acquire the GDK lock when invoking actions that arrive from other processes. The GDK lock is not touched for local action invocations. In order to have actions invoked in a predictable context it is therefore recommended that the GDK lock be held while invoking actions locally with gio::ActionGroup::activate_action. The same applies to actions associated with ApplicationWindow and to the “activate” and “open” gio::Application methods.

Automatic resources ## {automatic-resources}

Application will automatically load menus from the Builder resource located at "gtk/menus.ui", relative to the application's resource base path (see gio::ApplicationExt::set_resource_base_path). The menu with the ID "app-menu" is taken as the application's app menu and the menu with the ID "menubar" is taken as the application's menubar. Additional menus (most interesting submenus) can be named and accessed via GtkApplicationExt::get_menu_by_id which allows for dynamic population of a part of the menu structure.

If the resources "gtk/menus-appmenu.ui" or "gtk/menus-traditional.ui" are present then these files will be used in preference, depending on the value of GtkApplicationExt::prefers_app_menu. If the resource "gtk/menus-common.ui" is present it will be loaded as well. This is useful for storing items that are referenced from both "gtk/menus-appmenu.ui" and "gtk/menus-traditional.ui".

It is also possible to provide the menus manually using GtkApplicationExt::set_app_menu and GtkApplicationExt::set_menubar.

Application will also automatically setup an icon search path for the default icon theme by appending "icons" to the resource base path. This allows your application to easily store its icons as resources. See IconThemeExt::add_resource_path for more information.

If there is a resource located at "gtk/help-overlay.ui" which defines a ShortcutsWindow with ID "help_overlay" then Application associates an instance of this shortcuts window with each ApplicationWindow and sets up keyboard accelerators (Control-F1 and Control-?) to open it. To create a menu item that displays the shortcuts window, associate the item with the action win.show-help-overlay.

A simple application ## {gtkapplication}

A simple example

Application optionally registers with a session manager of the users session (if you set the Application:register-session property) and offers various functionality related to the session life-cycle.

An application can block various ways to end the session with the GtkApplicationExt::inhibit function. Typical use cases for this kind of inhibiting are long-running, uninterruptible operations, such as burning a CD or performing a disk backup. The session manager may not honor the inhibitor, but it can be expected to inform the user about the negative consequences of ending the session while inhibitors are present.

See Also ## {seealso}

HowDoI: Using Application, Getting Started with GTK+: Basics

Implements

GtkApplicationExt, gio::ApplicationExt, glib::object::ObjectExt, gio::ActionGroupExt, gio::ActionMapExt, gio::ApplicationExtManual

Methods

impl Application[src]

pub fn new(
    application_id: Option<&str>,
    flags: ApplicationFlags
) -> Result<Application, BoolError>
[src]

Creates a new Application instance.

When using Application, it is not necessary to call gtk_init manually. It is called as soon as the application gets registered as the primary instance.

Concretely, gtk_init is called in the default handler for the gio::Application::startup signal. Therefore, Application subclasses should chain up in their gio::Application::startup handler before using any GTK+ API.

Note that commandline arguments are not passed to gtk_init. All GTK+ functionality that is available via commandline arguments can also be achieved by setting suitable environment variables such as G_DEBUG, so this should not be a big problem. If you absolutely must support GTK+ commandline arguments, you can explicitly call gtk_init before creating the application instance.

If non-None, the application ID must be valid. See gio::Application::id_is_valid.

If no application ID is given then some features (most notably application uniqueness) will be disabled. A null application ID is only allowed with GTK+ 3.6 or later.

application_id

The application ID.

flags

the application flags

Returns

a new Application instance

Trait Implementations

impl Clone for Application

impl Debug for Application

impl Display for Application[src]

impl Eq for Application

impl Hash for Application

impl IsA<ActionGroup> for Application

impl IsA<ActionMap> for Application

impl IsA<Application> for Application

impl Ord for Application

impl<T: ObjectType> PartialEq<T> for Application

impl<T: ObjectType> PartialOrd<T> for Application

impl StaticType for Application

Auto Trait Implementations

impl RefUnwindSafe for Application

impl !Send for Application

impl !Sync for Application

impl Unpin for Application

impl UnwindSafe for Application

Blanket Implementations

impl<O> ActionGroupExt for O where
    O: IsA<ActionGroup>, 

impl<O> ActionMapExt for O where
    O: IsA<ActionMap>, 

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<O> ApplicationExt for O where
    O: IsA<Application>, 

impl<O> ApplicationExtManual for O where
    O: IsA<Application>, 

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<Super, Sub> CanDowncast<Sub> for Super where
    Sub: IsA<Super>,
    Super: IsA<Super>, 

impl<T> Cast for T where
    T: ObjectType, 

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ObjectExt for T where
    T: ObjectType, 

impl<'a, T> ToGlibContainerFromSlice<'a, *const GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GArray> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<Array>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<'a, T> ToGlibContainerFromSlice<'a, *mut GList> for T where
    T: GlibPtrDefault + ToGlibPtr<'a, <T as GlibPtrDefault>::GlibType>, 

type Storage = (Option<List>, Vec<Stash<'a, <T as GlibPtrDefault>::GlibType, T>>)

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> ToValue for T where
    T: SetValue + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = !

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.