glibmm 2.52.1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions | List of all members
Gio::Application Class Reference

Application - Core application class. More...

`#include <giomm/application.h>`

Inheritance diagram for Gio::Application:
[legend]

## Public Types
enum | OptionType { OPTION_TYPE_BOOL, OPTION_TYPE_STRING, OPTION_TYPE_INT, OPTION_TYPE_FILENAME = OPTION_TYPE_INT+2, OPTION_TYPE_STRING_VECTOR, OPTION_TYPE_FILENAME_VECTOR, OPTION_TYPE_DOUBLE, OPTION_TYPE_INT64 }
| The OptionType enum values determine the expected type of a command line option. More...
using | type_vec_files = std::vector< Glib::RefPtr< File > >
Public Types inherited from Glib::Object
using | DestroyNotify = void(*)(gpointer data)
Public Types inherited from sigc::trackable
typedef internal::func_destroy_notify | func_destroy_notify
Public Types inherited from Gio::ActionMap
using | ActivateSlot = sigc::slot< void >
| A Slot to be called when an action has been activated, without passing a parameter to the slot. More...
using | ActivateWithParameterSlot = sigc::slot< void, const Glib::VariantBase& >
| A Slot to be called when an action has been activated, passing a parameter of a specified type. More...
using | ActivateWithStringParameterSlot = sigc::slot< void, const Glib::ustring& >
| A Slot to be called when an action has been activated. More...
using | ActivateWithIntParameterSlot = sigc::slot< void, int >
| A Slot to be called when an action has been activated. More...

