[epiphany] Keep window open when closing the last non overview tab



commit 4109ff117f4adee8fcea5c4fd33e6e1fbdc19ac5
Author: Jan-Michael Brummer <jan brummer tabos org>
Date:   Wed Dec 19 14:31:10 2018 +0100

    Keep window open when closing the last non overview tab
    
    Fixes: https://gitlab.gnome.org/GNOME/epiphany/issues/80

 data/org.gnome.epiphany.gschema.xml |  5 +++++
 lib/ephy-prefs.h                    |  1 +
 src/ephy-window.c                   | 15 ++++++++++++++-
 3 files changed, 20 insertions(+), 1 deletion(-)
---
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index a22939bfb..531b7dd3b 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -118,6 +118,11 @@
                        <summary>The visibility policy for the tabs  bar.</summary>
                        <description>Controls when the tabs bar is shown. Possible values are “always” (the 
tabs bar is always shown), “more-than-one” (the tabs bar is only shown if there’s two or more tabs) and 
“never” (the tabs bar is never shown).</description>
                </key>
+               <key type="b" name="keep-window-open">
+                       <default>false</default>
+                       <summary>Keep window open when closing last tab</summary>
+                       <description>If enabled application window is kept open when closing the last 
tab.</description>
+               </key>
        </schema>
        <schema path="/org/gnome/epiphany/reader/" id="org.gnome.Epiphany.reader">
                <key name="font-style" enum="org.gnome.Epiphany.EphyPrefsReaderFontStyle">
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index f18fd0c58..0d84496e0 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -74,6 +74,7 @@ typedef enum
 #define EPHY_PREFS_UI_EXPAND_TABS_BAR            "expand-tabs-bar"
 #define EPHY_PREFS_UI_TABS_BAR_POSITION          "tabs-bar-position"
 #define EPHY_PREFS_UI_TABS_BAR_VISIBILITY_POLICY "tabs-bar-visibility-policy"
+#define EPHY_PREFS_UI_KEEP_WINDOW_OPEN           "keep-window-open"
 
 #define EPHY_PREFS_READER_SCHEMA                 "org.gnome.Epiphany.reader"
 #define EPHY_PREFS_READER_FONT_STYLE             "font-style"
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 22fe0b064..483c1f1fd 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -2676,6 +2676,8 @@ static void
 ephy_window_close_tab (EphyWindow *window,
                        EphyEmbed  *tab)
 {
+  gboolean keep_window_open;
+
   /* This function can be called many times for the same embed if the
    * web process (or network process) has hung. E.g. the user could
    * click the close button several times. This is difficult to guard
@@ -2697,6 +2699,17 @@ ephy_window_close_tab (EphyWindow *window,
   if (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (tab), "ephy-window-close-tab-closed")))
     return;
 
+  keep_window_open = g_settings_get_boolean (EPHY_SETTINGS_UI, EPHY_PREFS_UI_KEEP_WINDOW_OPEN);
+
+  if (keep_window_open && gtk_notebook_get_n_pages (window->notebook) == 1) {
+    EphyWebView *view = ephy_embed_get_web_view (tab);
+
+    if (ephy_web_view_get_is_blank (view) || ephy_web_view_is_overview (view))
+      return;
+
+    ephy_link_open (EPHY_LINK (window), NULL, NULL, EPHY_LINK_NEW_TAB);
+  }
+
   g_object_set_data (G_OBJECT (tab), "ephy-window-close-tab-closed", GINT_TO_POINTER (TRUE));
   gtk_widget_destroy (GTK_WIDGET (tab));
 
@@ -2706,7 +2719,7 @@ ephy_window_close_tab (EphyWindow *window,
    * tab, even if it wasn't at the start of this function.
    */
   if (!window->closing && gtk_notebook_get_n_pages (window->notebook) == 0)
-   gtk_widget_destroy (GTK_WIDGET (window));
+    gtk_widget_destroy (GTK_WIDGET (window));
 }
 
 typedef struct {


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