[epiphany] Restore preference to set homepage



commit 6b530964ac6de09dcb01c2dfa774bbaa111b29e5
Author: Michael Catanzaro <mcatanzaro gnome org>
Date:   Mon Oct 31 17:52:12 2016 -0500

    Restore preference to set homepage
    
    Several users have requested this and even if it seems silly, there's
    nothing to be gained in denying them. This feature is extremely
    low-maintenance.
    
    This will probably never be well-tested, since hardly anybody wants
    homepages anymore. Users should be prepared to report bugs if things
    break or are broken.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=702435

 data/org.gnome.epiphany.gschema.xml |    5 +++++
 embed/ephy-web-view.c               |   28 ++++++++++++++++++++--------
 lib/ephy-prefs.h                    |    1 +
 src/ephy-location-controller.c      |    7 ++++++-
 src/ephy-shell.c                    |    2 +-
 src/window-commands.c               |    2 +-
 6 files changed, 34 insertions(+), 11 deletions(-)
---
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index a994250..5913485 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -9,6 +9,11 @@
                        <default>false</default>
                        <summary>Browse with caret</summary>
                </key>
+               <key type="s" name="homepage-url">
+                       <default>''</default>
+                       <summary>Home page</summary>
+                       <description>Address of the user's home page.</description>
+               </key>
                <key type="s" name="keyword-search-url">
                        <!-- DuckDuckGo is the default search engine. Must exactly match the URL used
                             in the preferences dialog, except this string is surrounded by single quotes
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 483bbd8..79c77fc 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -3087,22 +3087,34 @@ ephy_web_view_save (EphyWebView *view, const char *uri)
  * ephy_web_view_load_homepage:
  * @view: an #EphyWebView
  *
- * Loads the homepage, which is hardcoded to be "about:overview"
- *
+ * Loads the homepage set by the user in @view.
  **/
 void
 ephy_web_view_load_homepage (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 (ephy_embed_shell_get_mode (ephy_embed_shell_get_default ())
-      == EPHY_EMBED_SHELL_MODE_INCOGNITO)
+  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");
+  } else {
+    char *home;
+    home = g_settings_get_string (EPHY_SETTINGS_MAIN, EPHY_PREFS_HOMEPAGE_URL);
+    if (home == NULL || home[0] == '\0') {
+      g_free (home);
+      home = g_strdup ("about:overview");
+    }
+
+    ephy_web_view_load_url (view, home);
+    g_free (home);
+  }
 }
 
 /**
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index ef93c27..683732b 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -86,6 +86,7 @@ typedef enum
 #define EPHY_PREFS_WEB_ENABLE_ADBLOCK        "enable-adblock"
 
 #define EPHY_PREFS_SCHEMA                         "org.gnome.Epiphany"
+#define EPHY_PREFS_HOMEPAGE_URL                   "homepage-url"
 #define EPHY_PREFS_USER_AGENT                     "user-agent"
 #define EPHY_PREFS_NEW_WINDOWS_IN_TABS            "new-windows-in-tabs"
 #define EPHY_PREFS_AUTO_DOWNLOADS                 "automatic-downloads"
diff --git a/src/ephy-location-controller.c b/src/ephy-location-controller.c
index 8404338..1670e55 100644
--- a/src/ephy-location-controller.c
+++ b/src/ephy-location-controller.c
@@ -351,7 +351,12 @@ focus_in_event_cb (GtkWidget              *entry,
                    GdkEventFocus          *event,
                    EphyLocationController *controller)
 {
-  if (!controller->sync_address_is_blocked) {
+  const char *address;
+
+  /* Never block sync if the location entry is empty, else homepage URL
+   * will be missing in homepage mode. */
+  address = ephy_title_widget_get_address (controller->title_widget);
+  if (!controller->sync_address_is_blocked && address && *address) {
     controller->sync_address_is_blocked = TRUE;
     g_signal_handlers_block_by_func (controller, G_CALLBACK (sync_address), entry);
   }
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 80d8ac0..3fbf302 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -993,7 +993,7 @@ ephy_shell_open_uris_idle (OpenURIsData *data)
     page_flags |= EPHY_NEW_TAB_APPEND_AFTER;
   else if (data->reuse_empty_tab) {
     embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (data->window));
-    /* Only load a new page in this embed if it was showing or loading the homepage about:overview */
+    /* Only load a new page in this embed if it was showing or loading the homepage */
     if (ephy_web_view_get_visit_type (ephy_embed_get_web_view (embed)) == EPHY_PAGE_VISIT_HOMEPAGE)
       reusing_empty_tab = TRUE;
   }
diff --git a/src/window-commands.c b/src/window-commands.c
index f48597c..4e36279 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -464,7 +464,7 @@ window_cmd_new_tab (GSimpleAction *action,
   ephy_link_open (EPHY_LINK (window),
                   "about:overview",
                   NULL,
-                  EPHY_LINK_HOME_PAGE | EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO);
+                  EPHY_LINK_NEW_TAB | EPHY_LINK_JUMP_TO);
 }
 
 static void


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