aboutsummaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/Makefile.am4
-rw-r--r--lib/eel-gconf-extensions.c724
-rw-r--r--lib/eel-gconf-extensions.h83
-rw-r--r--lib/ephy-dialog.c1144
-rw-r--r--lib/ephy-dialog.h38
-rw-r--r--lib/ephy-file-chooser.c12
-rw-r--r--lib/ephy-file-helpers.c5
-rw-r--r--lib/ephy-prefs.h126
-rw-r--r--lib/ephy-settings.c65
-rw-r--r--lib/ephy-settings.h44
10 files changed, 222 insertions, 2023 deletions
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 08f19224e..b98c1b37b 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -8,7 +8,6 @@ header_DATA = \
$(INST_H_FILES)
NOINST_H_FILES = \
- eel-gconf-extensions.h \
ephy-debug.h \
ephy-dnd.h \
ephy-file-chooser.h \
@@ -38,10 +37,10 @@ INST_H_FILES = \
ephy-loader.h \
ephy-node.h \
ephy-node-db.h \
+ ephy-settings.h \
ephy-state.h
libephymisc_la_SOURCES = \
- eel-gconf-extensions.c \
ephy-debug.c \
ephy-dialog.c \
ephy-dnd.c \
@@ -60,6 +59,7 @@ libephymisc_la_SOURCES = \
ephy-prefs.h \
ephy-profile-migration.c \
ephy-print-utils.c \
+ ephy-settings.c \
ephy-shlib-loader.c \
ephy-signal-accumulator.c \
ephy-state.c \
diff --git a/lib/eel-gconf-extensions.c b/lib/eel-gconf-extensions.c
deleted file mode 100644
index 310ce1c17..000000000
--- a/lib/eel-gconf-extensions.c
+++ /dev/null
@@ -1,724 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* eel-gconf-extensions.c - Stuff to make GConf easier to use.
-
- Copyright © 2000, 2001 Eazel, Inc.
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- Authors: Ramiro Estrugo <ramiro@eazel.com>
-
-*/
-
-#include "config.h"
-
-#include "eel-gconf-extensions.h"
-
-#include <glib/gi18n.h>
-
-#include <gconf/gconf-client.h>
-#include <gconf/gconf.h>
-#include <string.h>
-
-static GConfClient *global_gconf_client = NULL;
-
-static void
-global_client_free (void)
-{
- if (global_gconf_client == NULL) {
- return;
- }
-
- g_object_unref (global_gconf_client);
- global_gconf_client = NULL;
-}
-
-/* Public */
-GConfClient *
-eel_gconf_client_get_global (void)
-{
- if (global_gconf_client == NULL) {
- global_gconf_client = gconf_client_get_default ();
- g_atexit (global_client_free);
- }
-
- return global_gconf_client;
-}
-
-gboolean
-eel_gconf_handle_error (GError **error)
-{
- g_return_val_if_fail (error != NULL, FALSE);
-
- if (*error != NULL) {
- g_warning (_("GConf error:\n %s"), (*error)->message);
- g_error_free (*error);
- *error = NULL;
-
- return TRUE;
- }
-
- return FALSE;
-}
-
-void
-eel_gconf_set_boolean (const char *key,
- gboolean boolean_value)
-{
- GConfClient *client;
- GError *error = NULL;
-
- g_return_if_fail (key != NULL);
-
- client = eel_gconf_client_get_global ();
- g_return_if_fail (client != NULL);
-
- gconf_client_set_bool (client, key, boolean_value, &error);
- eel_gconf_handle_error (&error);
-}
-
-gboolean
-eel_gconf_get_boolean (const char *key)
-{
- gboolean result;
- GConfClient *client;
- GError *error = NULL;
-
- g_return_val_if_fail (key != NULL, FALSE);
-
- client = eel_gconf_client_get_global ();
- g_return_val_if_fail (client != NULL, FALSE);
-
- result = gconf_client_get_bool (client, key, &error);
-
- if (eel_gconf_handle_error (&error)) {
- result = FALSE;
- }
-
- return result;
-}
-
-void
-eel_gconf_set_integer (const char *key,
- int int_value)
-{
- GConfClient *client;
- GError *error = NULL;
-
- g_return_if_fail (key != NULL);
-
- client = eel_gconf_client_get_global ();
- g_return_if_fail (client != NULL);
-
- gconf_client_set_int (client, key, int_value, &error);
- eel_gconf_handle_error (&error);
-}
-
-int
-eel_gconf_get_integer (const char *key)
-{
- int result;
- GConfClient *client;
- GError *error = NULL;
-
- g_return_val_if_fail (key != NULL, 0);
-
- client = eel_gconf_client_get_global ();
- g_return_val_if_fail (client != NULL, 0);
-
- result = gconf_client_get_int (client, key, &error);
-
- if (eel_gconf_handle_error (&error)) {
- result = 0;
- }
-
- return result;
-}
-
-void
-eel_gconf_set_string (const char *key,
- const char *string_value)
-{
- GConfClient *client;
- GError *error = NULL;
-
- g_return_if_fail (key != NULL);
-
- client = eel_gconf_client_get_global ();
- g_return_if_fail (client != NULL);
-
- gconf_client_set_string (client, key, string_value, &error);
- eel_gconf_handle_error (&error);
-}
-
-char *
-eel_gconf_get_string (const char *key)
-{
- char *result;
- GConfClient *client;
- GError *error = NULL;
-
- g_return_val_if_fail (key != NULL, NULL);
-
- client = eel_gconf_client_get_global ();
- g_return_val_if_fail (client != NULL, NULL);
-
- result = gconf_client_get_string (client, key, &error);
-
- if (eel_gconf_handle_error (&error)) {
- result = g_strdup ("");
- }
-
- return result;
-}
-
-void
-eel_gconf_set_string_list (const char *key,
- const GSList *slist)
-{
- GConfClient *client;
- GError *error;
-
- g_return_if_fail (key != NULL);
-
- client = eel_gconf_client_get_global ();
- g_return_if_fail (client != NULL);
-
- error = NULL;
- gconf_client_set_list (client, key, GCONF_VALUE_STRING,
- /* Need cast cause of GConf api bug */
- (GSList *) slist,
- &error);
- eel_gconf_handle_error (&error);
-}
-
-GSList *
-eel_gconf_get_string_list (const char *key)
-{
- GSList *slist;
- GConfClient *client;
- GError *error;
-
- g_return_val_if_fail (key != NULL, NULL);
-
- client = eel_gconf_client_get_global ();
- g_return_val_if_fail (client != NULL, NULL);
-
- error = NULL;
- slist = gconf_client_get_list (client, key, GCONF_VALUE_STRING, &error);
- if (eel_gconf_handle_error (&error)) {
- slist = NULL;
- }
-
- return slist;
-}
-
-gboolean
-eel_gconf_is_default (const char *key)
-{
- gboolean result;
- GConfValue *value;
- GError *error = NULL;
-
- g_return_val_if_fail (key != NULL, FALSE);
-
- value = gconf_client_get_without_default (eel_gconf_client_get_global (), key, &error);
-
- if (eel_gconf_handle_error (&error)) {
- if (value != NULL) {
- gconf_value_free (value);
- }
- return FALSE;
- }
-
- result = (value == NULL);
- eel_gconf_value_free (value);
- return result;
-}
-
-gboolean
-eel_gconf_key_is_writable (const char *key)
-{
- gboolean result;
- GError *error = NULL;
-
- g_return_val_if_fail (key != NULL, FALSE);
-
- result = gconf_client_key_is_writable (eel_gconf_client_get_global (), key, &error);
-
- if (eel_gconf_handle_error (&error)) {
- return result;
- }
-
- return result;
-}
-
-gboolean
-eel_gconf_monitor_add (const char *directory)
-{
- GError *error = NULL;
- GConfClient *client;
-
- g_return_val_if_fail (directory != NULL, FALSE);
-
- client = gconf_client_get_default ();
- g_return_val_if_fail (client != NULL, FALSE);
-
- gconf_client_add_dir (client,
- directory,
- GCONF_CLIENT_PRELOAD_NONE,
- &error);
-
- if (eel_gconf_handle_error (&error)) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-eel_gconf_monitor_remove (const char *directory)
-{
- GError *error = NULL;
- GConfClient *client;
-
- if (directory == NULL) {
- return FALSE;
- }
-
- client = gconf_client_get_default ();
- g_return_val_if_fail (client != NULL, FALSE);
-
- gconf_client_remove_dir (client,
- directory,
- &error);
-
- if (eel_gconf_handle_error (&error)) {
- return FALSE;
- }
-
- return TRUE;
-}
-
-void
-eel_gconf_preload_cache (const char *directory,
- GConfClientPreloadType preload_type)
-{
- GError *error = NULL;
- GConfClient *client;
-
- if (directory == NULL) {
- return;
- }
-
- client = gconf_client_get_default ();
- g_return_if_fail (client != NULL);
-
- gconf_client_preload (client,
- directory,
- preload_type,
- &error);
-
- eel_gconf_handle_error (&error);
-}
-
-void
-eel_gconf_suggest_sync (void)
-{
- GConfClient *client;
- GError *error = NULL;
-
- client = eel_gconf_client_get_global ();
- g_return_if_fail (client != NULL);
-
- gconf_client_suggest_sync (client, &error);
- eel_gconf_handle_error (&error);
-}
-
-GConfValue*
-eel_gconf_get_value (const char *key)
-{
- GConfValue *value = NULL;
- GConfClient *client;
- GError *error = NULL;
-
- g_return_val_if_fail (key != NULL, NULL);
-
- client = eel_gconf_client_get_global ();
- g_return_val_if_fail (client != NULL, NULL);
-
- value = gconf_client_get (client, key, &error);
-
- if (eel_gconf_handle_error (&error)) {
- if (value != NULL) {
- gconf_value_free (value);
- value = NULL;
- }
- }
-
- return value;
-}
-
-GConfValue*
-eel_gconf_get_default_value (const char *key)
-{
- GConfValue *value = NULL;
- GConfClient *client;
- GError *error = NULL;
-
- g_return_val_if_fail (key != NULL, NULL);
-
- client = eel_gconf_client_get_global ();
- g_return_val_if_fail (client != NULL, NULL);
-
- value = gconf_client_get_default_from_schema (client, key, &error);
-
- if (eel_gconf_handle_error (&error)) {
- if (value != NULL) {
- gconf_value_free (value);
- value = NULL;
- }
- }
-
- return value;
-}
-
-static int
-eel_strcmp (const char *string_a, const char *string_b)
-{
- /* FIXME bugzilla.eazel.com 5450: Maybe we need to make this
- * treat 'NULL < ""', or have a flavor that does that. If we
- * didn't have code that already relies on 'NULL == ""', I
- * would change it right now.
- */
- return strcmp (string_a == NULL ? "" : string_a,
- string_b == NULL ? "" : string_b);
-}
-
-static gboolean
-eel_str_is_equal (const char *string_a, const char *string_b)
-{
- /* FIXME bugzilla.eazel.com 5450: Maybe we need to make this
- * treat 'NULL != ""', or have a flavor that does that. If we
- * didn't have code that already relies on 'NULL == ""', I
- * would change it right now.
- */
- return eel_strcmp (string_a, string_b) == 0;
-}
-
-static gboolean
-simple_value_is_equal (const GConfValue *a,
- const GConfValue *b)
-{
- g_return_val_if_fail (a != NULL, FALSE);
- g_return_val_if_fail (b != NULL, FALSE);
-
- switch (a->type) {
- case GCONF_VALUE_STRING:
- return eel_str_is_equal (gconf_value_get_string (a),
- gconf_value_get_string (b));
- break;
-
- case GCONF_VALUE_INT:
- return gconf_value_get_int (a) ==
- gconf_value_get_int (b);
- break;
-
- case GCONF_VALUE_FLOAT:
- return gconf_value_get_float (a) ==
- gconf_value_get_float (b);
- break;
-
- case GCONF_VALUE_BOOL:
- return gconf_value_get_bool (a) ==
- gconf_value_get_bool (b);
- break;
- default:
- g_assert_not_reached ();
- }
-
- return FALSE;
-}
-
-gboolean
-eel_gconf_value_is_equal (const GConfValue *a,
- const GConfValue *b)
-{
- GSList *node_a;
- GSList *node_b;
-
- if (a == NULL && b == NULL) {
- return TRUE;
- }
-
- if (a == NULL || b == NULL) {
- return FALSE;
- }
-
- if (a->type != b->type) {
- return FALSE;
- }
-
- switch (a->type) {
- case GCONF_VALUE_STRING:
- case GCONF_VALUE_INT:
- case GCONF_VALUE_FLOAT:
- case GCONF_VALUE_BOOL:
- return simple_value_is_equal (a, b);
- break;
-
- case GCONF_VALUE_LIST:
- if (gconf_value_get_list_type (a) !=
- gconf_value_get_list_type (b)) {
- return FALSE;
- }
-
- node_a = gconf_value_get_list (a);
- node_b = gconf_value_get_list (b);
-
- if (node_a == NULL && node_b == NULL) {
- return TRUE;
- }
-
- if (g_slist_length (node_a) !=
- g_slist_length (node_b)) {
- return FALSE;
- }
-
- for (;
- node_a != NULL && node_b != NULL;
- node_a = node_a->next, node_b = node_b->next) {
- g_assert (node_a->data != NULL);
- g_assert (node_b->data != NULL);
- if (!simple_value_is_equal (node_a->data, node_b->data)) {
- return FALSE;
- }
- }
-
- return TRUE;
- default:
- /* FIXME: pair ? */
- g_assert (0);
- }
-
- g_assert_not_reached ();
- return FALSE;
-}
-
-void
-eel_gconf_value_free (GConfValue *value)
-{
- if (value == NULL) {
- return;
- }
-
- gconf_value_free (value);
-}
-
-guint
-eel_gconf_notification_add (const char *key,
- GConfClientNotifyFunc notification_callback,
- gpointer callback_data)
-{
- guint notification_id;
- GConfClient *client;
- GError *error = NULL;
-
- g_return_val_if_fail (key != NULL, EEL_GCONF_UNDEFINED_CONNECTION);
- g_return_val_if_fail (notification_callback != NULL, EEL_GCONF_UNDEFINED_CONNECTION);
-
- client = eel_gconf_client_get_global ();
- g_return_val_if_fail (client != NULL, EEL_GCONF_UNDEFINED_CONNECTION);
-
- notification_id = gconf_client_notify_add (client,
- key,
- notification_callback,
- callback_data,
- NULL,
- &error);
-
- if (eel_gconf_handle_error (&error)) {
- if (notification_id != EEL_GCONF_UNDEFINED_CONNECTION) {
- gconf_client_notify_remove (client, notification_id);
- notification_id = EEL_GCONF_UNDEFINED_CONNECTION;
- }
- }
-
- return notification_id;
-}
-
-void
-eel_gconf_notification_remove (guint notification_id)
-{
- GConfClient *client;
-
- if (notification_id == EEL_GCONF_UNDEFINED_CONNECTION) {
- return;
- }
-
- client = eel_gconf_client_get_global ();
- g_return_if_fail (client != NULL);
-
- gconf_client_notify_remove (client, notification_id);
-}
-
-GSList *
-eel_gconf_value_get_string_list (const GConfValue *value)
-{
- GSList *result;
- const GSList *slist;
- const GSList *node;
- const char *string;
- const GConfValue *next_value;
-
- if (value == NULL) {
- return NULL;
- }
-
- g_return_val_if_fail (value->type == GCONF_VALUE_LIST, NULL);
- g_return_val_if_fail (gconf_value_get_list_type (value) == GCONF_VALUE_STRING, NULL);
-
- slist = gconf_value_get_list (value);
- result = NULL;
- for (node = slist; node != NULL; node = node->next) {
- next_value = node->data;
- g_return_val_if_fail (next_value != NULL, NULL);
- g_return_val_if_fail (next_value->type == GCONF_VALUE_STRING, NULL);
- string = gconf_value_get_string (next_value);
- result = g_slist_append (result, g_strdup (string));
- }
- return result;
-}
-
-void
-eel_gconf_value_set_string_list (GConfValue *value,
- const GSList *string_list)
-{
- const GSList *node;
- GConfValue *next_value;
- GSList *value_list;
-
- g_return_if_fail (value->type == GCONF_VALUE_LIST);
- g_return_if_fail (gconf_value_get_list_type (value) == GCONF_VALUE_STRING);
-
- value_list = NULL;
- for (node = string_list; node != NULL; node = node->next) {
- next_value = gconf_value_new (GCONF_VALUE_STRING);
- gconf_value_set_string (next_value, node->data);
- value_list = g_slist_append (value_list, next_value);
- }
-
- gconf_value_set_list (value, value_list);
-
- for (node = value_list; node != NULL; node = node->next) {
- gconf_value_free (node->data);
- }
- g_slist_free (value_list);
-}
-
-void
-eel_gconf_set_float (const char *key,
- gfloat float_value)
-{
- GConfClient *client;
- GError *error = NULL;
-
- g_return_if_fail (key != NULL);
-
- client = eel_gconf_client_get_global ();
- g_return_if_fail (client != NULL);
-
- gconf_client_set_float (client, key, float_value, &error);
- eel_gconf_handle_error (&error);
-}
-
-gfloat
-eel_gconf_get_float (const char *key)
-{
- gfloat result;
- GConfClient *client;
- GError *error = NULL;
-
- g_return_val_if_fail (key != NULL, 0);
-
- client = eel_gconf_client_get_global ();
- g_return_val_if_fail (client != NULL, 0);
-
- result = gconf_client_get_float (client, key, &error);
-
- if (eel_gconf_handle_error (&error)) {
- result = 0;
- }
-
- return result;
-}
-
-static char *
-tilde_compress (const char *path)
-{
- const char *home;
-
- if (path == NULL) return NULL;
-
- home = g_get_home_dir ();
- if (home == NULL) return g_strdup (path);
-
- if (g_str_has_prefix (path, home))
- {
- return g_strconcat ("~", path + strlen (home), NULL);
- }
-
- return g_strdup (path);
-}
-
-void
-eel_gconf_set_path (const char *key,
- const char *value)
-{
- char *tilde_path;
- char *converted;
-
- tilde_path = tilde_compress (value);
- converted = g_filename_to_utf8 (tilde_path, -1, NULL, NULL, NULL);
- eel_gconf_set_string (key, converted);
-
- g_free (tilde_path);
- g_free (converted);
-}
-
-void
-eel_gconf_unset_key (const char *key)
-{
- GConfClient *client;
- GError *error = NULL;
-
- client = eel_gconf_client_get_global ();
- g_return_if_fail (client != NULL);
-
- gconf_client_unset (client, key, &error);
- eel_gconf_handle_error (&error);
-}
-
-void
-eel_gconf_notify (const char *key)
-{
- GConfClient *client;
-
- client = eel_gconf_client_get_global ();
- g_return_if_fail (client != NULL);
-
- gconf_client_notify (client, key);
-}
diff --git a/lib/eel-gconf-extensions.h b/lib/eel-gconf-extensions.h
deleted file mode 100644
index 36ce01684..000000000
--- a/lib/eel-gconf-extensions.h
+++ /dev/null
@@ -1,83 +0,0 @@
-/* -*- Mode: C; indent-tabs-mode: t; c-basic-offset: 8; tab-width: 8 -*- */
-
-/* eel-gconf-extensions.h - Stuff to make GConf easier to use.
-
- Copyright © 2000, 2001 Eazel, Inc.
-
- The Gnome Library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public License as
- published by the Free Software Foundation; either version 2 of the
- License, or (at your option) any later version.
-
- The Gnome Library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with the Gnome Library; see the file COPYING.LIB. If not,
- write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- Boston, MA 02110-1301, USA.
-
- Authors: Ramiro Estrugo <ramiro@eazel.com>
-
-*/
-
-#ifndef EEL_GCONF_EXTENSIONS_H
-#define EEL_GCONF_EXTENSIONS_H
-
-#include <glib.h>
-#include <gconf/gconf.h>
-#include <gconf/gconf-client.h>
-
-G_BEGIN_DECLS
-
-#define EEL_GCONF_UNDEFINED_CONNECTION 0
-
-GConfClient *eel_gconf_client_get_global (void);
-gboolean eel_gconf_handle_error (GError **error);
-void eel_gconf_set_boolean (const char *key,
- gboolean boolean_value);
-gboolean eel_gconf_get_boolean (const char *key);
-int eel_gconf_get_integer (const char *key);
-void eel_gconf_set_integer (const char *key,
- int int_value);
-char * eel_gconf_get_string (const char *key);
-void eel_gconf_set_string (const char *key,
- const char *string_value);
-GSList * eel_gconf_get_string_list (const char *key);
-void eel_gconf_set_string_list (const char *key,
- const GSList *string_list_value);
-gboolean eel_gconf_key_is_writable (const char *key);
-gboolean eel_gconf_is_default (const char *key);
-gboolean eel_gconf_monitor_add (const char *directory);
-gboolean eel_gconf_monitor_remove (const char *directory);
-void eel_gconf_preload_cache (const char *directory,
- GConfClientPreloadType preload_type);
-void eel_gconf_suggest_sync (void);
-GConfValue* eel_gconf_get_value (const char *key);
-GConfValue* eel_gconf_get_default_value (const char *key);
-gboolean eel_gconf_value_is_equal (const GConfValue *a,
- const GConfValue *b);
-void eel_gconf_value_free (GConfValue *value);
-guint eel_gconf_notification_add (const char *key,
- GConfClientNotifyFunc notification_callback,
- gpointer callback_data);
-void eel_gconf_notification_remove (guint notification_id);
-GSList * eel_gconf_value_get_string_list (const GConfValue *value);
-void eel_gconf_value_set_string_list (GConfValue *value,
- const GSList *string_list);
-
-/* These are ephy additions, not part of the eel code */
-
-void eel_gconf_set_float (const char *key,
- gfloat float_value);
-gfloat eel_gconf_get_float (const char *key);
-void eel_gconf_set_path (const char *key,
- const char *value);
-void eel_gconf_unset_key (const char *key);
-void eel_gconf_notify (const char *key);
-
-G_END_DECLS
-
-#endif /* EEL_GCONF_EXTENSIONS_H */
diff --git a/lib/ephy-dialog.c b/lib/ephy-dialog.c
index f39a9f7b5..1ca4d0daa 100644
--- a/lib/ephy-dialog.c
+++ b/lib/ephy-dialog.c
@@ -23,7 +23,6 @@
#include "ephy-dialog.h"
#include "ephy-state.h"
#include "ephy-gui.h"
-#include "eel-gconf-extensions.h"
#include "ephy-debug.h"
#include <stdlib.h>
@@ -46,41 +45,17 @@ enum
PROP_DEFAULT_HEIGHT
};
-typedef enum
-{
- PT_TOGGLEBUTTON,
- PT_RADIOBUTTON,
- PT_SPINBUTTON,
- PT_COMBOBOX,
- PT_EDITABLE,
- PT_UNKNOWN
-} WidgetType;
-
-typedef struct
-{
- const char *id;
- EphyDialog *dialog;
- char *pref;
- EphyDialogApplyType apply_type;
- GtkWidget *widget;
- WidgetType widget_type;
- GType data_type;
- GList *string_enum;
- int data_col;
- gboolean loaded;
- gboolean sane_state;
-} PropertyInfo;
-
#define EPHY_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_DIALOG, EphyDialogPrivate))
struct _EphyDialogPrivate
{
char *name;
- GHashTable *props;
GtkWidget *parent;
GtkWidget *dialog;
+ GtkBuilder *builder;
+
guint has_default_size : 1;
guint disposing : 1;
guint initialized : 1;
@@ -89,8 +64,6 @@ struct _EphyDialogPrivate
int default_height;
};
-#define SPIN_DELAY 0.20
-
enum
{
CHANGED,
@@ -132,905 +105,6 @@ ephy_dialog_get_type (void)
return type;
}
-static PropertyInfo *
-lookup_info (EphyDialog *dialog, const char *id)
-{
- return g_hash_table_lookup (dialog->priv->props, id);
-}
-
-static void
-set_sensitivity (PropertyInfo *info, gboolean sensitive)
-{
- g_return_if_fail (info->widget != NULL);
-
- if (info->widget_type == PT_RADIOBUTTON)
- {
- GSList *list, *l;
-
- list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (info->widget));
-
- for (l = list; l != NULL; l = l->next)
- {
- sensitive = gtk_widget_is_sensitive (GTK_WIDGET (l->data)) && sensitive;
- gtk_widget_set_sensitive (GTK_WIDGET (l->data), sensitive);
- }
- }
- else if (info->widget_type == PT_EDITABLE)
- {
- sensitive = gtk_widget_is_sensitive (info->widget) && sensitive;
- gtk_editable_set_editable (GTK_EDITABLE (info->widget), sensitive);
- }
- else
- {
- sensitive = gtk_widget_is_sensitive (info->widget) && sensitive;
- gtk_widget_set_sensitive (info->widget, sensitive);
- }
-}
-
-static void
-set_value_from_pref (PropertyInfo *info, GValue *value)
-{
- char *text;
-
- switch (info->data_type)
- {
- case G_TYPE_STRING:
- g_value_init (value, G_TYPE_STRING);
- text = eel_gconf_get_string (info->pref);
- g_value_take_string (value, text);
- break;
- case G_TYPE_INT:
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, eel_gconf_get_integer (info->pref));
- break;
- case G_TYPE_FLOAT:
- g_value_init (value, G_TYPE_FLOAT);
- g_value_set_float (value, eel_gconf_get_float (info->pref));
- break;
- case G_TYPE_BOOLEAN:
- g_value_init (value, G_TYPE_BOOLEAN);
- g_value_set_boolean (value, eel_gconf_get_boolean (info->pref));
- break;
- default:
- g_warning ("Unsupported value read from pref %s\n", info->pref);
- break;
- }
-}
-
-static void
-set_pref_from_value (PropertyInfo *info, GValue *value)
-{
- const char *pref = info->pref;
-
- if (!G_VALUE_HOLDS (value, info->data_type))
- {
- g_warning ("Value type mismatch for id[%s], pref[%s]", info->id, info->pref);
- return;
- }
-
- switch (info->data_type)
- {
- case G_TYPE_STRING:
- {
- const char *string = g_value_get_string (value);
- if (string != NULL)
- {
- eel_gconf_set_string (pref, string);
- }
- else
- {
- eel_gconf_unset_key (pref);
- }
- break;
- }
- case G_TYPE_INT:
- eel_gconf_set_integer (pref, g_value_get_int (value));
- break;
- case G_TYPE_FLOAT:
- eel_gconf_set_float (pref, g_value_get_float (value));
- break;
- case G_TYPE_BOOLEAN:
- eel_gconf_set_boolean (pref, g_value_get_boolean (value));
- break;
- default:
- break;
- }
-}
-
-static gboolean
-set_value_from_editable (PropertyInfo *info, GValue *value)
-{
- char *text;
- gboolean retval = TRUE;
- gboolean free_text = TRUE;
-
- g_return_val_if_fail (GTK_IS_EDITABLE (info->widget), FALSE);
-
- text = gtk_editable_get_chars (GTK_EDITABLE (info->widget), 0, -1);
-
- g_value_init (value, info->data_type);
- switch (info->data_type)
- {
- case G_TYPE_STRING:
- g_value_take_string (value, text);
- free_text = FALSE;
- break;
- /* FIXME : handle possible errors in the input for int and float */
- case G_TYPE_INT:
- g_value_set_int (value, atoi (text));
- break;
- case G_TYPE_FLOAT:
- g_value_set_float (value, strtod (text, NULL));
- break;
- default:
- retval = FALSE;
- g_value_unset (value);
- g_warning ("Unsupported value type for editable %s", info->id);
- break;
- }
-
- if (free_text)
- {
- g_free (text);
- }
-
- return retval;
-}
-
-static gboolean
-set_value_from_combobox (PropertyInfo *info, GValue *value)
-{
- g_return_val_if_fail (GTK_IS_COMBO_BOX (info->widget), FALSE);
-
- if (info->data_col != -1)
- {
- GtkTreeModel *model;
- GtkTreeIter iter;
-
- if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (info->widget), &iter))
- {
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (info->widget));
- gtk_tree_model_get_value (model, &iter, info->data_col, value);
-
- return TRUE;
- }
- }
- else if (info->data_type == G_TYPE_INT)
- {
- int index;
-
- index = gtk_combo_box_get_active (GTK_COMBO_BOX (info->widget));
-
- if (index >= 0)
- {
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, index);
-
- return TRUE;
- }
- }
- else
- {
- g_warning ("Unsupported data type for combo %s\n", info->id);
- }
-
- return FALSE;
-}
-
-static int
-get_radio_button_active_index (GtkWidget *radiobutton)
-{
- GtkToggleButton *toggle_button;
- GSList *list;
- int index, i, length;
-
- /* get group list */
- list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (radiobutton));
- length = g_slist_length (list);
-
- /* iterate over list to find active button */
- for (i = 0; list != NULL; i++, list = list->next)
- {
- /* get button and text */
- toggle_button = GTK_TOGGLE_BUTTON (list->data);
- if (gtk_toggle_button_get_active (toggle_button))
- {
- break;
- }
- }
-
- /* check we didn't run off end */
- g_assert (list != NULL);
-
- /* return index (reverse order!) */
- return index = (length - 1) - i;
-}
-
-static gboolean
-set_value_from_radiobuttongroup (PropertyInfo *info, GValue *value)
-{
- gboolean retval = TRUE;
- int index;
-
- g_return_val_if_fail (GTK_IS_RADIO_BUTTON (info->widget), FALSE);
-
- index = get_radio_button_active_index (info->widget);
- g_return_val_if_fail (index >= 0, FALSE);
-
- if (info->data_type == G_TYPE_STRING)
- {
- g_return_val_if_fail (info->string_enum != NULL, FALSE);
- g_return_val_if_fail (g_list_nth_data (info->string_enum, index) != NULL, FALSE);
-
- g_value_init (value, G_TYPE_STRING);
- g_value_set_string (value, (char*) g_list_nth_data (info->string_enum, index));
- }
- else if (info->data_type == G_TYPE_INT)
- {
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, index);
- }
- else
- {
- retval = FALSE;
- g_warning ("unsupported data type for radio button %s\n", info->id);
- }
-
- return retval;
-}
-
-static gboolean
-set_value_from_spin_button (PropertyInfo *info, GValue *value)
-{
- gboolean retval = TRUE;
- gdouble f;
- gboolean is_int;
-
- g_return_val_if_fail (GTK_IS_SPIN_BUTTON (info->widget), FALSE);
-
- f = gtk_spin_button_get_value (GTK_SPIN_BUTTON (info->widget));
-
- is_int = (gtk_spin_button_get_digits (GTK_SPIN_BUTTON(info->widget)) == 0);
-
- if (info->data_type == G_TYPE_INT && is_int)
- {
- g_value_init (value, G_TYPE_INT);
- g_value_set_int (value, (int) f);
- }
- else if (info->data_type == G_TYPE_FLOAT)
- {
- g_value_init (value, G_TYPE_FLOAT);
- g_value_set_float (value, f);
- }
- else
- {
- retval = FALSE;
- g_warning ("Unsupported data type for spin button %s\n", info->id);
- }
-
- return retval;
-}
-
-static gboolean
-set_value_from_togglebutton (PropertyInfo *info, GValue *value)
-{
- gboolean retval = TRUE;
- gboolean active;
-
- g_return_val_if_fail (GTK_IS_TOGGLE_BUTTON (info->widget), FALSE);
-
- active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (info->widget));
-
- if (info->apply_type & PT_INVERTED)
- {
- active = !active;
- }
-
- if (info->data_type == G_TYPE_BOOLEAN)
- {
- g_value_init (value, info->data_type);
- g_value_set_boolean (value, active);
- }
- else
- {
- retval = FALSE;
- g_warning ("Unsupported data type for toggle button %s\n", info->id);
- }
-
- return retval;
-}
-
-static gboolean
-set_value_from_info (PropertyInfo *info, GValue *value)
-{
- gboolean retval;
-
- if (info->sane_state == FALSE)
- {
- return FALSE;
- }
-
- switch (info->widget_type)
- {
- case PT_SPINBUTTON:
- retval = set_value_from_spin_button (info, value);
- break;
- case PT_RADIOBUTTON:
- retval = set_value_from_radiobuttongroup (info, value);
- break;
- case PT_TOGGLEBUTTON:
- retval = set_value_from_togglebutton (info, value);
- break;
- case PT_EDITABLE:
- retval = set_value_from_editable (info, value);
- break;
- case PT_COMBOBOX:
- retval = set_value_from_combobox (info, value);
- break;
- default:
- retval = FALSE;
- g_warning ("Unsupported widget type\n");
- break;
- }
-
- return retval;
-}
-
-static void
-set_editable_from_value (PropertyInfo *info, const GValue *value)
-{
- char *text = NULL;
- int pos = 0; /* insertion position */
-
- g_return_if_fail (GTK_IS_EDITABLE (info->widget));
-
- switch (info->data_type)
- {
- case G_TYPE_STRING:
- text = g_value_dup_string (value);
- break;
- case G_TYPE_INT:
- text = g_strdup_printf ("%d", g_value_get_int (value));
- break;
- case G_TYPE_FLOAT:
- text = g_strdup_printf ("%.2f", g_value_get_float (value));
- break;
- default:
- break;
- }
-
- if (text == NULL)
- {
- text = g_strdup ("");
- }
-
- info->sane_state = TRUE;
-
- gtk_editable_delete_text (GTK_EDITABLE (info->widget), 0, -1);
- gtk_editable_insert_text (GTK_EDITABLE (info->widget), text, strlen (text), &pos);
-
- g_free (text);
-}
-
-static int
-strcmp_with_null (const char *key1,
- const char *key2)
-{
- if (key1 == NULL && key2 == NULL)
- {
- return 0;
- }
- if (key1 == NULL)
- {
- return -1;
- }
- if (key2 == NULL)
- {
- return 1;
- }
-
- return strcmp (key1, key2);
-}
-
-static int
-get_index_from_value (const GValue *value, GList *string_enum)
-{
- int index = -1;
- const char *val;
- GList *s = NULL;
-
- if (string_enum)
- {
- val = g_value_get_string (value);
-
- s = g_list_find_custom (string_enum, val, (GCompareFunc) strcmp_with_null);
-
- if (s)
- {
- index = g_list_position (string_enum, s);
- }
-
- }
- else
- {
- index = g_value_get_int (value);
- }
-
- return index;
-}
-
-static gboolean
-compare_values (const GValue *a, const GValue *b)
-{
- if (G_VALUE_HOLDS (a, G_TYPE_STRING))
- {
- const char *ta, *tb;
-
- ta = g_value_get_string (a);
- tb = g_value_get_string (b);
-
- return (strcmp_with_null (ta, tb) == 0);
- }
- else if (G_VALUE_HOLDS (a, G_TYPE_INT))
- {
- return g_value_get_int (a) == g_value_get_int (b);
- }
- else if (G_VALUE_HOLDS (a, G_TYPE_FLOAT))
- {
- return g_value_get_float (a) == g_value_get_float (b);
- }
- else if (G_VALUE_HOLDS (a, G_TYPE_BOOLEAN))
- {
- return g_value_get_boolean (a) == g_value_get_boolean (b);
- }
-
- return FALSE;
-}
-
-static void
-set_combo_box_from_value (PropertyInfo *info, const GValue *value)
-{
- g_return_if_fail (GTK_IS_COMBO_BOX (info->widget));
-
- if (info->data_col != -1)
- {
- GValue data = { 0, };
- GtkTreeModel *model;
- GtkTreeIter iter;
- gboolean valid, found = FALSE;
-
- model = gtk_combo_box_get_model (GTK_COMBO_BOX (info->widget));
-
- valid = gtk_tree_model_get_iter_first (model, &iter);
- while (valid)
- {
- gtk_tree_model_get_value (model, &iter, info->data_col, &data);
- found = compare_values (&data, value);
- g_value_unset (&data);
-
- if (found) break;
-
- valid = gtk_tree_model_iter_next (model, &iter);
- }
-
- if (found)
- {
- gtk_combo_box_set_active_iter (GTK_COMBO_BOX (info->widget), &iter);
- }
- else
- {
- gtk_combo_box_set_active (GTK_COMBO_BOX (info->widget), 0);
- }
-
- info->sane_state = found;
- }
- else if (info->data_type == G_TYPE_INT)
- {
- int index;
-
- index = g_value_get_int (value);
-
- info->sane_state = index >= 0;
-
- g_return_if_fail (index >= -1);
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (info->widget), index);
- }
- else
- {
- g_warning ("Unsupported data type for combo box %s\n", info->id);
- }
-}
-
-static void
-set_radiobuttongroup_from_value (PropertyInfo *info, const GValue *value)
-{
- GtkToggleButton *button;
- GSList *list;
- gint length;
- int index;
-
- g_return_if_fail (GTK_IS_RADIO_BUTTON (info->widget));
-
- list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (info->widget));
-
- length = g_slist_length (list);
-
- index = get_index_from_value (value, info->string_enum);
-
- /* new buttons are *prepended* to the list, so button added as first
- * has last position in the list */
- index = (length - 1) - index;
-
- if (index < 0 || index >= length)
- {
- info->sane_state = FALSE;
- g_return_if_fail (index >= 0 && index < length);
- return;
- }
-
- button = GTK_TOGGLE_BUTTON (g_slist_nth_data (list, index));
- g_return_if_fail (button != NULL);
-
- info->sane_state = TRUE;
-
- if (gtk_toggle_button_get_active (button) == FALSE)
- {
- gtk_toggle_button_set_active (button, TRUE);
- }
-}
-
-static void
-set_spin_button_from_value (PropertyInfo *info, const GValue *value)
-{
- gdouble f = 0.0;
- gboolean is_int;
-
- g_return_if_fail (GTK_IS_SPIN_BUTTON (info->widget));
-
- is_int = (gtk_spin_button_get_digits (GTK_SPIN_BUTTON (info->widget)) == 0);
-
- if (info->data_type == G_TYPE_INT && is_int)
- {
- f = (float) g_value_get_int (value);
- }
- else if (info->data_type == G_TYPE_FLOAT)
- {
- f = g_value_get_float (value);
- }
- else
- {
- info->sane_state = FALSE;
- g_warning ("Unsupported data type for spin button %s\n", info->id);
- return;
- }
-
- info->sane_state = TRUE;
-
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (info->widget), f);
-}
-
-static void
-set_togglebutton_from_value (PropertyInfo *info, const GValue *value)
-{
- gboolean active;
-
- g_return_if_fail (GTK_IS_TOGGLE_BUTTON (info->widget));
- g_return_if_fail (info->data_type == G_TYPE_BOOLEAN);
-
- active = g_value_get_boolean (value);
-
- if (info->apply_type & PT_INVERTED)
- {
- active = !active;
- }
-
- info->sane_state = TRUE;
-
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (info->widget), active);
-}
-
-static void
-set_info_from_value (PropertyInfo *info, const GValue *value)
-{
- if (!G_VALUE_HOLDS (value, info->data_type))
- {
- g_warning ("Incompatible value types for id %s\n", info->id);
- return;
- }
-
- switch (info->widget_type)
- {
- case PT_SPINBUTTON:
- set_spin_button_from_value (info, value);
- break;
- case PT_RADIOBUTTON:
- set_radiobuttongroup_from_value (info, value);
- break;
- case PT_TOGGLEBUTTON:
- set_togglebutton_from_value (info, value);
- break;
- case PT_EDITABLE:
- set_editable_from_value (info, value);
- break;
- case PT_COMBOBOX:
- set_combo_box_from_value (info, value);
- break;
- default:
- g_warning ("Unknown widget type\n");
- break;
- }
-}
-
-/* widget changed callbacks */
-
-static void
-set_pref_from_info_and_emit (PropertyInfo *info)
-{
- GValue value = { 0, };
-
- if (!set_value_from_info (info, &value))
- {
- return;
- }
-
- g_signal_emit (info->dialog, signals[CHANGED], g_quark_from_string (info->id), &value);
-
- if ((info->apply_type & PT_AUTOAPPLY) && info->pref != NULL)
- {
- set_pref_from_value (info, &value);
- }
-
- g_value_unset (&value);
-}
-
-static void
-togglebutton_clicked_cb (GtkWidget *widget, PropertyInfo *info)
-{
- info->sane_state = TRUE;
-
- set_pref_from_info_and_emit (info);
-}
-
-static void
-radiobutton_clicked_cb (GtkWidget *widget, PropertyInfo *info)
-{
- info->sane_state = TRUE;
-
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON(widget)))
- {
- return;
- }
-
- set_pref_from_info_and_emit (info);
-}
-
-static gboolean
-spinbutton_timeout_cb (PropertyInfo *info)
-{
- GTimer *spin_timer;
-
- spin_timer = (GTimer *) g_object_get_data (G_OBJECT (info->widget), "timer");
-
- /* timer still valid? */
- if (spin_timer == NULL)
- {
- /* don't call me again */
- return FALSE;
- }
-
- /* okay, we're ready to set */
- if (g_timer_elapsed (spin_timer, NULL) >= SPIN_DELAY)
- {
- /* kill off the timer */
- g_timer_destroy (spin_timer);
- g_object_set_data (G_OBJECT (info->widget), "timer", NULL);
-
- /* HACK update the spinbutton here so that the
- * changes made directly in the entry are accepted
- * and set in the pref. Otherwise the old value is used */
- gtk_spin_button_update (GTK_SPIN_BUTTON (info->widget));
-
- info->sane_state = TRUE;
-
- set_pref_from_info_and_emit (info);
-
- /* done, don't run again */
- return FALSE;
- }
-
- /* not elapsed yet, call me again */
- return TRUE;
-}
-
-static void
-spinbutton_changed_cb (GtkWidget *widget, PropertyInfo *info)
-{
- GTimer *spin_timer;
-
- if ((info->apply_type & PT_AUTOAPPLY) == 0) return;
-
- spin_timer = g_object_get_data (G_OBJECT (info->widget), "timer");
-
- /* destroy an existing timer */
- if (spin_timer != NULL)
- {
- g_timer_destroy (spin_timer);
- }
-
- /* start tnew timer */
- spin_timer = g_timer_new();
- g_timer_start (spin_timer);
- g_object_set_data (G_OBJECT (info->widget), "timer", spin_timer);
-
- g_timeout_add (50, (GSourceFunc) spinbutton_timeout_cb, info);
-}
-
-static void
-changed_cb (GtkWidget *widget, PropertyInfo *info)
-{
- info->sane_state = TRUE;
-
- set_pref_from_info_and_emit (info);
-}
-
-static void
-connect_signals (gpointer key, PropertyInfo *info, EphyDialog *dialog)
-{
- GSList *list;
-
- g_return_if_fail (info->widget != NULL);
-
- switch (info->widget_type)
- {
- case PT_TOGGLEBUTTON:
- g_signal_connect (G_OBJECT (info->widget), "clicked",
- G_CALLBACK (togglebutton_clicked_cb),
- (gpointer)info);
- break;
- case PT_RADIOBUTTON:
- list = gtk_radio_button_get_group
- (GTK_RADIO_BUTTON (info->widget));
- for (; list != NULL; list = list->next)
- {
- g_signal_connect
- (G_OBJECT (list->data), "clicked",
- G_CALLBACK (radiobutton_clicked_cb),
- info);
- }
- break;
- case PT_SPINBUTTON:
- g_signal_connect (G_OBJECT (info->widget), "changed",
- G_CALLBACK (spinbutton_changed_cb),
- info);
- break;
- case PT_COMBOBOX:
- g_signal_connect (G_OBJECT (info->widget), "changed",
- G_CALLBACK (changed_cb), info);
- break;
- case PT_EDITABLE:
- g_signal_connect (G_OBJECT (info->widget), "changed",
- G_CALLBACK (changed_cb), info);
- break;
- case PT_UNKNOWN:
- break;
- }
-}
-
-static void
-disconnect_signals (gpointer key, PropertyInfo *info, EphyDialog *dialog)
-{
- g_return_if_fail (info->widget != NULL);
-
- g_signal_handlers_disconnect_matched (info->widget, G_SIGNAL_MATCH_DATA, 0, 0, NULL, NULL, info);
-}
-
-static void
-init_props (EphyDialog *dialog, const EphyDialogProperty *properties, GtkBuilder *builder)
-{
- int i;
-
- for (i = 0 ; properties[i].id != NULL; i++)
- {
- PropertyInfo *info = g_new0 (PropertyInfo, 1);
-
- info->id = properties[i].id;
- info->dialog = dialog;
- info->pref = g_strdup (properties[i].pref);
- info->apply_type = properties[i].apply_type;
- info->string_enum = NULL;
- info->data_col = -1;
-
- info->widget = (GtkWidget*)gtk_builder_get_object (builder, info->id);
-
- if (GTK_IS_COMBO_BOX (info->widget))
- {
- info->widget_type = PT_COMBOBOX;
- info->data_type = G_TYPE_INT;
- }
- else if (GTK_IS_SPIN_BUTTON (info->widget))
- {
- info->widget_type = PT_SPINBUTTON;
- info->data_type = G_TYPE_INT;
- }
- else if (GTK_IS_RADIO_BUTTON (info->widget))
- {
- info->widget_type = PT_RADIOBUTTON;
- info->data_type = G_TYPE_INT;
- }
- else if (GTK_IS_TOGGLE_BUTTON (info->widget))
- {
- info->widget_type = PT_TOGGLEBUTTON;
- info->data_type = G_TYPE_BOOLEAN;
- }
- else if (GTK_IS_EDITABLE (info->widget))
- {
- info->widget_type = PT_EDITABLE;
- info->data_type = G_TYPE_STRING;
- }
- else
- {
- info->widget_type = PT_UNKNOWN;
- info->data_type = G_TYPE_INVALID;
- }
-
- if (properties[i].data_type != 0)
- {
- info->data_type = properties[i].data_type;
- }
-
- info->loaded = FALSE;
- info->sane_state = FALSE;
-
- g_hash_table_insert (dialog->priv->props, (char *) info->id, info);
- }
-}
-
-static void
-load_info (gpointer key, PropertyInfo *info, EphyDialog *dialog)
-{
- GValue value = { 0, };
-
- g_return_if_fail (info->widget != NULL);
-
- if (info->pref != NULL)
- {
- set_value_from_pref (info, &value);
- set_info_from_value (info, &value);
-
- g_signal_emit (info->dialog, signals[CHANGED], g_quark_from_string (info->id), &value);
-
- g_value_unset (&value);
-
- set_sensitivity (info, eel_gconf_key_is_writable (info->pref));
- }
-
- info->loaded = TRUE;
-}
-
-static void
-save_info (gpointer key, PropertyInfo *info, EphyDialog *dialog)
-{
- GValue value = { 0, };
-
- if (info->pref == NULL || (info->apply_type & PT_NORMAL) == 0)
- {
- return;
- }
-
- if (!info->sane_state)
- {
- g_warning ("Not persisting insane state of id[%s]", info->id);
- return;
- }
-
- if (set_value_from_info (info, &value))
- {
- set_pref_from_value (info, &value);
- g_value_unset (&value);
- }
-}
-
static void
setup_default_size (EphyDialog *dialog)
{
@@ -1058,8 +132,6 @@ setup_default_size (EphyDialog *dialog)
static void
dialog_destroy_cb (GtkWidget *widget, EphyDialog *dialog)
{
- g_hash_table_foreach (dialog->priv->props, (GHFunc) save_info, dialog);
-
if (dialog->priv->disposing == FALSE)
{
g_object_unref (dialog);
@@ -1068,7 +140,6 @@ dialog_destroy_cb (GtkWidget *widget, EphyDialog *dialog)
static void
impl_construct (EphyDialog *dialog,
- const EphyDialogProperty *properties,
const char *file,
const char *name,
const char *domain)
@@ -1087,7 +158,9 @@ impl_construct (EphyDialog *dialog,
return;
}
- priv->dialog = (GtkWidget*)gtk_builder_get_object (builder, name);
+ priv->builder = g_object_ref (builder);
+ priv->dialog = GTK_WIDGET (gtk_builder_get_object (builder, name));
+
g_return_if_fail (priv->dialog != NULL);
if (priv->name == NULL)
@@ -1095,11 +168,6 @@ impl_construct (EphyDialog *dialog,
priv->name = g_strdup (name);
}
- if (properties)
- {
- init_props (dialog, properties, builder);
- }
-
g_signal_connect_object (dialog->priv->dialog, "destroy",
G_CALLBACK(dialog_destroy_cb), dialog, 0);
@@ -1109,14 +177,6 @@ impl_construct (EphyDialog *dialog,
static void
impl_show (EphyDialog *dialog)
{
- if (dialog->priv->initialized == FALSE)
- {
- dialog->priv->initialized = TRUE;
-
- g_hash_table_foreach (dialog->priv->props, (GHFunc) load_info, dialog);
- g_hash_table_foreach (dialog->priv->props, (GHFunc) connect_signals, dialog);
- }
-
setup_default_size (dialog);
if (dialog->priv->parent != NULL)
@@ -1132,100 +192,6 @@ impl_show (EphyDialog *dialog)
}
/**
- * ephy_dialog_add_enum:
- * @dialog: an #EphyDialog
- * @property_id: string identifier of the property to modify
- * @n_items: length of @items array
- * @items: array of items to add to @property_id
- *
- * Modifies the property identified by @property_id in @dialog to have its
- * string_enum member set to a #GList constructed with the elements given as
- * @items.
- **/
-void
-ephy_dialog_add_enum (EphyDialog *dialog,
- const char *property_id,
- guint n_items,
- const char *const *items)
-{
- PropertyInfo *info;
- int i = 0;
- GList *l = NULL;
-
- g_return_if_fail (EPHY_IS_DIALOG (dialog));
-
- info = lookup_info (dialog, property_id);
- g_return_if_fail (info != NULL);
-
- for (i = 0; i < n_items; i++)
- {
- l = g_list_prepend (l, g_strdup (items[i]));
- }
-
- info->string_enum = g_list_reverse (l);
-}
-
-/**
- * ephy_dialog_set_data_column:
- * @dialog: an #EphyDialog
- * @property_id: string identifier of the property to modify
- * @column: value for the data_col member of @property_id
- *
- * Sets the data_col member of the property identified by @property_id in @dialog
- * to @column.
- **/
-void
-ephy_dialog_set_data_column (EphyDialog *dialog,
- const char *property_id,
- int column)
-{
- PropertyInfo *info;
-
- g_return_if_fail (EPHY_IS_DIALOG (dialog));
-
- info = lookup_info (dialog, property_id);
- g_return_if_fail (info != NULL);
-
- info->data_col = column;
-}
-
-/**
- * ephy_dialog_set_pref:
- * @dialog: an #EphyDialog
- * @property_id: string identifier of the property to modify
- * @pref: preference value of the property identified by @property_id
- *
- * Sets the pref member of the property of @dialog identified by @property_id
- * to @pref.
- **/
-void
-ephy_dialog_set_pref (EphyDialog *dialog,
- const char *property_id,
- const char *pref)
-{
- PropertyInfo *info;
-
- g_return_if_fail (EPHY_IS_DIALOG (dialog));
-
- info = lookup_info (dialog, property_id);
- g_return_if_fail (info != NULL);
-
- disconnect_signals (NULL, info, dialog);
-
- info->loaded = FALSE;
- info->sane_state = FALSE;
- g_free (info->pref);
- info->pref = g_strdup (pref);
-
- if (dialog->priv->initialized)
- {
- /* dialog is already initialised, so initialise this here */
- load_info (NULL, info, dialog);
- connect_signals (NULL, info, dialog);
- }
-}
-
-/**
* ephy_dialog_set_size_group:
* @dialog: an #EphyDialog
* @first_id: id of a widget in @dialog
@@ -1250,14 +216,12 @@ ephy_dialog_set_size_group (EphyDialog *dialog,
while (first_id != NULL)
{
- PropertyInfo *info;
+ GtkWidget *widget;
- info = lookup_info (dialog, first_id);
- g_return_if_fail (info != NULL);
+ widget = ephy_dialog_get_control (dialog, first_id);
+ g_return_if_fail (widget != NULL);
- g_return_if_fail (info->widget != NULL);
-
- gtk_size_group_add_widget (size_group, info->widget);
+ gtk_size_group_add_widget (size_group, widget);
first_id = va_arg (vl, const char*);
}
@@ -1270,24 +234,21 @@ ephy_dialog_set_size_group (EphyDialog *dialog,
/**
* ephy_dialog_construct:
* @dialog: an #EphyDialog
- * @properties: an array of #EphyDialogProperty elements
* @file: the path to a #GtkBuilder file
* @name: name of the widget to use for @dialog, found in @file
* @domain: translation domain to set for @dialog
*
* Constructs the widget part of @dialog using the widget identified by @name
- * in the #GtkBuilder file found at @file. Fills the dialog properties with
- * @properties and sets translation domain to @domain.
+ * in the #GtkBuilder file found at @file.
**/
void
ephy_dialog_construct (EphyDialog *dialog,
- const EphyDialogProperty *properties,
const char *file,
const char *name,
const char *domain)
{
EphyDialogClass *klass = EPHY_DIALOG_GET_CLASS (dialog);
- klass->construct (dialog, properties, file, name, domain);
+ klass->construct (dialog, file, name, domain);
}
/**
@@ -1354,16 +315,16 @@ ephy_dialog_run (EphyDialog *dialog)
**/
GtkWidget *
ephy_dialog_get_control (EphyDialog *dialog,
- const char *property_id)
+ const char *object_id)
{
- PropertyInfo *info;
+ GtkWidget *widget;
g_return_val_if_fail (EPHY_IS_DIALOG (dialog), NULL);
- info = lookup_info (dialog, property_id);
- g_return_val_if_fail (info != NULL, NULL);
+ widget = GTK_WIDGET (gtk_builder_get_object (dialog->priv->builder,
+ object_id));
- return info->widget;
+ return widget;
}
/**
@@ -1383,7 +344,6 @@ ephy_dialog_get_controls (EphyDialog *dialog,
const char *first_id,
...)
{
- PropertyInfo *info;
GtkWidget **wptr;
va_list varargs;
@@ -1391,11 +351,8 @@ ephy_dialog_get_controls (EphyDialog *dialog,
while (first_id != NULL)
{
- info = lookup_info (dialog, first_id);
- g_return_if_fail (info != NULL);
-
wptr = va_arg (varargs, GtkWidget **);
- *wptr = info->widget;
+ *wptr = ephy_dialog_get_control (dialog, first_id);
first_id = va_arg (varargs, const char *);
}
@@ -1403,68 +360,6 @@ ephy_dialog_get_controls (EphyDialog *dialog,
va_end (varargs);
}
-/**
- * ephy_dialog_get_value:
- * @dialog: an #EphyDialog
- * @property_id: property name
- * @value: (out): location to store the value of @property_id
- *
- * Gets the value of @property_id and stores it in @value.
- *
- * Returns: %TRUE if the operation was successful
- */
-gboolean
-ephy_dialog_get_value (EphyDialog *dialog,
- const char *property_id,
- GValue *value)
-{
- PropertyInfo *info;
-
- g_return_val_if_fail (EPHY_IS_DIALOG (dialog), FALSE);
-
- info = lookup_info (dialog, property_id);
- g_return_val_if_fail (info != NULL, FALSE);
-
- return set_value_from_info (info, value);
-}
-
-/**
- * ephy_dialog_set_value:
- * @dialog: an #EphyDialog
- * @property_id: @dialog property to set
- * @value: value to set @property_id to
- *
- * Sets the property identified by @property_id to @value in @dialog.
- **/
-void
-ephy_dialog_set_value (EphyDialog *dialog,
- const char *property_id,
- const GValue *value)
-{
- PropertyInfo *info;
-
- g_return_if_fail (EPHY_IS_DIALOG (dialog));
-
- info = lookup_info (dialog, property_id);
- g_return_if_fail (info != NULL);
-
- set_info_from_value (info, value);
-}
-
-static void
-free_prop_info (PropertyInfo *info)
-{
- if (info->string_enum)
- {
- g_list_foreach (info->string_enum, (GFunc)g_free, NULL);
- g_list_free (info->string_enum);
- }
-
- g_free (info->pref);
-
- g_free (info);
-}
-
static void
ephy_dialog_init (EphyDialog *dialog)
{
@@ -1472,9 +367,6 @@ ephy_dialog_init (EphyDialog *dialog)
dialog->priv->default_width = -1;
dialog->priv->default_height = -1;
-
- dialog->priv->props = g_hash_table_new_full
- (g_str_hash, g_str_equal, NULL, (GDestroyNotify) free_prop_info);
}
static void
@@ -1497,8 +389,6 @@ ephy_dialog_finalize (GObject *object)
{
EphyDialog *dialog = EPHY_DIALOG (object);
- g_hash_table_destroy (dialog->priv->props);
-
g_free (dialog->priv->name);
G_OBJECT_CLASS (parent_class)->finalize (object);
diff --git a/lib/ephy-dialog.h b/lib/ephy-dialog.h
index 4e73ab897..0373ea834 100644
--- a/lib/ephy-dialog.h
+++ b/lib/ephy-dialog.h
@@ -43,21 +43,6 @@ typedef struct _EphyDialog EphyDialog;
typedef struct _EphyDialogPrivate EphyDialogPrivate;
typedef struct _EphyDialogProperty EphyDialogProperty;
-typedef enum
-{
- PT_NORMAL = 0,
- PT_AUTOAPPLY = 1 << 0,
- PT_INVERTED = 1 << 1
-} EphyDialogApplyType;
-
-struct _EphyDialogProperty
-{
- const char *id;
- const char *pref;
- EphyDialogApplyType apply_type;
- GType data_type;
-};
-
struct _EphyDialogClass
{
GObjectClass parent_class;
@@ -69,7 +54,6 @@ struct _EphyDialogClass
/* Methods */
void (* construct) (EphyDialog *dialog,
- const EphyDialogProperty *properties,
const char *file,
const char *name,
const char *domain);
@@ -91,20 +75,10 @@ EphyDialog *ephy_dialog_new (void);
EphyDialog *ephy_dialog_new_with_parent (GtkWidget *parent_window);
void ephy_dialog_construct (EphyDialog *dialog,
- const EphyDialogProperty *properties,
const char *file,
const char *name,
const char *domain);
-void ephy_dialog_add_enum (EphyDialog *dialog,
- const char *property_id,
- guint n_items,
- const char * const *items);
-
-void ephy_dialog_set_data_column (EphyDialog *dialog,
- const char *property_id,
- int column);
-
void ephy_dialog_set_size_group (EphyDialog *dialog,
const char *first_id,
...);
@@ -127,18 +101,6 @@ void ephy_dialog_get_controls (EphyDialog *dialog,
const char *first_id,
...);
-gboolean ephy_dialog_get_value (EphyDialog *dialog,
- const char *property_id,
- GValue *value);
-
-void ephy_dialog_set_value (EphyDialog *dialog,
- const char *property_id,
- const GValue *value);
-
-void ephy_dialog_set_pref (EphyDialog *dialog,
- const char *property_id,
- const char *pref);
-
G_END_DECLS
#endif
diff --git a/lib/ephy-file-chooser.c b/lib/ephy-file-chooser.c
index 2fd9a7d3e..fe85eee4f 100644
--- a/lib/ephy-file-chooser.c
+++ b/lib/ephy-file-chooser.c
@@ -22,10 +22,10 @@
#include "ephy-file-chooser.h"
#include "ephy-file-helpers.h"
-#include "eel-gconf-extensions.h"
#include "ephy-state.h"
#include "ephy-gui.h"
#include "ephy-debug.h"
+#include "ephy-settings.h"
#include "ephy-stock-icons.h"
#include "ephy-string.h"
@@ -64,7 +64,8 @@ current_folder_changed_cb (GtkFileChooser *chooser, EphyFileChooser *dialog)
dir = gtk_file_chooser_get_current_folder (chooser);
- eel_gconf_set_path (dialog->priv->persist_key, dir);
+ g_settings_set_string (EPHY_SETTINGS_STATE,
+ dialog->priv->persist_key, dir);
g_free (dir);
}
@@ -86,7 +87,10 @@ file_chooser_response_cb (GtkWidget *widget,
dir = g_path_get_dirname (filename);
if (dir != NULL)
- eel_gconf_set_path (dialog->priv->persist_key, dir);
+ g_settings_set_string
+ (EPHY_SETTINGS_STATE,
+ dialog->priv->persist_key,
+ dir);
g_free (dir);
g_free (filename);
@@ -143,7 +147,7 @@ ephy_file_chooser_set_persist_key (EphyFileChooser *dialog, const char *key)
dialog->priv->persist_key = g_strdup (key);
- dir = eel_gconf_get_string (key);
+ dir = g_settings_get_string (EPHY_SETTINGS_STATE, key);
if (dir != NULL)
{
/* FIXME: Maybe we will find a better way to do this when the
diff --git a/lib/ephy-file-helpers.c b/lib/ephy-file-helpers.c
index 495164d84..1a36cb457 100644
--- a/lib/ephy-file-helpers.c
+++ b/lib/ephy-file-helpers.c
@@ -25,8 +25,8 @@
#include "ephy-file-helpers.h"
#include "ephy-prefs.h"
-#include "eel-gconf-extensions.h"
#include "ephy-debug.h"
+#include "ephy-settings.h"
#include "ephy-string.h"
#include <glib.h>
@@ -154,7 +154,8 @@ ephy_file_get_downloads_dir (void)
{
char *download_dir, *expanded;
- download_dir = eel_gconf_get_string (CONF_STATE_DOWNLOAD_DIR);
+ download_dir = g_settings_get_string (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_DOWNLOAD_DIR);
if (download_dir && strcmp (download_dir, _("Downloads")) == 0)
{
diff --git a/lib/ephy-prefs.h b/lib/ephy-prefs.h
index 5f2fa16da..e61a49e94 100644
--- a/lib/ephy-prefs.h
+++ b/lib/ephy-prefs.h
@@ -1,5 +1,6 @@
/*
* Copyright © 2000-2003 Marco Pesenti Gritti
+ * Copyright © 2010 Igalia S.L.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -26,54 +27,93 @@
G_BEGIN_DECLS
-#define EPIPHANY_SCHEMA_VERSION 1
-#define CONF_SCHEMA_VERSION "/apps/epiphany/schema_version"
+typedef enum
+{
+ EPHY_PREFS_UI_TOOLBAR_STYLE_BOTH,
+ EPHY_PREFS_UI_TOOLBAR_STYLE_BOTH_HORIZ,
+ EPHY_PREFS_UI_TOOLBAR_STYLE_BOTH_ICONS,
+ EPHY_PREFS_UI_TOOLBAR_STYLE_BOTH_TEXT
+} EphyPrefsUIToolbarStyle;
-/* General */
-#define CONF_GENERAL_HOMEPAGE "/apps/epiphany/general/homepage"
-#define CONF_URL_SEARCH "/apps/epiphany/general/url_search"
-#define CONF_ALWAYS_SHOW_TABS_BAR "/apps/epiphany/general/always_show_tabs_bar"
-#define CONF_WINDOWS_SHOW_TOOLBARS "/apps/epiphany/general/show_toolbars"
-#define CONF_WINDOWS_SHOW_BOOKMARKS_BAR "/apps/epiphany/general/show_bookmarks_bar"
-#define CONF_WINDOWS_SHOW_STATUSBAR "/apps/epiphany/general/show_statusbar"
-#define CONF_INTERFACE_MIDDLE_CLICK_OPEN_URL "/apps/epiphany/general/middle_click_open_url"
-#define CONF_INTERFACE_TOOLBAR_STYLE "/apps/epiphany/general/toolbar_style"
-#define CONF_INTERFACE_OPEN_NEW_WINDOWS_IN_TAB "/apps/epiphany/general/open_new_windows_in_tab"
-#define CONF_AUTO_DOWNLOADS "/apps/epiphany/general/automatic_downloads"
-#define CONF_DESKTOP_IS_HOME_DIR "/apps/nautilus/preferences/desktop_is_home_dir"
-#define CONF_NETWORK_MANAGED "/apps/epiphany/general/managed_network"
-#define CONF_DOWNLOADS_HIDDEN "/apps/epiphany/dialogs/downloads_hidden"
-#define CONF_WARN_ON_CLOSE_UNSUBMITTED_DATA "/apps/epiphany/dialogs/warn_on_close_unsubmitted_data"
+typedef enum
+{
+ EPHY_PREFS_WEB_COOKIES_POLICY_ALWAYS,
+ EPHY_PREFS_WEB_COOKIES_POLICY_NO_THIRD_PARTY,
+ EPHY_PREFS_WEB_COOKIES_POLICY_NEVER
+} EphyPrefsWebCookiesPolicy;
-/* Directories */
-#define CONF_STATE_SAVE_DIR "/apps/epiphany/directories/save"
-#define CONF_STATE_SAVE_IMAGE_DIR "/apps/epiphany/directories/saveimage"
-#define CONF_STATE_OPEN_DIR "/apps/epiphany/directories/open"
-#define CONF_STATE_DOWNLOAD_DIR "/apps/epiphany/directories/downloads_folder"
-#define CONF_STATE_UPLOAD_DIR "/apps/epiphany/directories/upload"
+typedef enum
+{
+ EPHY_PREFS_STATE_HISTORY_DATE_FILTER_LAST_HALF_HOUR,
+ EPHY_PREFS_STATE_HISTORY_DATE_FILTER_EVER,
+ EPHY_PREFS_STATE_HISTORY_DATE_FILTER_TODAY,
+ EPHY_PREFS_STATE_HISTORY_DATE_FILTER_LAST_TWO_DAYS,
+ EPHY_PREFS_STATE_HISTORY_DATE_FILTER_LAST_THREE_DAYS
+} EphyPrefsStateHistoryDateFilter;
-/* Lockdown */
-#define CONF_LOCKDOWN_FULLSCREEN "/apps/epiphany/lockdown/fullscreen"
-#define CONF_LOCKDOWN_DISABLE_ARBITRARY_URL "/apps/epiphany/lockdown/disable_arbitrary_url"
-#define CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING "/apps/epiphany/lockdown/disable_bookmark_editing"
-#define CONF_LOCKDOWN_DISABLE_TOOLBAR_EDITING "/apps/epiphany/lockdown/disable_toolbar_editing"
-#define CONF_LOCKDOWN_DISABLE_HISTORY "/apps/epiphany/lockdown/disable_history"
-#define CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK "/desktop/gnome/lockdown/disable_save_to_disk"
-#define CONF_LOCKDOWN_DISABLE_HISTORY "/apps/epiphany/lockdown/disable_history"
-#define CONF_LOCKDOWN_DISABLE_PRINTING "/desktop/gnome/lockdown/disable_printing"
-#define CONF_LOCKDOWN_DISABLE_PRINT_SETUP "/desktop/gnome/lockdown/disable_print_setup"
-#define CONF_LOCKDOWN_DISABLE_COMMAND_LINE "/desktop/gnome/lockdown/disable_command_line"
-#define CONF_LOCKDOWN_DISABLE_QUIT "/apps/epiphany/lockdown/disable_quit"
-#define CONF_LOCKDOWN_DISABLE_JAVASCRIPT_CHROME "/apps/epiphany/lockdown/disable_javascript_chrome"
+#define EPHY_PREFS_UI_SCHEMA "org.gnome.Epiphany.ui"
+#define EPHY_PREFS_UI_ALWAYS_SHOW_TABS_BAR "always-show-tabs-bar"
+#define EPHY_PREFS_UI_SHOW_TOOLBARS "show-toolbars"
+#define EPHY_PREFS_UI_SHOW_BOOKMARKS_BAR "show-bookmarks-bar"
+#define EPHY_PREFS_UI_TOOLBAR_STYLE "toolbar-style"
+#define EPHY_PREFS_UI_DOWNLOADS_HIDDEN "downloads-hidden"
-/* System prefs */
-#define CONF_DESKTOP_FTP_HANDLER "/desktop/gnome/url-handlers/ftp/command"
-#define CONF_DESKTOP_TOOLBAR_STYLE "/desktop/gnome/interface/toolbar_style"
-#define CONF_DESKTOP_BG_PICTURE "/desktop/gnome/background/picture_filename"
-#define CONF_DESKTOP_BG_TYPE "/desktop/gnome/background/picture_options"
+#define EPHY_PREFS_STATE_SCHEMA "org.gnome.Epiphany.state"
+#define EPHY_PREFS_STATE_SAVE_DIR "save-dir"
+#define EPHY_PREFS_STATE_SAVE_IMAGE_DIR "save-image-dir"
+#define EPHY_PREFS_STATE_OPEN_DIR "open-dir"
+#define EPHY_PREFS_STATE_DOWNLOAD_DIR "download-dir"
+#define EPHY_PREFS_STATE_UPLOAD_DIR "upload-dir"
+#define EPHY_PREFS_STATE_RECENT_ENCODINGS "recent-encodings"
+#define EPHY_PREFS_STATE_BOOKMARKS_VIEW_TITLE "bookmarks-view-title"
+#define EPHY_PREFS_STATE_BOOKMARKS_VIEW_ADDRESS "bookmarks-view-address"
+#define EPHY_PREFS_STATE_HISTORY_VIEW_TITLE "history-view-title"
+#define EPHY_PREFS_STATE_HISTORY_VIEW_ADDRESS "history-view-address"
+#define EPHY_PREFS_STATE_HISTORY_VIEW_DATE "history-view-date"
+#define EPHY_PREFS_STATE_HISTORY_DATE_FILTER "history-date-filter"
-/* Privacy */
-#define CONF_PRIVACY_REMEMBER_PASSWORDS "/apps/epiphany/general/remember_passwords"
+#define EPHY_PREFS_WEB_SCHEMA "org.gnome.Epiphany.web"
+#define EPHY_PREFS_WEB_FONT_MIN_SIZE "min-font-size"
+#define EPHY_PREFS_WEB_LANGUAGE "language"
+#define EPHY_PREFS_WEB_USE_OWN_FONTS "use-own-fonts"
+#define EPHY_PREFS_WEB_USE_OWN_COLORS "use-own-colors"
+#define EPHY_PREFS_WEB_ENABLE_USER_CSS "enable-user-css"
+#define EPHY_PREFS_WEB_ENABLE_POPUPS "enable-popups"
+#define EPHY_PREFS_WEB_ENABLE_PLUGINS "enable-plugins"
+#define EPHY_PREFS_WEB_ENABLE_JAVASCRIPT "enable-javascript"
+#define EPHY_PREFS_WEB_COOKIES_POLICY "cookies-policy"
+#define EPHY_PREFS_WEB_IMAGE_ANIMATION_MODE "image-animation-mode"
+#define EPHY_PREFS_WEB_DEFAULT_ENCODING "default-encoding"
+
+#define EPHY_PREFS_SCHEMA "org.gnome.Epiphany"
+#define EPHY_PREFS_HOMEPAGE_URL "homepage-url"
+#define EPHY_PREFS_USER_AGENT "user-agent"
+#define EPHY_PREFS_CACHE_SIZE "cache-size"
+#define EPHY_PREFS_NEW_WINDOWS_IN_TABS "new-windows-in-tabs"
+#define EPHY_PREFS_AUTO_DOWNLOADS "automatic-downloads"
+#define EPHY_PREFS_WARN_ON_CLOSE_UNSUBMITTED_DATA "warn-on-close-unsubmitted-data"
+#define EPHY_PREFS_MIDDLE_CLICK_OPENS_URL "middle-click-opens-url"
+#define EPHY_PREFS_REMEMBER_PASSWORDS "remember-passwords"
+#define EPHY_PREFS_KEYWORD_SEARCH_URL "keyword-search-url"
+#define EPHY_PREFS_MANAGED_NETWORK "managed-network"
+#define EPHY_PREFS_ENABLE_SMOOTH_SCROLLING "enable-smooth-scrolling"
+#define EPHY_PREFS_ENABLE_WEB_INSPECTOR "enable-web-inspector"
+#define EPHY_PREFS_ENABLE_CARET_BROWSING "enable-caret-browsing"
+#define EPHY_PREFS_ENABLED_EXTENSIONS "enabled-extensions"
+
+#define EPHY_PREFS_LOCKDOWN_SCHEMA "org.gnome.Epiphany.lockdown"
+#define EPHY_PREFS_LOCKDOWN_FULLSCREEN "disable-fullscreen"
+#define EPHY_PREFS_LOCKDOWN_ARBITRARY_URL "disable-arbitrary-url"
+#define EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING "disable-bookmark-editing"
+#define EPHY_PREFS_LOCKDOWN_TOOLBAR_EDITING "disable-toolbar-editing"
+#define EPHY_PREFS_LOCKDOWN_HISTORY "disable-history"
+#define EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK "disable-save-to-disk"
+#define EPHY_PREFS_LOCKDOWN_PRINTING "disable-printing"
+#define EPHY_PREFS_LOCKDOWN_PRINT_SETUP "disable-print-setup"
+#define EPHY_PREFS_LOCKDOWN_COMMAND_LINE "disable-command-line"
+#define EPHY_PREFS_LOCKDOWN_QUIT "disable-quit"
+#define EPHY_PREFS_LOCKDOWN_JAVASCRIPT_CHROME "disable-javascript-chrome"
+#define EPHY_PREFS_LOCKDOWN_MENUBAR "disable-menubar"
G_END_DECLS
diff --git a/lib/ephy-settings.c b/lib/ephy-settings.c
new file mode 100644
index 000000000..4c9810933
--- /dev/null
+++ b/lib/ephy-settings.c
@@ -0,0 +1,65 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=2 sts=2 et: */
+/*
+ * Copyright © 2010 Igalia S.L.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+
+#include "ephy-settings.h"
+
+#include "ephy-debug.h"
+
+#include <glib.h>
+#include <gio/gio.h>
+
+static GHashTable *settings = NULL;
+
+void
+ephy_settings_shutdown (void)
+{
+ if (settings != NULL) {
+ g_hash_table_remove_all (settings);
+ g_hash_table_unref (settings);
+ }
+}
+
+GSettings *
+ephy_settings_get (const char *schema)
+{
+ GSettings *gsettings = NULL;
+
+ if (settings == NULL) {
+ settings = g_hash_table_new_full (g_str_hash,
+ g_str_equal, g_free,
+ g_object_unref);
+ }
+
+ gsettings = g_hash_table_lookup (settings, schema);
+
+ if (gsettings == NULL) {
+ gsettings = g_settings_new (schema);
+
+ if (gsettings == NULL)
+ g_warning ("Invalid schema requested");
+ else
+ g_hash_table_insert (settings, g_strdup (schema), gsettings);
+ }
+
+ return gsettings;
+}
diff --git a/lib/ephy-settings.h b/lib/ephy-settings.h
new file mode 100644
index 000000000..197941c66
--- /dev/null
+++ b/lib/ephy-settings.h
@@ -0,0 +1,44 @@
+/* -*- Mode: C; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* vim: set sw=2 ts=2 sts=2 et: */
+/*
+ * Copyright © 2010 Igalia S.L.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#if !defined (__EPHY_EPIPHANY_H_INSIDE__) && !defined (EPIPHANY_COMPILATION)
+#error "Only <epiphany/epiphany.h> can be included directly."
+#endif
+
+#ifndef EPHY_SETTINGS_H
+#define EPHY_SETTINGS_H
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "ephy-prefs.h"
+
+#define EPHY_SETTINGS_MAIN ephy_settings_get (EPHY_PREFS_SCHEMA)
+#define EPHY_SETTINGS_UI ephy_settings_get (EPHY_PREFS_UI_SCHEMA)
+#define EPHY_SETTINGS_WEB ephy_settings_get (EPHY_PREFS_WEB_SCHEMA)
+#define EPHY_SETTINGS_LOCKDOWN ephy_settings_get (EPHY_PREFS_LOCKDOWN_SCHEMA)
+#define EPHY_SETTINGS_STATE ephy_settings_get (EPHY_PREFS_STATE_SCHEMA)
+
+GSettings *ephy_settings_get (const char *schema);
+
+void ephy_settings_shutdown (void);
+
+#endif /* EPHY_SETTINGS_H */