From 5bdfb0e2232b2f127c49ebb79f835e23560838e7 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Tue, 12 Jan 2021 01:27:45 +0100 Subject: [PATCH] application: Hang up calls when closing the UI --- src/calls-application.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/calls-application.c b/src/calls-application.c index 716b767..25bb960 100644 --- a/src/calls-application.c +++ b/src/calls-application.c @@ -328,6 +328,22 @@ startup (GApplication *application) } +static void +notify_window_visible_cb (GtkWidget *window, + GParamSpec *pspec, + CallsApplication *application) +{ + CallsManager *manager = calls_manager_get_default (); + + g_return_if_fail (CALLS_IS_APPLICATION (application)); + g_return_if_fail (CALLS_IS_CALL_WINDOW (window)); + + /* The UI is being closed, hang up active calls */ + if (!gtk_widget_is_visible (window)) + calls_manager_hang_up_all_calls (manager); +} + + static gboolean start_proper (CallsApplication *self) { @@ -360,6 +376,11 @@ start_proper (CallsApplication *self) self->call_window = calls_call_window_new (gtk_app); g_assert (self->call_window != NULL); + g_signal_connect (self->call_window, + "notify::visible", + G_CALLBACK (notify_window_visible_cb), + self); + return TRUE; }