Commit a250f0f7 authored by Sébastien Blin's avatar Sébastien Blin

mainwindow: alert user if minimizing in systray with calls

When the user click on close when systray is enabled, the app will
only be minimized, not closed. So the call will continue to turn in
background. This means that the camera will be still visible to the
peer. This patches had a dialog to warn the user about that.

Change-Id: Ib5afe0415156aa5d7d29ee66acec89865e59e73d
Gitlab: #1000
parent a783592d
......@@ -222,8 +222,11 @@ on_close_window(GtkWidget *window, G_GNUC_UNUSED GdkEvent *event, RingClient *cl
if (g_settings_get_boolean(priv->settings, "show-status-icon")) {
/* we want to simply hide the window and keep the client running */
ring_window_hide(client);
ring_main_window_reset(RING_MAIN_WINDOW(window));
auto closeWindow = ring_main_window_can_close(RING_MAIN_WINDOW(window));
if (closeWindow) {
ring_window_hide(client);
ring_main_window_reset(RING_MAIN_WINDOW(window));
}
return TRUE; /* do not propagate event */
} else {
/* we want to quit the application, so just propagate the event */
......
......@@ -2242,6 +2242,32 @@ ring_main_window_reset(RingMainWindow* self)
priv->cpp->leaveSettingsView();
}
bool
ring_main_window_can_close(RingMainWindow* self)
{
g_return_val_if_fail(IS_RING_MAIN_WINDOW(self), true);
auto* priv = RING_MAIN_WINDOW_GET_PRIVATE(RING_MAIN_WINDOW(self));
if (priv->cpp && (priv->cpp->activeCalls > 0)) {
auto* close_dialog = gtk_message_dialog_new(GTK_WINDOW(self),
GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_QUESTION, GTK_BUTTONS_OK_CANCEL,
_("A call is currently ongoing. Do you want to close the window and stop all current calls?"));
gtk_window_set_title(GTK_WINDOW(close_dialog), _("Stop current call?"));
gtk_dialog_set_default_response(GTK_DIALOG(close_dialog), GTK_RESPONSE_CANCEL);
gtk_widget_show_all(close_dialog);
auto res = gtk_dialog_run(GTK_DIALOG(close_dialog));
gtk_widget_destroy(close_dialog);
if (res == GTK_RESPONSE_OK) {
lrc::api::NewCallModel::hangupCallsAndConferences();
return true;
} else {
return false;
}
}
return true;
}
//==============================================================================
static void
......
......@@ -38,6 +38,7 @@ typedef struct _RingMainWindowClass RingMainWindowClass;
GType ring_main_window_get_type (void) G_GNUC_CONST;
GtkWidget *ring_main_window_new (GtkApplication *app);
void ring_main_window_reset (RingMainWindow *win);
bool ring_main_window_can_close(RingMainWindow *win);
G_END_DECLS
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment