[epiphany] Warn user when closing a multitabbed window



commit 689bd1f67c3c5aa08e2e4ec1fda7453f5337c794
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Sun Apr 21 00:18:49 2019 +0200

    Warn user when closing a multitabbed window
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/276

 src/ephy-window.c | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
---
diff --git a/src/ephy-window.c b/src/ephy-window.c
index e61a21d87..50328ffc1 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -290,6 +290,23 @@ confirm_close_with_downloads (EphyWindow *window)
   return response == GTK_RESPONSE_ACCEPT;
 }
 
+static gboolean
+confirm_close_with_multiple_tabs (EphyWindow *window)
+{
+  GtkWidget *dialog;
+  int response;
+
+  dialog = construct_confirm_close_dialog (window,
+                                           _("There are multiple tabs open."),
+                                           _("If you close this window, all open tabs will be lost"),
+                                           _("C_lose tabs"));
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  gtk_widget_destroy (dialog);
+
+  return response == GTK_RESPONSE_ACCEPT;
+}
+
 static void
 impl_remove_child (EphyEmbedContainer *container,
                    EphyEmbed          *child)
@@ -4129,11 +4146,19 @@ ephy_window_close (EphyWindow *window)
       g_settings_get_boolean (EPHY_SETTINGS_MAIN,
                               EPHY_PREFS_WARN_ON_CLOSE_UNSUBMITTED_DATA) &&
       gtk_notebook_get_n_pages (window->notebook) > 0) {
+
     ephy_window_check_modified_forms (window);
     /* stop window close */
     return FALSE;
   }
 
+  if (ephy_shell_get_n_windows (ephy_shell_get_default ()) > 1 &&
+      gtk_notebook_get_n_pages (window->notebook) > 1 &&
+      !confirm_close_with_multiple_tabs (window)) {
+      /* stop window close */
+      return FALSE;
+  }
+
   /* If this is the last window, check ongoing downloads and save its state in the session. */
   if (ephy_shell_get_n_windows (ephy_shell_get_default ()) == 1) {
     EphyDownloadsManager *manager = ephy_embed_shell_get_downloads_manager (EPHY_EMBED_SHELL 
(ephy_shell_get_default ()));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]