Index: src/ephy-shell.c =================================================================== RCS file: /cvs/gnome/epiphany/src/ephy-shell.c,v retrieving revision 1.120 diff -p -u -u -p -r1.120 ephy-shell.c --- src/ephy-shell.c 21 Feb 2005 11:23:21 -0000 1.120 +++ src/ephy-shell.c 26 Mar 2005 19:55:55 -0000 @@ -624,10 +624,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); @@ -638,9 +653,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; } /** @@ -674,6 +693,7 @@ ephy_shell_new_tab_full (EphyShell *shel 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; @@ -695,8 +715,6 @@ ephy_shell_new_tab_full (EphyShell *shel window = ephy_window_new_with_chrome (chrome); } - toolbar = EPHY_TOOLBAR (ephy_window_get_toolbar (window)); - if (previous_tab != NULL) { previous_embed = ephy_tab_get_embed (previous_tab); @@ -731,14 +749,34 @@ ephy_shell_new_tab_full (EphyShell *shel flags & EPHY_NEW_TAB_NEW_PAGE) { ephy_tab_set_location (tab, "", EPHY_TAB_ADDRESS_EXPIRE_NEXT); - 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 + { + /* non-empty page, focus the page */ + ephy_embed_activate (embed); + } + } return tab; }