GApplication: Add a way to replace a unique instance

While uniqueness is great, sometimes you want to restart
a newer version of the same app. These two flags make that
possible.

We also add a ::name-lost signal, that is emitted when it
happens. The default handler for this signal just calls
g_application_quit(), but applications may want to connect
and do cleanup or state-saving here.
This commit is contained in:
Matthias Clasen
2018-08-18 15:35:33 -04:00
parent 051c9ada8e
commit 3a4b18f903
4 changed files with 117 additions and 7 deletions

View File

@@ -1474,6 +1474,11 @@ typedef enum
* @G_APPLICATION_CAN_OVERRIDE_APP_ID: Allow users to override the
* application ID from the command line with `--gapplication-app-id`.
* Since: 2.48
* @G_APPLICATION_ALLOW_REPLACEMENT: Allow another instance to take over
* the bus name. Since: 2.60
* @G_APPLICATION_REPLACE: Take over from another instance. This flag is
* usually set by passing `--gapplication-replace` on the commandline.
* Since: 2.60
*
* Flags used to define the behaviour of a #GApplication.
*
@@ -1491,7 +1496,9 @@ typedef enum
G_APPLICATION_NON_UNIQUE = (1 << 5),
G_APPLICATION_CAN_OVERRIDE_APP_ID = (1 << 6)
G_APPLICATION_CAN_OVERRIDE_APP_ID = (1 << 6),
G_APPLICATION_ALLOW_REPLACEMENT = (1 << 7),
G_APPLICATION_REPLACE = (1 << 8)
} GApplicationFlags;
/**