glibmm 2.34.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

typedef std::vector < Glib::RefPtr< File > > | type_vec_files
Public Types inherited from Glib::Object
typedef void(* | DestroyNotify )(gpointer data)

## Public Member Functions

virtual | ~Application ()
GApplication* | gobj ()
| Provides access to the underlying C GObject.
const GApplication* | gobj () const
| Provides access to the underlying C GObject.
GApplication* | gobj_copy ()
| Provides access to the underlying C instance. The caller is responsible for unrefing it. Use when directly setting fields in structs.
Glib::ustring | get_id () const
| Gets the unique identifier for application.
void | set_id (const Glib::ustring& application_id)
| Sets the unique identifier for application.
Glib::RefPtr< DBus::Connection > | get_dbus_connection ()
| Gets the DBusConnection being used by the application, or `0`.
Glib::RefPtr< const DBus::Connection > | get_dbus_connection () const
| Gets the DBusConnection being used by the application, or `0`.
Glib::ustring | get_dbus_object_path () const
| Gets the D-Bus object path being used by the application, or `0`.
guint | get_inactivity_timeout () const
| Gets the current inactivity timeout for the application.
void | set_inactivity_timeout (guint inactivity_timeout)
| Sets the current inactivity timeout for the application.
ApplicationFlags | get_flags () const
| Gets the flags for application.
void | set_flags (ApplicationFlags flags)
| Sets the flags for application.
void | set_action_group (const Glib::RefPtr< ActionGroup >& action_group)
| This used to be how actions were associated with a Application.
bool | is_registered () const
| Checks if application is registered.
bool | is_remote () const
| Checks if application is remote.
bool | register_application (const Glib::RefPtr< Gio::Cancellable >& cancellable)
| Attempts registration of the application.
bool | register_application ()
| A register_application() convenience overload.
void | hold ()
| Increases the use count of application.
void | release ()
| Decrease the use count of application.
void | activate ()
| Activates the application.
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.
void | quit ()
| Immediately quits the application.
Glib::PropertyProxy_WriteOnly < Glib::RefPtr< ActionGroup > > | property_action_group ()
| The group of actions that the application exports.
Glib::PropertyProxy < Glib::ustring > | property_application_id ()
| The unique identifier for the application.
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_application_id () const
| The unique identifier for the application.
Glib::PropertyProxy < ApplicationFlags > | property_flags ()
| Flags specifying the behaviour of the application.
Glib::PropertyProxy_ReadOnly < ApplicationFlags > | property_flags () const
| Flags specifying the behaviour of the application.
Glib::PropertyProxy< guint > | property_inactivity_timeout ()
| Time (ms) to stay alive after becoming idle.
Glib::PropertyProxy_ReadOnly < guint > | property_inactivity_timeout () const
| Time (ms) to stay alive after becoming idle.
Glib::PropertyProxy_ReadOnly < bool > | property_is_registered () const
| If g_application_register() has been called.
Glib::PropertyProxy_ReadOnly < bool > | property_is_remote () const
| If this application instance is remote.
Glib::SignalProxy0< void > | signal_startup ()
Glib::SignalProxy0< void > | signal_activate ()
Glib::SignalProxy2< void, const type_vec_files&, const Glib::ustring& > | signal_open ()
Glib::SignalProxy1< int, const Glib::RefPtr < ApplicationCommandLine >& > | signal_command_line ()
Public Member Functions inherited from Glib::Object
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
void | set_property_value (const Glib::ustring& property_name, const Glib::ValueBase& value)
| You probably want to use a specific property_*() accessor method instead.
void | get_property_value (const Glib::ustring& property_name, Glib::ValueBase& value) const
| You probably want to use a specific property_*() accessor method instead.
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.
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.
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, but this is necessary when using the reduced API.
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, but this is necessary when using the reduced API.
void | freeze_notify ()
| Increases the freeze count on object.
void | thaw_notify ()
| Reverts the effect of a previous call to freeze_notify().
virtual void | reference () const
| Increment the reference count for this object.
virtual void | unreference () const
| Decrement the reference count for this object.
GObject* | gobj ()
| Provides access to the underlying C GObject.
const GObject* | gobj () const
| Provides access to the underlying C GObject.
GObject* | gobj_copy () const
| Give a ref-ed copy to someone. Use for direct struct access.
Public Member Functions inherited from sigc::trackable
| trackable (const trackable &src)
trackable & | operator= (const trackable &src)
void | add_destroy_notify_callback (void *data, func_destroy_notify func) const
void | remove_destroy_notify_callback (void *data) const
void | notify_callbacks ()
Public Member Functions inherited from Gio::ActionGroup
virtual | ~ActionGroup ()
GActionGroup* | gobj ()
| Provides access to the underlying C GObject.
const GActionGroup* | gobj () const
| Provides access to the underlying C GObject.
bool | has_action (const Glib::ustring& action_name) const
| Checks if the named action exists within action_group.
std::vector< Glib::ustring > | list_actions () const
| Lists the actions contained within action_group.
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.
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.
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.
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantType& parameter_type, Glib::VariantBase& state_hint)
| A query_action() convenience overload.
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.
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantBase& state_hint, Glib::VariantType& state_type)
| A query_action() convenience overload.
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantBase& state_hint, Glib::VariantBase& state)
| A query_action() convenience overload.
bool | query_action (const Glib::ustring& action_name, bool& enabled, Glib::VariantBase& state_hint)
| A query_action() convenience overload.
bool | get_action_enabled (const Glib::ustring& action_name) const
| Checks if the named action within action_group is currently enabled.
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.
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.
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.
Glib::VariantBase | get_action_state (const Glib::ustring& action_name) const
| Queries the current state of the named action within action_group.
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.
void | activate_action (const Glib::ustring& action_name, const Glib::VariantBase& parameter)
| Activate the named action within action_group.
void | action_added (const Glib::ustring& action_name)
| Emits the ActionGroup::signal_action_added() signal on action_group.
void | action_removed (const Glib::ustring& action_name)
| Emits the ActionGroup::signal_action_removed() signal on action_group.
void | action_enabled_changed (const Glib::ustring& action_name, bool enabled)
| Emits the ActionGroup::signal_action_enabled_changed() signal on action_group.
void | action_state_changed (const Glib::ustring& action_name, const Glib::VariantBase& state)
| Emits the ActionGroup::signal_action_state_changed() signal on action_group.
Glib::SignalProxy1< void, const Glib::ustring& > | signal_action_added ()
Glib::SignalProxy2< void, const Glib::ustring&, bool > | signal_action_enabled_changed ()
Glib::SignalProxy1< void, const Glib::ustring& > | signal_action_removed ()
Glib::SignalProxy2< 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 (const Glib::Interface_Class& interface_class)
| Called by constructors of derived classes.
| Interface (GObject* castitem)
| Called by constructors of derived classes.
virtual | ~Interface ()
GObject* | gobj ()
const GObject* | gobj () const
Public Member Functions inherited from Gio::ActionMap
virtual | ~ActionMap ()
GActionMap* | gobj ()
| Provides access to the underlying C GObject.
const GActionMap* | gobj () const
| Provides access to the underlying C GObject.
Glib::RefPtr< Action > | lookup_action (const Glib::ustring& action_name)
| Looks up the action with the name action_name in action_map.
Glib::RefPtr< const Action > | lookup_action (const Glib::ustring& action_name) const
| Looks up the action with the name action_name in action_map.
void | add_action (const Glib::RefPtr< Action >& action)
| Adds an action to the action_map.
void | remove_action (const Glib::ustring& action_name)
| Removes the named action from the action map.
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.
static Glib::RefPtr< Application > | create (const Glib::ustring& application_id=Glib::ustring(), ApplicationFlags flags=APPLICATION_FLAGS_NONE)
| Creates an application instance.
static bool | id_is_valid (const Glib::ustring& application_id)
| Checks if application_id is a valid application identifier.
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().
static void | unset_default ()
| Unsets any existing default application.
static Glib::RefPtr< Application > | get_default ()
| Returns the default Application instance for this process.
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.
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.

