From 90586b820dea7fdb2588b24939ae72514f87c73d Mon Sep 17 00:00:00 2001 From: Christian Persch Date: Thu, 28 Jul 2005 17:52:51 +0000 Subject: Work around gtkmozembed focus bug. Fixes bug #105153. 2005-07-28 Christian Persch * configure.ac: * embed/mozilla/EphyBrowser.cpp: * embed/mozilla/EphyBrowser.h: * embed/mozilla/mozilla-embed.cpp: * src/ephy-shell.c: (url_is_empty), (load_homepage), (ephy_shell_new_tab_full): Work around gtkmozembed focus bug. Fixes bug #105153. --- src/ephy-shell.c | 45 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 43 insertions(+), 2 deletions(-) (limited to 'src/ephy-shell.c') diff --git a/src/ephy-shell.c b/src/ephy-shell.c index f80114471..02aec0cbd 100644 --- a/src/ephy-shell.c +++ b/src/ephy-shell.c @@ -639,10 +639,25 @@ ephy_shell_new (void) return EPHY_SHELL (g_object_new (EPHY_TYPE_SHELL, NULL)); } -static void +static gboolean +url_is_empty (const char *location) +{ + gboolean is_empty = FALSE; + + if (location == NULL || location[0] == '\0' || + strcmp (location, "about:blank") == 0) + { + is_empty = TRUE; + } + + return is_empty; +} + +static gboolean load_homepage (EphyEmbed *embed) { char *home; + gboolean is_empty; home = eel_gconf_get_string(CONF_GENERAL_HOMEPAGE); @@ -653,9 +668,13 @@ load_homepage (EphyEmbed *embed) home = g_strdup ("about:blank"); } + is_empty = url_is_empty (home); + ephy_embed_load_url (embed, home); g_free (home); + + return is_empty; } /** @@ -691,6 +710,7 @@ ephy_shell_new_tab_full (EphyShell *shell, EphyEmbed *previous_embed = NULL; GtkWidget *nb; int position = -1; + gboolean is_empty = FALSE; EphyToolbar *toolbar; if (flags & EPHY_NEW_TAB_IN_NEW_WINDOW) in_new_window = TRUE; @@ -749,14 +769,35 @@ ephy_shell_new_tab_full (EphyShell *shell, flags & EPHY_NEW_TAB_NEW_PAGE) { ephy_toolbar_activate_location (toolbar); - load_homepage (embed); + is_empty = load_homepage (embed); } else if (flags & EPHY_NEW_TAB_OPEN_PAGE) { g_assert (url != NULL); ephy_embed_load_url (embed, url); + is_empty = url_is_empty (url); } + /* Make sure the initial focus is somewhere sensible and not, for + * example, on the reload button. + */ + if (in_new_window || jump_to) + { + /* If the location entry is blank, focus that, except if the + * page was a copy */ + if (is_empty) + { + /* empty page, focus location entry */ + toolbar = EPHY_TOOLBAR (ephy_window_get_toolbar (window)); + ephy_toolbar_activate_location (toolbar); + } + else if (embed != NULL) + { + /* non-empty page, focus the page */ + ephy_embed_activate (embed); + } + } + return tab; } -- cgit v1.2.3