# Gio::Application Class Reference

Application - Core application class. More...

`#include <giomm/application.h>`

Inheritance diagram for Gio::Application:
[legend]

List of all members.

## Public Types

typedef std::vector < Glib::RefPtr< File > > | type_vec_files

## 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
void | set_id (const Glib::ustring& application_id)
guint | get_inactivity_timeout () const
void | set_inactivity_timeout (guint inactivity_timeout)
ApplicationFlags | get_flags () const
void | set_flags (ApplicationFlags flags)
void | set_action_group (const Glib::RefPtr< ActionGroup >& action_group)
bool | is_registered () const
bool | is_remote () const
bool | register_application (const Glib::RefPtr< Gio::Cancellable >& cancellable)
| By default, Application ensures process uniqueness when initialized, but this behavior is controlled by the GApplication:register property.
bool | register_application ()
| Non-cancellable version of register_application().
void | hold ()
void | release ()
void | activate ()
void | open (const type_vec_files& files, const Glib::ustring& hint=Glib::ustring())
int | run (int argc, char** argv)
| Starts 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 ()
| Iime (ms) to stay alive after becoming idle.
Glib::PropertyProxy_ReadOnly < guint > | property_inactivity_timeout () const
| Iime (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::SignalProxy1< bool, const Glib::RefPtr < ApplicationCommandLine >& > | signal_command_line ()

## Static Public Member Functions

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

## Protected Member Functions

| Application (const Glib::ustring& application_id, ApplicationFlags flags=APPLICATION_FLAGS_NONE)
virtual void | on_startup ()
virtual void | on_activate ()
virtual bool | on_command_line (const Glib::RefPtr< ApplicationCommandLine >& command_line)

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

## Detailed Description

Application - Core application class.

A 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 a 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.28:

## 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,
|  | ApplicationFlags | flags = `APPLICATION_FLAGS_NONE`
| ) |  | `[explicit, protected]`

## Member Function Documentation

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

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

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

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

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

const GApplication* Gio::Application::gobj | ( | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

GApplication* Gio::Application::gobj | ( | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::ObjectBase.

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

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

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

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

virtual void Gio::Application::on_activate | ( | ) | `[protected, virtual]`

virtual bool Gio::Application::on_command_line | ( | const Glib::RefPtr< ApplicationCommandLine >& | command_line ) | `[protected, virtual]`

virtual void Gio::Application::on_startup | ( | ) | `[protected, virtual]`

void Gio::Application::open | ( | const type_vec_files & | files,
|  | 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 that allows you to get or set the property of the value, 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 property of the value, 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 that allows you to get or set the property of the value, 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 property of the value, 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 that allows you to get or set the property of the value, or receive notification when the value of the property changes.

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

Iime (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 property of the value, or receive notification when the value of the property changes.

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

Iime (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 property of the value, 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 that allows you to get or set the property of the value, 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 that allows you to get or set the property of the value, or receive notification when the value of the property changes.

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

By default, Application ensures process uniqueness when initialized, but this behavior is controlled by the GApplication:register property.

If it was given as `false` at construction time, this function allows you to later attempt to ensure uniqueness. Note that the GApplication:default-quit property no longer applies at this point; if this function returns `false`, platform activation will occur, but the current process will not be terminated.

It is an error to call this function more than once. It is also an error to call this function if the GApplication:register property was `true` at construction time.

Returns:
  `true` if registration was successful.

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

Non-cancellable version of register_application().

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

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

Starts the application.

The default implementation of this virtual function will simply run a main loop.

It is an error to call this function if application is a proxy for a remote application.

Since glibmm 2.26:

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

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

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

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

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

Prototype:
  `void on_my_activate()`

Glib::SignalProxy1< bool,const Glib::RefPtr<ApplicationCommandLine>& > Gio::Application::signal_command_line | ( | ) |

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

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

Prototype:
  `void on_my_startup()`

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