application: Drop ignore_activation flag

Rather use gapplication service. This makes the flow similar to what
Chatty does and makes us hold/release rather than having an application
window.

It also allows us to drop the --daemon.

Part-of: <https://gitlab.gnome.org/GNOME/calls/-/merge_requests/760>
This commit is contained in:
Guido Günther
2024-10-03 14:35:37 +02:00
committed by Evangelos Ribeiro Tzaras
parent fbfe680f6a
commit 574e1f79a3
4 changed files with 14 additions and 32 deletions

View File

@@ -7,7 +7,7 @@ Keywords=Telephone;Call;Phone;Dial;Dialer;PSTN;
# Translators: Do NOT translate or transliterate this text (this is an icon file name)!
Icon=org.gnome.Calls
TryExec=gnome-calls
Exec=gnome-calls --daemon
Exec=gnome-calls --gapplication-service
Type=Application
StartupNotify=true
NoDisplay=true

View File

@@ -1,3 +1,3 @@
[D-BUS Service]
Name=org.gnome.Calls
Exec=@bindir@/gnome-calls --daemon
Exec=@bindir@/gnome-calls --gapplication-service

View File

@@ -60,7 +60,6 @@
struct _CallsApplication {
AdwApplication parent_instance;
gboolean ignore_activation;
CallsRinger *ringer;
CallsNotifier *notifier;
CallsRecordStore *record_store;
@@ -104,6 +103,9 @@ quit_calls (CallsApplication *self)
if (self->call_window)
gtk_application_remove_window (GTK_APPLICATION (self), GTK_WINDOW (self->call_window));
if (g_application_get_flags (G_APPLICATION (self)) & G_APPLICATION_IS_SERVICE)
g_application_release (G_APPLICATION (self));
self->shutdown = TRUE;
}
@@ -241,18 +243,6 @@ set_default_plugins_action (GSimpleAction *action,
}
static void
set_daemon_action (GSimpleAction *action,
GVariant *parameter,
gpointer user_data)
{
CallsApplication *self = CALLS_APPLICATION (user_data);
self->ignore_activation = g_variant_get_boolean (parameter);
g_debug ("Application ignores activation: %d", self->ignore_activation);
}
#define DIALLING "0-9*#+ABCD"
#define SIGNALLING ",TP!W@X"
#define VISUAL "[:space:]\\-.()t/"
@@ -444,7 +434,6 @@ static const GActionEntry actions[] =
{
{ "set-plugin-names", set_plugin_names_action, "as" },
{ "set-default-plugins", set_default_plugins_action, NULL },
{ "set-daemon", set_daemon_action, "b" },
{ "dial", dial_action, "s" },
{ "copy-number", copy_number, "s" },
/* TODO About dialog { "about", show_about, NULL}, */
@@ -509,6 +498,11 @@ startup (GApplication *application)
application,
G_CONNECT_SWAPPED);
if (g_application_get_flags (application) & G_APPLICATION_IS_SERVICE) {
g_application_hold (application);
g_debug ("Enable daemon mode");
}
manager_state_changed_cb (application);
}
@@ -552,10 +546,6 @@ calls_application_command_line (GApplication *application,
NULL);
}
g_action_group_activate_action (G_ACTION_GROUP (application),
"set-daemon",
g_variant_new_boolean (g_variant_dict_contains (options, "daemon")));
if (g_variant_dict_lookup (options, "dial", "&s", &arg))
g_action_group_activate_action (G_ACTION_GROUP (application),
"dial", g_variant_new_string (arg));
@@ -702,9 +692,7 @@ activate (GApplication *application)
start_proper (self);
if (!self->ignore_activation || self->uri) {
gtk_window_present (GTK_WINDOW (self->main_window));
}
gtk_window_present (GTK_WINDOW (self->main_window));
if (self->uri) {
if (g_str_has_prefix (self->uri, "tel:"))
@@ -716,7 +704,6 @@ activate (GApplication *application)
}
g_clear_pointer (&self->uri, g_free);
self->ignore_activation = FALSE;
}
@@ -825,12 +812,6 @@ calls_application_init (CallsApplication *self)
_("The name of the plugins to load"),
_("PLUGIN")
},
{
"daemon", 'd', G_OPTION_FLAG_NONE,
G_OPTION_ARG_NONE, NULL,
_("Whether to present the main window on startup"),
NULL
},
{
"dial", 'l', G_OPTION_FLAG_NONE,
G_OPTION_ARG_STRING, NULL,

View File

@@ -26,7 +26,7 @@ static void
test_application_shutdown_daemon (void)
{
CallsApplication *app = calls_application_new ();
char *argv[] = { "test", "--daemon", "-p", "dummy", NULL };
char *argv[] = { "test", "--gapplication-service", "-p", "dummy", NULL };
int status;
g_idle_add (on_idle_quit, app);
@@ -135,10 +135,11 @@ main (int argc,
g_test_init (&argc, &argv, NULL);
g_test_add_func ("/Calls/application/shutdown_daemon", (GTestFunc) test_application_shutdown_daemon);
g_test_add_func ("/Calls/application/shutdown_no_daemon", (GTestFunc) test_application_shutdown_no_daemon);
g_test_add_func ("/Calls/application/shutdown_delayed", (GTestFunc) test_application_shutdown_delayed);
g_test_add_func ("/Calls/application/shutdown_sigterm", (GTestFunc) test_application_shutdown_sigterm);
/* Last test so we don't need to bother if --gpplication-service keeps us alive a bit longer */
g_test_add_func ("/Calls/application/shutdown_daemon", (GTestFunc) test_application_shutdown_daemon);
status = g_test_run ();