[epiphany/kiosk-mode] Reintroduced homepage preference on GSettings



commit 3d143c0209e755d98c0bbc650ab0ad168e2b5fa6
Author: Lorenzo Tilve Álvaro <ltilve igalia com>
Date:   Fri Jul 5 12:09:54 2013 +0200

    Reintroduced homepage preference on GSettings
    
    This setting is particulary important for the kiosk mode
    of Epiphany where it's neccesary that the browser is opened
    starting on a very specific home address.
    
    There is not a need to create a UI for the configuration of the
    setting as on the mentioned main purposes of the flag like
    the mentioned kiosk mode, or intranets, the homepage-url, would
    be basically system-configured.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=702435

 data/org.gnome.epiphany.gschema.xml |    5 +++++
 embed/ephy-embed-private.h          |    2 +-
 embed/ephy-embed-utils.c            |    3 ++-
 embed/ephy-web-view.c               |   29 +++++++++++++++++++++++------
 lib/ephy-prefs.h                    |    1 +
 src/ephy-home-action.c              |   12 ++++++++++--
 src/ephy-shell.c                    |    3 +--
 src/ephy-window.c                   |   11 +++++++++--
 8 files changed, 52 insertions(+), 14 deletions(-)
---
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index 5a32af1..b22fe65 100644
--- a/data/org.gnome.epiphany.gschema.xml
+++ b/data/org.gnome.epiphany.gschema.xml
@@ -64,6 +64,11 @@
                        <summary>Custom HTTP errors management</summary>
                        <description>Show a custom page when a HTTP error happens browsing the 
web.</description>
                </key>
+               <key type="s" name="homepage-url">
+                       <default>''</default>
+                       <summary>Home page</summary>
+                       <description>Address of the user's home page.</description>
+               </key>
        </schema>
        <schema path="/org/gnome/epiphany/ui/" id="org.gnome.Epiphany.ui">
                <key type="b" name="show-toolbars">
