[epiphany] Do not open an additional empty window when ephy is launched in private mode with arguments



commit 4d89990c17c398cda445caf156c0497f962299c3
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Sun Jan 26 16:08:57 2014 +0100

    Do not open an additional empty window when ephy is launched in private mode with arguments
    
    When the session is resumed in private mode, a new empty window is
    always shown. The shell should reuse that empty window for the first
    argument, and open new tabs for the rest of the aguments.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=723022

 src/ephy-main.c  |   10 +++++++---
 src/ephy-shell.c |    8 ++++++--
 2 files changed, 13 insertions(+), 5 deletions(-)
---
diff --git a/src/ephy-main.c b/src/ephy-main.c
index 1f9af3e..d10f4c5 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -425,10 +425,15 @@ main (int argc,
     exit (0);
   }
 
+  startup_flags = get_startup_flags ();
+
   /* Now create the shell */
-  if (private_instance)
+  if (private_instance) {
     mode = EPHY_EMBED_SHELL_MODE_PRIVATE;
-  else if (incognito_mode) {
+    /* In private mode the session autoresume will always open an empty window.
+     * If there are arguments, we want the URIs to be opened in thet existing window. */
+    startup_flags |= EPHY_STARTUP_NEW_TAB;
+  } else if (incognito_mode) {
     mode = EPHY_EMBED_SHELL_MODE_INCOGNITO;
   } else if (application_mode) {
     char *app_name;
@@ -471,7 +476,6 @@ main (int argc,
 
   _ephy_shell_create_instance (mode);
 
-  startup_flags = get_startup_flags ();
   ctx = ephy_shell_startup_context_new (startup_flags,
                                         bookmarks_file,
                                         session_filename,
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index a84a7ac..2392c02 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -717,7 +717,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
   if (flags & EPHY_NEW_TAB_FIRST)
     position = 0;
 
-  if (flags & EPHY_NEW_TAB_FROM_EXTERNAL) {
+  if (flags & EPHY_NEW_TAB_FROM_EXTERNAL && position == -1) {
     /* If the active embed is blank, use that to open the url and jump to it */
     embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
     if (embed != NULL) {
@@ -1046,6 +1046,7 @@ typedef struct {
   char **uris;
   EphyNewTabFlags flags;
   guint32 user_time;
+  EphyEmbed *previous_embed;
   guint current_uri;
 } OpenURIsData;
 
@@ -1113,12 +1114,14 @@ ephy_shell_open_uris_idle (OpenURIsData *data)
     page_flags = EPHY_NEW_TAB_HOME_PAGE;
   } else {
     page_flags = EPHY_NEW_TAB_OPEN_PAGE;
+    if (data->previous_embed)
+      page_flags |= EPHY_NEW_TAB_APPEND_AFTER;
     request = webkit_uri_request_new (url);
   }
 
   embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
                                    data->window,
-                                   NULL /* parent tab */,
+                                   data->previous_embed,
                                    request,
                                    data->flags | page_flags,
                                    EPHY_WEB_VIEW_CHROME_ALL,
@@ -1130,6 +1133,7 @@ ephy_shell_open_uris_idle (OpenURIsData *data)
 
   data->window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed)));
   data->current_uri++;
+  data->previous_embed = embed;
 
   return data->uris[data->current_uri] != NULL;
 }


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