pub trait ApplicationExt: 'static {
Show 41 methods fn activate(&self); fn add_main_option(
        long_name: &str,
        short_name: Char,
        flags: OptionFlags,
        arg: OptionArg,
        description: &str,
        arg_description: Option<&str>
    ); fn bind_busy_property(&self, object: &impl IsA<Object>, property: &str); fn application_id(&self) -> Option<GString>; fn dbus_connection(&self) -> Option<DBusConnection>; fn dbus_object_path(&self) -> Option<GString>; fn flags(&self) -> ApplicationFlags; fn inactivity_timeout(&self) -> u32; fn is_busy(&self) -> bool; fn is_registered(&self) -> bool; fn is_remote(&self) -> bool; fn resource_base_path(&self) -> Option<GString>; fn open(&self, files: &[File], hint: &str); fn quit(&self); fn register(
        cancellable: Option<&impl IsA<Cancellable>>
    ) -> Result<(), Error>; fn send_notification(&self, id: Option<&str>, notification: &Notification); fn set_application_id(&self, application_id: Option<&str>); fn set_default(&self); fn set_flags(&self, flags: ApplicationFlags); fn set_inactivity_timeout(&self, inactivity_timeout: u32); fn set_option_context_description(&self, description: Option<&str>); fn set_option_context_parameter_string(
        parameter_string: Option<&str>
    ); fn set_option_context_summary(&self, summary: Option<&str>); fn set_resource_base_path(&self, resource_path: Option<&str>); fn unbind_busy_property(&self, object: &impl IsA<Object>, property: &str); fn withdraw_notification(&self, id: &str); fn set_action_group<P: IsA<ActionGroup>>(&self, action_group: Option<&P>); fn connect_activate<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_command_line<F: Fn(&Self, &ApplicationCommandLine) -> i32 + 'static>(
        f: F
    ) -> SignalHandlerId; fn connect_handle_local_options<F: Fn(&Self, &VariantDict) -> i32 + 'static>(
        f: F
    ) -> SignalHandlerId; fn connect_name_lost<F: Fn(&Self) -> bool + 'static>(
        f: F
    ) -> SignalHandlerId; fn connect_shutdown<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_startup<F: Fn(&Self) + 'static>(&self, f: F) -> SignalHandlerId; fn connect_action_group_notify<F: Fn(&Self) + 'static>(
        f: F
    ) -> SignalHandlerId; fn connect_application_id_notify<F: Fn(&Self) + 'static>(
        f: F
    ) -> SignalHandlerId; fn connect_flags_notify<F: Fn(&Self) + 'static>(
        f: F
    ) -> SignalHandlerId; fn connect_inactivity_timeout_notify<F: Fn(&Self) + 'static>(
        f: F
    ) -> SignalHandlerId; fn connect_is_busy_notify<F: Fn(&Self) + 'static>(
        f: F
    ) -> SignalHandlerId; fn connect_is_registered_notify<F: Fn(&Self) + 'static>(
        f: F
    ) -> SignalHandlerId; fn connect_is_remote_notify<F: Fn(&Self) + 'static>(
        f: F
    ) -> SignalHandlerId; fn connect_resource_base_path_notify<F: Fn(&Self) + 'static>(
        f: F
    ) -> SignalHandlerId;
Expand description

Trait containing all Application methods.



Required Methods

Activates the application.

In essence, this results in the signal::Application::activate signal being emitted in the primary instance.

The application must be registered before calling this function.

Add an option to be handled by self.

Calling this function is the equivalent of calling g_application_add_main_option_entries() with a single GOptionEntry that has its arg_data member set to None.

The parsed arguments will be packed into a glib::VariantDict which is passed to signal::Application::handle-local-options. If ApplicationFlags::HANDLES_COMMAND_LINE is set, then it will also be sent to the primary instance. See g_application_add_main_option_entries() for more details.

See GOptionEntry for more documentation of the arguments.


the long name of an option used to specify it in a commandline


the short name of an option


flags from glib::OptionFlags


the type of the option, as a glib::OptionArg


the description for the option in --help output


the placeholder to use for the extra argument parsed by the option in --help output

Marks self as busy (see ApplicationExtManual::mark_busy()) while property on object is true.

The binding holds a reference to self while it is active, but not to object. Instead, the binding is destroyed when object is finalized.


a glib::Object


the name of a boolean property of object

Gets the unique identifier for self.


the identifier for self, owned by self

Gets the DBusConnection being used by the application, or None.

If Application is using its D-Bus backend then this function will return the DBusConnection being used for uniqueness and communication with the desktop environment and other instances of the application.

If Application is not using D-Bus then this function will return None. This includes the situation where the D-Bus backend would normally be in use but we were unable to connect to the bus.