## Public Member Functions
| Application (Application&& src) noexcept
Application& | operator= (Application&& src) noexcept
| ~Application () noexceptoverride
GApplication* | gobj ()
| Provides access to the underlying C GObject. More...
const GApplication* | gobj () const
| Provides access to the underlying C GObject. More...
GApplication* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs. More...
Glib::ustring | get_id () const
| Gets the unique identifier for application. More...
void | set_id (const Glib::ustring& application_id)
| Sets the unique identifier for application. More...
Glib::RefPtr< DBus::Connection > | get_dbus_connection ()
| Gets the DBusConnection being used by the application, or `nullptr`. More...
Glib::RefPtr< const DBus::Connection > | get_dbus_connection () const
| Gets the DBusConnection being used by the application, or `nullptr`. More...
Glib::ustring | get_dbus_object_path () const
| Gets the D-Bus object path being used by the application, or `nullptr`. More...
guint | get_inactivity_timeout () const
| Gets the current inactivity timeout for the application. More...
void | set_inactivity_timeout (guint inactivity_timeout)
| Sets the current inactivity timeout for the application. More...
ApplicationFlags | get_flags () const
| Gets the flags for application. More...
void | set_flags (ApplicationFlags flags)
| Sets the flags for application. More...
std::string | get_resource_base_path () const
| Gets the resource base path of application. More...
void | set_resource_base_path (const std::string& resource_path)
| Sets (or unsets) the base resource path of application. More...
void | unset_resource_base_path ()
| Disable automatic resource loading functionality. More...
void | set_action_group (const Glib::RefPtr< ActionGroup >& action_group)
| This used to be how actions were associated with a Application. More...
void | add_main_option_entry (OptionType arg_type, const Glib::ustring& long_name, gchar short_name= '\0', const Glib::ustring& description=Glib::ustring(), const Glib::ustring& arg_description=Glib::ustring(), int flags=0)
| Adds a main option entry to be handled by the Application. More...
void | add_main_option_entry (const Glib::OptionGroup::SlotOptionArgString& slot, const Glib::ustring& long_name, gchar short_name= '\0', const Glib::ustring& description=Glib::ustring(), const Glib::ustring& arg_description=Glib::ustring(), int flags=0)
| Adds a main option entry to be handled by the Application. More...
void | add_main_option_entry_filename (const Glib::OptionGroup::SlotOptionArgFilename& slot, const Glib::ustring& long_name, gchar short_name= '\0', const Glib::ustring& description=Glib::ustring(), const Glib::ustring& arg_description=Glib::ustring(), int flags=0)
| Adds a main option entry to be handled by the Application. More...
bool | is_registered () const
| Checks if application is registered. More...
bool | is_remote () const
| Checks if application is remote. More...
bool | register_application (const Glib::RefPtr< Gio::Cancellable >& cancellable)
| Attempts registration of the application. More...
bool | register_application ()
| A register_application() convenience overload. More...
void | hold ()
| Increases the use count of application. More...
void | release ()
| Decrease the use count of application. More...
void | activate ()
| Activates the application. More...
void | open (const type_vec_files& files, const Glib::ustring& hint=Glib::ustring())
void | open (const Glib::RefPtr< Gio::File >& file, const Glib::ustring& hint=Glib::ustring())
int | run (int argc, char** argv)
| Runs the application. More...
void | quit ()
| Immediately quits the application. More...
void | mark_busy ()
| Increases the busy count of application. More...
void | unmark_busy ()
| Decreases the busy count of application. More...
bool | get_is_busy () const
| Gets the application's current busy state, as set through g_application_mark_busy() or g_application_bind_busy_property(). More...
void | send_notification (const Glib::ustring& id, const Glib::RefPtr< Notification >& notification)
| Sends a notification on behalf of application to the desktop shell. More...
void | send_notification (const Glib::RefPtr< Notification >& notification)
| A send_notification() convenience overload. More...
void | withdraw_notification (const Glib::ustring& id)
| Withdraws a notification that was sent with g_application_send_notification(). More...
Glib::PropertyProxy_WriteOnly< Glib::RefPtr< ActionGroup > > | property_action_group ()
| The group of actions that the application exports. More...
Glib::PropertyProxy< Glib::ustring > | property_application_id ()
| The unique identifier for the application. More...
Glib::PropertyProxy_ReadOnly< Glib::ustring > | property_application_id () const
| The unique identifier for the application. More...
Glib::PropertyProxy< ApplicationFlags > | property_flags ()
| Flags specifying the behaviour of the application. More...
Glib::PropertyProxy_ReadOnly< ApplicationFlags > | property_flags () const
| Flags specifying the behaviour of the application. More...
Glib::PropertyProxy< guint > | property_inactivity_timeout ()
| Time (ms) to stay alive after becoming idle. More...
Glib::PropertyProxy_ReadOnly< guint > | property_inactivity_timeout () const
| Time (ms) to stay alive after becoming idle. More...
Glib::PropertyProxy_ReadOnly< bool > | property_is_registered () const
| If g_application_register() has been called. More...
Glib::PropertyProxy_ReadOnly< bool > | property_is_remote () const
| If this application instance is remote. More...
Glib::PropertyProxy< bool > | property_resource_base_path ()
| The base resource path for the application. More...
Glib::PropertyProxy_ReadOnly< bool > | property_resource_base_path () const
| The base resource path for the application. More...
Glib::PropertyProxy_ReadOnly< bool > | property_is_busy () const
| Whether the application is currently marked as busy through g_application_mark_busy() or g_application_bind_busy_property(). More...
Glib::SignalProxy< void > | signal_startup ()
Glib::SignalProxy< void > | signal_shutdown ()
Glib::SignalProxy< void > | signal_activate ()
Glib::SignalProxy< void, const type_vec_files&, const Glib::ustring& > | signal_open ()
Glib::SignalProxy< int, const Glib::RefPtr< ApplicationCommandLine >& > | signal_command_line ()
Glib::SignalProxy< int, const Glib::RefPtr< Glib::VariantDict >& > | signal_handle_local_options ()
Public Member Functions inherited from Glib::Object
| Object (const Object&)=delete
Object& | operator= (const Object&)=delete
| Object (Object&& src) noexcept
Object& | operator= (Object&& src) noexcept
void* | get_data (const QueryQuark& key)
void | set_data (const Quark& key, void* data)
void | set_data (const Quark& key, void* data, DestroyNotify notify)
void | remove_data (const QueryQuark& quark)
void* | steal_data (const QueryQuark& quark)
Public Member Functions inherited from Glib::ObjectBase
| ObjectBase (const ObjectBase&)=delete
ObjectBase& | operator= (const ObjectBase&)=delete
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase& value)
| You probably want to use a specific property_*() accessor method instead. More...
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | set_property (const Glib::ustring& property_name, const PropertyType& value)
| You probably want to use a specific property_*() accessor method instead. More...
template<class PropertyType >
void | get_property (const Glib::ustring& property_name, PropertyType& value) const
| You probably want to use a specific property_*() accessor method instead. More...
void | connect_property_changed (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | connect_property_changed (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, const sigc::slot< void >& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
sigc::connection | connect_property_changed_with_return (const Glib::ustring& property_name, sigc::slot< void >&& slot)
| You can use the signal_changed() signal of the property proxy instead. More...
void | freeze_notify ()
| Increases the freeze count on object. More...
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify(). More...
virtual void | reference () const
| Increment the reference count for this object. More...
virtual void | unreference () const
| Decrement the reference count for this object. More...
GObject* | gobj ()
| Provides access to the underlying C GObject. More...
const GObject* | gobj () const
| Provides access to the underlying C GObject. More...
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access. More...
Public Member Functions inherited from sigc::trackable
| trackable () noexcept
| trackable (const trackable &src) noexcept
| trackable (trackable &&src)
| ~trackable ()
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | notify_callbacks ()
trackable & | operator= (const trackable &src)
trackable & | operator= (trackable &&src)
void | remove_destroy_notify_callback (void *data) const
Public Member Functions inherited from Gio::ActionGroup
| ActionGroup (ActionGroup&& src) noexcept
ActionGroup& | operator= (ActionGroup&& src) noexcept
| ~ActionGroup () noexceptoverride
GActionGroup* | gobj ()
| Provides access to the underlying C GObject. More...
const GActionGroup* | gobj () const
| Provides access to the underlying C GObject. More...
bool | has_action (const Glib::ustring& action_name) const
| Checks if the named action exists within action_group. More...
std::vector< Glib::ustring > | list_actions () const
| Lists the actions contained within action_group. More...
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantType& parameter_type, Glib::VariantBase& state_hint, Glib::VariantType& state_type, Glib::VariantBase& state)
| Queries all aspects of the named action within an action_group. More...
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantType& parameter_type, Glib::VariantBase& state_hint, Glib::VariantType& state_type)
| A query_action() convenience overload. More...
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantType& parameter_type, Glib::VariantBase& state_hint, Glib::VariantBase& state)
| A query_action() convenience overload. More...
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantType& parameter_type, Glib::VariantBase& state_hint)
| A query_action() convenience overload. More...
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantBase& state_hint, Glib::VariantType& state_type, Glib::VariantBase& state)
| A query_action() convenience overload. More...
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantBase& state_hint, Glib::VariantType& state_type)
| A query_action() convenience overload. More...
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantBase& state_hint, Glib::VariantBase& state)
| A query_action() convenience overload. More...
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantBase& state_hint)
| A query_action() convenience overload. More...
bool | get_action_enabled (const Glib::ustring& action_name) const
| Checks if the named action within action_group is currently enabled. More...
Glib::VariantType | get_action_parameter_type (const Glib::ustring& action_name) const
| Queries the type of the parameter that must be given when activating the named action within action_group. More...
Glib::VariantType | get_action_state_type (const Glib::ustring& action_name) const
| Queries the type of the state of the named action within action_group. More...
Glib::VariantContainerBase | get_action_state_hint (const Glib::ustring& action_name) const
| Requests a hint about the valid range of values for the state of the named action within action_group. More...
template<typename T_Value >
void | get_action_state_hint (const Glib::ustring& action_name, T_Value& value) const
| Requests a hint about the valid range of values for the state of the named action within the action group. More...
Glib::VariantContainerBase | get_action_state_hint_variant (const Glib::ustring& action_name) const
| Requests a hint about the valid range of values for the state of the named action within action_group. More...
Glib::VariantBase | get_action_state (const Glib::ustring& action_name) const
| Queries the current state of the named action within action_group. More...
template<typename T_Value >
void | get_action_state (const Glib::ustring& action_name, T_Value& value) const
| Queries the current state of the named action within the action group. More...
Glib::VariantBase | get_action_state_variant (const Glib::ustring& action_name) const
| Queries the current state of the named action within action_group. More...
void | change_action_state (const Glib::ustring& action_name, const Glib::VariantBase& value)
| Request for the state of the named action within action_group to be changed to value. More...
void | activate_action (const Glib::ustring& action_name, const Glib::VariantBase& parameter)
| Activate the named action within action_group. More...
void | activate_action (const Glib::ustring& action_name)
| A activate_action() convenience overload. More...
void | action_added (const Glib::ustring& action_name)
| Emits the ActionGroup::signal_action_added() signal on action_group. More...
void | action_removed (const Glib::ustring& action_name)
| Emits the ActionGroup::signal_action_removed() signal on action_group. More...
void | action_enabled_changed (const Glib::ustring& action_name, bool enabled)
| Emits the ActionGroup::signal_action_enabled_changed() signal on action_group. More...
void | action_state_changed (const Glib::ustring& action_name, const Glib::VariantBase& state)
| Emits the ActionGroup::signal_action_state_changed() signal on action_group. More...
Glib::SignalProxy< void, const Glib::ustring& > | signal_action_added ()
Glib::SignalProxy< void, const Glib::ustring&, bool > | signal_action_enabled_changed ()
Glib::SignalProxy< void, const Glib::ustring& > | signal_action_removed ()
Glib::SignalProxy< void, const Glib::ustring&, const Glib::VariantBase& > | signal_action_state_changed ()
virtual bool | has_action_vfunc (const Glib::ustring& name) const
virtual std::vector< Glib::ustring > | list_actions_vfunc () const
virtual bool | get_action_enabled_vfunc (const Glib::ustring& name) const
virtual Glib::VariantType | get_action_parameter_type_vfunc (const Glib::ustring& name) const
virtual Glib::VariantType | get_action_state_type_vfunc (const Glib::ustring& name) const
virtual Glib::VariantBase | get_action_state_hint_vfunc (const Glib::ustring& name) const
virtual Glib::VariantBase | get_action_state_vfunc (const Glib::ustring& name) const
virtual void | change_action_state_vfunc (const Glib::ustring& name, const Glib::VariantBase& value)
virtual void | activate_action_vfunc (const Glib::ustring& name, const Glib::VariantBase& parameter)
Public Member Functions inherited from Glib::Interface
| Interface ()
| A Default constructor. More...
| Interface (Interface&& src) noexcept
Interface& | operator= (Interface&& src) noexcept
| Interface (const Glib::Interface_Class& interface_class)
| Called by constructors of derived classes. More...
| Interface (GObject* castitem)
| Called by constructors of derived classes. More...
| ~Interface () noexceptoverride
| Interface (const Interface&)=delete
Interface& | operator= (const Interface&)=delete
GObject* | gobj ()
const GObject* | gobj () const
Public Member Functions inherited from Gio::ActionMap
| ActionMap (ActionMap&& src) noexcept
ActionMap& | operator= (ActionMap&& src) noexcept
| ~ActionMap () noexceptoverride
GActionMap* | gobj ()
| Provides access to the underlying C GObject. More...
const GActionMap* | gobj () const
| Provides access to the underlying C GObject. More...
void | add_action (const Glib::RefPtr< Action >& action)
| Adds an action to the action_map. More...
void | remove_action (const Glib::ustring& action_name)
| Removes the named action from the action map. More...
Glib::RefPtr< Action > | lookup_action (const Glib::ustring& action_name)
| Looks up the action with the name action_name in action_map. More...
Glib::RefPtr< const Action > | lookup_action (const Glib::ustring& action_name) const
| Looks up the action with the name action_name in action_map. More...
Glib::RefPtr< SimpleAction > | add_action (const Glib::ustring& name)
| A convenience method for creating a SimpleAction instance and adding it to the ActionMap. More...
Glib::RefPtr< SimpleAction > | add_action (const Glib::ustring& name, const ActivateSlot& slot)
| A convenience method for creating a SimpleAction instance and adding it to the ActionMap. More...
Glib::RefPtr< SimpleAction > | add_action_with_parameter (const Glib::ustring& name, const ActivateWithParameterSlot& slot)
| A convenience method for creating a SimpleAction instance and adding it to the ActionMap. More...
Glib::RefPtr< SimpleAction > | add_action_with_parameter (const Glib::ustring& name, const Glib::VariantType& parameter_type, const ActivateWithParameterSlot& slot)
| A convenience method for creating a SimpleAction instance, which when activated will call a slot receiving a given type of parameter, and adding that SimpleAction to the ActionMap. More...
Glib::RefPtr< SimpleAction > | add_action_bool (const Glib::ustring& name, bool state=false)
| A convenience method for creating a boolean-stateful SimpleAction instance and adding it to the ActionMap. More...
Glib::RefPtr< SimpleAction > | add_action_bool (const Glib::ustring& name, const ActivateSlot& slot, bool state=false)
| A convenience method for creating a boolean-stateful (toggle) SimpleAction instance and adding it to the ActionMap. More...
Glib::RefPtr< SimpleAction > | add_action_radio_string (const Glib::ustring& name, const Glib::ustring& state)
| A convenience method for creating a string-based radio SimpleAction instance and adding it to the ActionMap. More...
Glib::RefPtr< SimpleAction > | add_action_radio_string (const Glib::ustring& name, const ActivateWithStringParameterSlot& slot, const Glib::ustring& state)
| A convenience method for creating a string-based radio SimpleAction instance and adding it to the ActionMap. More...
Glib::RefPtr< SimpleAction > | add_action_radio_integer (const Glib::ustring& name, gint32 state)
| A convenience method for creating an integer-based radio SimpleAction instance and adding it to the ActionMap. More...
Glib::RefPtr< SimpleAction > | add_action_radio_integer (const Glib::ustring& name, const ActivateWithIntParameterSlot& slot, gint32 state)
| A convenience method for creating an integer-based radio SimpleAction instance and adding it to the ActionMap. More...
virtual Glib::RefPtr< Action > | lookup_action_vfunc (const Glib::ustring& name) const
virtual void | add_action_vfunc (Glib::RefPtr< Action > action) const
virtual void | remove_action_vfunc (const Glib::ustring& name)

