aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGustavo Noronha Silva <gns@gnome.org>2012-12-11 01:13:27 +0800
committerGustavo Noronha Silva <gns@gnome.org>2012-12-11 20:34:37 +0800
commitb7f88ee85c61fee4f8059e7fc2456c3ca83ccb64 (patch)
treef1047567ac13933d429f948cb18509fa543849f7
parentc968c68cabc319896ad4d2096940c9a34d4c13cd (diff)
downloadgsoc2013-epiphany-b7f88ee85c61fee4f8059e7fc2456c3ca83ccb64.tar
gsoc2013-epiphany-b7f88ee85c61fee4f8059e7fc2456c3ca83ccb64.tar.gz
gsoc2013-epiphany-b7f88ee85c61fee4f8059e7fc2456c3ca83ccb64.tar.bz2
gsoc2013-epiphany-b7f88ee85c61fee4f8059e7fc2456c3ca83ccb64.tar.lz
gsoc2013-epiphany-b7f88ee85c61fee4f8059e7fc2456c3ca83ccb64.tar.xz
gsoc2013-epiphany-b7f88ee85c61fee4f8059e7fc2456c3ca83ccb64.tar.zst
gsoc2013-epiphany-b7f88ee85c61fee4f8059e7fc2456c3ca83ccb64.zip
Open new windows when called with no URIs to open
GNOME Shell tries to open new windows by calling the application with no parameters. This strategy is also used by the 'Launch web browser' keybinding, that can be interpreted as the user requesting a new window, so open a new window when called with no URIs, unless --new-tag is given explicitly. Partially fixes https://bugzilla.gnome.org/show_bug.cgi?id=685976
-rw-r--r--src/ephy-session.c10
-rw-r--r--tests/ephy-session-test.c28
2 files changed, 34 insertions, 4 deletions
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 3a0f197a3..044b75414 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -256,6 +256,7 @@ session_command_open_uris (EphySession *session,
EphyNewTabFlags flags = 0;
guint i;
gboolean new_windows_in_tabs;
+ gboolean have_uris;
shell = ephy_shell_get_default ();
@@ -266,6 +267,8 @@ session_command_open_uris (EphySession *session,
new_windows_in_tabs = g_settings_get_boolean (EPHY_SETTINGS_MAIN,
EPHY_PREFS_NEW_WINDOWS_IN_TABS);
+ have_uris = ! (g_strv_length (uris) == 1 && g_str_equal (uris[0], ""));
+
if (options != NULL && strstr (options, "external") != NULL)
{
flags |= EPHY_NEW_TAB_FROM_EXTERNAL;
@@ -276,12 +279,17 @@ session_command_open_uris (EphySession *session,
flags |= EPHY_NEW_TAB_IN_NEW_WINDOW;
}
else if ((options != NULL && strstr (options, "new-tab") != NULL) ||
- new_windows_in_tabs)
+ (new_windows_in_tabs && have_uris))
{
flags |= EPHY_NEW_TAB_IN_EXISTING_WINDOW |
EPHY_NEW_TAB_JUMP |
EPHY_NEW_TAB_PRESENT_WINDOW;
}
+ else if (!have_uris)
+ {
+ window = NULL;
+ flags |= EPHY_NEW_TAB_IN_NEW_WINDOW;
+ }
for (i = 0; uris[i] != NULL; ++i)
{
diff --git a/tests/ephy-session-test.c b/tests/ephy-session-test.c
index 4923f2779..b69403f85 100644
--- a/tests/ephy-session-test.c
+++ b/tests/ephy-session-test.c
@@ -160,7 +160,7 @@ test_ephy_session_load_many_windows (void)
}
static void
-test_ephy_session_open_uri_after_loading_session (void)
+open_uris_after_loading_session (const char** uris, int final_num_windows)
{
EphySession *session;
gboolean ret;
@@ -168,7 +168,6 @@ test_ephy_session_open_uri_after_loading_session (void)
EphyEmbed *embed;
EphyWebView *view;
guint32 user_time;
- const char* uris[] = { "ephy-about:epiphany", NULL };
session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default ()));
g_assert (session);
@@ -229,7 +228,27 @@ test_ephy_session_open_uri_after_loading_session (void)
*/
l = ephy_shell_get_windows (ephy_shell_get_default ());
g_assert (l);
- g_assert_cmpint (g_list_length (l), ==, 2);
+ g_assert_cmpint (g_list_length (l), ==, final_num_windows);
+
+ /* FIXME: See comments above. */
+ for (p = l; p; p = p->next)
+ gtk_widget_destroy (GTK_WIDGET (p->data));
+}
+
+static void
+test_ephy_session_open_uri_after_loading_session (void)
+{
+ const char* uris[] = { "ephy-about:epiphany", NULL };
+
+ open_uris_after_loading_session (uris, 2);
+}
+
+static void
+test_ephy_session_open_empty_uri_forces_new_window (void)
+{
+ const char* uris[] = { "", NULL };
+
+ open_uris_after_loading_session (uris, 3);
}
int
@@ -266,6 +285,9 @@ main (int argc, char *argv[])
g_test_add_func ("/src/ephy-session/open-uri-after-loading_session",
test_ephy_session_open_uri_after_loading_session);
+ g_test_add_func ("/src/ephy-session/open-empty-uri-forces-new-window",
+ test_ephy_session_open_empty_uri_forces_new_window);
+
ret = g_test_run ();
g_object_unref (ephy_shell_get_default ());