This function must not be called before the application has been registered. See is_registered().


a DBusConnection, or None

Gets the D-Bus object path being used by the application, or None.

If Application is using its D-Bus backend then this function will return the D-Bus object path that Application is using. If the application is the primary instance then there is an object published at this path. If the application is not the primary instance then the result of this function is undefined.

If Application is not using D-Bus then this function will return None. This includes the situation where the D-Bus backend would normally be in use but we were unable to connect to the bus.

This function must not be called before the application has been registered. See is_registered().


the object path, or None

Gets the flags for self.

See ApplicationFlags.


the flags for self

Gets the current inactivity timeout for the application.

This is the amount of time (in milliseconds) after the last call to [ApplicationExtManual::release()][crate::prelude::ApplicationExtManual::release()] before the application stops running.


the timeout, in milliseconds

Gets the application’s current busy state, as set through ApplicationExtManual::mark_busy() or bind_busy_property().


true if self is currently marked as busy

Checks if self is registered.

An application is registered if register() has been successfully called.


true if self is registered

Checks if self is remote.

If self is remote then it means that another instance of application already exists (the ‘primary’ instance). Calls to perform actions on self will result in the actions being performed by the primary instance.

The value of this property cannot be accessed before register() has been called. See is_registered().


true if self is remote

Gets the resource base path of self.

See set_resource_base_path() for more information.


the base resource path, if one is set

Opens the given files.

In essence, this results in the signal::Application::open signal being emitted in the primary instance.

n_files must be greater than zero.

hint is simply passed through to the ::open signal. It is intended to be used by applications that have multiple modes for opening files (eg: “view” vs “edit”, etc). Unless you have a need for this functionality, you should use “”.

The application must be registered before calling this function and it must have the ApplicationFlags::HANDLES_OPEN flag set.


an array of GFiles to open


a hint (or “”), but never None

Immediately quits the application.

Upon return to the mainloop, ApplicationExtManual::run() will return, calling only the ‘shutdown’ function before doing so.

The hold count is ignored. Take care if your code has called ApplicationExtManual::hold() on the application and is therefore still expecting it to exist. (Note that you may have called ApplicationExtManual::hold() indirectly, for example through gtk_application_add_window().)

The result of calling ApplicationExtManual::run() again after it returns is unspecified.

Attempts registration of the application.

This is the point at which the application discovers if it is the primary instance or merely acting as a remote for an already-existing primary instance. This is implemented by attempting to acquire the application identifier as a unique bus name on the session bus using GDBus.

If there is no application ID or if ApplicationFlags::NON_UNIQUE was given, then this process will always become the primary instance.

Due to the internal architecture of GDBus, method calls can be dispatched at any time (even if a main loop is not running). For this reason, you must ensure that any object paths that you wish to register are registered before calling this function.

If the application has already been registered then true is returned with no work performed.

The signal::Application::startup signal is emitted if registration succeeds and self is the primary instance (including the non-unique case).

In the event of an error (such as cancellable being cancelled, or a failure to connect to the session bus), false is returned and error is set appropriately.

Note: the return value of this function is not an indicator that this instance is or is not the primary instance of the application. See is_remote() for that.


a Cancellable, or None


true if registration succeeded

Sends a notification on behalf of self to the desktop shell. There is no guarantee that the notification is displayed immediately, or even at all.

Notifications may persist after the application exits. It will be D-Bus-activated when the notification or one of its actions is activated.

Modifying notification after this call has no effect. However, the object can be reused for a later call to this function.

id may be any string that uniquely identifies the event for the application. It does not need to be in any special format. For example, “new-message” might be appropriate for a notification about new messages.

If a previous notification was sent with the same id, it will be replaced with notification and shown again as if it was a new notification. This works even for notifications sent from a previous execution of the application, as long as id is the same string.

id may be None, but it is impossible to replace or withdraw notifications without an id.

If notification is no longer relevant, it can be withdrawn with withdraw_notification().


id of the notification, or None


the Notification to send

Sets the unique identifier for self.

The application id can only be modified if self has not yet been registered.

If non-None, the application id must be valid. See Application::id_is_valid().


the identifier for self

Sets or unsets the default application for the process, as returned by Application::default().

This function does not take its own reference on self. If self is destroyed then the default application will revert back to None.

Sets the flags for self.

The flags can only be modified if self has not yet been registered.

See ApplicationFlags.


the flags for self

Sets the current inactivity timeout for the application.

This is the amount of time (in milliseconds) after the last call to [ApplicationExtManual::release()][crate::prelude::ApplicationExtManual::release()] before the application stops running.

