[epiphany] Remove the open new/in existing window flags and always create the new tab in the given window



commit 722721e1740fae0736d6b3af834c736f3e3a5d5b
Author: Carlos Garcia Campos <cgarcia igalia com>
Date:   Wed Feb 12 13:46:21 2014 +0100

    Remove the open new/in existing window flags and always create the new tab in the given window

 src/bookmarks/ephy-bookmarks-editor.c |   11 ++----
 src/ephy-history-window.c             |    6 +--
 src/ephy-navigation-history-action.c  |    6 ++--
 src/ephy-session.c                    |   16 ++++-----
 src/ephy-shell.c                      |   39 +++++++---------------
 src/ephy-shell.h                      |    9 +-----
 src/ephy-window.c                     |   30 +++++++----------
 src/popup-commands.c                  |    9 ++---
 src/window-commands.c                 |    7 ++--
 tests/ephy-shell-test.c               |   57 ++++++++++++++-------------------
 10 files changed, 75 insertions(+), 115 deletions(-)
---
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 560d1b1..76e31b5 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -316,8 +316,7 @@ cmd_open_bookmarks_in_tabs (GtkAction *action,
 
                new_embed = ephy_shell_new_tab (ephy_shell_get_default (),
                                                window, NULL, location,
-                                               EPHY_NEW_TAB_OPEN_PAGE |
-                                               EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+                                               EPHY_NEW_TAB_OPEN_PAGE);
                /* if there was no target window, a new one was opened. Get it
                 * from the new tab so we open the remaining links in the
                 * same window. See bug 138343.
@@ -340,7 +339,7 @@ cmd_open_bookmarks_in_browser (GtkAction *action,
        GList *selection;
        GList *l;
 
-       window = EPHY_WINDOW (get_target_window (editor));
+       window = ephy_window_new ();
        selection = ephy_node_view_get_selection (EPHY_NODE_VIEW (editor->priv->bm_view));
 
        for (l = selection; l; l = l->next)
@@ -353,8 +352,7 @@ cmd_open_bookmarks_in_browser (GtkAction *action,
 
                ephy_shell_new_tab (ephy_shell_get_default (),
                                    window, NULL, location,
-                                   EPHY_NEW_TAB_OPEN_PAGE |
-                                   EPHY_NEW_TAB_IN_NEW_WINDOW);
+                                   EPHY_NEW_TAB_OPEN_PAGE);
        }
 
        g_list_free (selection);
@@ -1067,8 +1065,7 @@ ephy_bookmarks_editor_node_middle_clicked_cb (GtkWidget *view,
 
        ephy_shell_new_tab (ephy_shell_get_default (),
                            window, NULL, location,
-                           EPHY_NEW_TAB_OPEN_PAGE |
-                           EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+                           EPHY_NEW_TAB_OPEN_PAGE);
 }
 
 static void
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index 979d439..ddc26f3 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -309,8 +309,7 @@ open_selected (EphyHistoryWindow *self)
                EphyHistoryURL *url = l->data;
                ephy_shell_new_tab (ephy_shell_get_default (),
                                    window, NULL, url->url,
-                                   EPHY_NEW_TAB_OPEN_PAGE |
-                                   EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+                                   EPHY_NEW_TAB_OPEN_PAGE);
        }
 
        g_list_free_full (selection, (GDestroyNotify) ephy_history_url_free);
@@ -430,8 +429,7 @@ on_treeview_row_activated (GtkTreeView *view,
 
        ephy_shell_new_tab (ephy_shell_get_default (),
                            window, NULL, url->url,
-                           EPHY_NEW_TAB_OPEN_PAGE |
-                           EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+                           EPHY_NEW_TAB_OPEN_PAGE);
        ephy_history_url_free (url);
 }
 
diff --git a/src/ephy-navigation-history-action.c b/src/ephy-navigation-history-action.c
index 9737e84..ca6fa15 100644
--- a/src/ephy-navigation-history-action.c
+++ b/src/ephy-navigation-history-action.c
@@ -116,7 +116,7 @@ action_activate (GtkAction *action)
                                   EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
                                   NULL,
                                   NULL,
-                                  EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+                                  0);
 
       web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
       webkit_web_view_load_uri (web_view, back_uri);
@@ -144,7 +144,7 @@ action_activate (GtkAction *action)
                                   EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
                                   embed,
                                   NULL,
-                                  EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+                                  0);
 
       web_view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
       webkit_web_view_load_uri (web_view, forward_uri);
@@ -328,7 +328,7 @@ middle_click_handle_on_history_menu_item (EphyNavigationHistoryAction *action,
                                   EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
                                   embed,
                                   NULL,
-                                  EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+                                  0);
   g_return_if_fail (new_embed != NULL);
 
   /* We manually set the back history instead of trusting
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 3fa8bc0..bcff252 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -248,8 +248,6 @@ ephy_session_undo_close_tab (EphySession *session)
        {
                GtkWidget *window;
 
-               flags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW;
-
                if (tab->position > 0)
                {
                        /* Append in the n-th position. */
@@ -273,9 +271,10 @@ ephy_session_undo_close_tab (EphySession *session)
        else
        {
                EphyNotebook *notebook;
-               flags |=  EPHY_NEW_TAB_IN_NEW_WINDOW;
+               EphyWindow *window = ephy_window_new ();
+
                new_tab = ephy_shell_new_tab (ephy_shell_get_default (),
-                                             NULL, NULL, tab->url, flags);
+                                             window, NULL, tab->url, flags);
 
                /* FIXME: This makes the assumption that the notebook
                   is the parent of the returned EphyEmbed. */
@@ -387,11 +386,12 @@ session_maybe_open_window (EphySession *session,
        /* FIXME: maybe just check for normal windows? */
        if (ephy_shell_get_n_windows (shell) == 0)
        {
+               EphyWindow *window = ephy_window_new ();
+
                ephy_shell_new_tab_full (shell,
                                         NULL /* related view */,
-                                        NULL /* window */, NULL /* tab */,
+                                        window, NULL /* tab */,
                                         NULL /* NetworkRequest */,
-                                        EPHY_NEW_TAB_IN_NEW_WINDOW |
                                         EPHY_NEW_TAB_HOME_PAGE,
                                         user_time);
        }
@@ -909,7 +909,6 @@ confirm_before_recover (EphyWindow *window, const char *url, const char *title)
 
        embed = ephy_shell_new_tab (ephy_shell_get_default (),
                                    window, NULL, NULL,
-                                   EPHY_NEW_TAB_IN_EXISTING_WINDOW |
                                    EPHY_NEW_TAB_APPEND_LAST);
 
        ephy_web_view_load_error_page (ephy_embed_get_web_view (embed), url,
@@ -1057,8 +1056,7 @@ session_parse_embed (SessionParserContext *context,
                delay_loading = g_settings_get_boolean (EPHY_SETTINGS_MAIN,
                                                        EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS);
 
-               flags = EPHY_NEW_TAB_IN_EXISTING_WINDOW;
-               flags |= EPHY_NEW_TAB_APPEND_LAST;
+               flags = EPHY_NEW_TAB_APPEND_LAST;
 
                if (delay_loading)
                {
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 7c4699c..71509be 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -646,7 +646,7 @@ ephy_shell_get_default (void)
 /**
  * ephy_shell_new_tab_full:
  * @shell: a #EphyShell
- * @parent_window: the target #EphyWindow or %NULL
+ * @window: the target #EphyWindow or %NULL
  * @previous_embed: the referrer embed, or %NULL
  * @request: a #WebKitNetworkRequest to load or %NULL
  * @user_time: a timestamp, or 0
@@ -659,16 +659,14 @@ ephy_shell_get_default (void)
 EphyEmbed *
 ephy_shell_new_tab_full (EphyShell *shell,
                          WebKitWebView *related_view,
-                         EphyWindow *parent_window,
+                         EphyWindow *window,
                          EphyEmbed *previous_embed,
                          WebKitURIRequest *request,
                          EphyNewTabFlags flags,
                          guint32 user_time)
 {
   EphyEmbedShell *embed_shell;
-  EphyWindow *window;
   EphyEmbed *embed = NULL;
-  gboolean in_new_window = TRUE;
   gboolean open_page = FALSE;
   gboolean delayed_open_page = FALSE;
   gboolean jump_to = FALSE;
@@ -677,7 +675,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
   int position = -1;
 
   g_return_val_if_fail (EPHY_IS_SHELL (shell), NULL);
-  g_return_val_if_fail (EPHY_IS_WINDOW (parent_window) || !parent_window, NULL);
+  g_return_val_if_fail (EPHY_IS_WINDOW (window), NULL);
   g_return_val_if_fail (EPHY_IS_EMBED (previous_embed) || !previous_embed, NULL);
   g_return_val_if_fail (WEBKIT_IS_URI_REQUEST (request) || !request, NULL);
 
@@ -685,19 +683,12 @@ ephy_shell_new_tab_full (EphyShell *shell,
 
   if (flags & EPHY_NEW_TAB_OPEN_PAGE) open_page = TRUE;
   if (flags & EPHY_NEW_TAB_DELAYED_OPEN_PAGE) delayed_open_page = TRUE;
-  if (flags & EPHY_NEW_TAB_IN_NEW_WINDOW) in_new_window = TRUE;
-  if (flags & EPHY_NEW_TAB_IN_EXISTING_WINDOW) in_new_window = FALSE;
   if (flags & EPHY_NEW_TAB_JUMP) jump_to = TRUE;
 
   g_return_val_if_fail ((open_page || delayed_open_page) == (gboolean)(request != NULL), NULL);
 
-  LOG ("Opening new tab parent-window %p parent-embed %p in-new-window:%s jump-to:%s",
-       parent_window, previous_embed, in_new_window ? "t" : "f", jump_to ? "t" : "f");
-
-  if (!in_new_window && parent_window != NULL)
-    window = parent_window;
-  else
-    window = ephy_window_new ();
+  LOG ("Opening new tab window %p parent-embed %p jump-to:%s",
+       window, previous_embed, jump_to ? "t" : "f");
 
   if (flags & EPHY_NEW_TAB_APPEND_AFTER) {
     if (previous_embed) {
@@ -768,7 +759,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
   /* Make sure the initial focus is somewhere sensible and not, for
    * example, on the reload button.
    */
-  if (in_new_window || jump_to) {
+  if (jump_to) {
     /* If the location entry is blank, focus that, except if the
      * page was a copy */
     if (is_empty) {
@@ -1070,8 +1061,6 @@ open_uris_data_new (EphyShell *shell,
   data->uris = g_strdupv ((char **)uris);
   data->user_time = user_time;
 
-  data->window = ephy_shell_get_main_window (shell);
-
   new_windows_in_tabs = g_settings_get_boolean (EPHY_SETTINGS_MAIN,
                                                 EPHY_PREFS_NEW_WINDOWS_IN_TABS);
   fullscreen_lockdown = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
@@ -1079,17 +1068,13 @@ open_uris_data_new (EphyShell *shell,
 
   have_uris = ! (g_strv_length ((char **)uris) == 1 && g_str_equal (uris[0], ""));
 
-  if (startup_flags & EPHY_STARTUP_NEW_TAB)
-    data->flags |= EPHY_NEW_TAB_FROM_EXTERNAL;
-
   if (startup_flags & EPHY_STARTUP_NEW_WINDOW && !fullscreen_lockdown) {
-    data->window = NULL;
-    data->flags |= EPHY_NEW_TAB_IN_NEW_WINDOW;
+    data->window = ephy_window_new ();
   } else if (startup_flags & EPHY_STARTUP_NEW_TAB || (new_windows_in_tabs && have_uris)) {
-    data->flags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW | EPHY_NEW_TAB_JUMP | EPHY_NEW_TAB_PRESENT_WINDOW | 
EPHY_NEW_TAB_FROM_EXTERNAL;
+    data->flags |= EPHY_NEW_TAB_JUMP | EPHY_NEW_TAB_PRESENT_WINDOW | EPHY_NEW_TAB_FROM_EXTERNAL;
+    data->window = ephy_shell_get_main_window (shell);
   } else if (!have_uris) {
-    data->window = NULL;
-    data->flags |= EPHY_NEW_TAB_IN_NEW_WINDOW;
+    data->window = ephy_window_new ();
   }
 
   g_application_hold (G_APPLICATION (shell));
@@ -1125,6 +1110,9 @@ ephy_shell_open_uris_idle (OpenURIsData *data)
     request = webkit_uri_request_new (url);
   }
 
+  if (!data->window)
+    data->window = ephy_window_new ();
+
   embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
                                    NULL,
                                    data->window,
@@ -1136,7 +1124,6 @@ ephy_shell_open_uris_idle (OpenURIsData *data)
   if (request)
     g_object_unref (request);
 
-  data->window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed)));
   data->current_uri++;
   data->previous_embed = embed;
 
diff --git a/src/ephy-shell.h b/src/ephy-shell.h
index 5a80bbd..c20703d 100644
--- a/src/ephy-shell.h
+++ b/src/ephy-shell.h
@@ -66,9 +66,6 @@ typedef struct _EphyShellPrivate  EphyShellPrivate;
  * @EPHY_NEW_TAB_APPEND_AFTER: appends the new tab right after the
  *        current one in the notebook.
  * @EPHY_NEW_TAB_JUMP: jumps to the new tab immediately.
- * @EPHY_NEW_TAB_IN_NEW_WINDOW: creates the new tab in a new window.
- * @EPHY_NEW_TAB_IN_EXISTING_WINDOW: creates the new tab in the current
- *        active window, if there is none, creates a window.
  * @EPHY_NEW_TAB_FROM_EXTERNAL: tries to open the new tab in the current
  *        active tab if it is currently not loading anything and is
  *        blank.
@@ -94,12 +91,8 @@ typedef enum {
   EPHY_NEW_TAB_APPEND_AFTER = 1 << 9,
   EPHY_NEW_TAB_JUMP   = 1 << 10,
 
-  /* Where */
-  EPHY_NEW_TAB_IN_NEW_WINDOW  = 1 << 11,
-  EPHY_NEW_TAB_IN_EXISTING_WINDOW = 1 << 12,
-
   /* The way to load */
-  EPHY_NEW_TAB_FROM_EXTERNAL      = 1 << 13,
+  EPHY_NEW_TAB_FROM_EXTERNAL      = 1 << 11,
 } EphyNewTabFlags;
 
 typedef enum {
diff --git a/src/ephy-window.c b/src/ephy-window.c
index a7c8c1d..2ac9230 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -548,6 +548,7 @@ ephy_window_open_link (EphyLink *link,
                      EPHY_LINK_NEW_WINDOW))
        {
                EphyNewTabFlags ntflags = EPHY_NEW_TAB_OPEN_PAGE;
+               EphyWindow *target_window = EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed)));
 
                if (flags & EPHY_LINK_JUMP_TO)
                {
@@ -556,11 +557,7 @@ ephy_window_open_link (EphyLink *link,
                if (flags & EPHY_LINK_NEW_WINDOW ||
                    (flags & EPHY_LINK_NEW_TAB && priv->is_popup))
                {
-                       ntflags |= EPHY_NEW_TAB_IN_NEW_WINDOW;
-               }
-               else
-               {
-                       ntflags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW;
+                       target_window = ephy_window_new ();
                }
 
                if (flags & EPHY_LINK_NEW_TAB_APPEND_AFTER)
@@ -573,7 +570,7 @@ ephy_window_open_link (EphyLink *link,
 
                new_embed = ephy_shell_new_tab
                                (ephy_shell_get_default (),
-                                EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
+                                target_window,
                                 embed, address, ntflags);
        }
        else
@@ -2023,28 +2020,26 @@ create_web_view_cb (WebKitWebView *web_view,
        EphyEmbed *embed;
        WebKitWebView *new_web_view;
        EphyNewTabFlags flags;
-       EphyWindow *parent_window;
+       EphyWindow *target_window;
 
        if (g_settings_get_boolean (EPHY_SETTINGS_MAIN,
                                    EPHY_PREFS_NEW_WINDOWS_IN_TABS) ||
            g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
                                    EPHY_PREFS_LOCKDOWN_FULLSCREEN))
        {
-               parent_window = window;
-               flags = EPHY_NEW_TAB_IN_EXISTING_WINDOW |
-                       EPHY_NEW_TAB_JUMP |
+               target_window = window;
+               flags = EPHY_NEW_TAB_JUMP |
                        EPHY_NEW_TAB_APPEND_AFTER;
        }
        else
        {
-               parent_window = NULL;
-               flags = EPHY_NEW_TAB_IN_NEW_WINDOW |
-                       EPHY_NEW_TAB_DONT_SHOW_WINDOW;
+               target_window = ephy_window_new ();
+               flags = EPHY_NEW_TAB_DONT_SHOW_WINDOW;
        }
 
        embed = ephy_shell_new_tab_full (ephy_shell_get_default (),
                                         web_view,
-                                        parent_window,
+                                        target_window,
                                         EPHY_GET_EMBED_FROM_EPHY_WEB_VIEW (web_view),
                                         NULL,
                                         flags,
@@ -2168,6 +2163,7 @@ decide_policy_cb (WebKitWebView *web_view,
                gint button;
                gint state;
                EphyNewTabFlags flags;
+               EphyWindow *target_window = window;
 
                button = webkit_navigation_policy_decision_get_mouse_button (navigation_decision);
                state = webkit_navigation_policy_decision_get_modifiers (navigation_decision);
@@ -2181,13 +2177,13 @@ decide_policy_cb (WebKitWebView *web_view,
                    !g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
                                             EPHY_PREFS_LOCKDOWN_FULLSCREEN))
                {
-                       flags |= EPHY_NEW_TAB_IN_NEW_WINDOW;
+                       target_window = ephy_window_new ();
                }
                /* New tab in existing window for middle click and
                 * control+click */
                else if (button == 2 || (button == 1 && state == GDK_CONTROL_MASK))
                {
-                       flags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW | EPHY_NEW_TAB_APPEND_AFTER;
+                       flags |= EPHY_NEW_TAB_APPEND_AFTER;
                }
                /* Because we connect to button-press-event *after*
                 * (G_CONNECT_AFTER) we need to prevent WebKit from browsing to
@@ -2211,7 +2207,7 @@ decide_policy_cb (WebKitWebView *web_view,
 
                ephy_shell_new_tab_full (ephy_shell_get_default (),
                                         NULL,
-                                        window,
+                                        target_window,
                                         embed,
                                         request,
                                         flags,
diff --git a/src/popup-commands.c b/src/popup-commands.c
index 10c3d44..861a70d 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -42,6 +42,7 @@ void
 popup_cmd_link_in_new_window (GtkAction *action,
                              EphyWindow *window)
 {
+       EphyWindow *new_window;
        EphyEmbedEvent *event;
        EphyEmbed *embed;
        GValue value = { 0, };
@@ -52,13 +53,13 @@ popup_cmd_link_in_new_window (GtkAction *action,
        event = ephy_window_get_context_event (window);
        g_return_if_fail (event != NULL);
 
+       new_window = ephy_window_new ();
        ephy_embed_event_get_property (event, "link-uri", &value);
 
        ephy_shell_new_tab (ephy_shell_get_default (),
-                           NULL, embed,
+                           new_window, embed,
                            g_value_get_string (&value),
-                           EPHY_NEW_TAB_OPEN_PAGE |
-                           EPHY_NEW_TAB_IN_NEW_WINDOW);
+                           EPHY_NEW_TAB_OPEN_PAGE);
        g_value_unset (&value);
 }
 
@@ -82,7 +83,6 @@ popup_cmd_link_in_new_tab (GtkAction *action,
                            window, embed,
                            g_value_get_string (&value),
                            EPHY_NEW_TAB_OPEN_PAGE |
-                           EPHY_NEW_TAB_IN_EXISTING_WINDOW |
                            EPHY_NEW_TAB_APPEND_AFTER);
        g_value_unset (&value);
 }
@@ -325,7 +325,6 @@ popup_cmd_view_image_in_new_tab (GtkAction *action,
                            window, embed,
                            g_value_get_string (&value),
                            EPHY_NEW_TAB_OPEN_PAGE |
-                           EPHY_NEW_TAB_IN_EXISTING_WINDOW |
                            EPHY_NEW_TAB_APPEND_AFTER);
        g_value_unset (&value);
 }
diff --git a/src/window-commands.c b/src/window-commands.c
index 50db305..62233fa 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -906,9 +906,10 @@ void
 window_cmd_file_new_window (GtkAction *action,
                            EphyWindow *window)
 {
+       EphyWindow *new_window = ephy_window_new ();
+
        ephy_shell_new_tab (ephy_shell_get_default (),
-                           NULL, NULL, NULL,
-                           EPHY_NEW_TAB_IN_NEW_WINDOW |
+                           NULL, new_window, NULL,
                            EPHY_NEW_TAB_HOME_PAGE);
 }
 
@@ -1190,7 +1191,7 @@ view_source_embedded (const char *uri, EphyEmbed *embed)
                         EPHY_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))),
                         embed,
                         NULL,
-                        EPHY_NEW_TAB_JUMP | EPHY_NEW_TAB_IN_EXISTING_WINDOW | EPHY_NEW_TAB_APPEND_AFTER);
+                        EPHY_NEW_TAB_JUMP | EPHY_NEW_TAB_APPEND_AFTER);
 
        webkit_web_view_set_view_mode
                (EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (new_embed), WEBKIT_VIEW_MODE_SOURCE);
diff --git a/tests/ephy-shell-test.c b/tests/ephy-shell-test.c
index 6d68810..079a47f 100644
--- a/tests/ephy-shell-test.c
+++ b/tests/ephy-shell-test.c
@@ -42,7 +42,7 @@ static void
 test_ephy_shell_basic_embeds (void)
 {
   EphyShell *ephy_shell;
-  GtkWidget *window;
+  EphyWindow *window;
 
   EphyEmbed *embed1;
   EphyEmbed *embed2;
@@ -51,32 +51,34 @@ test_ephy_shell_basic_embeds (void)
 
   ephy_shell = ephy_shell_get_default ();
 
-  /* Both embed and window should be created. */
+  window = ephy_window_new ();
+  g_assert (EPHY_IS_WINDOW (window));
+
+  /* Embed should be created. */
   embed1 = ephy_shell_new_tab_full
                   (ephy_shell,
                    NULL, /* related view */
-                   NULL, /* window */
+                   window,
                    NULL, /* embed */
                    NULL, /* network-request */
-                   EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_IN_NEW_WINDOW, /* flags */
+                   EPHY_NEW_TAB_DONT_SHOW_WINDOW, /* flags */
                    gtk_get_current_event_time ());
   g_assert (EPHY_IS_EMBED (embed1));
 
-  window = gtk_widget_get_toplevel (GTK_WIDGET (embed1));
-  g_assert (EPHY_IS_WINDOW (window));
+  g_assert (gtk_widget_get_toplevel (GTK_WIDGET (embed1)) == GTK_WIDGET (window));
 
   children = ephy_embed_container_get_children (EPHY_EMBED_CONTAINER (window));
   g_assert_cmpint (g_list_length (children), ==, 1);
   g_list_free (children);
 
-  /* Only the embed should be created */
+  /* Another embed should be created */
   embed2 = ephy_shell_new_tab_full
                   (ephy_shell,
                    NULL, /* related view */
-                   EPHY_WINDOW (window), /* window */
+                   window, /* window */
                    NULL, /* embed */
                    NULL, /* network-request */
-                   EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_IN_EXISTING_WINDOW, /* flags */
+                   EPHY_NEW_TAB_DONT_SHOW_WINDOW, /* flags */
                    gtk_get_current_event_time ());
   g_assert (EPHY_IS_EMBED (embed2));
 
@@ -85,7 +87,7 @@ test_ephy_shell_basic_embeds (void)
   g_assert_cmpint (g_list_length (children), ==, 2);
   g_list_free (children);
 
-  gtk_widget_destroy (window);
+  gtk_widget_destroy (GTK_WIDGET (window));
 }
 
 static void
@@ -102,32 +104,21 @@ test_ephy_shell_parent_windows (void)
   /* parent-window provided */
   embed = ephy_shell_new_tab
                   (ephy_shell, EPHY_WINDOW (window), NULL, NULL,
-                   EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+                   EPHY_NEW_TAB_DONT_SHOW_WINDOW);
 
   g_assert (EPHY_IS_EMBED (embed));
   g_assert (gtk_widget_get_toplevel (GTK_WIDGET (embed)) == window);
   g_object_ref_sink (embed);
   g_object_unref (embed);
 
-  /* parent-window not provided, new-window not requested */
+  /* Another new-window */
+  window2 = GTK_WIDGET (ephy_window_new ());
   embed = ephy_shell_new_tab
-                  (ephy_shell, NULL, NULL, NULL,
-                   EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_IN_EXISTING_WINDOW);
-
-  g_assert (EPHY_IS_EMBED (embed));
-  g_assert (EPHY_IS_WINDOW (gtk_widget_get_toplevel (GTK_WIDGET (embed))));
-  g_object_ref_sink (embed);
-  g_object_unref (embed);
-
-  /* parent-window provided, but asking for a new-window */
-  embed = ephy_shell_new_tab
-                  (ephy_shell, EPHY_WINDOW (window), NULL, NULL,
-                   EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_IN_NEW_WINDOW);
+                  (ephy_shell, EPHY_WINDOW (window2), NULL, NULL,
+                   EPHY_NEW_TAB_DONT_SHOW_WINDOW);
 
   /* The parent window should be a completely new one. */
   g_assert (EPHY_IS_EMBED (embed));
-  window2 = gtk_widget_get_toplevel (GTK_WIDGET (embed));
-  g_assert (EPHY_IS_WINDOW (window2));
   g_assert (gtk_widget_get_toplevel (GTK_WIDGET (embed)) != window);
   g_assert (gtk_widget_get_toplevel (GTK_WIDGET (embed)) == window2);
 
@@ -151,7 +142,7 @@ test_ephy_shell_tab_load (void)
 
   /* homepage is "about:blank" for now, see embed/ephy-web-view.c */
   embed = ephy_shell_new_tab
-                  (ephy_shell, NULL, NULL, NULL,
+                  (ephy_shell, EPHY_WINDOW (window), NULL, NULL,
                    EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_HOME_PAGE);
 
   g_assert (EPHY_IS_EMBED (embed));
@@ -169,7 +160,7 @@ test_ephy_shell_tab_load (void)
 
   /* open-page "about:epiphany" for testing. */
   embed = ephy_shell_new_tab
-                  (ephy_shell, NULL, NULL, "about:epiphany",
+                  (ephy_shell, EPHY_WINDOW (window), NULL, "about:epiphany",
                    EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_OPEN_PAGE);
 
   g_assert (EPHY_IS_EMBED (embed));
@@ -205,29 +196,29 @@ test_ephy_shell_tab_append (void)
   notebook = ephy_window_get_notebook (EPHY_WINDOW (window));
 
   embed1 = ephy_shell_new_tab (ephy_shell, EPHY_WINDOW (window), NULL, NULL,
-                               EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+                               EPHY_NEW_TAB_DONT_SHOW_WINDOW);
   g_assert_cmpint (get_notebook_page_num (notebook, embed1), ==, 0);
 
   embed2 = ephy_shell_new_tab (ephy_shell, EPHY_WINDOW (window), embed1, NULL,
-                               EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_IN_EXISTING_WINDOW);
+                               EPHY_NEW_TAB_DONT_SHOW_WINDOW);
   g_assert_cmpint (get_notebook_page_num (notebook, embed1), ==, 0);
   g_assert_cmpint (get_notebook_page_num (notebook, embed2), ==, 1);
 
   embed3 = ephy_shell_new_tab (ephy_shell, EPHY_WINDOW (window), embed1, NULL,
-                               EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_IN_EXISTING_WINDOW | 
EPHY_NEW_TAB_APPEND_AFTER);
+                               EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_APPEND_AFTER);
   g_assert_cmpint (get_notebook_page_num (notebook, embed1), ==, 0);
   g_assert_cmpint (get_notebook_page_num (notebook, embed3), ==, 1);
   g_assert_cmpint (get_notebook_page_num (notebook, embed2), ==, 2);
 
   embed4 = ephy_shell_new_tab (ephy_shell, EPHY_WINDOW (window), embed1, NULL,
-                               EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_IN_EXISTING_WINDOW | 
EPHY_NEW_TAB_APPEND_LAST);
+                               EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_APPEND_LAST);
   g_assert_cmpint (get_notebook_page_num (notebook, embed1), ==, 0);
   g_assert_cmpint (get_notebook_page_num (notebook, embed3), ==, 1);
   g_assert_cmpint (get_notebook_page_num (notebook, embed2), ==, 2);
   g_assert_cmpint (get_notebook_page_num (notebook, embed4), ==, 3);
 
   embed5 = ephy_shell_new_tab (ephy_shell, EPHY_WINDOW (window), embed3, NULL,
-                               EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_IN_EXISTING_WINDOW | 
EPHY_NEW_TAB_APPEND_AFTER);
+                               EPHY_NEW_TAB_DONT_SHOW_WINDOW | EPHY_NEW_TAB_APPEND_AFTER);
   g_assert_cmpint (get_notebook_page_num (notebook, embed1), ==, 0);
   g_assert_cmpint (get_notebook_page_num (notebook, embed3), ==, 1);
   g_assert_cmpint (get_notebook_page_num (notebook, embed5), ==, 2);


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