[epiphany] window: focus the location entry when opening new tabs
- From: Carlos Garcia Campos <carlosgc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [epiphany] window: focus the location entry when opening new tabs
- Date: Mon, 5 Dec 2016 14:16:39 +0000 (UTC)
commit b58ee9dc49de05e00d2f6931d70dfd3a2ca4a821
Author: Carlos Garcia Campos <cgarcia igalia com>
Date: Mon Dec 5 12:13:04 2016 +0100
window: focus the location entry when opening new tabs
This is a regression introduced in commit
6b530964ac6de09dcb01c2dfa774bbaa111b29e5 that removes the
EPHY_LINK_HOME_PAGE flag when calling ephy_link_open() on new tab
command callback. This patch brings that back, making
ephy_window_open_link() handle null address when EPHY_LINK_HOME_PAGE
flag is passed, and simplifying the llogic to decide whether to focus
the web view or the location entry. If the web view is blank after the
load we focus the location entry and otherwise the embed is focused.
https://bugzilla.gnome.org/show_bug.cgi?id=774599
embed/ephy-web-view.c | 42 +++++++++++++++++++++++++++++++-----------
embed/ephy-web-view.h | 1 +
src/ephy-session.c | 13 +++----------
src/ephy-shell.c | 5 +++--
src/ephy-window.c | 43 +++++++++++++++++++++----------------------
src/window-commands.c | 11 ++++-------
6 files changed, 63 insertions(+), 52 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 8fc0884..d91a8b2 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -3190,26 +3190,46 @@ ephy_web_view_load_homepage (EphyWebView *view)
{
EphyEmbedShell *shell;
EphyEmbedShellMode mode;
+ char *home;
g_return_if_fail (EPHY_IS_WEB_VIEW (view));
shell = ephy_embed_shell_get_default ();
mode = ephy_embed_shell_get_mode (shell);
- ephy_web_view_freeze_history (view);
- ephy_web_view_set_visit_type (view, EPHY_PAGE_VISIT_HOMEPAGE);
if (mode == EPHY_EMBED_SHELL_MODE_INCOGNITO) {
- ephy_web_view_load_url (view, "about:incognito");
- } else {
- char *home;
+ ephy_web_view_load_new_tab_page (view);
+ return;
+ }
- home = g_settings_get_string (EPHY_SETTINGS_MAIN, EPHY_PREFS_HOMEPAGE_URL);
- if (home == NULL || home[0] == '\0')
- ephy_web_view_load_url (view, "about:overview");
- else
- ephy_web_view_load_url (view, home);
- g_free (home);
+ home = g_settings_get_string (EPHY_SETTINGS_MAIN, EPHY_PREFS_HOMEPAGE_URL);
+ if (home == NULL || home[0] == '\0') {
+ ephy_web_view_load_new_tab_page(view);
+ } else {
+ ephy_web_view_freeze_history (view);
+ ephy_web_view_set_visit_type (view, EPHY_PAGE_VISIT_HOMEPAGE);
+ ephy_web_view_load_url (view, home);
}
+ g_free (home);
+}
+
+void
+ephy_web_view_load_new_tab_page (EphyWebView *view)
+{
+ EphyEmbedShell *shell;
+ EphyEmbedShellMode mode;
+
+ g_return_if_fail (EPHY_IS_WEB_VIEW (view));
+
+ shell = ephy_embed_shell_get_default ();
+ mode = ephy_embed_shell_get_mode (shell);
+
+ ephy_web_view_freeze_history (view);
+ ephy_web_view_set_visit_type (view, EPHY_PAGE_VISIT_HOMEPAGE);
+ if (mode == EPHY_EMBED_SHELL_MODE_INCOGNITO)
+ ephy_web_view_load_url (view, "about:incognito");
+ else
+ ephy_web_view_load_url (view, "about:overview");
}
/**
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index 47524dd..e2c79f0 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -138,6 +138,7 @@ void ephy_web_view_popups_manager_reset (EphyWebView
void ephy_web_view_save (EphyWebView *view,
const char *uri);
void ephy_web_view_load_homepage (EphyWebView *view);
+void ephy_web_view_load_new_tab_page (EphyWebView *view);
char * ephy_web_view_create_web_application (EphyWebView *view,
const char *title,
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 5cf0874..659065f 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -31,6 +31,7 @@
#include "ephy-embed.h"
#include "ephy-file-helpers.h"
#include "ephy-gui.h"
+#include "ephy-link.h"
#include "ephy-notebook.h"
#include "ephy-prefs.h"
#include "ephy-settings.h"
@@ -373,16 +374,8 @@ 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 ();
- EphyEmbed *embed;
- embed = ephy_shell_new_tab_full (shell,
- NULL /* title */,
- NULL /* related view */,
- window, NULL /* tab */,
- 0,
- user_time);
- ephy_web_view_load_homepage (ephy_embed_get_web_view (embed));
- ephy_window_activate_location (window);
+ ephy_link_open (EPHY_LINK (window), NULL, NULL, EPHY_LINK_HOME_PAGE);
}
}
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index b4fe508..f821876 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -1044,8 +1044,9 @@ ephy_shell_open_uris_idle (OpenURIsData *data)
if (data->flags & EPHY_NEW_TAB_JUMP && mode != EPHY_EMBED_SHELL_MODE_TEST)
gtk_window_present_with_time (GTK_WINDOW (data->window), data->user_time);
} else {
- ephy_web_view_load_homepage (ephy_embed_get_web_view (embed));
- ephy_window_activate_location (data->window);
+ ephy_web_view_load_new_tab_page (ephy_embed_get_web_view (embed));
+ if (data->flags & EPHY_NEW_TAB_JUMP)
+ ephy_window_activate_location (data->window);
}
/* Set address from the very beginning. Looks odd in app mode if it appears later on. */
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 938ba82..166ffe4 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -319,8 +319,9 @@ ephy_window_open_link (EphyLink *link,
{
EphyWindow *window = EPHY_WINDOW (link);
EphyEmbed *new_embed;
+ EphyWebView *web_view;
- g_return_val_if_fail (address != NULL, NULL);
+ g_assert (address != NULL || (flags & (EPHY_LINK_NEW_WINDOW | EPHY_LINK_NEW_TAB | EPHY_LINK_HOME_PAGE)));
if (embed == NULL) {
embed = window->active_embed;
@@ -351,31 +352,29 @@ ephy_window_open_link (EphyLink *link,
if (flags & EPHY_LINK_NEW_TAB_APPEND_AFTER)
ntflags |= EPHY_NEW_TAB_APPEND_AFTER;
- new_embed = ephy_shell_new_tab
- (ephy_shell_get_default (),
- target_window,
- embed, ntflags);
- if (flags & EPHY_LINK_HOME_PAGE) {
- ephy_web_view_load_homepage (ephy_embed_get_web_view (new_embed));
- ephy_window_activate_location (window);
- } else {
- ephy_web_view_load_url (ephy_embed_get_web_view (new_embed), address);
- if (flags & EPHY_LINK_JUMP_TO) {
- gtk_widget_grab_focus (GTK_WIDGET (new_embed));
- }
- }
+ new_embed = ephy_shell_new_tab (ephy_shell_get_default (),
+ target_window,
+ embed, ntflags);
+ } else if (!embed) {
+ new_embed = ephy_shell_new_tab (ephy_shell_get_default (), window, NULL, 0);
} else {
- ephy_web_view_load_url (ephy_embed_get_web_view (embed), address);
-
- if (address == NULL || address[0] == '\0' || g_str_equal (address, "about:blank")) {
- ephy_window_activate_location (window);
- } else {
- gtk_widget_grab_focus (GTK_WIDGET (embed));
- }
-
new_embed = embed;
}
+ web_view = ephy_embed_get_web_view (new_embed);
+
+ if (address)
+ ephy_web_view_load_url (web_view, address);
+ else if (flags & EPHY_LINK_NEW_TAB)
+ ephy_web_view_load_new_tab_page (web_view);
+ else if (flags & (EPHY_LINK_NEW_WINDOW | EPHY_LINK_HOME_PAGE))
+ ephy_web_view_load_homepage (web_view);
+
+ if (ephy_web_view_get_is_blank (web_view))
+ ephy_window_activate_location (window);
+ else
+ gtk_widget_grab_focus (GTK_WIDGET (new_embed));
+
return new_embed;
}
diff --git a/src/window-commands.c b/src/window-commands.c
index 05e5f76..adfae84 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -82,9 +82,7 @@ window_cmd_new_window (GSimpleAction *action,
}
new_window = ephy_window_new ();
- embed = ephy_shell_new_tab (shell, new_window, NULL, 0);
- ephy_web_view_load_homepage (ephy_embed_get_web_view (embed));
- ephy_window_activate_location (new_window);
+ ephy_link_open (EPHY_LINK (new_window), NULL, NULL, EPHY_LINK_HOME_PAGE);
}
void
@@ -867,8 +865,8 @@ window_cmd_new_tab (GSimpleAction *action,
EphyWindow *window = user_data;
ephy_link_open (EPHY_LINK (window),
- "about:overview",
- NULL, EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO);
+ NULL, NULL,
+ EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO);
}
static void
@@ -2112,8 +2110,7 @@ window_cmd_go_home (GSimpleAction *action,
gpointer user_data)
{
ephy_link_open (EPHY_LINK (user_data),
- "about:overview",
- NULL,
+ NULL, NULL,
EPHY_LINK_HOME_PAGE);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]