This call has no side effects of its own. The value set here is only used for next time [ApplicationExtManual::release()][crate::prelude::ApplicationExtManual::release()] drops the use count to zero. Any timeouts currently in progress are not impacted.


the timeout, in milliseconds

Adds a description to the self option context.

See g_option_context_set_description() for more information.


a string to be shown in --help output after the list of options, or None

Sets the parameter string to be used by the commandline handling of self.

This function registers the argument to be passed to g_option_context_new() when the internal GOptionContext of self is created.

See g_option_context_new() for more information about parameter_string.


a string which is displayed in the first line of --help output, after the usage summary programname [OPTION...].

Adds a summary to the self option context.

See g_option_context_set_summary() for more information.


a string to be shown in --help output before the list of options, or None

Sets (or unsets) the base resource path of self.

The path is used to automatically load various [application resources][gresource] such as menu layouts and action descriptions. The various types of resources will be found at fixed names relative to the given base path.

By default, the resource base path is determined from the application ID by prefixing ‘/’ and replacing each ‘.’ with ‘/’. This is done at the time that the Application object is constructed. Changes to the application ID after that point will not have an impact on the resource base path.

As an example, if the application has an ID of “” then the default resource base path will be “/org/example/app”. If this is a GtkApplication (and you have not manually changed the path) then Gtk will then search for the menus of the application at “/org/example/app/gtk/menus.ui”.

See Resource for more information about adding resources to your application.

You can disable automatic resource loading functionality by setting the path to None.

Changing the resource base path once the application is running is not recommended. The point at which the resource path is consulted for forming paths for various purposes is unspecified. When writing a sub-class of Application you should either set the property::Application::resource-base-path property at construction time, or call this function during the instance initialization. Alternatively, you can call this function in the GApplicationClass.startup virtual function, before chaining up to the parent implementation.


the resource path to use

Destroys a binding between property and the busy state of self that was previously created with bind_busy_property().


a glib::Object


the name of a boolean property of object

Withdraws a notification that was sent with send_notification().

This call does nothing if a notification with id doesn’t exist or the notification was never sent.

This function works even for notifications sent in previous executions of this application, as long id is the same as it was for the sent notification.

Note that notifications are dismissed when the user clicks on one of the buttons in a notification or triggers its default action, so there is no need to explicitly withdraw the notification in that case.


id of a previously sent notification

The ::activate signal is emitted on the primary instance when an activation occurs. See activate().

The ::command-line signal is emitted on the primary instance when a commandline is not handled locally. See ApplicationExtManual::run() and the ApplicationCommandLine documentation for more information.


a ApplicationCommandLine representing the passed commandline


An integer that is set as the exit status for the calling process. See ApplicationCommandLineExt::set_exit_status().

The ::handle-local-options signal is emitted on the local instance after the parsing of the commandline options has occurred.

You can add options to be recognised during commandline option parsing using g_application_add_main_option_entries() and g_application_add_option_group().

Signal handlers can inspect options (along with values pointed to from the arg_data of an installed GOptionEntrys) in order to decide to perform certain actions, including direct local handling (which may be useful for options like –version).

In the event that the application is marked ApplicationFlags::HANDLES_COMMAND_LINE the “normal processing” will send the options dictionary to the primary instance where it can be read with ApplicationCommandLineExt::options_dict(). The signal handler can modify the dictionary before returning, and the modified dictionary will be sent.

In the event that ApplicationFlags::HANDLES_COMMAND_LINE is not set, “normal processing” will treat the remaining uncollected command line arguments as filenames or URIs. If there are no arguments, the application is activated by activate(). One or more arguments results in a call to open().

If you want to handle the local commandline arguments for yourself by converting them to calls to open() or ActionGroupExt::activate_action() then you must be sure to register the application first. You should probably not call activate() for yourself, however: just return -1 and allow the default handler to do it for you. This will ensure that the --gapplication-service switch works properly (i.e. no activation in that case).

Note that this signal is emitted from the default implementation of local_command_line(). If you override that function and don’t chain up then this signal will never be emitted.

You can override local_command_line() if you need more powerful capabilities than what is provided here, but this should not normally be required.


the options dictionary


an exit code. If you have handled your options and want to exit the process, return a non-negative option, 0 for success, and a positive value for failure. To continue, return -1 to let the default option processing continue.

Available on crate feature v2_60 only.

The ::name-lost signal is emitted only on the registered primary instance when a new instance has taken over. This can only happen if the application is using the ApplicationFlags::ALLOW_REPLACEMENT flag.

The default handler for this signal calls quit().


true if the signal has been handled

The ::shutdown signal is emitted only on the registered primary instance immediately after the main loop terminates.

The ::startup signal is emitted on the primary instance immediately after registration. See register().