diff --git a/embed/ephy-embed-private.h b/embed/ephy-embed-private.h
index d023efb..f0b8761 100644
--- a/embed/ephy-embed-private.h
+++ b/embed/ephy-embed-private.h
@@ -56,7 +56,7 @@ void                       ephy_web_view_set_loading_title        (EphyWebView
 void                       ephy_web_view_popups_manager_reset     (EphyWebView               *view);
 void                       ephy_web_view_save                     (EphyWebView               *view,
                                                                    const char                *uri);
-void                       ephy_web_view_load_homepage            (EphyWebView               *view);
+gboolean                   ephy_web_view_load_homepage            (EphyWebView               *view);
 
 char *                     ephy_web_view_create_web_application   (EphyWebView               *view,
                                                                    const char                *title,
diff --git a/embed/ephy-embed-utils.c b/embed/ephy-embed-utils.c
index 80a28bc..5b1760b 100644
--- a/embed/ephy-embed-utils.c
+++ b/embed/ephy-embed-utils.c
@@ -157,7 +157,8 @@ ephy_embed_utils_url_is_empty (const char *location)
 
   if (location == NULL || 
       location[0] == '\0' || 
-      strcmp (location, "about:blank") == 0)
+      strcmp (location, "about:blank") == 0 ||
+      strcmp (location, "about:overview") == 0)
     is_empty = TRUE;
   
   return is_empty;
diff --git a/embed/ephy-web-view.c b/embed/ephy-web-view.c
index 224bf78..042697a 100644
--- a/embed/ephy-web-view.c
+++ b/embed/ephy-web-view.c
@@ -4099,23 +4099,40 @@ 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 defined by EPHY_PREFS_HOMEPAGE_URL,
+ * or "about:overview" if there is none configured
+ *
+ * Returns: %TRUE if there is an empty configuration for the
+ * homepage on the gsettings preference, %FALSE otherwise
  *
  **/
-void
+gboolean
 ephy_web_view_load_homepage (EphyWebView *view)
 {
-  g_return_if_fail (EPHY_IS_WEB_VIEW (view));
+  gboolean is_empty = FALSE;
+
+  g_return_val_if_fail (EPHY_IS_WEB_VIEW (view), FALSE);
 
   g_signal_emit_by_name (view, "loading-homepage");
 
   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_EMBED_SHELL_MODE_INCOGNITO) {
     ephy_web_view_load_url (view, "about:incognito");
-  else
-    ephy_web_view_load_url (view, "about:overview");
+  } else {
+    char *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");
+    }
+
+    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/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 17bc63c..cc42ccd 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -125,6 +125,7 @@ typedef enum
 #define EPHY_PREFS_RESTORE_SESSION_POLICY         "restore-session-policy"
 #define EPHY_PREFS_RESTORE_SESSION_DELAYING_LOADS "restore-session-delaying-loads"
 #define EPHY_PREFS_CUSTOM_HTTP_ERRORS_MANAGEMENT  "custom-http-errors-management"
+#define EPHY_PREFS_HOMEPAGE_URL                   "homepage-url"
 
 #define EPHY_PREFS_LOCKDOWN_SCHEMA            "org.gnome.Epiphany.lockdown"
 #define EPHY_PREFS_LOCKDOWN_FULLSCREEN        "disable-fullscreen"
diff --git a/src/ephy-home-action.c b/src/ephy-home-action.c
index 2d8e02d..74d662b 100644
--- a/src/ephy-home-action.c
+++ b/src/ephy-home-action.c
@@ -22,6 +22,7 @@
 #include "ephy-home-action.h"
 
 #include "ephy-link.h"
+#include "ephy-settings.h"
 
 G_DEFINE_TYPE (EphyHomeAction, ephy_home_action, EPHY_TYPE_LINK_ACTION)
 
@@ -53,11 +54,18 @@ static void
 ephy_home_action_activate (GtkAction *action)
 {
        char *action_name;
+       char *address;
 
        g_object_get (G_OBJECT (action), "name", &action_name, NULL);
-               
-       action_name_association (action, action_name, "about:overview");
 
+       address = g_settings_get_string (EPHY_SETTINGS_MAIN, EPHY_PREFS_HOMEPAGE_URL);
+       if (address == NULL || address[0] == '\0') {
+               action_name_association (action, action_name, "about:overview");
+       } else {
+               action_name_association (action, action_name, address);
+       }
+
+       g_free (address);
        g_free (action_name);
 }
 
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 252a4cb..1859e0b 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -809,8 +809,7 @@ ephy_shell_new_tab_full (EphyShell *shell,
     EphyWebView *view = ephy_embed_get_web_view (embed);
     ephy_web_view_set_typed_address (view, "");
     ephy_window_activate_location (window);
-    ephy_web_view_load_homepage (view);
-    is_empty = TRUE;
+    is_empty = ephy_web_view_load_homepage (view);
   } else if (open_page) {
     ephy_web_view_load_request (ephy_embed_get_web_view (embed),
                                 request);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index fe79671..3eefd36 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -1292,7 +1292,8 @@ setup_ui_manager (EphyWindow *window)
        GtkActionGroup *action_group;
        GtkAction *action;
        GtkUIManager *manager;
-       const char *prev_icon, *next_icon;
+       const char *prev_icon, *next_icon, *home_action_label;
+       char *address;
 
        window->priv->main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
        gtk_widget_show (window->priv->main_vbox);
@@ -1402,10 +1403,16 @@ setup_ui_manager (EphyWindow *window)
        gtk_action_group_add_action_with_accel (action_group, action, "<control>T");
        g_object_unref (action);
 
+       address = g_settings_get_string (EPHY_SETTINGS_MAIN, EPHY_PREFS_HOMEPAGE_URL);
+       if (address == NULL || address[0] == '\0')
+               home_action_label = _("Go to most visited");
+       else
+               home_action_label = _("Go to home page");
+       g_free (address);
        action =
                g_object_new (EPHY_TYPE_HOME_ACTION,
                              "name", "FileHome",
-                             "label", _("Go to most visited"),
+                             "label", home_action_label,
                              NULL);
        gtk_action_group_add_action_with_accel (action_group, action, "<alt>Home");
        g_signal_connect_swapped (action, "open-link",


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