[epiphany] Move homepage loading code to EphyWebView



commit 6ef9fa4aa4d068482412e3cde4dbdaf8dadc925b
Author: Xan Lopez <xan gnome org>
Date:   Mon May 3 12:31:25 2010 +0200

    Move homepage loading code to EphyWebView
    
    Create a method to make the EphyWebView load the homepage set by the
    user. This is in preparation for creating a signal for this action,
    which other code in Epiphany will need.

 embed/ephy-web-view.c |   31 +++++++++++++++++++++++++++++++
 embed/ephy-web-view.h |    2 ++
 src/ephy-shell.c      |   28 +++-------------------------
 3 files changed, 36 insertions(+), 25 deletions(-)
---
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 19498da..c3fa53a 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -3523,4 +3523,35 @@ ephy_web_view_save (EphyWebView *view, const char *uri)
   ephy_web_view_save_sub_resources (view, uri, subresources);
 }
 
+/**
+ * ephy_web_view_load_homepage:
+ * @view: an #EphyWebView
+ * 
+ * Loads the homepage set by the user in @view.
+ * 
+ * Returns: %TRUE if there was a homepage set to be loaded in the user
+ * preferences, %FALSE otherwise
+ **/
+gboolean
+ephy_web_view_load_homepage (EphyWebView *view)
+{
+	char *home;
+	gboolean is_empty;
+
+	home = eel_gconf_get_string (CONF_GENERAL_HOMEPAGE);
+
+	if (home == NULL || home[0] == '\0')
+	{
+		g_free (home);
+
+		home = g_strdup ("about:blank");
+	}
+
+	is_empty = ephy_embed_utils_url_is_empty (home);
+	ephy_web_view_load_url (view, home);
+
+	g_free (home);
+
+	return is_empty;
+}
 
diff --git a/embed/ephy-web-view.h b/embed/ephy-web-view.h
index b3ffb53..323a856 100644
--- a/embed/ephy-web-view.h
+++ b/embed/ephy-web-view.h
@@ -190,6 +190,8 @@ void                       ephy_web_view_popups_manager_reset    (EphyWebView
 void                       ephy_web_view_save                    (EphyWebView                     *view,
                                                                   const char                      *uri);
 
+gboolean                   ephy_web_view_load_homepage           (EphyWebView                     *view);
+
 G_END_DECLS
 
 #endif
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 5e830dc..2c3e3e2 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -367,29 +367,6 @@ ephy_shell_get_default (void)
 	return ephy_shell;
 }
 
-static gboolean
-load_homepage (EphyEmbed *embed)
-{
-	char *home;
-	gboolean is_empty;
-
-	home = eel_gconf_get_string(CONF_GENERAL_HOMEPAGE);
-
-	if (home == NULL || home[0] == '\0')
-	{
-		g_free (home);
-
-		home = g_strdup ("about:blank");
-	}
-
-	is_empty = ephy_embed_utils_url_is_empty (home);
-	ephy_web_view_load_url (ephy_embed_get_web_view (embed), home);
-
-	g_free (home);
-
-	return is_empty;
-}
-
 /**
  * ephy_shell_new_tab_full:
  * @shell: a #EphyShell
@@ -502,9 +479,10 @@ ephy_shell_new_tab_full (EphyShell *shell,
 	if (flags & EPHY_NEW_TAB_HOME_PAGE ||
 	    flags & EPHY_NEW_TAB_NEW_PAGE)
 	{
-		ephy_web_view_set_typed_address (ephy_embed_get_web_view (embed), "");
+		EphyWebView *view = ephy_embed_get_web_view (embed);
+		ephy_web_view_set_typed_address (view, "");
 		ephy_toolbar_activate_location (toolbar);
-		is_empty = load_homepage (embed);
+		is_empty = ephy_web_view_load_homepage (view);
 	}
 	else if (flags & EPHY_NEW_TAB_OPEN_PAGE)
 	{



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