summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLorenzo Tilve Álvaro <ltilve@igalia.com>2013-07-05 12:09:54 +0200
committerManuel Rego Casasnovas <rego@igalia.com>2013-07-23 11:51:45 +0200
commit3d143c0209e755d98c0bbc650ab0ad168e2b5fa6 (patch)
tree07441575540d9e7fe079da9942ae4a2fee5c0e67
parent90909abb45223bd776b871667bebc16ccb409292 (diff)
downloadepiphany-3d143c0209e755d98c0bbc650ab0ad168e2b5fa6.tar.gz
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
-rw-r--r--data/org.gnome.epiphany.gschema.xml5
-rw-r--r--embed/ephy-embed-private.h2
-rw-r--r--embed/ephy-embed-utils.c3
-rw-r--r--embed/ephy-web-view.c29
-rw-r--r--lib/ephy-prefs.h1
-rw-r--r--src/ephy-home-action.c12
-rw-r--r--src/ephy-shell.c3
-rw-r--r--src/ephy-window.c11
8 files changed, 52 insertions, 14 deletions
diff --git a/data/org.gnome.epiphany.gschema.xml b/data/org.gnome.epiphany.gschema.xml
index 5a32af1dd..b22fe6517 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 d023efb6a..f0b876192 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 80a28bc70..5b1760bcd 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 224bf7853..042697a0d 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 17bc63c6e..cc42ccd40 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 2d8e02d8e..74d662b45 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 252a4cbaf..1859e0b95 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 fe7967190..3eefd36d4 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",