### Method

# Gio Application register

since: 2.28

#### Declaration [src]

    gboolean
    g_application_register (
      GApplication* application,
      GCancellable* cancellable,
      GError** error
    )

#### Description [src]

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 `G_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 `GApplication::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.

Available since: 2.28

#### Parameters

`cancellable`

  Type: `GCancellable`

  A `GCancellable`, or `NULL`.

  The argument can be `NULL`.
  The data is owned by the caller of the method.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the method if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `gboolean`

`TRUE` if registration succeeded.