From dc0242eda54123c90726056ff69a3f4cb199309a Mon Sep 17 00:00:00 2001 From: Julian Sparber Date: Wed, 20 Jan 2021 16:58:42 +0100 Subject: [PATCH] application: disable dial action when making calls isn't possible Fixes: https://source.puri.sm/Librem5/calls/-/issues/109 --- src/calls-application.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/calls-application.c b/src/calls-application.c index 7266c75..d4fa042 100644 --- a/src/calls-application.c +++ b/src/calls-application.c @@ -281,6 +281,15 @@ copy_number (GSimpleAction *action, g_debug ("Copied `%s' to clipboard", number); } +static void +manager_state_changed_cb (GApplication *application) +{ + GAction* dial_action = g_action_map_lookup_action (G_ACTION_MAP (application), "dial"); + CallsManagerState state = calls_manager_get_state (calls_manager_get_default ()); + + g_simple_action_set_enabled (G_SIMPLE_ACTION (dial_action), state == CALLS_MANAGER_STATE_READY); +} + static const GActionEntry actions[] = { { "set-provider-name", set_provider_name_action, "s" }, @@ -317,6 +326,13 @@ startup (GApplication *application) G_N_ELEMENTS (actions), application); + g_signal_connect_swapped (calls_manager_get_default (), + "notify::state", + G_CALLBACK (manager_state_changed_cb), + application); + + manager_state_changed_cb (application); + provider = gtk_css_provider_new (); gtk_css_provider_load_from_resource (provider, "/sm/puri/calls/style.css"); gtk_style_context_add_provider_for_screen (gdk_screen_get_default (),