## Static Public Member Functions
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
static Glib::RefPtr< Application > | create (const Glib::ustring& application_id=Glib::ustring(), ApplicationFlags flags=APPLICATION_FLAGS_NONE)
| Creates an application instance. More...
static bool | id_is_valid (const Glib::ustring& application_id)
| Checks if application_id is a valid application identifier. More...
static void | set_default (const Glib::RefPtr< Application >& application)
| Sets or unsets the default application for the process, as returned by g_application_get_default(). More...
static void | unset_default ()
| Unsets any existing default application. More...
static Glib::RefPtr< Application > | get_default ()
| Returns the default Application instance for this process. More...
Static Public Member Functions inherited from Gio::ActionGroup
static void | add_interface (GType gtype_implementer)
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...
Static Public Member Functions inherited from Gio::ActionMap
static void | add_interface (GType gtype_implementer)
static GType | get_type ()
| Get the GType for this class, for use with the underlying GObject type system. More...

## Protected Member Functions
| Application (const Glib::ustring& application_id=Glib::ustring(), ApplicationFlags flags=APPLICATION_FLAGS_NONE)
| Constructs an application instance. More...
virtual void | on_open (const type_vec_files& files, const Glib::ustring& hint)
virtual bool | local_command_line_vfunc (char**& arguments, int& exit_status)
virtual void | before_emit_vfunc (const Glib::VariantBase& platform_data)
virtual void | after_emit_vfunc (const Glib::VariantBase& platform_data)
virtual void | quit_mainloop_vfunc ()
virtual void | run_mainloop_vfunc ()
virtual void | on_startup ()
| This is a default handler for the signal signal_startup(). More...
virtual void | on_activate ()
| This is a default handler for the signal signal_activate(). More...
virtual int | on_command_line (const Glib::RefPtr< ApplicationCommandLine >& command_line)
| This is a default handler for the signal signal_command_line(). More...
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams& construct_params)
| Object (GObject* castitem)
| ~Object () noexceptoverride
Protected Member Functions inherited from Glib::ObjectBase
| ObjectBase ()
| This default constructor is called implicitly from the constructor of user-derived classes, even if, for instance, Gtk::Button calls a different ObjectBase constructor. More...
| ObjectBase (const char* custom_type_name)
| A derived constructor always overrides this choice. More...
| ObjectBase (const std::type_info& custom_type_info)
| This constructor is a special feature to allow creation of derived types on the fly, without having to use g_object_new() manually. More...
| ObjectBase (ObjectBase&& src) noexcept
ObjectBase& | operator= (ObjectBase&& src) noexcept
virtual | ~ObjectBase () noexcept=0
void | initialize (GObject* castitem)
void | initialize_move (GObject* castitem, Glib::ObjectBase* previous_wrapper)
Protected Member Functions inherited from Gio::ActionGroup
| ActionGroup ()
| You should derive from this class to use it. More...
virtual void | on_action_added (const Glib::ustring& action_name)
| This is a default handler for the signal signal_action_added(). More...
virtual void | on_action_enabled_changed (const Glib::ustring& action_name, bool enabled)
| This is a default handler for the signal signal_action_enabled_changed(). More...
virtual void | on_action_removed (const Glib::ustring& action_name)
| This is a default handler for the signal signal_action_removed(). More...
virtual void | on_action_state_changed (const Glib::ustring& action_name, const Glib::VariantBase& value)
| This is a default handler for the signal signal_action_state_changed(). More...
Protected Member Functions inherited from Gio::ActionMap
| ActionMap ()
| You should derive from this class to use it. More...

## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gio::Application > | wrap (GApplication* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Glib::Object
Glib::RefPtr< Glib::Object > | wrap (GObject* object, bool take_copy=false)
Related Functions inherited from Gio::ActionGroup
Glib::RefPtr< Gio::ActionGroup > | wrap (GActionGroup* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...
Related Functions inherited from Gio::ActionMap
Glib::RefPtr< Gio::ActionMap > | wrap (GActionMap* object, bool take_copy=false)
| A Glib::wrap() method for this object. More...

## Detailed Description

Application - Core application class.

An Application is the foundation of an application, unique for a given application identifier. The Application class wraps some low-level platform-specific services and is intended to act as the foundation for higher-level application classes such as Gtk::Application or MxApplication. In general, you should not use this class outside of a higher level framework.

One of the core features that Application provides is process uniqueness, in the context of a "session". The session concept is platform-dependent, but corresponds roughly to a graphical desktop login. When your application is launched again, its arguments are passed through platform communication to the already running program. The already running instance of the program is called the primary instance.

Before using Application, you must choose an "application identifier". The expected form of an application identifier is very close to that of of a DBus bus name. Examples include: "com.example.MyApp", "org.example.internal-apps.Calculator". For details on valid application identifiers, see id_is_valid().

Application provides convenient life cycle management by maintaining a use count for the primary application instance. The use count can be changed using hold() and release(). If it drops to zero, the application exits.

Application also implements the ActionGroup and ActionMap interfaces and lets you easily export actions by adding them with Gio::ActionMap::add_action(). When invoking an action by calling Gio::ActionGroup::activate_action() on the application, it is always invoked in the primary instance.

There is a number of different entry points into an Application:

- via 'Activate' (i.e. just starting the application)
- via 'Open' (i.e. opening some files)
- via activating an action

The signal_startup() signal lets you handle the application initialization for all of these in a single place.

See the C API docs for an example.

Since glibmm 2.32:

## Member Typedef Documentation

using Gio::Application::type_vec_files = std::vector< Glib::RefPtr<File> >

## Constructor & Destructor Documentation

Gio::Application::Application | ( | Application&& | src | ) |
| noexcept

Gio::Application::~Application | ( |  | ) |
| override noexcept

Gio::Application::Application | ( | const Glib::ustring& | application_id = `Glib::ustring()`,
|  | ApplicationFlags | flags = `APPLICATION_FLAGS_NONE`
| ) |  |
| explicit protected

Constructs an application instance.

If no application ID is given then some features (most notably application uniqueness) will be disabled.

Parameters

  application_id | The application ID.
  flags | The application flags.

## Member Function Documentation

void Gio::Application::activate | ( |  | ) |

Activates the application.

In essence, this results in the Application::signal_activate() signal being emitted in the primary instance.

The application must be registered before calling this function.

Since glibmm 2.28:

void Gio::Application::add_main_option_entry | ( | OptionType | arg_type,
|  | const Glib::ustring& | long_name,
|  | gchar | short_name = `'\0'`,
|  | const Glib::ustring& | description = `Glib::ustring()`,
|  | const Glib::ustring& | arg_description = `Glib::ustring()`,
|  | int | flags = `0`
| ) |  |

Adds a main option entry to be handled by the Application.

This function is comparable to Glib::OptionGroup::add_entry() + Glib::OptionContext::set_main_group().

After the commandline arguments are parsed, the signal_handle_local_options() signal will be emitted. At this point, the application can inspect the parsed values.

Unlike OptionGroup + OptionContext, Application packs the arguments into a Glib::VariantDict which is passed to the signal_handle_local_options() handler, where it can be inspected and modified. If Gio::APPLICATION_HANDLES_COMMAND_LINE is set, then the resulting dictionary is sent to the primary instance, where Gio::ApplicationCommandLine::get_options_dict() will return it. This "packing" is done according to the type of the argument – booleans for normal flags, Glib::ustring's for strings, std::string's for filenames, etc. The packing only occurs if the flag is given (ie: we do not pack a "false" Variant in the case that a flag is missing).

In general, it is recommended that all commandline arguments are parsed locally. The options dictionary should then be used to transmit the result of the parsing to the primary instance, where Glib::VariantDict::lookup_value() can be used. For local options, it is possible to consult (and potentially remove) the option from the options dictionary.

This function is new in GLib 2.40. Before then, the only real choice was to send all of the commandline arguments (options and all) to the primary instance for handling. Application ignored them completely on the local side. Calling this function "opts in" to the new behaviour, and in particular, means that unrecognised options will be treated as errors. Unrecognised options have never been ignored when Gio::APPLICATION_HANDLES_COMMAND_LINE is unset.

If signal_handle_local_options() needs to see the list of filenames, then the use of G_OPTION_REMAINING as long_name is recommended. G_OPTION_REMAINING can be used as a key into the options dictionary. If you do use G_OPTION_REMAINING then you need to handle these arguments for yourself because once they are consumed, they will no longer be visible to the default handling (which treats them as filenames to be opened).

Since glibmm 2.42:

Parameters

  arg_type | A Gio::Application::OptionType.
  long_name | The long name of an option can be used to specify it in a commandline as `--long_name`. Every option must have a long name.
  short_name | If an option has a short name, it can be specified `-short_name` in a commandline. short_name must be a printable ASCII character different from '-', or '\0' if the option has no short name.
  description | The description for the option in `--help` output.
  arg_description | The placeholder to use for the extra argument parsed by the option in `--help` output.
  flags | Flags from Glib::OptionEntry::Flags. Do not set FLAG_FILENAME. Character encoding is chosen with arg_type.

void Gio::Application::add_main_option_entry | ( | const Glib::OptionGroup::SlotOptionArgString& | slot,
|  | const Glib::ustring& | long_name,
|  | gchar | short_name = `'\0'`,
|  | const Glib::ustring& | description = `Glib::ustring()`,
|  | const Glib::ustring& | arg_description = `Glib::ustring()`,
|  | int | flags = `0`
| ) |  |

Adds a main option entry to be handled by the Application.

Adds a string option entry, but lets the callback slot parse the extra argument instead of having it packed in a Glib::VariantDict.

If you create more than one Application instance (unusual), one Application instance can't add an option with the same name as another instance adds. This restriction does not apply to the add_main_option_entry() that takes an OptionType parameter.

Since glibmm 2.42:

See also
  add_main_option_entry(OptionType, const Glib::ustring&, gchar, const Glib::ustring&, const Glib::ustring&, int)

void Gio::Application::add_main_option_entry_filename | ( | const Glib::OptionGroup::SlotOptionArgFilename& | slot,
|  | const Glib::ustring& | long_name,
|  | gchar | short_name = `'\0'`,
|  | const Glib::ustring& | description = `Glib::ustring()`,
|  | const Glib::ustring& | arg_description = `Glib::ustring()`,
|  | int | flags = `0`
| ) |  |

Adds a main option entry to be handled by the Application.

Adds a filename option entry, but lets the callback slot parse the extra argument instead of having it packed in a Glib::VariantDict.

If you create more than one Application instance (unusual), one Application instance can't add an option with the same name as another instance adds. This restriction does not apply to the add_main_option_entry() that takes an OptionType parameter.

Since glibmm 2.42:

See also
  add_main_option_entry(OptionType, const Glib::ustring&, gchar, const Glib::ustring&, const Glib::ustring&, int)

virtual void Gio::Application::after_emit_vfunc | ( | const Glib::VariantBase& | platform_data | ) |
| protected virtual

virtual void Gio::Application::before_emit_vfunc | ( | const Glib::VariantBase& | platform_data | ) |
| protected virtual

static Glib::RefPtr<Application> Gio::Application::create | ( | const Glib::ustring& | application_id = `Glib::ustring()`,
|  | ApplicationFlags | flags = `APPLICATION_FLAGS_NONE`
| ) |  |
| static

Creates an application instance.

If no application ID is given then some features (most notably application uniqueness) will be disabled.

Parameters

  application_id | The application ID.
  flags | The application flags.

Glib::RefPtr<DBus::Connection> Gio::Application::get_dbus_connection | ( |  | ) |

Gets the DBusConnection being used by the application, or `nullptr`.

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 `nullptr`. 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 g_application_get_is_registered().

Since glibmm 2.34:

Returns
  A DBusConnection, or `nullptr`.

Glib::RefPtr<const DBus::Connection> Gio::Application::get_dbus_connection | ( |  | ) | const

Gets the DBusConnection being used by the application, or `nullptr`.

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 `nullptr`. 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 g_application_get_is_registered().

Since glibmm 2.34:

Returns
  A DBusConnection, or `nullptr`.

Glib::ustring Gio::Application::get_dbus_object_path | ( |  | ) | const

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

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 `nullptr`. 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 g_application_get_is_registered().

Since glibmm 2.34:

Returns
  The object path, or `nullptr`.

static Glib::RefPtr<Application> Gio::Application::get_default | ( |  | ) |
| static

Returns the default Application instance for this process.

Normally there is only one Application per process and it becomes the default when it is created. You can exercise more control over this by using g_application_set_default().

If there is no default application then `nullptr` is returned.

Since glibmm 2.32:

Returns
  The default application for this process, or `nullptr`.

ApplicationFlags Gio::Application::get_flags | ( |  | ) | const

Gets the flags for application.

See ApplicationFlags.

Since glibmm 2.28:

Returns
  The flags for application.

Glib::ustring Gio::Application::get_id | ( |  | ) | const

Gets the unique identifier for application.

Since glibmm 2.28:

Returns
  The identifier for application, owned by application.

guint Gio::Application::get_inactivity_timeout | ( |  | ) | const

Gets the current inactivity timeout for the application.

This is the amount of time (in milliseconds) after the last call to g_application_release() before the application stops running.

Since glibmm 2.28:

Returns
  The timeout, in milliseconds.

bool Gio::Application::get_is_busy | ( |  | ) | const

Gets the application's current busy state, as set through g_application_mark_busy() or g_application_bind_busy_property().

Since glibmm 2.44:

Returns
  `true` if application is currenty marked as busy.

std::string Gio::Application::get_resource_base_path | ( |  | ) | const

Gets the resource base path of application.

See g_application_set_resource_base_path() for more information.

Since glibmm 2.44:

Returns
  The base resource path, if one is set.

static GType Gio::Application::get_type | ( |  | ) |
| static

Get the GType for this class, for use with the underlying GObject type system.

GApplication* Gio::Application::gobj | ( |  | ) |
| inline

Provides access to the underlying C GObject.

const GApplication* Gio::Application::gobj | ( |  | ) | const
| inline

Provides access to the underlying C GObject.

GApplication* Gio::Application::gobj_copy | ( |  | ) |

Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.

void Gio::Application::hold | ( |  | ) |

Increases the use count of application.

Use this function to indicate that the application has a reason to continue to run. For example, g_application_hold() is called by GTK+ when a toplevel window is on the screen.

To cancel the hold, call g_application_release().

static bool Gio::Application::id_is_valid | ( | const Glib::ustring& | application_id | ) |
| static

Checks if application_id is a valid application identifier.

A valid ID is required for calls to g_application_new() and g_application_set_application_id().

For convenience, the restrictions on application identifiers are reproduced here:

- Application identifiers must contain only the ASCII characters "[A-Z][a-z][0-9]_-." and must not begin with a digit.
- Application identifiers must contain at least one '.' (period) character (and thus at least three elements).
- Application identifiers must not begin or end with a '.' (period) character.
- Application identifiers must not contain consecutive '.' (period) characters.
- Application identifiers must not exceed 255 characters.

Parameters

  application_id | A potential application identifier.

Returns
  `true` if application_id is valid.

bool Gio::Application::is_registered | ( |  | ) | const

Checks if application is registered.

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

Since glibmm 2.28:

Returns
  `true` if application is registered.

bool Gio::Application::is_remote | ( |  | ) | const

Checks if application is remote.

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

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

Since glibmm 2.28:

Returns
  `true` if application is remote.

virtual bool Gio::Application::local_command_line_vfunc | ( | char **& | arguments,
|  | int & | exit_status
| ) |  |
| protected virtual

void Gio::Application::mark_busy | ( |  | ) |

Increases the busy count of application.

Use this function to indicate that the application is busy, for instance while a long running operation is pending.

The busy state will be exposed to other processes, so a session shell will use that information to indicate the state to the user (e.g. with a spinner).

To cancel the busy indication, use g_application_unmark_busy().

Since glibmm 2.38:

virtual void Gio::Application::on_activate | ( |  | ) |
| protected virtual

This is a default handler for the signal signal_activate().

virtual int Gio::Application::on_command_line | ( | const Glib::RefPtr< ApplicationCommandLine >& | command_line | ) |
| protected virtual

This is a default handler for the signal signal_command_line().

virtual void Gio::Application::on_open | ( | const type_vec_files& | files,
|  | const Glib::ustring& | hint
| ) |  |
| protected virtual

virtual void Gio::Application::on_startup | ( |  | ) |
| protected virtual

This is a default handler for the signal signal_startup().

void Gio::Application::open | ( | const type_vec_files& | files,
|  | const Glib::ustring& | hint = `Glib::ustring()`
| ) |  |

void Gio::Application::open | ( | const Glib::RefPtr< Gio::File >& | file,
|  | const Glib::ustring& | hint = `Glib::ustring()`
| ) |  |

Application& Gio::Application::operator= | ( | Application&& | src | ) |
| noexcept

Glib::PropertyProxy_WriteOnly< Glib::RefPtr<ActionGroup> > Gio::Application::property_action_group | ( |  | ) |

The group of actions that the application exports.

Deprecated:
  Use the Gio::ActionMap interface instead.

Returns
  A PropertyProxy_WriteOnly that allows you to set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy< Glib::ustring > Gio::Application::property_application_id | ( |  | ) |

The unique identifier for the application.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gio::Application::property_application_id | ( |  | ) | const

The unique identifier for the application.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy< ApplicationFlags > Gio::Application::property_flags | ( |  | ) |

Flags specifying the behaviour of the application.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< ApplicationFlags > Gio::Application::property_flags | ( |  | ) | const

Flags specifying the behaviour of the application.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy< guint > Gio::Application::property_inactivity_timeout | ( |  | ) |

Time (ms) to stay alive after becoming idle.

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< guint > Gio::Application::property_inactivity_timeout | ( |  | ) | const

Time (ms) to stay alive after becoming idle.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< bool > Gio::Application::property_is_busy | ( |  | ) | const

Whether the application is currently marked as busy through g_application_mark_busy() or g_application_bind_busy_property().

Since glibmm 2.44:

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< bool > Gio::Application::property_is_registered | ( |  | ) | const

If g_application_register() has been called.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< bool > Gio::Application::property_is_remote | ( |  | ) | const

If this application instance is remote.

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy< bool > Gio::Application::property_resource_base_path | ( |  | ) |

The base resource path for the application.

Since glibmm 2.44:

Returns
  A PropertyProxy that allows you to get or set the value of the property, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< bool > Gio::Application::property_resource_base_path | ( |  | ) | const

The base resource path for the application.

Since glibmm 2.44:

Returns
  A PropertyProxy_ReadOnly that allows you to get the value of the property, or receive notification when the value of the property changes.

void Gio::Application::quit | ( |  | ) |

Immediately quits the application.

Upon return to the mainloop, g_application_run() will return, calling only the 'shutdown' function before doing so.

The hold count is ignored.

The result of calling g_application_run() again after it returns is unspecified.

Since glibmm 2.32:

virtual void Gio::Application::quit_mainloop_vfunc | ( |  | ) |
| protected virtual

bool Gio::Application::register_application | ( | const Glib::RefPtr< Gio::Cancellable >& | cancellable | ) |

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 APPLICATION_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 Application::signal_startup() signal is emitted if registration succeeds and application 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 g_application_get_is_remote() for that.

Since glibmm 2.28:

Parameters

  cancellable | A Cancellable, or `nullptr`.

Returns
  `true` if registration succeeded.

bool Gio::Application::register_application | ( |  | ) |

A register_application() convenience overload.

void Gio::Application::release | ( |  | ) |

Decrease the use count of application.

When the use count reaches zero, the application will stop running.

Never call this function except to cancel the effect of a previous call to g_application_hold().

int Gio::Application::run | ( | int | argc,
|  | char ** | argv
| ) |  |

Runs the application.

This function is intended to be run from main() and its return value is intended to be returned by main(). Although you are expected to pass the argc, argv parameters from main() to this function, it is possible to pass `nullptr` if argv is not available or commandline handling is not required. Note that on Windows, argc and argv are ignored, and Glib::win32_get_command_line() is called internally (for proper support of Unicode commandline arguments).

Application will attempt to parse the commandline arguments. You can add commandline flags to the list of recognised options by way of g_application_add_main_option_entries(). After this, the Application::signal_handle_local_options() signal is emitted, from which the application can inspect the values of its OptionEntrys.

Application::signal_handle_local_options() is a good place to handle options such as `--version`, where an immediate reply from the local process is desired (instead of communicating with an already-running instance). A Application::signal_handle_local_options() handler can stop further processing by returning a non-negative value, which then becomes the exit status of the process.

What happens next depends on the flags: if APPLICATION_HANDLES_COMMAND_LINE was specified then the remaining commandline arguments are sent to the primary instance, where a Application::signal_command_line() signal is emitted. Otherwise, the remaining commandline arguments are assumed to be a list of files. If there are no files listed, the application is activated via the Application::signal_activate() signal. If there are one or more files, and APPLICATION_HANDLES_OPEN was specified then the files are opened via the Application::signal_open() signal.

If you are interested in doing more complicated local handling of the commandline then you should implement your own Application subclass and override local_command_line(). In this case, you most likely want to return `true` from your local_command_line() implementation to suppress the default handling. See [gapplication-example-cmdline2.c][gapplication-example-cmdline2] for an example.

If, after the above is done, the use count of the application is zero then the exit status is returned immediately. If the use count is non-zero then the default main context is iterated until the use count falls to zero, at which point 0 is returned.

If the APPLICATION_IS_SERVICE flag is set, then the service will run for as much as 10 seconds with a use count of zero while waiting for the message that caused the activation to arrive. After that, if the use count falls to zero the application will exit immediately, except in the case that g_application_set_inactivity_timeout() is in use.

This function sets the prgname (Glib::set_prgname()), if not already set, to the basename of argv[0].

Much like Glib::main_loop_run(), this function will acquire the main context for the duration that the application is running.

Since 2.40, applications that are not explicitly flagged as services or launchers (ie: neither APPLICATION_IS_SERVICE or APPLICATION_IS_LAUNCHER are given as flags) will check (from the default handler for local_command_line) if "--gapplication-service" was given in the command line. If this flag is present then normal commandline processing is interrupted and the APPLICATION_IS_SERVICE flag is set. This provides a "compromise" solution whereby running an application directly from the commandline will invoke it in the normal way (which can be useful for debugging) while still allowing applications to be D-Bus activated in service mode. The D-Bus service file should invoke the executable with "--gapplication-service" as the sole commandline argument. This approach is suitable for use by most graphical applications but should not be used from applications like editors that need precise control over when processes invoked via the commandline will exit and what their exit status will be.

Since glibmm 2.28:

Parameters

  argc | The argc from main() (or 0 if argv is `nullptr`).
  argv | The argv from main(), or `nullptr`.

Returns
  The exit status.

virtual void Gio::Application::run_mainloop_vfunc | ( |  | ) |
| protected virtual

void Gio::Application::send_notification | ( | const Glib::ustring& | id,
|  | const Glib::RefPtr< Notification >& | notification
| ) |  |

Sends a notification on behalf of application 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 `nullptr`, but it is impossible to replace or withdraw notifications without an id.

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

Since glibmm 2.40:

Parameters

  id | Id of the notification, or `nullptr`.
  notification | The Notification to send.

void Gio::Application::send_notification | ( | const Glib::RefPtr< Notification >& | notification | ) |

A send_notification() convenience overload.

void Gio::Application::set_action_group | ( | const Glib::RefPtr< ActionGroup >& | action_group | ) |

This used to be how actions were associated with a Application.

Now there is ActionMap for that.

Since glibmm 2.28:

Deprecated:2.32:Use the ActionMap interface instead. Never ever mix use of this API with use of ActionMap on the same application or things will go very badly wrong. This function is known to introduce buggy behaviour (ie: signals not emitted on changes to the action group), so you should really use ActionMap instead.

Deprecated:
  Use the Gio::ActionMap interface instead.

Parameters

  action_group | A ActionGroup, or `nullptr`.

static void Gio::Application::set_default | ( | const Glib::RefPtr< Application >& | application | ) |
| static

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

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

Since glibmm 2.32:

Parameters

  application | The application to set as default, or `nullptr`.

void Gio::Application::set_flags | ( | ApplicationFlags | flags | ) |

Sets the flags for application.

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

See ApplicationFlags.

Since glibmm 2.28:

Parameters

  flags | The flags for application.

void Gio::Application::set_id | ( | const Glib::ustring& | application_id | ) |

Sets the unique identifier for application.

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

If non-`nullptr`, the application id must be valid. See g_application_id_is_valid().

Since glibmm 2.28:

Parameters

  application_id | The identifier for application.

void Gio::Application::set_inactivity_timeout | ( | guint | inactivity_timeout | ) |

Sets the current inactivity timeout for the application.

This is the amount of time (in milliseconds) after the last call to g_application_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 g_application_release() drops the use count to zero. Any timeouts currently in progress are not impacted.

Since glibmm 2.28:

Parameters

  inactivity_timeout | The timeout, in milliseconds.

void Gio::Application::set_resource_base_path | ( | const std::string & | resource_path | ) |

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

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 "org.example.app" then the default resource base path will be "/org/example/app". If this is a Gtk::Application (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 `nullptr`.

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 Application::property_resource_base_path() property at construction time, or call this function during the instance initialization. Alternatively, you can call this function in the ApplicationClass.startup virtual function, before chaining up to the parent implementation.

Since glibmm 2.44:

Parameters

  resource_path | The resource path to use.

Glib::SignalProxy< void > Gio::Application::signal_activate | ( |  | ) |

Slot Prototype:
  `void on_my_activate()`

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

Glib::SignalProxy< int,const Glib::RefPtr<ApplicationCommandLine>& > Gio::Application::signal_command_line | ( |  | ) |

Slot Prototype:
  `int on_my_command_line(const Glib::RefPtr<ApplicationCommandLine>& command_line)`

The signal_command_line() signal is emitted on the primary instance when a commandline is not handled locally. See g_application_run() and the ApplicationCommandLine documentation for more information.

Parameters

  command_line | A ApplicationCommandLine representing the passed commandline.

Returns
  An integer that is set as the exit status for the calling process. See g_application_command_line_set_exit_status().

Glib::SignalProxy< int,const Glib::RefPtr<Glib::VariantDict>& > Gio::Application::signal_handle_local_options | ( |  | ) |

Slot Prototype:
  `int on_my_handle_local_options(const Glib::RefPtr<Glib::VariantDict>& options)`

The signal_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 OptionEntrys) 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 APPLICATION_HANDLES_COMMAND_LINE the "normal processing" will send the options dictionary to the primary instance where it can be read with g_application_command_line_get_options_dict(). The signal handler can modify the dictionary before returning, and the modified dictionary will be sent.

In the event that APPLICATION_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 g_application_activate(). One or more arguments results in a call to g_application_open().

If you want to handle the local commandline arguments for yourself by converting them to calls to g_application_open() or g_action_group_activate_action() then you must be sure to register the application first. You should probably not call g_application_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.

Since glibmm 2.40:

Parameters

  options | The options dictionary.

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

Glib::SignalProxy< void, const type_vec_files&, const Glib::ustring& > Gio::Application::signal_open | ( |  | ) |

Glib::SignalProxy< void > Gio::Application::signal_shutdown | ( |  | ) |

Slot Prototype:
  `void on_my_shutdown()`

The signal_shutdown() signal is emitted only on the registered primary instance immediately after the main loop terminates.

Since glibmm 2.46:

Glib::SignalProxy< void > Gio::Application::signal_startup | ( |  | ) |

Slot Prototype:
  `void on_my_startup()`

The signal_startup() signal is emitted on the primary instance immediately after registration. See g_application_register().

void Gio::Application::unmark_busy | ( |  | ) |

Decreases the busy count of application.

When the busy count reaches zero, the new state will be propagated to other processes.

This function must only be called to cancel the effect of a previous call to g_application_mark_busy().

Since glibmm 2.38:

static void Gio::Application::unset_default | ( |  | ) |
| static

Unsets any existing default application.

void Gio::Application::unset_resource_base_path | ( |  | ) |

Disable automatic resource loading functionality.

See set_resource_base_path().

Since glibmm 2.44:

void Gio::Application::withdraw_notification | ( | const Glib::ustring& | id | ) |

Withdraws a notification that was sent with g_application_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.

Since glibmm 2.40:

Parameters

  id | Id of a previously sent notification.

## Friends And Related Function Documentation

Glib::RefPtr< Gio::Application > wrap | ( | GApplication * | object,
|  | bool | take_copy = `false`
| ) |  |
| related

A Glib::wrap() method for this object.

Parameters

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns
  A C++ instance that wraps this C instance.