mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 12:25:31 +00:00
calls-application: Add --daemon option to not display main window
This commit is contained in:
parent
587c3444b6
commit
fc16ec7a71
1 changed files with 53 additions and 5 deletions
|
@ -55,6 +55,7 @@ struct _CallsApplication
|
||||||
{
|
{
|
||||||
GtkApplication parent_instance;
|
GtkApplication parent_instance;
|
||||||
|
|
||||||
|
gboolean daemon;
|
||||||
GString *provider_name;
|
GString *provider_name;
|
||||||
CallsProvider *provider;
|
CallsProvider *provider;
|
||||||
CallsRinger *ringer;
|
CallsRinger *ringer;
|
||||||
|
@ -90,6 +91,14 @@ handle_local_options (GApplication *application,
|
||||||
g_variant_new_string (name));
|
g_variant_new_string (name));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ok = g_variant_dict_contains (options, "daemon");
|
||||||
|
if (ok)
|
||||||
|
{
|
||||||
|
g_action_group_activate_action (G_ACTION_GROUP (application),
|
||||||
|
"set-daemon",
|
||||||
|
NULL);
|
||||||
|
}
|
||||||
|
|
||||||
return -1; // Continue processing signal
|
return -1; // Continue processing signal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,9 +129,30 @@ set_provider_name_action (GSimpleAction *action,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void
|
||||||
|
set_daemon_action (GSimpleAction *action,
|
||||||
|
GVariant *parameter,
|
||||||
|
gpointer user_data)
|
||||||
|
{
|
||||||
|
CallsApplication *self = CALLS_APPLICATION (user_data);
|
||||||
|
|
||||||
|
if (self->main_window)
|
||||||
|
{
|
||||||
|
g_warning ("Cannot set application as a daemon"
|
||||||
|
" because application is already started");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
self->daemon = TRUE;
|
||||||
|
|
||||||
|
g_debug ("Application marked as daemon");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static const GActionEntry actions[] =
|
static const GActionEntry actions[] =
|
||||||
{
|
{
|
||||||
{ "set-provider-name", set_provider_name_action, "s" },
|
{ "set-provider-name", set_provider_name_action, "s" },
|
||||||
|
{ "set-daemon", set_daemon_action, NULL },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -268,17 +298,29 @@ static void
|
||||||
activate (GApplication *application)
|
activate (GApplication *application)
|
||||||
{
|
{
|
||||||
CallsApplication *self = CALLS_APPLICATION (application);
|
CallsApplication *self = CALLS_APPLICATION (application);
|
||||||
gboolean ok;
|
gboolean present;
|
||||||
|
|
||||||
g_debug ("Activated");
|
g_debug ("Activated");
|
||||||
|
|
||||||
ok = start_proper (self);
|
if (self->main_window)
|
||||||
if (!ok)
|
|
||||||
{
|
{
|
||||||
return;
|
present = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
gboolean ok = start_proper (self);
|
||||||
|
if (!ok)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
present = !self->daemon;
|
||||||
}
|
}
|
||||||
|
|
||||||
gtk_window_present (GTK_WINDOW (self->main_window));
|
if (present)
|
||||||
|
{
|
||||||
|
gtk_window_present (GTK_WINDOW (self->main_window));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -426,6 +468,12 @@ calls_application_init (CallsApplication *self)
|
||||||
_("The name of the plugin to use for the call Provider"),
|
_("The name of the plugin to use for the call Provider"),
|
||||||
_("PLUGIN")
|
_("PLUGIN")
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"daemon", 'd', G_OPTION_FLAG_NONE,
|
||||||
|
G_OPTION_ARG_NONE, NULL,
|
||||||
|
_("Whether to present the main window on startup"),
|
||||||
|
NULL
|
||||||
|
},
|
||||||
{
|
{
|
||||||
NULL
|
NULL
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue