if (!application->priv->is_registered)
{
- if (~application->priv->flags & G_APPLICATION_NON_UNIQUE)
- {
- application->priv->impl =
- g_application_impl_register (application, application->priv->id,
- application->priv->flags,
- application->priv->actions,
- &application->priv->remote_actions,
- cancellable, error);
-
- if (application->priv->impl == NULL)
- return FALSE;
- }
+ application->priv->impl =
+ g_application_impl_register (application, application->priv->id,
+ application->priv->flags,
+ application->priv->actions,
+ &application->priv->remote_actions,
+ cancellable, error);
+
+ if (application->priv->impl == NULL)
+ return FALSE;
application->priv->is_remote = application->priv->remote_actions != NULL;
application->priv->is_registered = TRUE;
*/
static gboolean
g_application_impl_attempt_primary (GApplicationImpl *impl,
+ gboolean non_unique,
GCancellable *cancellable,
GError **error)
{
if (impl->actions_id == 0)
return FALSE;
+ if (non_unique)
+ {
+ /* If this is a non-unique application then it is sufficient to
+ * have our object paths registered. We can return now.
+ *
+ * Note: non-unique applications always act as primary-instance.
+ */
+ impl->primary = TRUE;
+ return TRUE;
+ }
+
+ /* If this is a unique application then we need to attempt to own
+ * the well-known name and fall back to remote mode (!is_primary)
+ * in the case that we can't do that.
+ */
/* DBUS_NAME_FLAG_DO_NOT_QUEUE: 0x4 */
reply = g_dbus_connection_call_sync (impl->session_bus, "org.freedesktop.DBus", "/org/freedesktop/DBus",
"org.freedesktop.DBus", "RequestName",
*/
if (~flags & G_APPLICATION_IS_LAUNCHER)
{
- if (!g_application_impl_attempt_primary (impl, cancellable, error))
+ gboolean non_unique;
+
+ non_unique = (flags & G_APPLICATION_NON_UNIQUE) != 0;
+
+ if (!g_application_impl_attempt_primary (impl, non_unique, cancellable, error))
{
g_application_impl_destroy (impl);
return NULL;