## Protected Member Functions

| Application (const Glib::ustring& application_id=Glib::ustring(), ApplicationFlags flags=APPLICATION_FLAGS_NONE)
| Constructs an application instance.
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().
virtual void | on_activate ()
| This is a default handler for the signal signal_activate().
virtual int | on_command_line (const Glib::RefPtr< ApplicationCommandLine >& command_line)
| This is a default handler for the signal signal_command_line().
Protected Member Functions inherited from Glib::Object
| Object ()
| Object (const Glib::ConstructParams& construct_params)
| Object (GObject* castitem)
virtual | ~Object ()
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.
| ObjectBase (const char* custom_type_name)
| A derived constructor always overrides this choice.
| 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.
virtual | ~ObjectBase ()=0
void | initialize (GObject* castitem)
Protected Member Functions inherited from Gio::ActionGroup
| ActionGroup ()
| You should derive from this class to use it.
virtual void | on_action_added (const Glib::ustring& action_name)
| This is a default handler for the signal signal_action_added().
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().
virtual void | on_action_removed (const Glib::ustring& action_name)
| This is a default handler for the signal signal_action_removed().
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().
Protected Member Functions inherited from Gio::ActionMap
| ActionMap ()
| You should derive from this class to use it.

## 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.
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.
Related Functions inherited from Gio::ActionMap
Glib::RefPtr< Gio::ActionMap > | wrap (GActionMap* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## 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 interface and lets you easily export actions by adding them with set_action_group(). 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

typedef std::vector< Glib::RefPtr<File> > Gio::Application::type_vec_files

## Constructor & Destructor Documentation

virtual Gio::Application::~Application | ( |  | ) |

virtual

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

explicitprotected

Constructs an application instance.

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

application_id The application ID.

Parameters

  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:

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

protectedvirtual

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

protectedvirtual

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.

application_id The application ID.

Parameters

  flags | The application flags.

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

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

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 `0`. 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 `0`.

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

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

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 `0`. 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 `0`.

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

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

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 `0`. 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 `0`.

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 `0` is returned.

Since glibmm 2.32:

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

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.

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

protectedvirtual

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

protectedvirtual

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

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

protectedvirtual

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

protectedvirtual

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

protectedvirtual

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()`
| ) |  |

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

The group of actions that the application exports.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

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

protectedvirtual

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 `0`.

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 `0` if argv is not available or commandline handling is not required.

First, the local_command_line() virtual function is invoked. This function always runs on the local instance. It gets passed a pointer to a `0`-terminated copy of argv and is expected to remove the arguments that it handled (shifting up remaining arguments). See <xref linkend="gapplication-example-cmdline2"> for an example of parsing argv manually. Alternatively, you may use the OptionContext API, after setting `argc = g_strv_length (argv);`.

The last argument to local_command_line() is a pointer to the status variable which can used to set the exit status that is returned from g_application_run().

If local_command_line() returns `true`, the command line is expected to be completely handled, including possibly registering as the primary instance, calling g_application_activate() or g_application_open(), etc.

If local_command_line() returns `false` then the application is registered and the Application::signal_command_line() signal is emitted in the primary instance (which may or may not be this instance). The signal handler gets passed a ApplicationCommandLine object that (among other things) contains the remaining commandline arguments that have not been handled by local_command_line().

If the application has the APPLICATION_HANDLES_COMMAND_LINE flag set then the default implementation of local_command_line() always returns `false` immediately, resulting in the commandline always being handled in the primary instance.

Otherwise, the default implementation of local_command_line() tries to do a couple of things that are probably reasonable for most applications. First, g_application_register() is called to attempt to register the application. If that works, then the command line arguments are inspected. If no commandline arguments are given, then g_application_activate() is called. If commandline arguments are given and the APPLICATION_HANDLES_OPEN flag is set then they are assumed to be filenames and g_application_open() is called.

If you need to handle commandline arguments that are not filenames, and you don't mind commandline handling to happen in the primary instance, you should set APPLICATION_HANDLES_COMMAND_LINE and process the commandline arguments in your Application::signal_command_line() signal handler, either manually or using the OptionContext API.

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 <xref linkend="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 exiting at use count of zero is delayed for a while (ie: the instance stays around to provide its service to others).

Since glibmm 2.28:

Parameters

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

Returns
  The exit status.

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

protectedvirtual

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.

Parameters

  action_group | A ActionGroup, or `0`.

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 `0`.

Since glibmm 2.32:

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-`0`, 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.

Glib::SignalProxy0< 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::SignalProxy1< 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::SignalProxy2< void, const type_vec_files&, const Glib::ustring& > Gio::Application::signal_open | ( |  | ) |

Glib::SignalProxy0< 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().

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

static

Unsets any existing default application.

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