1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-13 16:07:36 +00:00

application: Don't show application window if started as daemon

If calls was already running as a daemon it and were invoked again with
`--daemon` it ended up showing the UI.

Now we always set the `daemon` variable and simplify activation logic as
a side effect.

Fixes #500
This commit is contained in:
Evangelos Ribeiro Tzaras 2022-09-20 13:35:12 +02:00
parent 3badf72725
commit c3c315d8e7

View file

@ -186,16 +186,12 @@ set_daemon_action (GSimpleAction *action,
gpointer user_data) gpointer user_data)
{ {
CallsApplication *self = CALLS_APPLICATION (user_data); CallsApplication *self = CALLS_APPLICATION (user_data);
gboolean daemon = g_variant_get_boolean (parameter);
if (self->main_window) { self->daemon = daemon;
g_warning ("Cannot set application as a daemon"
" because application is already started");
return;
}
self->daemon = TRUE; g_debug ("Application %smarked as daemon",
daemon ? "" : "not ");
g_debug ("Application marked as daemon");
} }
@ -390,7 +386,7 @@ static const GActionEntry actions[] =
{ {
{ "set-provider-names", set_provider_names_action, "as" }, { "set-provider-names", set_provider_names_action, "as" },
{ "set-default-providers", set_default_providers_action, NULL }, { "set-default-providers", set_default_providers_action, NULL },
{ "set-daemon", set_daemon_action, NULL }, { "set-daemon", set_daemon_action, "b" },
{ "dial", dial_action, "s" }, { "dial", dial_action, "s" },
{ "copy-number", copy_number, "s" }, { "copy-number", copy_number, "s" },
/* TODO About dialog { "about", show_about, NULL}, */ /* TODO About dialog { "about", show_about, NULL}, */
@ -484,9 +480,9 @@ calls_application_command_line (GApplication *application,
NULL); NULL);
} }
if (g_variant_dict_contains (options, "daemon"))
g_action_group_activate_action (G_ACTION_GROUP (application), g_action_group_activate_action (G_ACTION_GROUP (application),
"set-daemon", NULL); "set-daemon",
g_variant_new_boolean (g_variant_dict_contains (options, "daemon")));
if (g_variant_dict_lookup (options, "dial", "&s", &arg)) if (g_variant_dict_lookup (options, "dial", "&s", &arg))
g_action_group_activate_action (G_ACTION_GROUP (application), g_action_group_activate_action (G_ACTION_GROUP (application),
@ -577,12 +573,8 @@ activate (GApplication *application)
g_debug ("Activated"); g_debug ("Activated");
if (self->main_window) {
present = TRUE;
} else {
start_proper (self); start_proper (self);
present = !self->daemon; present = !self->daemon;
}
if (present || self->uri) { if (present || self->uri) {
gtk_window_present (GTK_WINDOW (self->main_window)); gtk_window_present (GTK_WINDOW (self->main_window));