aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/bookmarks/ephy-bookmark-properties.c6
-rw-r--r--src/bookmarks/ephy-bookmarks-editor.c126
-rw-r--r--src/bookmarks/ephy-bookmarks-import.c18
-rw-r--r--src/bookmarks/ephy-bookmarks-ui.c7
-rw-r--r--src/bookmarks/ephy-bookmarks.c31
-rw-r--r--src/ephy-activation.c5
-rw-r--r--src/ephy-encoding-dialog.c42
-rw-r--r--src/ephy-extensions-manager.c181
-rw-r--r--src/ephy-history-window.c256
-rw-r--r--src/ephy-home-action.c5
-rw-r--r--src/ephy-lockdown.c378
-rw-r--r--src/ephy-main.c12
-rw-r--r--src/ephy-net-monitor.c46
-rw-r--r--src/ephy-notebook.c24
-rw-r--r--src/ephy-session.c10
-rw-r--r--src/ephy-shell.c11
-rw-r--r--src/ephy-toolbar-editor.c14
-rw-r--r--src/ephy-toolbars-model.c24
-rw-r--r--src/ephy-window.c89
-rw-r--r--src/pdm-dialog.c77
-rw-r--r--src/popup-commands.c2
-rw-r--r--src/prefs-dialog.c548
-rw-r--r--src/window-commands.c12
23 files changed, 823 insertions, 1101 deletions
diff --git a/src/bookmarks/ephy-bookmark-properties.c b/src/bookmarks/ephy-bookmark-properties.c
index b681f21e4..c566678a7 100644
--- a/src/bookmarks/ephy-bookmark-properties.c
+++ b/src/bookmarks/ephy-bookmark-properties.c
@@ -34,8 +34,7 @@
#include "ephy-gui.h"
#include "ephy-dnd.h"
#include "ephy-prefs.h"
-
-#include "eel-gconf-extensions.h"
+#include "ephy-settings.h"
#include <glib/gi18n.h>
#include <gtk/gtk.h>
@@ -523,7 +522,8 @@ ephy_bookmark_properties_constructor (GType type,
EPHY_STATE_WINDOW_SAVE_SIZE);
}
/* Lockdown */
- lockdown = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING);
+ lockdown = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING);
update_window_title (properties);
content_area = gtk_dialog_get_content_area (dialog);
diff --git a/src/bookmarks/ephy-bookmarks-editor.c b/src/bookmarks/ephy-bookmarks-editor.c
index 2f81b8c6a..32a25caa1 100644
--- a/src/bookmarks/ephy-bookmarks-editor.c
+++ b/src/bookmarks/ephy-bookmarks-editor.c
@@ -34,6 +34,7 @@
#include "ephy-node-view.h"
#include "ephy-window.h"
#include "ephy-dnd.h"
+#include "ephy-settings.h"
#include "ephy-shell.h"
#include "ephy-session.h"
#include "ephy-file-helpers.h"
@@ -45,7 +46,6 @@
#include "ephy-stock-icons.h"
#include "ephy-search-entry.h"
#include "ephy-favicon-cache.h"
-#include "eel-gconf-extensions.h"
#include "ephy-debug.h"
#include "egg-toolbars-model.h"
#include "ephy-prefs.h"
@@ -126,8 +126,6 @@ static void cmd_help_contents (GtkAction *action,
#define EPHY_BOOKMARKS_EDITOR_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_BOOKMARKS_EDITOR, EphyBookmarksEditorPrivate))
-#define CONF_BOOKMARKS_VIEW_DETAILS "/apps/epiphany/dialogs/bookmarks_view_details"
-
#define RESERVED_STRING N_("Remove from this topic")
struct _EphyBookmarksEditorPrivate
@@ -216,22 +214,11 @@ static const GtkToggleActionEntry ephy_bookmark_toggle_entries [] = {
{ "ShowOnToolbar", NULL, N_("_Show on Toolbar"), NULL,
N_("Show the selected bookmark on a toolbar"),
G_CALLBACK (cmd_toolbar), FALSE },
-};
-
-enum
-{
- VIEW_TITLE,
- VIEW_TITLE_AND_ADDRESS
-};
-
-static const GtkRadioActionEntry ephy_bookmark_radio_entries [] =
-{
/* View Menu */
{ "ViewTitle", NULL, N_("_Title"), NULL,
- N_("Show only the title column"), VIEW_TITLE },
- { "ViewTitleAddress", NULL, N_("T_itle and Address"), NULL,
- N_("Show both the title and address columns"),
- VIEW_TITLE_AND_ADDRESS }
+ N_("Show the title column"), NULL, TRUE },
+ { "ViewAddress", NULL, N_("Address"), NULL,
+ N_("Show the address column"), NULL, FALSE }
};
G_DEFINE_TYPE (EphyBookmarksEditor, ephy_bookmarks_editor, GTK_TYPE_WINDOW)
@@ -1117,50 +1104,6 @@ cmd_help_contents (GtkAction *action,
}
static void
-set_columns_visibility (EphyBookmarksEditor *editor, int value)
-{
- switch (value)
- {
- case VIEW_TITLE:
- gtk_tree_view_column_set_visible (editor->priv->title_col, TRUE);
- gtk_tree_view_column_set_visible (editor->priv->address_col, FALSE);
- break;
- case VIEW_TITLE_AND_ADDRESS:
- gtk_tree_view_column_set_visible (editor->priv->title_col, TRUE);
- gtk_tree_view_column_set_visible (editor->priv->address_col, TRUE);
- break;
- }
-}
-
-static void
-cmd_view_columns (GtkAction *action,
- GtkRadioAction *current,
- EphyBookmarksEditor *editor)
-{
- int value;
- GSList *svalues = NULL;
-
- g_return_if_fail (EPHY_IS_BOOKMARKS_EDITOR (editor));
-
- value = gtk_radio_action_get_current_value (current);
- set_columns_visibility (editor, value);
-
- switch (value)
- {
- case VIEW_TITLE:
- svalues = g_slist_append (svalues, (gpointer)"title");
- break;
- case VIEW_TITLE_AND_ADDRESS:
- svalues = g_slist_append (svalues, (gpointer)"title");
- svalues = g_slist_append (svalues, (gpointer)"address");
- break;
- }
-
- eel_gconf_set_string_list (CONF_BOOKMARKS_VIEW_DETAILS, svalues);
- g_slist_free (svalues);
-}
-
-static void
ephy_bookmarks_editor_show (GtkWidget *widget)
{
EphyBookmarksEditor *editor = EPHY_BOOKMARKS_EDITOR (widget);
@@ -1699,31 +1642,6 @@ provide_keyword_uri (EphyNode *node, GValue *value, gpointer data)
g_free (uri);
}
-static int
-get_details_value (EphyBookmarksEditor *editor)
-{
- int value;
- GSList *svalues;
-
- svalues = eel_gconf_get_string_list (CONF_BOOKMARKS_VIEW_DETAILS);
-
- if (svalues &&
- g_slist_find_custom (svalues, "title", (GCompareFunc)strcmp) &&
- g_slist_find_custom (svalues, "address", (GCompareFunc)strcmp))
- {
- value = VIEW_TITLE_AND_ADDRESS;
- }
- else
- {
- value = VIEW_TITLE;
- }
-
- g_slist_foreach (svalues, (GFunc) g_free, NULL);
- g_slist_free (svalues);
-
- return value;
-}
-
static void
ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
{
@@ -1735,7 +1653,7 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
GtkUIManager *ui_merge;
GtkActionGroup *action_group;
GtkAction *action;
- int col_id, url_col_id, title_col_id, details_value;
+ int col_id, url_col_id, title_col_id;
ephy_gui_ensure_window_group (GTK_WINDOW (editor));
@@ -1758,13 +1676,6 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
gtk_action_group_add_toggle_actions (action_group, ephy_bookmark_toggle_entries,
G_N_ELEMENTS (ephy_bookmark_toggle_entries), editor);
- details_value = get_details_value (editor);
- gtk_action_group_add_radio_actions (action_group,
- ephy_bookmark_radio_entries,
- G_N_ELEMENTS (ephy_bookmark_radio_entries),
- details_value,
- G_CALLBACK (cmd_view_columns),
- editor);
gtk_ui_manager_insert_action_group (ui_merge,
action_group, 0);
gtk_ui_manager_add_ui_from_file (ui_merge,
@@ -1901,6 +1812,27 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
gtk_container_add (GTK_CONTAINER (scrolled_window), bm_view);
gtk_widget_show (bm_view);
editor->priv->bm_view = bm_view;
+
+ action = gtk_action_group_get_action (action_group, "ViewTitle");
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_BOOKMARKS_VIEW_TITLE,
+ action, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_BOOKMARKS_VIEW_TITLE,
+ editor->priv->title_col, "visible",
+ G_SETTINGS_BIND_DEFAULT);
+
+ action = gtk_action_group_get_action (action_group, "ViewAddress");
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_BOOKMARKS_VIEW_ADDRESS,
+ action, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_BOOKMARKS_VIEW_ADDRESS,
+ editor->priv->address_col, "visible",
+ G_SETTINGS_BIND_DEFAULT);
+
g_signal_connect (G_OBJECT (bm_view),
"key_press_event",
G_CALLBACK (key_pressed_cb),
@@ -1931,12 +1863,12 @@ ephy_bookmarks_editor_construct (EphyBookmarksEditor *editor)
"bookmarks_paned",
130);
- set_columns_visibility (editor, details_value);
-
/* Lockdown settings */
action = gtk_action_group_get_action (action_group, "Export");
gtk_action_set_sensitive (action,
- eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK) == FALSE);
+ g_settings_get_boolean
+ (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK) == FALSE);
}
void
diff --git a/src/bookmarks/ephy-bookmarks-import.c b/src/bookmarks/ephy-bookmarks-import.c
index 1efdb71de..f6ed781cb 100644
--- a/src/bookmarks/ephy-bookmarks-import.c
+++ b/src/bookmarks/ephy-bookmarks-import.c
@@ -32,8 +32,7 @@
#include "ephy-bookmarks-import.h"
#include "ephy-debug.h"
#include "ephy-prefs.h"
-
-#include "eel-gconf-extensions.h"
+#include "ephy-settings.h"
/**
* NSItemType: netscape bookmark item type
@@ -73,7 +72,9 @@ ephy_bookmarks_import (EphyBookmarks *bookmarks,
GFile *file;
GFileInfo *file_info;
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE;
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
+ return FALSE;
g_return_val_if_fail (filename != NULL, FALSE);
@@ -712,7 +713,9 @@ ephy_bookmarks_import_mozilla (EphyBookmarks *bookmarks,
char *parsedname;
GList *folders = NULL;
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE;
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
+ return FALSE;
name = g_string_new (NULL);
url = g_string_new (NULL);
@@ -792,7 +795,9 @@ ephy_bookmarks_import_xbel (EphyBookmarks *bookmarks,
xmlTextReaderPtr reader;
int ret;
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE;
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
+ return FALSE;
if (g_file_test (filename, G_FILE_TEST_EXISTS) == FALSE)
{
@@ -969,7 +974,8 @@ ephy_bookmarks_import_rdf (EphyBookmarks *bookmarks,
xmlNodePtr child;
xmlNodePtr root;
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return FALSE;
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
if (g_file_test (filename, G_FILE_TEST_EXISTS) == FALSE)
return FALSE;
diff --git a/src/bookmarks/ephy-bookmarks-ui.c b/src/bookmarks/ephy-bookmarks-ui.c
index 91479db85..1f97eddb3 100644
--- a/src/bookmarks/ephy-bookmarks-ui.c
+++ b/src/bookmarks/ephy-bookmarks-ui.c
@@ -20,7 +20,6 @@
#include "config.h"
-#include "eel-gconf-extensions.h"
#include "ephy-bookmarks.h"
#include "ephy-bookmarks-ui.h"
#include "ephy-bookmarks-menu.h"
@@ -36,6 +35,7 @@
#include "ephy-node-common.h"
#include "ephy-link.h"
#include "ephy-dnd.h"
+#include "ephy-embed-shell.h"
#include "ephy-history.h"
#include "ephy-shell.h"
#include "ephy-string.h"
@@ -44,6 +44,7 @@
#include "ephy-gui.h"
#include "ephy-stock-icons.h"
#include "ephy-prefs.h"
+#include "ephy-settings.h"
#include "egg-editable-toolbar.h"
#include <string.h>
@@ -434,7 +435,9 @@ ephy_bookmarks_ui_add_bookmark (GtkWindow *parent,
EphyNode *bookmark;
GtkWidget *dialog;
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING)) return;
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
+ return;
bookmarks = ephy_shell_get_bookmarks (ephy_shell_get_default ());
bookmark = ephy_bookmarks_add (bookmarks, title, location);
diff --git a/src/bookmarks/ephy-bookmarks.c b/src/bookmarks/ephy-bookmarks.c
index 507426978..43c1ad9d9 100644
--- a/src/bookmarks/ephy-bookmarks.c
+++ b/src/bookmarks/ephy-bookmarks.c
@@ -34,12 +34,11 @@
#include "ephy-bookmarks-import.h"
#include "ephy-bookmark-properties.h"
#include "ephy-prefs.h"
+#include "ephy-settings.h"
#include "ephy-marshal.h"
#include "ephy-signal-accumulator.h"
#include "ephy-stock-icons.h"
-#include "eel-gconf-extensions.h"
-
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
@@ -82,7 +81,6 @@ struct _EphyBookmarksPrivate
EphyNode *smartbookmarks;
EphyNode *lower_fav;
double lower_score;
- guint disable_bookmark_editing_notifier_id;
#ifdef ENABLE_ZEROCONF
/* Local sites */
@@ -630,14 +628,6 @@ topics_removed_cb (EphyNode *node,
}
static void
-update_bookmark_editing (EphyBookmarks *eb)
-{
- g_object_set (G_OBJECT (eb->priv->db),
- "immutable", eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING),
- NULL);
-}
-
-static void
fix_hierarchy_topic (EphyBookmarks *eb,
EphyNode *topic)
{
@@ -693,15 +683,6 @@ fix_hierarchy (EphyBookmarks *eb)
}
static void
-disable_bookmark_editing_notifier (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- EphyBookmarks *eb)
-{
- update_bookmark_editing (eb);
-}
-
-static void
backup_file (const char *original_filename, const char *extension)
{
char *template, *backup_filename;
@@ -1339,10 +1320,10 @@ ephy_bookmarks_init (EphyBookmarks *eb)
fix_hierarchy (eb);
- eb->priv->disable_bookmark_editing_notifier_id = eel_gconf_notification_add
- (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING,
- (GConfClientNotifyFunc)disable_bookmark_editing_notifier, eb);
- update_bookmark_editing (eb);
+ g_settings_bind (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING,
+ eb->priv->db, "immutable",
+ G_SETTINGS_BIND_GET);
ephy_setup_history_notifiers (eb);
ephy_bookmarks_update_favorites (eb);
@@ -1354,8 +1335,6 @@ ephy_bookmarks_finalize (GObject *object)
EphyBookmarks *eb = EPHY_BOOKMARKS (object);
EphyBookmarksPrivate *priv = eb->priv;
- eel_gconf_notification_remove (priv->disable_bookmark_editing_notifier_id);
-
if (priv->save_timeout_id != 0)
{
g_source_remove (priv->save_timeout_id);
diff --git a/src/ephy-activation.c b/src/ephy-activation.c
index 85e2cf91c..802ca4bd6 100644
--- a/src/ephy-activation.c
+++ b/src/ephy-activation.c
@@ -21,10 +21,10 @@
#include "ephy-activation.h"
+#include "ephy-settings.h"
#include "ephy-shell.h"
#include "ephy-session.h"
#include "ephy-prefs.h"
-#include "eel-gconf-extensions.h"
#include "ephy-debug.h"
static gboolean
@@ -86,7 +86,8 @@ ephy_activation_open_bookmarks_editor (EphyDbus *ephy_dbus,
guint startup_id,
GError **error)
{
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING))
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
{
g_set_error (error,
g_quark_from_static_string ("ephy-activation-error"),
diff --git a/src/ephy-encoding-dialog.c b/src/ephy-encoding-dialog.c
index 7bb055c73..009a3dd64 100644
--- a/src/ephy-encoding-dialog.c
+++ b/src/ephy-encoding-dialog.c
@@ -39,25 +39,6 @@
#include <string.h>
#include <webkit/webkit.h>
-enum
-{
- WINDOW_PROP,
- SCROLLED_WINDOW_PROP,
- AUTOMATIC_PROP,
- MANUAL_PROP
-};
-
-static const
-EphyDialogProperty properties [] =
-{
- { "encoding_dialog", NULL, PT_NORMAL, 0 },
- { "scrolled_window", NULL, PT_NORMAL, 0 },
- { "automatic_button", NULL, PT_NORMAL, 0 },
- { "manual_button", NULL, PT_NORMAL, 0 },
-
- { NULL }
-};
-
#define EPHY_ENCODING_DIALOG_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_ENCODING_DIALOG, EphyEncodingDialogPrivate))
struct _EphyEncodingDialogPrivate
@@ -127,7 +108,8 @@ sync_encoding_against_embed (EphyEncodingDialog *dialog)
g_list_free (rows);
}
- button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[AUTOMATIC_PROP].id);
+ button = ephy_dialog_get_control (EPHY_DIALOG (dialog),
+ "automatic_button");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), is_automatic);
dialog->priv->update_tag = FALSE;
@@ -206,7 +188,8 @@ activate_choice (EphyEncodingDialog *dialog)
embed = ephy_embed_dialog_get_embed (EPHY_EMBED_DIALOG (dialog));
g_return_if_fail (EPHY_IS_EMBED (embed));
- button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[AUTOMATIC_PROP].id);
+ button = ephy_dialog_get_control (EPHY_DIALOG (dialog),
+ "automatic_button");
is_automatic = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button));
view = EPHY_GET_WEBKIT_WEB_VIEW_FROM_EMBED (embed);
@@ -253,7 +236,7 @@ view_node_selected_cb (EphyNodeView *view,
if (dialog->priv->update_tag) return;
- button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[MANUAL_PROP].id);
+ button = ephy_dialog_get_control (EPHY_DIALOG (dialog), "manual_button");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
activate_choice (dialog);
@@ -270,7 +253,7 @@ view_node_activated_cb (GtkWidget *view,
if (dialog->priv->update_tag) return;
- button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[MANUAL_PROP].id);
+ button = ephy_dialog_get_control (EPHY_DIALOG (dialog), "manual_button");
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (button), TRUE);
activate_choice (dialog);
@@ -302,12 +285,12 @@ ephy_encoding_dialog_init (EphyEncodingDialog *dialog)
(EPHY_EMBED_SHELL (ephy_shell)));
ephy_dialog_construct (EPHY_DIALOG (dialog),
- properties,
ephy_file ("epiphany.ui"),
"encoding_dialog",
NULL);
- window = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[WINDOW_PROP].id);
+ window = ephy_dialog_get_control (EPHY_DIALOG (dialog),
+ "encoding_dialog");
g_signal_connect (window, "response",
G_CALLBACK (ephy_encoding_dialog_response_cb), dialog);
@@ -341,17 +324,18 @@ ephy_encoding_dialog_init (EphyEncodingDialog *dialog)
gtk_widget_show (treeview);
- scroller = ephy_dialog_get_control
- (EPHY_DIALOG (dialog), properties[SCROLLED_WINDOW_PROP].id);
+ scroller = ephy_dialog_get_control (EPHY_DIALOG (dialog),
+ "scrolled_window");
gtk_container_add (GTK_CONTAINER (scroller), treeview);
- button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[AUTOMATIC_PROP].id);
+ button = ephy_dialog_get_control (EPHY_DIALOG (dialog),
+ "automatic_button");
child = gtk_bin_get_child (GTK_BIN (button));
gtk_label_set_use_markup (GTK_LABEL (child), TRUE);
g_signal_connect (button, "toggled",
G_CALLBACK (automatic_toggled_cb), dialog);
- button = ephy_dialog_get_control (EPHY_DIALOG (dialog), properties[MANUAL_PROP].id);
+ button = ephy_dialog_get_control (EPHY_DIALOG (dialog), "manual_button");
gtk_label_set_use_markup (GTK_LABEL (child), TRUE);
dialog->priv->enc_view = treeview;
diff --git a/src/ephy-extensions-manager.c b/src/ephy-extensions-manager.c
index e3e57ffe2..35122c87d 100644
--- a/src/ephy-extensions-manager.c
+++ b/src/ephy-extensions-manager.c
@@ -32,12 +32,11 @@
#include "ephy-node-db.h"
#include "ephy-shell.h"
-#include "eel-gconf-extensions.h"
#include "ephy-file-helpers.h"
#include "ephy-object-helpers.h"
#include "ephy-debug.h"
-
-#include <gconf/gconf-client.h>
+#include "ephy-prefs.h"
+#include "ephy-settings.h"
#include <gio/gio.h>
#include <gmodule.h>
@@ -47,7 +46,6 @@
#include "ephy-seed-loader.h"
#endif
-#define CONF_LOADED_EXTENSIONS "/apps/epiphany/general/active_extensions"
#define EE_GROUP "Epiphany Extension"
#define DOT_INI ".ephy-extension"
#define RELOAD_DELAY 333 /* ms */
@@ -64,7 +62,6 @@ struct _EphyExtensionsManagerPrivate
GList *extensions;
GList *dir_monitors;
GList *windows;
- guint active_extensions_notifier_id;
guint sync_timeout_id;
GHashTable *reload_hash;
};
@@ -110,35 +107,60 @@ G_DEFINE_TYPE_WITH_CODE (EphyExtensionsManager, ephy_extensions_manager, G_TYPE_
G_IMPLEMENT_INTERFACE (EPHY_TYPE_EXTENSION,
ephy_extensions_manager_iface_init))
-/**
- * ephy_extensions_manager_load:
- * @manager: an #EphyExtensionsManager
- * @identifier: identifier of the extension to load
- *
- * Loads the extension corresponding to @identifier.
- **/
-void
-ephy_extensions_manager_load (EphyExtensionsManager *manager,
- const char *identifier)
+static void
+ephy_extensions_manager_toggle_load (EphyExtensionsManager *manager,
+ const char *identifier,
+ gboolean status)
{
- GSList *gconf_exts;
+ char **exts;
+ GVariantBuilder builder;
+ gboolean dirty = FALSE;
+ int i;
g_return_if_fail (EPHY_IS_EXTENSIONS_MANAGER (manager));
g_return_if_fail (identifier != NULL);
- LOG ("Adding '%s' to extensions", identifier);
+ if (status)
+ LOG ("Adding '%s' to extensions", identifier);
+ else
+ LOG ("Removing '%s' from extensions", identifier);
- gconf_exts = eel_gconf_get_string_list (CONF_LOADED_EXTENSIONS);
+ exts = g_settings_get_strv (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_ENABLED_EXTENSIONS);
- if (!g_slist_find_custom (gconf_exts, identifier, (GCompareFunc) strcmp))
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
+ for (i = 0; exts[i]; i++)
{
- gconf_exts = g_slist_prepend (gconf_exts, g_strdup (identifier));
+ if (g_strcmp0 (exts[i], identifier) == 0)
+ {
+ dirty = TRUE;
+ if (status)
+ break;
+ else
+ continue;
+ }
- eel_gconf_set_string_list (CONF_LOADED_EXTENSIONS, gconf_exts);
+ g_variant_builder_add (&builder, "s", exts[i]);
}
- g_slist_foreach (gconf_exts, (GFunc) g_free, NULL);
- g_slist_free (gconf_exts);
+ if (!dirty)
+ g_settings_set (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_ENABLED_EXTENSIONS,
+ "as", &builder);
+}
+
+/**
+ * ephy_extensions_manager_load:
+ * @manager: an #EphyExtensionsManager
+ * @identifier: identifier of the extension to load
+ *
+ * Loads the extension corresponding to @identifier.
+ **/
+void
+ephy_extensions_manager_load (EphyExtensionsManager *manager,
+ const char *identifier)
+{
+ ephy_extensions_manager_toggle_load (manager, identifier, TRUE);
}
/**
@@ -156,29 +178,7 @@ void
ephy_extensions_manager_unload (EphyExtensionsManager *manager,
const char *identifier)
{
- GSList *gconf_exts;
- GSList *l;
-
- g_return_if_fail (EPHY_IS_EXTENSIONS_MANAGER (manager));
- g_return_if_fail (identifier != NULL);
-
- LOG ("Removing '%s' from extensions", identifier);
-
- gconf_exts = eel_gconf_get_string_list (CONF_LOADED_EXTENSIONS);
-
- l = g_slist_find_custom (gconf_exts, identifier, (GCompareFunc) strcmp);
-
- if (l != NULL)
- {
- gconf_exts = g_slist_remove_link (gconf_exts, l);
- g_free (l->data);
- g_slist_free_1 (l);
-
- eel_gconf_set_string_list (CONF_LOADED_EXTENSIONS, gconf_exts);
- }
-
- g_slist_foreach (gconf_exts, (GFunc) g_free, NULL);
- g_slist_free (gconf_exts);
+ ephy_extensions_manager_toggle_load (manager, identifier, FALSE);
}
/**
@@ -629,50 +629,65 @@ unload_extension (EphyExtensionsManager *manager,
static void
sync_loaded_extensions (EphyExtensionsManager *manager)
{
- GConfClient *client;
- GConfValue *value;
- GSList *active_extensions = NULL;
+ char **extensions;
+ GVariantBuilder builder;
+ int i;
+ gboolean has_ui = FALSE;
GList *l;
- gboolean active;
ExtensionInfo *info;
LOG ("Synching changed list of active extensions");
- client = gconf_client_get_default ();
- g_return_if_fail (client != NULL);
+ extensions = g_settings_get_strv (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_ENABLED_EXTENSIONS);
- value = gconf_client_get (client, CONF_LOADED_EXTENSIONS, NULL);
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
- /* make sure the extensions-manager-ui is loaded */
- if (value == NULL ||
- value->type != GCONF_VALUE_LIST ||
- gconf_value_get_list_type (value) != GCONF_VALUE_STRING)
+ /* Make sure the extensions-manager-ui is always loaded. */
+ for (i = 0; extensions[i]; i++)
{
- active_extensions = g_slist_prepend (active_extensions,
- g_strdup ("extensions-manager-ui"));
- eel_gconf_set_string_list (CONF_LOADED_EXTENSIONS, active_extensions);
+ if (!has_ui && g_strcmp0 (extensions[i],
+ "extensions-manager-ui") == 0)
+ has_ui = TRUE;
+
+ g_variant_builder_add (&builder, "s", extensions[i]);
}
- else
+
+ if (!has_ui)
{
- active_extensions = eel_gconf_get_string_list (CONF_LOADED_EXTENSIONS);
+ g_variant_builder_add (&builder, "s", "extensions-manager-ui");
+ g_settings_set (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_ENABLED_EXTENSIONS,
+ "as", &builder);
+
+ g_strfreev (extensions);
+ extensions = g_settings_get_strv
+ (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_ENABLED_EXTENSIONS);
}
+
for (l = manager->priv->data; l != NULL; l = l->next)
{
gboolean changed;
+ gboolean active = FALSE;
+ int j;
info = (ExtensionInfo *) l->data;
- active = (g_slist_find_custom (active_extensions,
- info->info.identifier,
- (GCompareFunc) strcmp) != NULL);
+ for (j = 0; extensions[j]; j++)
+ {
+ if (!active && g_strcmp0 (extensions[j],
+ info->info.identifier) == 0)
+ active = TRUE;
+ }
LOG ("Extension '%s' is %sactive and %sloaded",
info->info.identifier,
active ? "" : "not ",
info->info.active ? "" : "not ");
- changed = ( info->info.enabled != active );
+ changed = (info->info.enabled != active);
info->info.enabled = active;
@@ -699,14 +714,7 @@ sync_loaded_extensions (EphyExtensionsManager *manager)
}
}
- g_slist_foreach (active_extensions, (GFunc) g_free, NULL);
- g_slist_free (active_extensions);
-
- if (value != NULL)
- {
- gconf_value_free (value);
- }
- g_object_unref (client);
+ g_strfreev (extensions);
}
static void
@@ -920,10 +928,9 @@ ephy_extensions_manager_load_dir (EphyExtensionsManager *manager,
}
static void
-active_extensions_notifier (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- EphyExtensionsManager *manager)
+active_extensions_cb (GSettings *settings,
+ char *key,
+ EphyExtensionsManager *manager)
{
sync_loaded_extensions (manager);
}
@@ -964,12 +971,12 @@ ephy_extensions_manager_startup (EphyExtensionsManager *manager)
ephy_extensions_manager_load_dir (manager, EXTENSIONS_DIR);
- active_extensions_notifier (NULL, 0, NULL, manager);
- manager->priv->active_extensions_notifier_id =
- eel_gconf_notification_add
- (CONF_LOADED_EXTENSIONS,
- (GConfClientNotifyFunc) active_extensions_notifier,
- manager);
+ sync_loaded_extensions (manager);
+
+ g_signal_connect (EPHY_SETTINGS_MAIN,
+ "changed::" EPHY_PREFS_ENABLED_EXTENSIONS,
+ G_CALLBACK (active_extensions_cb),
+ manager);
}
static void
@@ -978,12 +985,6 @@ ephy_extensions_manager_dispose (GObject *object)
EphyExtensionsManager *manager = EPHY_EXTENSIONS_MANAGER (object);
EphyExtensionsManagerPrivate *priv = manager->priv;
- if (priv->active_extensions_notifier_id != 0)
- {
- eel_gconf_notification_remove (priv->active_extensions_notifier_id);
- priv->active_extensions_notifier_id = 0;
- }
-
if (priv->reload_hash != NULL)
{
g_hash_table_destroy (priv->reload_hash);
diff --git a/src/ephy-history-window.c b/src/ephy-history-window.c
index 6fabfbda1..ba81c6e0d 100644
--- a/src/ephy-history-window.c
+++ b/src/ephy-history-window.c
@@ -39,12 +39,12 @@
#include "ephy-search-entry.h"
#include "ephy-session.h"
#include "ephy-favicon-cache.h"
-#include "eel-gconf-extensions.h"
#include "ephy-node.h"
#include "ephy-node-common.h"
#include "ephy-node-view.h"
#include "ephy-bookmarks-ui.h"
#include "ephy-prefs.h"
+#include "ephy-settings.h"
#include "ephy-gui.h"
#include "ephy-time-helpers.h"
@@ -90,17 +90,12 @@ static void cmd_select_all (GtkAction *action,
EphyHistoryWindow *editor);
static void cmd_help_contents (GtkAction *action,
EphyHistoryWindow *editor);
-static void cmd_view_columns (GtkAction *action,
- EphyHistoryWindow *view);
static void search_entry_search_cb (GtkWidget *entry,
char *search_text,
EphyHistoryWindow *editor);
#define EPHY_HISTORY_WINDOW_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_HISTORY_WINDOW, EphyHistoryWindowPrivate))
-#define CONF_HISTORY_DATE_FILTER "/apps/epiphany/dialogs/history_date_filter"
-#define CONF_HISTORY_VIEW_DETAILS "/apps/epiphany/dialogs/history_view_details"
-
struct _EphyHistoryWindowPrivate
{
EphyHistory *history;
@@ -127,21 +122,6 @@ enum
PROP_HISTORY
};
-enum
-{
- TIME_LAST_HALF_HOUR,
- TIME_TODAY,
- TIME_LAST_TWO_DAYS,
- TIME_LAST_THREE_DAYS,
- TIME_EVER
-};
-
-#define TIME_LAST_HALF_HOUR_STRING "last_half_hour"
-#define TIME_EVER_STRING "ever"
-#define TIME_TODAY_STRING "today"
-#define TIME_LAST_TWO_DAYS_STRING "last_two_days"
-#define TIME_LAST_THREE_DAYS_STRING "last_three_days"
-
static const GtkActionEntry ephy_history_ui_entries [] = {
/* Toplevel */
{ "File", NULL, N_("_File") },
@@ -204,11 +184,11 @@ static const GtkToggleActionEntry ephy_history_toggle_entries [] =
{
/* View Menu */
{ "ViewTitle", NULL, N_("_Title"), NULL,
- N_("Show the title column"), G_CALLBACK (cmd_view_columns), TRUE },
+ N_("Show the title column"), NULL, TRUE },
{ "ViewAddress", NULL, N_("_Address"), NULL,
- N_("Show the address column"), G_CALLBACK (cmd_view_columns), TRUE },
+ N_("Show the address column"), NULL, TRUE },
{ "ViewDateTime", NULL, N_("_Date and Time"), NULL,
- N_("Show the date and time column"), G_CALLBACK (cmd_view_columns), TRUE }
+ N_("Show the date and time column"), NULL, TRUE }
};
static void
@@ -493,77 +473,6 @@ cmd_help_contents (GtkAction *action,
ephy_gui_help (GTK_WIDGET (editor), "ephy-managing-history");
}
-static void
-set_column_visibility (EphyHistoryWindow *view,
- const char *action_name,
- gboolean active)
-{
- if (strcmp (action_name, "ViewTitle") == 0)
- {
- gtk_tree_view_column_set_visible (view->priv->title_col, active);
- }
- if (strcmp (action_name, "ViewAddress") == 0)
- {
- gtk_tree_view_column_set_visible (view->priv->address_col, active);
- }
- if (strcmp (action_name, "ViewDateTime") == 0)
- {
- gtk_tree_view_column_set_visible (view->priv->datetime_col, active);
- }
-}
-
-static void
-set_all_columns_visibility (EphyHistoryWindow *view,
- EphyHistoryWindowColumns details_value)
-{
- GtkActionGroup *action_group;
- GtkAction *action_title, *action_address, *action_datetime;
-
- action_group = view->priv->action_group;
- action_title = gtk_action_group_get_action (action_group, "ViewTitle");
- action_address = gtk_action_group_get_action (action_group, "ViewAddress");
- action_datetime = gtk_action_group_get_action (action_group, "ViewDateTime");
-
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action_title), (details_value & VIEW_TITLE));
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action_address), (details_value & VIEW_ADDRESS));
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action_datetime), (details_value & VIEW_DATETIME));
-}
-
-static void
-cmd_view_columns (GtkAction *action,
- EphyHistoryWindow *view)
-{
- gboolean active;
- const char *action_name;
- GSList *svalues = NULL;
-
- active = gtk_toggle_action_get_active (GTK_TOGGLE_ACTION (action));
- action_name = gtk_action_get_name (action);
- set_column_visibility (view, action_name, active);
-
- svalues = eel_gconf_get_string_list (CONF_HISTORY_VIEW_DETAILS);
-
- if (active)
- {
- if (!g_slist_find_custom (svalues, (gpointer) action_name, (GCompareFunc) strcmp))
- {
- svalues = g_slist_append (svalues, (gpointer) action_name);
- }
- }
- else
- {
- GSList *delete;
- delete = g_slist_find_custom (svalues, (gpointer) action_name, (GCompareFunc) strcmp);
- if (delete)
- {
- svalues = g_slist_delete_link (svalues, delete);
- }
- }
-
- eel_gconf_set_string_list (CONF_HISTORY_VIEW_DETAILS, svalues);
- g_slist_free (svalues);
-}
-
G_DEFINE_TYPE (EphyHistoryWindow, ephy_history_window, GTK_TYPE_WINDOW)
static void
@@ -719,7 +628,9 @@ ephy_history_window_update_menu (EphyHistoryWindow *editor)
open_in_window = (pages_focus && pages_selection);
open_in_tab = (pages_focus && pages_selection);
delete = (pages_focus && pages_selection);
- bookmarks_locked = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING);
+ bookmarks_locked = g_settings_get_boolean
+ (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING);
bookmark_page = (pages_focus && single_page_selected) && !bookmarks_locked;
action_group = editor->priv->action_group;
@@ -853,7 +764,7 @@ add_by_date_filter (EphyHistoryWindow *editor,
(GTK_COMBO_BOX (editor->priv->time_combo));
/* no need to setup a new filter */
- if (time_range == TIME_EVER) return;
+ if (time_range == EPHY_PREFS_STATE_HISTORY_DATE_FILTER_EVER) return;
now = time (NULL);
if (localtime_r (&now, &btime) == NULL) return;
@@ -866,16 +777,18 @@ add_by_date_filter (EphyHistoryWindow *editor,
switch (time_range)
{
- case TIME_LAST_HALF_HOUR:
+ case EPHY_PREFS_STATE_HISTORY_DATE_FILTER_LAST_HALF_HOUR:
cmp_time = now - 30 * 60;
break;
- case TIME_LAST_THREE_DAYS:
+ case EPHY_PREFS_STATE_HISTORY_DATE_FILTER_TODAY:
+ cmp_time = midnight;
+ break;
+ case EPHY_PREFS_STATE_HISTORY_DATE_FILTER_LAST_TWO_DAYS:
days++;
- /* fall-through */
- case TIME_LAST_TWO_DAYS:
+ cmp_time = midnight;
+ break;
+ case EPHY_PREFS_STATE_HISTORY_DATE_FILTER_LAST_THREE_DAYS:
days++;
- /* fall-through */
- case TIME_TODAY:
cmp_time = midnight;
break;
default:
@@ -1019,7 +932,6 @@ build_search_box (EphyHistoryWindow *editor)
GtkWidget *box, *label, *entry;
GtkWidget *combo;
char *str;
- int time_range;
box = gtk_hbox_new (FALSE, 6);
gtk_container_set_border_width (GTK_CONTAINER (box), 6);
@@ -1045,42 +957,25 @@ build_search_box (EphyHistoryWindow *editor)
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Last 30 minutes"));
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), _("Today"));
+
str = g_strdup_printf (ngettext ("Last %d day", "Last %d days", 2), 2);
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), str);
g_free (str);
+
str = g_strdup_printf (ngettext ("Last %d day", "Last %d days", 3), 3);
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), str);
g_free (str);
- /* keep this in sync with embed/ephy-history.c's HISTORY_PAGE_OBSOLETE_DAYS */
+
+ /* keep this in sync with embed/ephy-history.c's
+ * HISTORY_PAGE_OBSOLETE_DAYS */
str = g_strdup_printf (ngettext ("Last %d day", "Last %d days", 10), 10);
gtk_combo_box_append_text (GTK_COMBO_BOX (combo), str);
g_free (str);
- str = eel_gconf_get_string (CONF_HISTORY_DATE_FILTER);
- if (str && strcmp (TIME_LAST_HALF_HOUR_STRING, str) == 0)
- {
- time_range = TIME_LAST_HALF_HOUR;
- }
- if (str && strcmp (TIME_TODAY_STRING, str) == 0)
- {
- time_range = TIME_TODAY;
- }
- else if (str && strcmp (TIME_LAST_TWO_DAYS_STRING, str) == 0)
- {
- time_range = TIME_LAST_TWO_DAYS;
- }
- else if (str && strcmp (TIME_LAST_THREE_DAYS_STRING, str) == 0)
- {
- time_range = TIME_LAST_THREE_DAYS;
- }
- else
- {
- time_range = TIME_EVER;
- }
- g_free (str);
-
- gtk_combo_box_set_active (GTK_COMBO_BOX (combo),
- time_range);
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_HISTORY_DATE_FILTER,
+ combo, "active",
+ G_SETTINGS_BIND_DEFAULT);
editor->priv->time_combo = combo;
@@ -1184,40 +1079,6 @@ view_selection_changed_cb (GtkWidget *view, EphyHistoryWindow *editor)
ephy_history_window_update_menu (editor);
}
-static EphyHistoryWindowColumns
-get_details_value (void)
-{
- guint value = 0;
- GSList *svalues;
-
- svalues = eel_gconf_get_string_list (CONF_HISTORY_VIEW_DETAILS);
- if (svalues == NULL)
- {
- svalues = g_slist_append (svalues, (gpointer) "ViewAddress");
- svalues = g_slist_append (svalues, (gpointer) "ViewTitle");
- eel_gconf_set_string_list (CONF_HISTORY_VIEW_DETAILS, svalues);
- return (VIEW_ADDRESS | VIEW_TITLE);
- }
-
- if (g_slist_find_custom (svalues, "ViewTitle", (GCompareFunc)strcmp))
- {
- value |= VIEW_TITLE;
- }
- if (g_slist_find_custom (svalues, "ViewAddress", (GCompareFunc)strcmp))
- {
- value |= VIEW_ADDRESS;
- }
- if (g_slist_find_custom (svalues, "ViewDateTime", (GCompareFunc)strcmp))
- {
- value |= VIEW_DATETIME;
- }
-
- g_slist_foreach (svalues, (GFunc) g_free, NULL);
- g_slist_free (svalues);
-
- return value;
-}
-
static void
ephy_history_window_construct (EphyHistoryWindow *editor)
{
@@ -1229,8 +1090,8 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
EphyNode *node;
GtkUIManager *ui_merge;
GtkActionGroup *action_group;
+ GtkAction *action;
int url_col_id, title_col_id, datetime_col_id;
- EphyHistoryWindowColumns details_value;
ephy_gui_ensure_window_group (GTK_WINDOW (editor));
@@ -1253,7 +1114,6 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
gtk_action_group_add_actions (action_group, ephy_history_ui_entries,
G_N_ELEMENTS (ephy_history_ui_entries), editor);
- details_value = get_details_value ();
gtk_action_group_add_toggle_actions (action_group,
ephy_history_toggle_entries,
G_N_ELEMENTS (ephy_history_toggle_entries),
@@ -1391,6 +1251,36 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
gtk_widget_show (pages_view);
editor->priv->pages_view = pages_view;
+ action = gtk_action_group_get_action (action_group, "ViewTitle");
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_HISTORY_VIEW_TITLE,
+ action, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_HISTORY_VIEW_TITLE,
+ editor->priv->title_col, "visible",
+ G_SETTINGS_BIND_DEFAULT);
+
+ action = gtk_action_group_get_action (action_group, "ViewAddress");
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_HISTORY_VIEW_ADDRESS,
+ action, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_HISTORY_VIEW_ADDRESS,
+ editor->priv->address_col, "visible",
+ G_SETTINGS_BIND_DEFAULT);
+
+ action = gtk_action_group_get_action (action_group, "ViewDateTime");
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_HISTORY_VIEW_DATE,
+ action, "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_HISTORY_VIEW_DATE,
+ editor->priv->datetime_col, "visible",
+ G_SETTINGS_BIND_DEFAULT);
+
g_signal_connect (G_OBJECT (pages_view),
"node_activated",
G_CALLBACK (ephy_history_window_node_activated_cb),
@@ -1420,7 +1310,6 @@ ephy_history_window_construct (EphyHistoryWindow *editor)
"history_paned",
130);
- set_all_columns_visibility (editor, details_value);
setup_filters (editor, TRUE, TRUE);
}
@@ -1508,37 +1397,6 @@ ephy_history_window_init (EphyHistoryWindow *editor)
}
static void
-save_date_filter (EphyHistoryWindow *editor)
-{
- const char *time_string = NULL;
- int time_range;
-
- time_range = gtk_combo_box_get_active
- (GTK_COMBO_BOX (editor->priv->time_combo));
-
- switch (time_range)
- {
- case TIME_LAST_HALF_HOUR:
- time_string = TIME_LAST_HALF_HOUR_STRING;
- break;
- case TIME_EVER:
- time_string = TIME_EVER_STRING;
- break;
- case TIME_TODAY:
- time_string = TIME_TODAY_STRING;
- break;
- case TIME_LAST_TWO_DAYS:
- time_string = TIME_LAST_TWO_DAYS_STRING;
- break;
- case TIME_LAST_THREE_DAYS:
- time_string = TIME_LAST_THREE_DAYS_STRING;
- break;
- }
-
- eel_gconf_set_string (CONF_HISTORY_DATE_FILTER, time_string);
-}
-
-static void
ephy_history_window_dispose (GObject *object)
{
EphyHistoryWindow *editor;
@@ -1555,8 +1413,6 @@ ephy_history_window_dispose (GObject *object)
remove_focus_monitor (editor, editor->priv->search_entry);
editor->priv->sites_view = NULL;
-
- save_date_filter (editor);
}
G_OBJECT_CLASS (ephy_history_window_parent_class)->dispose (object);
diff --git a/src/ephy-home-action.c b/src/ephy-home-action.c
index c2826a3bf..05290a0ec 100644
--- a/src/ephy-home-action.c
+++ b/src/ephy-home-action.c
@@ -22,9 +22,9 @@
#include "ephy-home-action.h"
#include "ephy-link.h"
#include "ephy-prefs.h"
+#include "ephy-settings.h"
#include "ephy-gui.h"
#include "ephy-dnd.h"
-#include "eel-gconf-extensions.h"
#include <string.h>
@@ -162,7 +162,8 @@ ephy_home_action_activate (GtkAction *action)
g_object_get (G_OBJECT (action), "name", &action_name, NULL);
- address = eel_gconf_get_string (CONF_GENERAL_HOMEPAGE);
+ address = g_settings_get_string (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_HOMEPAGE_URL);
action_name_association (action, action_name, address, FALSE);
diff --git a/src/ephy-lockdown.c b/src/ephy-lockdown.c
index 1910aca2c..61aec8d86 100644
--- a/src/ephy-lockdown.c
+++ b/src/ephy-lockdown.c
@@ -2,6 +2,7 @@
/*
* Copyright © 2000, 2001, 2002, 2003, 2004 Marco Pesenti Gritti
* Copyright © 2003, 2004, 2005 Christian Persch
+ * 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
@@ -21,49 +22,25 @@
#include "config.h"
+#include "ephy-action-helper.h"
#include "ephy-embed-container.h"
+#include "ephy-embed-shell.h"
#include "ephy-embed-utils.h"
#include "ephy-web-view.h"
#include "ephy-lockdown.h"
#include "ephy-extension.h"
-#include "ephy-action-helper.h"
+#include "ephy-settings.h"
#include "ephy-toolbar.h"
#include "ephy-prefs.h"
-#include "eel-gconf-extensions.h"
#include "ephy-debug.h"
#include <gtk/gtk.h>
#include <string.h>
-static void ephy_lockdown_iface_init (EphyExtensionIface *iface);
-
-/* Make sure these don't overlap with those in ephy-window.c and ephy-toolbar.c */
-enum
-{
- LOCKDOWN_FLAG = 1 << 31
-};
+#define LOCKDOWN_FLAG 1 << 8
-static const char * const keys [] =
-{
- CONF_LOCKDOWN_DISABLE_ARBITRARY_URL,
- CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING,
- CONF_LOCKDOWN_DISABLE_COMMAND_LINE,
- CONF_LOCKDOWN_DISABLE_HISTORY,
- CONF_LOCKDOWN_DISABLE_PRINTING,
- CONF_LOCKDOWN_DISABLE_PRINT_SETUP,
- CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK,
- CONF_LOCKDOWN_DISABLE_TOOLBAR_EDITING,
- CONF_LOCKDOWN_FULLSCREEN
-};
-
-#define EPHY_LOCKDOWN_GET_PRIVATE(object)(G_TYPE_INSTANCE_GET_PRIVATE ((object), EPHY_TYPE_LOCKDOWN, EphyLockdownPrivate))
-
-struct _EphyLockdownPrivate
-{
- guint notifier_id[G_N_ELEMENTS (keys)];
- GList *windows;
-};
+static void ephy_lockdown_iface_init (EphyExtensionIface *iface);
static int
find_name (GtkActionGroup *action_group,
@@ -86,237 +63,226 @@ find_action_group (GtkUIManager *manager,
}
static void
-update_location_editable (EphyWindow *window,
- GtkAction *action,
- gboolean editable)
+arbitrary_url_cb (GSettings *settings,
+ char *key,
+ EphyWindow *window)
{
EphyEmbed *embed;
GtkWidget *toolbar;
char *address;
- g_object_set (action, "editable", editable, NULL);
-
/* Restore the real web page address when disabling entry */
- if (editable == FALSE)
+ if (g_settings_get_boolean (settings, key))
{
- toolbar = ephy_window_get_toolbar (window);
embed = ephy_embed_container_get_active_child (EPHY_EMBED_CONTAINER (window));
/* embed is NULL on startup */
- if (embed != NULL)
- {
- address = ephy_web_view_get_location (ephy_embed_get_web_view (embed), TRUE);
- ephy_toolbar_set_location (EPHY_TOOLBAR (toolbar), address);
- ephy_web_view_set_typed_address (ephy_embed_get_web_view (embed), NULL);
- g_free (address);
- }
+ if (embed == NULL)
+ return;
+
+ toolbar = ephy_window_get_toolbar (window);
+ address = ephy_web_view_get_location (ephy_embed_get_web_view (embed), TRUE);
+ ephy_toolbar_set_location (EPHY_TOOLBAR (toolbar), address);
+ ephy_web_view_set_typed_address (ephy_embed_get_web_view (embed), NULL);
+ g_free (address);
}
}
-/* NOTE: If you bring more actions under lockdown control, make sure
- * that all sensitivity updates on them are done using the helpers!
- */
static void
-update_window (EphyWindow *window,
- EphyLockdown *lockdown)
+fullscreen_cb (GSettings *settings,
+ char *key,
+ EphyWindow *window)
{
- GtkUIManager *manager;
- GtkActionGroup *action_group, *popups_action_group;
- GtkActionGroup *toolbar_action_group, *special_toolbar_action_group;
- GtkAction *action;
- gboolean disabled, fullscreen, print_setup_disabled, writable;
-
- LOG ("Updating window %p", window);
-
- manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
- action_group = find_action_group (manager, "WindowActions");
- popups_action_group = find_action_group (manager, "PopupsActions");
- toolbar_action_group = find_action_group (manager, "ToolbarActions");
- special_toolbar_action_group = find_action_group (manager, "SpecialToolbarActions");
- g_return_if_fail (action_group != NULL
- && popups_action_group != NULL
- && toolbar_action_group != NULL
- && special_toolbar_action_group != NULL);
-
- disabled = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINTING);
- print_setup_disabled = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_PRINT_SETUP) ||
- eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_COMMAND_LINE);
- action = gtk_action_group_get_action (action_group, "FilePrintSetup");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled || print_setup_disabled);
- action = gtk_action_group_get_action (action_group, "FilePrintPreview");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (action_group, "FilePrint");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
-
- writable = eel_gconf_key_is_writable (CONF_WINDOWS_SHOW_TOOLBARS);
- action = gtk_action_group_get_action (action_group, "ViewToolbar");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, !writable);
-
- disabled = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_ARBITRARY_URL);
- action = gtk_action_group_get_action (action_group, "GoLocation");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (special_toolbar_action_group, "Location");
- update_location_editable (window, action, !disabled);
- action = gtk_action_group_get_action (special_toolbar_action_group, "NavigationUp");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
-
- disabled = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_HISTORY);
- action = gtk_action_group_get_action (action_group, "GoHistory");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (special_toolbar_action_group, "NavigationBack");
- gtk_action_set_visible (action, !disabled);
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (special_toolbar_action_group, "NavigationForward");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- gtk_action_set_visible (action, !disabled);
-
- disabled = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING);
- action = gtk_action_group_get_action (action_group, "GoBookmarks");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (action_group, "FileBookmarkPage");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (popups_action_group, "BookmarkLink");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
-
- disabled = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_SAVE_TO_DISK);
- action = gtk_action_group_get_action (action_group, "FileSaveAs");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (popups_action_group, "DownloadLink");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (popups_action_group, "DownloadLinkAs");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (popups_action_group, "SaveImageAs");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (popups_action_group, "OpenImage");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- writable = eel_gconf_key_is_writable (CONF_DESKTOP_BG_PICTURE);
- action = gtk_action_group_get_action (popups_action_group, "SetImageAsBackground");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled || !writable);
-
- disabled = eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_TOOLBAR_EDITING);
- action = gtk_action_group_get_action (action_group, "ViewToolbarEditor");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (toolbar_action_group, "MoveToolItem");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (toolbar_action_group, "RemoveToolItem");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
- action = gtk_action_group_get_action (toolbar_action_group, "RemoveToolbar");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, disabled);
-
- fullscreen = eel_gconf_get_boolean (CONF_LOCKDOWN_FULLSCREEN);
- action = gtk_action_group_get_action (special_toolbar_action_group, "FileNewWindow");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, fullscreen);
- action = gtk_action_group_get_action (action_group, "ViewFullscreen");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, fullscreen);
-
- action = gtk_action_group_get_action (action_group, "TabsDetach");
- ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, fullscreen);
-
- if (fullscreen)
- {
+ if (g_settings_get_boolean (settings, key))
gtk_window_fullscreen (GTK_WINDOW (window));
- }
+ else
+ gtk_window_unfullscreen (GTK_WINDOW (window));
}
-static void
-notifier (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- EphyLockdown *lockdown)
-{
- EphyLockdownPrivate *priv = lockdown->priv;
+typedef struct {
+ char *key;
+ char *action;
+ char *prop;
+} BindAction;
- LOG ("Key %s changed", entry->key);
+static const BindAction window_actions[] = {
+ { EPHY_PREFS_LOCKDOWN_PRINTING, "FilePrint", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_PRINTING, "FilePrintPreview", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_PRINTING, "FilePrintSetup", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_PRINT_SETUP, "FilePrintSetup", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_COMMAND_LINE, "FilePrintSetup", "sensitive" },
- g_list_foreach (priv->windows, (GFunc) update_window, lockdown);
-}
+ { EPHY_PREFS_LOCKDOWN_TOOLBAR_EDITING, "ViewToolbarEditor", "sensitive" },
-static void
-ephy_lockdown_init (EphyLockdown *lockdown)
+ { EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING, "GoBookmarks", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING, "FileBookmarkPage", "sensitive" },
+
+ { EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, "GoLocation", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "FileSaveAs", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_HISTORY, "GoHistory", "sensitive" },
+
+ { EPHY_PREFS_LOCKDOWN_FULLSCREEN, "ViewFullscreen", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_FULLSCREEN, "TabsDetach", "sensitive" }
+};
+
+static const BindAction popup_actions[] = {
+ { EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "DownloadLink", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "DownloadLinkAs", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "SaveImageAs", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_SAVE_TO_DISK, "OpenImage", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING, "BookmarkLink", "sensitive" }
+};
+
+static const BindAction special_toolbar_actions[] = {
+ { EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, "Location", "editable" },
+ { EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, "NavigationUp", "sensitive" },
+
+ { EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationBack", "visible" },
+ { EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationBack", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationForward", "visible" },
+ { EPHY_PREFS_LOCKDOWN_HISTORY, "NavigationForward", "sensitive" },
+
+ { EPHY_PREFS_LOCKDOWN_FULLSCREEN, "FileNewWindow", "sensitive" }
+};
+
+static const BindAction toolbar_actions[] = {
+ { EPHY_PREFS_LOCKDOWN_TOOLBAR_EDITING, "MoveToolItem", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_TOOLBAR_EDITING, "RemoveToolItem", "sensitive" },
+ { EPHY_PREFS_LOCKDOWN_TOOLBAR_EDITING, "RemoveToolbar", "sensitive" }
+};
+
+static gboolean
+sensitive_get_mapping (GValue *value,
+ GVariant *variant,
+ gpointer data)
{
- EphyLockdownPrivate *priv;
- guint i;
+ GtkAction *action;
+ gboolean active, before, after;
- lockdown->priv = priv = EPHY_LOCKDOWN_GET_PRIVATE (lockdown);
+ action = GTK_ACTION (data);
+ active = g_variant_get_boolean (variant);
- LOG ("EphyLockdown initialising");
+ before = gtk_action_get_sensitive (action);
+ ephy_action_change_sensitivity_flags (action, LOCKDOWN_FLAG, active);
+ after = gtk_action_get_sensitive (action);
- for (i = 0; i < G_N_ELEMENTS (keys); i++)
- {
- priv->notifier_id[i] =eel_gconf_notification_add
- (keys[i], (GConfClientNotifyFunc) notifier, lockdown);
- }
- /* We know that no windows are open yet,
- * so we don't need to do notify here.
- */
+ /* Set (GtkAction::sensitive) to the value in GSettings _only if_
+ * the LOCKDOWN_FLAG had some real effect in the GtkAction */
+ g_value_set_boolean (value, (before != after) ? after : before);
- eel_gconf_monitor_add ("/apps/epiphany/lockdown");
- eel_gconf_monitor_add ("/desktop/gnome/lockdown");
+ return TRUE;
}
-G_DEFINE_TYPE_WITH_CODE (EphyLockdown, ephy_lockdown, G_TYPE_OBJECT,
- G_IMPLEMENT_INTERFACE (EPHY_TYPE_EXTENSION,
- ephy_lockdown_iface_init))
-
static void
-ephy_lockdown_finalize (GObject *object)
+bind_settings_and_actions (GSettings *settings,
+ GtkActionGroup *action_group,
+ const BindAction *actions,
+ int actions_n)
{
- EphyLockdown *lockdown = EPHY_LOCKDOWN (object);
- EphyLockdownPrivate *priv = lockdown->priv;
- guint i;
+ int i;
- LOG ("EphyLockdown finalising");
+ for (i = 0; i < actions_n; i++)
+ {
+ GtkAction *action;
- eel_gconf_monitor_remove ("/apps/epiphany/lockdown");
- eel_gconf_monitor_remove ("/desktop/gnome/lockdown");
+ action = gtk_action_group_get_action (action_group,
+ actions[i].action);
- for (i = 0; i < G_N_ELEMENTS (keys); i++)
- {
- eel_gconf_notification_remove (priv->notifier_id[i]);
+ if (g_strcmp0 (actions[i].prop, "visible") == 0)
+ {
+ g_settings_bind (settings, actions[i].key,
+ action, actions[i].prop,
+ G_SETTINGS_BIND_GET |
+ G_SETTINGS_BIND_INVERT_BOOLEAN);
+ }
+ else
+ {
+ /* We need a custom get_mapping for 'sensitive'
+ * properties, see usage of
+ * ephy_action_change_sensitivity_flags in
+ * ephy-window.c. */
+ g_settings_bind_with_mapping (settings, actions[i].key,
+ action, actions[i].prop,
+ G_SETTINGS_BIND_GET,
+ sensitive_get_mapping,
+ NULL,
+ action, NULL);
+ }
}
-
- G_OBJECT_CLASS (ephy_lockdown_parent_class)->finalize (object);
}
static void
impl_attach_window (EphyExtension *extension,
EphyWindow *window)
{
- EphyLockdown *lockdown = EPHY_LOCKDOWN (extension);
- EphyLockdownPrivate *priv = lockdown->priv;
+ GtkUIManager *manager;
+ GtkActionGroup *action_group;
+ GtkAction *action;
+ GSettings *settings;
+
+ g_signal_connect (EPHY_SETTINGS_LOCKDOWN,
+ "changed::" EPHY_PREFS_LOCKDOWN_FULLSCREEN,
+ G_CALLBACK (fullscreen_cb), window);
+ g_signal_connect (EPHY_SETTINGS_LOCKDOWN,
+ "changed::" EPHY_PREFS_LOCKDOWN_ARBITRARY_URL,
+ G_CALLBACK (arbitrary_url_cb), window);
+
+ /* Trigger an initial state on these elements. */
+ fullscreen_cb (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_FULLSCREEN, window);
+ arbitrary_url_cb (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_ARBITRARY_URL, window);
+
+ manager = GTK_UI_MANAGER (ephy_window_get_ui_manager (window));
- priv->windows = g_list_prepend (priv->windows, window);
+ action_group = find_action_group (manager, "WindowActions");
+ bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
+ action_group, window_actions,
+ G_N_ELEMENTS (window_actions));
- update_window (window, lockdown);
+ action = gtk_action_group_get_action (action_group, "ViewToolbar");
+ g_settings_bind_writable (EPHY_SETTINGS_UI,
+ EPHY_PREFS_UI_SHOW_TOOLBARS,
+ action, "sensitive", FALSE);
+
+ action_group = find_action_group (manager, "PopupsActions");
+ bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
+ action_group, popup_actions,
+ G_N_ELEMENTS (popup_actions));
+
+ action = gtk_action_group_get_action (action_group,
+ "SetImageAsBackground");
+ settings = ephy_settings_get ("org.gnome.desktop.background");
+ g_settings_bind_writable (settings, "picture-filename",
+ action, "sensitive", FALSE);
+
+ action_group = find_action_group (manager, "SpecialToolbarActions");
+ bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
+ action_group, special_toolbar_actions,
+ G_N_ELEMENTS (special_toolbar_actions));
+
+ action_group = find_action_group (manager, "ToolbarActions");
+ bind_settings_and_actions (EPHY_SETTINGS_LOCKDOWN,
+ action_group, toolbar_actions,
+ G_N_ELEMENTS (toolbar_actions));
}
static void
-impl_detach_window (EphyExtension *extension,
- EphyWindow *window)
+ephy_lockdown_init (EphyLockdown *lockdown)
{
- EphyLockdown *lockdown = EPHY_LOCKDOWN (extension);
- EphyLockdownPrivate *priv = lockdown->priv;
-
- priv->windows = g_list_remove (priv->windows, window);
-
- /* Since we know that the window closes now, we don't have to
- * undo anything.
- */
+ LOG ("EphyLockdown initialising");
}
+G_DEFINE_TYPE_WITH_CODE (EphyLockdown, ephy_lockdown, G_TYPE_OBJECT,
+ G_IMPLEMENT_INTERFACE (EPHY_TYPE_EXTENSION,
+ ephy_lockdown_iface_init))
+
static void
ephy_lockdown_iface_init (EphyExtensionIface *iface)
{
iface->attach_window = impl_attach_window;
- iface->detach_window = impl_detach_window;
}
static void
ephy_lockdown_class_init (EphyLockdownClass *klass)
{
- GObjectClass *object_class = G_OBJECT_CLASS (klass);
-
- object_class->finalize = ephy_lockdown_finalize;
-
- g_type_class_add_private (object_class, sizeof (EphyLockdownPrivate));
}
-
diff --git a/src/ephy-main.c b/src/ephy-main.c
index dd7b69f55..1f0692884 100644
--- a/src/ephy-main.c
+++ b/src/ephy-main.c
@@ -20,13 +20,13 @@
#include "config.h"
+#include "ephy-settings.h"
#include "ephy-shell.h"
#include "ephy-file-helpers.h"
#include "ephy-object-helpers.h"
#include "ephy-state.h"
#include "ephy-debug.h"
#include "ephy-stock-icons.h"
-#include "eel-gconf-extensions.h"
#include "ephy-dbus-client-bindings.h"
#include "ephy-activation.h"
#include "ephy-session.h"
@@ -438,6 +438,7 @@ main (int argc,
DBusGProxy *proxy;
GError *error = NULL;
guint32 user_time;
+ gboolean arbitrary_url;
#ifdef ENABLE_NLS
/* Initialize the i18n stuff */
@@ -572,8 +573,10 @@ main (int argc,
exit (1);
}
- if (arguments != NULL &&
- eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_ARBITRARY_URL))
+ arbitrary_url = g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_ARBITRARY_URL);
+
+ if (arguments != NULL && arbitrary_url)
{
g_print ("URL loading is locked down\n");
exit (1);
@@ -718,7 +721,6 @@ main (int argc,
if (ephy_has_private_profile () == FALSE)
_ephy_profile_migrate ();
- eel_gconf_monitor_add ("/apps/epiphany/general");
ephy_stock_icons_init ();
load_accels ();
@@ -745,9 +747,9 @@ main (int argc,
if (notify_is_initted ())
notify_uninit ();
#endif
- eel_gconf_monitor_remove ("/apps/epiphany/general");
save_accels ();
ephy_state_save ();
+ ephy_settings_shutdown ();
ephy_file_helpers_shutdown ();
xmlCleanupParser ();
diff --git a/src/ephy-net-monitor.c b/src/ephy-net-monitor.c
index a6fb56fd9..3c970c1bf 100644
--- a/src/ephy-net-monitor.c
+++ b/src/ephy-net-monitor.c
@@ -21,9 +21,9 @@
#include "ephy-net-monitor.h"
-#include "eel-gconf-extensions.h"
#include "ephy-dbus.h"
#include "ephy-debug.h"
+#include "ephy-settings.h"
#include "ephy-prefs.h"
#include <NetworkManager.h>
@@ -41,7 +41,6 @@ typedef enum
struct _EphyNetMonitorPrivate
{
DBusConnection *bus;
- guint notify_id;
guint active : 1;
NetworkStatus status;
};
@@ -285,31 +284,6 @@ ephy_net_monitor_shutdown (EphyNetMonitor *monitor)
}
static void
-notify_network_managed_cb (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- EphyNetMonitor *monitor)
-{
- EphyNetMonitorPrivate *priv = monitor->priv;
- GConfValue *value;
- gboolean active = TRUE;
-
- LOG (CONF_NETWORK_MANAGED " key changed");
-
- g_assert (entry != NULL);
-
- value = gconf_entry_get_value (entry);
- if (value != NULL && value->type == GCONF_VALUE_BOOL)
- {
- active = gconf_value_get_bool (value);
- }
-
- priv->active = active;
-
- g_object_notify (G_OBJECT (monitor), "network-status");
-}
-
-static void
ephy_net_monitor_init (EphyNetMonitor *monitor)
{
EphyNetMonitorPrivate *priv;
@@ -320,12 +294,6 @@ ephy_net_monitor_init (EphyNetMonitor *monitor)
priv->status = NETWORK_UP;
- priv->notify_id = eel_gconf_notification_add
- (CONF_NETWORK_MANAGED,
- (GConfClientNotifyFunc) notify_network_managed_cb,
- monitor);
- eel_gconf_notify (CONF_NETWORK_MANAGED);
-
ephy_net_monitor_startup (monitor);
}
@@ -333,18 +301,11 @@ static void
ephy_net_monitor_dispose (GObject *object)
{
EphyNetMonitor *monitor = EPHY_NET_MONITOR (object);
- EphyNetMonitorPrivate *priv = monitor->priv;
LOG ("EphyNetMonitor finalising");
ephy_net_monitor_shutdown (monitor);
- if (priv->notify_id != 0)
- {
- eel_gconf_notification_remove (priv->notify_id);
- priv->notify_id = 0;
- }
-
G_OBJECT_CLASS (ephy_net_monitor_parent_class)->dispose (object);
}
@@ -401,10 +362,13 @@ gboolean
ephy_net_monitor_get_net_status (EphyNetMonitor *monitor)
{
EphyNetMonitorPrivate *priv;
+ gboolean managed;
g_return_val_if_fail (EPHY_IS_NET_MONITOR (monitor), FALSE);
priv = monitor->priv;
+ managed = g_settings_get_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_MANAGED_NETWORK);
- return !priv->active || priv->status != NETWORK_DOWN;
+ return !managed || priv->status != NETWORK_DOWN;
}
diff --git a/src/ephy-notebook.c b/src/ephy-notebook.c
index 73fad2b63..23805d267 100644
--- a/src/ephy-notebook.c
+++ b/src/ephy-notebook.c
@@ -23,8 +23,8 @@
#include "config.h"
#include "ephy-notebook.h"
-#include "eel-gconf-extensions.h"
#include "ephy-prefs.h"
+#include "ephy-settings.h"
#include "ephy-marshal.h"
#include "ephy-file-helpers.h"
#include "ephy-dnd.h"
@@ -371,7 +371,8 @@ notebook_drag_data_received_cb (GtkWidget* widget,
g_signal_stop_emission_by_name (widget, "drag_data_received");
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_ARBITRARY_URL)) return;
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_ARBITRARY_URL)) return;
data = gtk_selection_data_get_data (selection_data);
if (gtk_selection_data_get_length (selection_data) <= 0 || data == NULL) return;
@@ -437,17 +438,18 @@ update_tabs_visibility (EphyNotebook *nb,
if (before_inserting) num++;
- show_tabs = (eel_gconf_get_boolean (CONF_ALWAYS_SHOW_TABS_BAR) || num > 1) &&
+ show_tabs = (g_settings_get_boolean (EPHY_SETTINGS_UI,
+ EPHY_PREFS_UI_ALWAYS_SHOW_TABS_BAR)
+ || num > 1) &&
priv->show_tabs == TRUE;
gtk_notebook_set_show_tabs (GTK_NOTEBOOK (nb), show_tabs);
}
static void
-tabs_visibility_notifier (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- EphyNotebook *nb)
+show_tabs_changed_cb (GSettings *settings,
+ char *key,
+ EphyNotebook *nb)
{
update_tabs_visibility (nb, FALSE);
}
@@ -484,9 +486,9 @@ ephy_notebook_init (EphyNotebook *notebook)
GDK_ACTION_MOVE | GDK_ACTION_COPY);
gtk_drag_dest_add_text_targets (widget);
- priv->tabs_vis_notifier_id = eel_gconf_notification_add
- (CONF_ALWAYS_SHOW_TABS_BAR,
- (GConfClientNotifyFunc)tabs_visibility_notifier, notebook);
+ g_signal_connect (EPHY_SETTINGS_UI,
+ "changed::" EPHY_PREFS_UI_ALWAYS_SHOW_TABS_BAR,
+ G_CALLBACK (show_tabs_changed_cb), notebook);
}
static void
@@ -495,8 +497,6 @@ ephy_notebook_finalize (GObject *object)
EphyNotebook *notebook = EPHY_NOTEBOOK (object);
EphyNotebookPrivate *priv = notebook->priv;
- eel_gconf_notification_remove (priv->tabs_vis_notifier_id);
-
g_list_free (priv->focused_pages);
G_OBJECT_CLASS (ephy_notebook_parent_class)->finalize (object);
diff --git a/src/ephy-session.c b/src/ephy-session.c
index 9adf2dcfd..558793c6f 100644
--- a/src/ephy-session.c
+++ b/src/ephy-session.c
@@ -32,11 +32,11 @@
#include "ephy-embed-container.h"
#include "ephy-extension.h"
#include "ephy-file-helpers.h"
-#include "eel-gconf-extensions.h"
#include "ephy-gui.h"
#include "ephy-history-window.h"
#include "ephy-notebook.h"
#include "ephy-prefs.h"
+#include "ephy-settings.h"
#include "ephy-shell.h"
#include "ephy-stock-icons.h"
#include "ephy-window.h"
@@ -1667,14 +1667,18 @@ ephy_session_load (EphySession *session,
if (id && xmlStrEqual ((const xmlChar *) BOOKMARKS_EDITOR_ID, id))
{
- if (!eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_BOOKMARK_EDITING))
+ if (!g_settings_get_boolean
+ (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_BOOKMARK_EDITING))
{
widget = ephy_shell_get_bookmarks_editor (ephy_shell);
}
}
else if (id && xmlStrEqual ((const xmlChar *) HISTORY_WINDOW_ID, id))
{
- if (!eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_HISTORY))
+ if (!g_settings_get_boolean
+ (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_HISTORY))
{
widget = ephy_shell_get_history_window (ephy_shell);
}
diff --git a/src/ephy-shell.c b/src/ephy-shell.c
index 2d575d092..f15ceda6a 100644
--- a/src/ephy-shell.c
+++ b/src/ephy-shell.c
@@ -30,10 +30,8 @@
#include "ephy-shell.h"
#include "ephy-type-builtins.h"
#include "ephy-embed-container.h"
-#include "ephy-embed-shell.h"
#include "ephy-embed-single.h"
#include "ephy-embed-utils.h"
-#include "eel-gconf-extensions.h"
#include "ephy-prefs.h"
#include "ephy-file-helpers.h"
#include "ephy-favicon-cache.h"
@@ -54,6 +52,7 @@
#include "egg-toolbars-model.h"
#include "ephy-toolbars-model.h"
#include "ephy-toolbar.h"
+#include "ephy-settings.h"
#include "ephy-prefs.h"
#include "ephy-gui.h"
#include "ephy-stock-icons.h"
@@ -124,7 +123,8 @@ ephy_shell_new_window_cb (EphyEmbedSingle *single,
LOG ("ephy_shell_new_window_cb tab chrome %d", chromemask);
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_JAVASCRIPT_CHROME))
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_JAVASCRIPT_CHROME))
{
chromemask = EPHY_WEB_VIEW_CHROME_ALL;
}
@@ -368,7 +368,10 @@ ephy_shell_new_tab_full (EphyShell *shell,
if (flags & EPHY_NEW_TAB_IN_EXISTING_WINDOW) in_new_window = FALSE;
if (flags & EPHY_NEW_TAB_DONT_COPY_HISTORY) copy_history = FALSE;
- in_new_window = in_new_window && !eel_gconf_get_boolean (CONF_LOCKDOWN_FULLSCREEN);
+ in_new_window = in_new_window &&
+ !g_settings_get_boolean
+ (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_FULLSCREEN);
g_return_val_if_fail (open_page == (gboolean)(request != NULL), NULL);
jump_to = (flags & EPHY_NEW_TAB_JUMP) != 0;
diff --git a/src/ephy-toolbar-editor.c b/src/ephy-toolbar-editor.c
index 4476e1fbe..2fd49250f 100644
--- a/src/ephy-toolbar-editor.c
+++ b/src/ephy-toolbar-editor.c
@@ -20,19 +20,19 @@
#include "config.h"
-#include "ephy-toolbar-editor.h"
+#include "ephy-debug.h"
#include "ephy-gui.h"
#include "ephy-prefs.h"
+#include "ephy-settings.h"
#include "ephy-state.h"
#include "ephy-file-helpers.h"
#include "ephy-shell.h"
+#include "ephy-stock-icons.h"
+#include "ephy-toolbar-editor.h"
#include "eggtypebuiltins.h"
#include "egg-toolbars-model.h"
#include "egg-editable-toolbar.h"
#include "egg-toolbar-editor.h"
-#include "eel-gconf-extensions.h"
-#include "ephy-stock-icons.h"
-#include "ephy-debug.h"
#include <glib/gi18n.h>
#include <gtk/gtk.h>
@@ -115,7 +115,8 @@ combo_changed_cb (GtkComboBox *combo,
pref = value->value_nick;
}
- eel_gconf_set_string (CONF_INTERFACE_TOOLBAR_STYLE, pref);
+ g_settings_set_string (EPHY_SETTINGS_UI,
+ EPHY_PREFS_UI_TOOLBAR_STYLE, pref);
g_type_class_unref (flags_class);
}
@@ -240,7 +241,8 @@ ephy_toolbar_editor_constructor (GType type,
gtk_widget_show_all (hbox);
/* get active from pref */
- pref = eel_gconf_get_string (CONF_INTERFACE_TOOLBAR_STYLE);
+ pref = g_settings_get_string (EPHY_SETTINGS_UI,
+ EPHY_PREFS_UI_TOOLBAR_STYLE);
if (pref != NULL)
{
flags_class = g_type_class_ref (EGG_TYPE_TB_MODEL_FLAGS);
diff --git a/src/ephy-toolbars-model.c b/src/ephy-toolbars-model.c
index a10fc3ada..5dc6cf4b1 100644
--- a/src/ephy-toolbars-model.c
+++ b/src/ephy-toolbars-model.c
@@ -23,7 +23,7 @@
#include "ephy-toolbars-model.h"
#include "ephy-file-helpers.h"
#include "ephy-prefs.h"
-#include "eel-gconf-extensions.h"
+#include "ephy-settings.h"
#include "eggtypebuiltins.h"
#include "ephy-debug.h"
@@ -39,7 +39,6 @@ struct _EphyToolbarsModelPrivate
char *xml_file;
EggTbModelFlags style;
guint timeout;
- guint style_notifier_id;
};
static void ephy_toolbars_model_class_init (EphyToolbarsModelClass *klass);
@@ -118,7 +117,8 @@ get_toolbar_style (void)
EggTbModelFlags flags = 0;
char *pref;
- pref = eel_gconf_get_string (CONF_INTERFACE_TOOLBAR_STYLE);
+ pref = g_settings_get_string (EPHY_SETTINGS_UI,
+ EPHY_PREFS_UI_TOOLBAR_STYLE);
if (pref != NULL)
{
flags_class = g_type_class_ref (EGG_TYPE_TB_MODEL_FLAGS);
@@ -137,10 +137,9 @@ get_toolbar_style (void)
}
static void
-toolbar_style_notifier (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- EphyToolbarsModel *model)
+toolbar_style_changed_cb (GSettings *settings,
+ char *key,
+ EphyToolbarsModel *model)
{
model->priv->style = get_toolbar_style ();
@@ -233,9 +232,9 @@ ephy_toolbars_model_init (EphyToolbarsModel *model)
NULL);
priv->style = get_toolbar_style ();
- priv->style_notifier_id = eel_gconf_notification_add
- (CONF_INTERFACE_TOOLBAR_STYLE,
- (GConfClientNotifyFunc) toolbar_style_notifier, model);
+ g_signal_connect (EPHY_SETTINGS_UI,
+ "changed::" EPHY_PREFS_UI_TOOLBAR_STYLE,
+ G_CALLBACK (toolbar_style_changed_cb), model);
g_signal_connect_after (model, "item_added",
G_CALLBACK (save_changes), NULL);
@@ -263,11 +262,6 @@ ephy_toolbars_model_finalize (GObject *object)
EphyToolbarsModel *model = EPHY_TOOLBARS_MODEL (object);
EphyToolbarsModelPrivate *priv = model->priv;
- if (priv->style_notifier_id != 0)
- {
- eel_gconf_notification_remove (priv->style_notifier_id);
- }
-
if (priv->timeout != 0)
{
g_source_remove (priv->timeout);
diff --git a/src/ephy-window.c b/src/ephy-window.c
index 0f8a666bd..7cd5253e1 100644
--- a/src/ephy-window.c
+++ b/src/ephy-window.c
@@ -31,8 +31,8 @@
#include "ephy-embed-single.h"
#include "ephy-embed-utils.h"
#include "ephy-shell.h"
-#include "eel-gconf-extensions.h"
#include "ephy-prefs.h"
+#include "ephy-settings.h"
#include "ephy-embed-prefs.h"
#include "ephy-embed-utils.h"
#include "ephy-zoom.h"
@@ -412,8 +412,6 @@ static const struct
#endif /* HAVE_X11_XF86KEYSYM_H */
};
-#define CONF_LOCKDOWN_HIDE_MENUBAR "/apps/epiphany/lockdown/hide_menubar"
-
#define BOOKMARKS_MENU_PATH "/menubar/BookmarksMenu"
#define SETTINGS_CONNECTION_DATA_KEY "EphyWindowSettings"
@@ -446,8 +444,6 @@ struct _EphyWindowPrivate
guint idle_worker;
GtkWidget *entry;
- guint browse_with_caret_notifier_id;
- guint allow_popups_notifier_id;
guint clear_progress_timeout_id;
guint menubar_accel_keyval;
@@ -552,7 +548,8 @@ construct_confirm_close_dialog (EphyWindow *window)
static gboolean
confirm_close_with_modified_forms (EphyWindow *window)
{
- if (eel_gconf_get_boolean (CONF_WARN_ON_CLOSE_UNSUBMITTED_DATA))
+ if (g_settings_get_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_WARN_ON_CLOSE_UNSUBMITTED_DATA))
{
GtkWidget *dialog;
int response;
@@ -817,7 +814,9 @@ ephy_window_fullscreen (EphyWindow *window)
priv->fullscreen_mode = TRUE;
- lockdown_fs = eel_gconf_get_boolean (CONF_LOCKDOWN_FULLSCREEN);
+ lockdown_fs = g_settings_get_boolean
+ (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_FULLSCREEN);
popup = ephy_fullscreen_popup_new (window);
ephy_fullscreen_popup_set_show_leave
@@ -975,7 +974,8 @@ ephy_window_key_press_event (GtkWidget *widget,
}
/* Don't activate menubar in lockdown mode */
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_HIDE_MENUBAR))
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_MENUBAR))
{
return GTK_WIDGET_CLASS (ephy_window_parent_class)->key_press_event (widget, event);
}
@@ -1014,7 +1014,8 @@ ephy_window_delete_event (GtkWidget *widget,
/* We ignore the delete_event if the disable_quit lockdown has been set
*/
- if (eel_gconf_get_boolean("/apps/epiphany/lockdown/disable_quit")) return TRUE;
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_QUIT)) return TRUE;
tabs = impl_get_children (EPHY_EMBED_CONTAINER (window));
for (l = tabs; l != NULL; l = l->next)
@@ -1080,7 +1081,9 @@ update_popup_actions_visibility (EphyWindow *window,
action = gtk_action_group_get_action (action_group, "OpenFrame");
gtk_action_set_visible (action, is_frame);
- inspector_enabled = eel_gconf_get_boolean (CONF_WEB_INSPECTOR_ENABLED);
+ inspector_enabled = g_settings_get_boolean
+ (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_ENABLE_WEB_INSPECTOR);
action = gtk_action_group_get_action (action_group, "InspectElement");
gtk_action_set_visible (action, inspector_enabled);
}
@@ -2251,8 +2254,11 @@ ephy_window_dom_mouse_click_cb (WebKitWebView *view,
is_middle_click = (button == 2);
middle_click_opens =
- eel_gconf_get_boolean (CONF_INTERFACE_MIDDLE_CLICK_OPEN_URL) &&
- !eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_ARBITRARY_URL);
+ g_settings_get_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_MIDDLE_CLICK_OPENS_URL) &&
+ !g_settings_get_boolean
+ (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_ARBITRARY_URL);
is_link = (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_LINK) != 0;
is_image = (context & WEBKIT_HIT_TEST_RESULT_CONTEXT_IMAGE) != 0;
@@ -2400,7 +2406,8 @@ create_web_view_cb (WebKitWebView *web_view,
EphyNewTabFlags flags;
EphyWindow *parent_window;
- if (eel_gconf_get_boolean (CONF_INTERFACE_OPEN_NEW_WINDOWS_IN_TAB))
+ if (g_settings_get_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_NEW_WINDOWS_IN_TABS))
{
parent_window = window;
flags = EPHY_NEW_TAB_IN_EXISTING_WINDOW |
@@ -2973,7 +2980,8 @@ notebook_page_close_request_cb (EphyNotebook *notebook,
{
EphyWindowPrivate *priv = window->priv;
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_QUIT) &&
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_QUIT) &&
gtk_notebook_get_n_pages (priv->notebook) == 1)
{
return;
@@ -3045,12 +3053,14 @@ ephy_window_set_chrome (EphyWindow *window, EphyWebViewChrome mask)
window->priv->should_save_chrome = TRUE;
}
- if (!eel_gconf_get_boolean (CONF_WINDOWS_SHOW_TOOLBARS))
+ if (!g_settings_get_boolean (EPHY_SETTINGS_UI,
+ EPHY_PREFS_UI_SHOW_TOOLBARS))
{
chrome_mask &= ~EPHY_WEB_VIEW_CHROME_TOOLBAR;
}
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_HIDE_MENUBAR))
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_MENUBAR))
{
chrome_mask &= ~EPHY_WEB_VIEW_CHROME_MENUBAR;
}
@@ -3089,11 +3099,6 @@ ephy_window_dispose (GObject *object)
g_signal_handlers_disconnect_by_func
(single, G_CALLBACK (sync_network_status), window);
- eel_gconf_notification_remove (priv->browse_with_caret_notifier_id);
- eel_gconf_notification_remove (priv->allow_popups_notifier_id);
- priv->browse_with_caret_notifier_id = 0;
- priv->allow_popups_notifier_id = 0;
-
if (priv->idle_resize_handler != 0)
{
g_source_remove (priv->idle_resize_handler);
@@ -3282,24 +3287,8 @@ ephy_window_class_init (EphyWindowClass *klass)
}
static void
-browse_with_caret_notifier (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
- EphyWindow *window)
-{
- GtkAction *action;
- gboolean enabled;
-
- enabled = eel_gconf_get_boolean (CONF_CARET_BROWSING_ENABLED);
- action = gtk_action_group_get_action (window->priv->action_group,
- "BrowseWithCaret");
- gtk_toggle_action_set_active (GTK_TOGGLE_ACTION (action), enabled);
-}
-
-static void
-allow_popups_notifier (GConfClient *client,
- guint cnxn_id,
- GConfEntry *entry,
+allow_popups_notifier (GSettings *settings,
+ char *key,
EphyWindow *window)
{
GList *tabs;
@@ -3539,14 +3528,17 @@ ephy_window_constructor (GType type,
(EGG_EDITABLE_TOOLBAR (priv->toolbar), model);
/* other notifiers */
- browse_with_caret_notifier (NULL, 0, NULL, window);
- priv->browse_with_caret_notifier_id = eel_gconf_notification_add
- (CONF_CARET_BROWSING_ENABLED,
- (GConfClientNotifyFunc)browse_with_caret_notifier, window);
+ action = gtk_action_group_get_action (window->priv->action_group,
+ "BrowseWithCaret");
+
+ g_settings_bind (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_ENABLE_CARET_BROWSING,
+ action, "active",
+ G_SETTINGS_BIND_GET);
- priv->allow_popups_notifier_id = eel_gconf_notification_add
- (CONF_SECURITY_ALLOW_POPUPS,
- (GConfClientNotifyFunc)allow_popups_notifier, window);
+ g_signal_connect (EPHY_SETTINGS_WEB,
+ "changed::" EPHY_PREFS_WEB_ENABLE_POPUPS,
+ G_CALLBACK (allow_popups_notifier), window);
/* network status */
single = EPHY_EMBED_SINGLE (ephy_embed_shell_get_embed_single (embed_shell));
@@ -3850,8 +3842,9 @@ sync_prefs_with_chrome (EphyWindow *window)
if (window->priv->should_save_chrome)
{
- eel_gconf_set_boolean (CONF_WINDOWS_SHOW_TOOLBARS,
- flags & EPHY_WEB_VIEW_CHROME_TOOLBAR);
+ g_settings_set_boolean (EPHY_SETTINGS_UI,
+ EPHY_PREFS_UI_SHOW_TOOLBARS,
+ flags & EPHY_WEB_VIEW_CHROME_TOOLBAR);
}
}
diff --git a/src/pdm-dialog.c b/src/pdm-dialog.c
index aae26c0a6..1b3e94ca1 100644
--- a/src/pdm-dialog.c
+++ b/src/pdm-dialog.c
@@ -67,7 +67,7 @@ struct PdmActionInfo
GtkTreeView *treeview;
GtkTreeSelection *selection;
GtkTreeModel *model;
- int remove_id;
+ const char *remove_id;
int data_col;
char *scroll_to_host;
gboolean filled;
@@ -115,37 +115,9 @@ enum
enum
{
- PROP_WINDOW,
- PROP_NOTEBOOK,
- PROP_COOKIES_TREEVIEW,
- PROP_COOKIES_REMOVE,
- PROP_COOKIES_PROPERTIES,
- PROP_PASSWORDS_TREEVIEW,
- PROP_PASSWORDS_REMOVE,
- PROP_PASSWORDS_SHOW
-};
-
-enum
-{
PDM_DIALOG_RESPONSE_CLEAR = 1
};
-static const
-EphyDialogProperty properties [] =
-{
- { "pdm_dialog", NULL, PT_NORMAL, 0 },
- { "pdm_notebook", NULL, PT_NORMAL, 0 },
-
- { "cookies_treeview", NULL, PT_NORMAL, 0 },
- { "cookies_remove_button", NULL, PT_NORMAL, 0 },
- { "cookies_properties_button", NULL, PT_NORMAL, 0 },
- { "passwords_treeview", NULL, PT_NORMAL, 0 },
- { "passwords_remove_button", NULL, PT_NORMAL, 0 },
- { "passwords_show_button", NULL, PT_NORMAL, 0 },
-
- { NULL }
-};
-
static void pdm_dialog_class_init (PdmDialogClass *klass);
static void pdm_dialog_init (PdmDialog *dialog);
static void pdm_dialog_finalize (GObject *object);
@@ -174,11 +146,10 @@ pdm_dialog_show_help (PdmDialog *pd)
"managing-passwords"
};
- ephy_dialog_get_controls
- (EPHY_DIALOG (pd),
- properties[PROP_WINDOW].id, &window,
- properties[PROP_NOTEBOOK].id, &notebook,
- NULL);
+ ephy_dialog_get_controls (EPHY_DIALOG (pd),
+ "pdm_dialog", &window,
+ "pdm_notebook", &notebook,
+ NULL);
id = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
g_return_if_fail (id == 0 || id == 1);
@@ -488,7 +459,7 @@ action_treeview_selection_changed_cb (GtkTreeSelection *selection,
has_selection = gtk_tree_selection_count_selected_rows (selection) > 0;
- widget = ephy_dialog_get_control (d, properties[action->remove_id].id);
+ widget = ephy_dialog_get_control (d, action->remove_id);
gtk_widget_set_sensitive (widget, has_selection);
}
@@ -616,7 +587,7 @@ setup_action (PdmActionInfo *action)
GtkTreeSelection *selection;
widget = ephy_dialog_get_control (EPHY_DIALOG(action->dialog),
- properties[action->remove_id].id);
+ action->remove_id);
g_signal_connect (widget, "clicked",
G_CALLBACK (pdm_dialog_remove_button_clicked_cb),
action);
@@ -645,8 +616,7 @@ show_cookies_properties (PdmDialog *dialog,
GtkWidget *content_area;
char *str;
- parent = ephy_dialog_get_control (EPHY_DIALOG(dialog),
- properties[PROP_WINDOW].id);
+ parent = ephy_dialog_get_control (EPHY_DIALOG(dialog), "pdm_dialog");
gdialog = gtk_dialog_new_with_buttons
(_("Cookie Properties"),
@@ -791,7 +761,7 @@ cookies_treeview_selection_changed_cb (GtkTreeSelection *selection,
has_selection = gtk_tree_selection_count_selected_rows (selection) == 1;
- widget = ephy_dialog_get_control (d, properties[PROP_COOKIES_PROPERTIES].id);
+ widget = ephy_dialog_get_control (d, "cookies_properties_button");
gtk_widget_set_sensitive (widget, has_selection);
}
@@ -828,8 +798,8 @@ pdm_dialog_cookies_construct (PdmActionInfo *info)
LOG ("pdm_dialog_cookies_construct");
ephy_dialog_get_controls (EPHY_DIALOG (dialog),
- properties[PROP_COOKIES_TREEVIEW].id, &treeview,
- properties[PROP_COOKIES_PROPERTIES].id, &button,
+ "cookies_treeview", &treeview,
+ "cookies_properties_button", &button,
NULL);
g_signal_connect (button, "clicked",
@@ -1234,8 +1204,8 @@ passwords_show_toggled_cb (GtkWidget *button,
GtkTreeViewColumn *column;
gboolean active;
- treeview = GTK_TREE_VIEW (ephy_dialog_get_control
- (EPHY_DIALOG(dialog), properties[PROP_PASSWORDS_TREEVIEW].id));
+ treeview = GTK_TREE_VIEW (ephy_dialog_get_control (EPHY_DIALOG(dialog),
+ "passwords_treeview"));
column = gtk_tree_view_get_column (treeview, COL_PASSWORDS_PASSWORD);
active = gtk_toggle_button_get_active ((GTK_TOGGLE_BUTTON (button)));
@@ -1257,8 +1227,8 @@ pdm_dialog_passwords_construct (PdmActionInfo *info)
LOG ("pdm_dialog_passwords_construct");
ephy_dialog_get_controls (EPHY_DIALOG (dialog),
- properties[PROP_PASSWORDS_TREEVIEW].id, &treeview,
- properties[PROP_PASSWORDS_SHOW].id, &button,
+ "passwords_treeview", &treeview,
+ "passwords_show_button", &button,
NULL);
g_signal_connect (button, "toggled",
@@ -1521,7 +1491,7 @@ pdm_dialog_response_cb (GtkDialog *widget,
GtkWidget *parent;
parent = ephy_dialog_get_control (EPHY_DIALOG (dialog),
- properties[PROP_WINDOW].id);
+ "pdm_dialog");
page = gtk_notebook_get_current_page (GTK_NOTEBOOK (dialog->priv->notebook));
if (page == 0)
@@ -1554,14 +1524,13 @@ pdm_dialog_init (PdmDialog *dialog)
priv = dialog->priv = EPHY_PDM_DIALOG_GET_PRIVATE (dialog);
ephy_dialog_construct (EPHY_DIALOG(dialog),
- properties,
ephy_file ("epiphany.ui"),
"pdm_dialog",
NULL);
ephy_dialog_get_controls (EPHY_DIALOG (dialog),
- properties[PROP_WINDOW].id, &window,
- properties[PROP_NOTEBOOK].id, &priv->notebook,
+ "pdm_dialog", &window,
+ "pdm_notebook", &priv->notebook,
NULL);
ephy_gui_ensure_window_group (GTK_WINDOW (window));
@@ -1576,9 +1545,9 @@ pdm_dialog_init (PdmDialog *dialog)
* one set of buttons is wider than another.
*/
ephy_dialog_set_size_group (EPHY_DIALOG (dialog),
- properties[PROP_COOKIES_REMOVE].id,
- properties[PROP_COOKIES_PROPERTIES].id,
- properties[PROP_PASSWORDS_REMOVE].id,
+ "cookies_remove_button",
+ "cookies_properties_button",
+ "passwords_remove_button",
NULL);
cookies = g_new0 (PdmActionInfo, 1);
@@ -1589,7 +1558,7 @@ pdm_dialog_init (PdmDialog *dialog)
cookies->remove = pdm_dialog_cookie_remove;
cookies->scroll_to = pdm_dialog_cookie_scroll_to;
cookies->dialog = dialog;
- cookies->remove_id = PROP_COOKIES_REMOVE;
+ cookies->remove_id = "cookies_remove_button";
cookies->data_col = COL_COOKIES_DATA;
cookies->scroll_to_host = NULL;
cookies->filled = FALSE;
@@ -1603,7 +1572,7 @@ pdm_dialog_init (PdmDialog *dialog)
passwords->add = pdm_dialog_password_add;
passwords->remove = pdm_dialog_password_remove;
passwords->dialog = dialog;
- passwords->remove_id = PROP_PASSWORDS_REMOVE;
+ passwords->remove_id = "passwords_remove_button";
passwords->data_col = COL_PASSWORDS_DATA;
passwords->scroll_to_host = NULL;
passwords->filled = FALSE;
diff --git a/src/popup-commands.c b/src/popup-commands.c
index c90dcf0fc..4db684ea7 100644
--- a/src/popup-commands.c
+++ b/src/popup-commands.c
@@ -234,7 +234,7 @@ save_property_url (GtkAction *action,
(persist, EPHY_EMBED_PERSIST_FROM_CACHE |
(ask_dest ? EPHY_EMBED_PERSIST_ASK_DESTINATION : 0));
ephy_embed_persist_set_persist_key
- (persist, CONF_STATE_SAVE_DIR);
+ (persist, EPHY_PREFS_STATE_SAVE_DIR);
ephy_embed_persist_set_source (persist, location);
ephy_embed_persist_set_embed (persist, embed);
diff --git a/src/prefs-dialog.c b/src/prefs-dialog.c
index 437a88b10..b1dcc7165 100644
--- a/src/prefs-dialog.c
+++ b/src/prefs-dialog.c
@@ -2,6 +2,7 @@
/*
* Copyright © 200-2003 Marco Pesenti Gritti
* Copyright © 2003, 2004, 2005 Christian Persch
+ * 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
@@ -24,6 +25,7 @@
#include "prefs-dialog.h"
#include "ephy-dialog.h"
#include "ephy-prefs.h"
+#include "ephy-settings.h"
#include "ephy-embed-container.h"
#include "ephy-embed-shell.h"
#include "ephy-embed-utils.h"
@@ -33,7 +35,6 @@
#include "ephy-embed-single.h"
#include "ephy-shell.h"
#include "ephy-gui.h"
-#include "eel-gconf-extensions.h"
#include "ephy-langs.h"
#include "ephy-encodings.h"
#include "ephy-debug.h"
@@ -54,115 +55,6 @@ static void prefs_dialog_init (PrefsDialog *pd);
#include "languages.h"
-static const char * const cookies_accept_enum [] =
-{
- "anywhere", "current site", "nowhere"
-};
-
-enum
-{
- WINDOW_PROP,
- NOTEBOOK_PROP,
-
- /* General */
- HOMEPAGE_ENTRY_PROP,
- HOMEPAGE_CURRENT_PROP,
- HOMEPAGE_BLANK_PROP,
- AUTO_OPEN_PROP,
- DOWNLOAD_PATH_HBOX_PROP,
- DOWNLOAD_PATH_LABEL_PROP,
- WEB_INSPECTOR_BUTTON_PROP,
-
- /* Fonts and Colors */
- USE_FONTS_PROP,
- MIN_SIZE_PROP,
- USE_COLORS_PROP,
- CSS_CONTAINER_PROP,
- CSS_CHECKBOX_PROP,
- CSS_EDIT_BOX_PROP,
- CSS_EDIT_BUTTON_PROP,
-
- /* Privacy */
- ALLOW_POPUPS_PROP,
- ALLOW_JAVA_PROP,
- ALLOW_JS_PROP,
- ACCEPT_COOKIES_PROP,
- REMEMBER_PASSWORDS_PROP,
- DISK_CACHE_PROP,
- CLEAR_CACHE_BUTTON_PROP,
-
- /* Language */
- DEFAULT_ENCODING_PROP,
- DEFAULT_ENCODING_LABEL_PROP,
- LANGUAGE_ADD_BUTTON_PROP,
- LANGUAGE_REMOVE_BUTTON_PROP,
- LANGUAGE_UP_BUTTON_PROP,
- LANGUAGE_DOWN_BUTTON_PROP,
- LANGUAGE_TREEVIEW_PROP
-};
-
-static const
-EphyDialogProperty properties [] =
-{
- { "prefs_dialog", NULL, PT_NORMAL, 0},
- { "prefs_notebook", NULL, PT_NORMAL, 0},
-
- /* General */
- { "homepage_entry", CONF_GENERAL_HOMEPAGE, PT_AUTOAPPLY, G_TYPE_STRING },
- { "homepage_current_button", NULL, PT_NORMAL, 0 },
- { "homepage_blank_button", NULL, PT_NORMAL, 0 },
- { "automatic_downloads_checkbutton", CONF_AUTO_DOWNLOADS, PT_AUTOAPPLY, 0 },
- { "download_button_hbox", NULL, PT_NORMAL, 0 },
- { "download_button_label", NULL, PT_NORMAL, 0 },
- { "web_inspector_checkbutton", CONF_WEB_INSPECTOR_ENABLED, PT_AUTOAPPLY, 0 },
-
- /* Fonts and Colors */
- { "use_fonts_checkbutton", CONF_RENDERING_USE_OWN_FONTS, PT_AUTOAPPLY | PT_INVERTED, 0 },
- { "min_size_spinbutton", CONF_RENDERING_FONT_MIN_SIZE, PT_AUTOAPPLY, 0 },
- { "use_colors_checkbutton", CONF_RENDERING_USE_OWN_COLORS, PT_AUTOAPPLY | PT_INVERTED, 0 },
- { "css_container", NULL, PT_NORMAL, 0 },
- { "css_checkbox", CONF_USER_CSS_ENABLED, PT_AUTOAPPLY, 0 },
- { "css_edit_box", NULL, PT_NORMAL, 0 },
- { "css_edit_button", NULL, PT_NORMAL, 0 },
-
- /* Privacy */
- { "popups_allow_checkbutton", CONF_SECURITY_ALLOW_POPUPS, PT_AUTOAPPLY, 0 },
- { "enable_plugins_checkbutton", CONF_SECURITY_PLUGINS_ENABLED, PT_AUTOAPPLY, 0 },
- { "enable_javascript_checkbutton", CONF_SECURITY_JAVASCRIPT_ENABLED, PT_AUTOAPPLY, 0 },
- { "cookies_radiobutton", CONF_SECURITY_COOKIES_ACCEPT, PT_AUTOAPPLY, G_TYPE_STRING },
- { "remember_passwords_checkbutton", CONF_PRIVACY_REMEMBER_PASSWORDS, PT_AUTOAPPLY, 0 },
- { "disk_cache_spin", CONF_NETWORK_CACHE_SIZE, PT_AUTOAPPLY, 0 },
- { "clear_cache_button", NULL, PT_NORMAL, 0 },
-
- /* Languages */
- { "default_encoding_combo", CONF_LANGUAGE_DEFAULT_ENCODING, PT_AUTOAPPLY, G_TYPE_STRING },
- { "default_encoding_label", NULL, PT_NORMAL, 0 },
- { "lang_add_button", NULL, PT_NORMAL, 0 },
- { "lang_remove_button", NULL, PT_NORMAL, 0 },
- { "lang_up_button", NULL, PT_NORMAL, 0 },
- { "lang_down_button", NULL, PT_NORMAL, 0 },
- { "lang_treeview", NULL, PT_NORMAL, 0 },
-
- { NULL }
-};
-
-enum
-{
- LANGUAGE_DIALOG,
- LANGUAGE_PROP,
- LANGUAGE_ACCEPT_BUTTON_PROP
-};
-
-static const
-EphyDialogProperty add_lang_props [] =
-{
- { "add_language_dialog", NULL, PT_NORMAL, 0 },
- { "languages_treeview", NULL, PT_NORMAL, G_TYPE_STRING },
- { "add_button", NULL, PT_NORMAL, 0 },
-
- { NULL }
-};
-
enum
{
COL_LANG_NAME,
@@ -232,8 +124,8 @@ prefs_dialog_show_help (EphyDialog *dialog)
};
ephy_dialog_get_controls (dialog,
- properties[WINDOW_PROP].id, &window,
- properties[NOTEBOOK_PROP].id, &notebook,
+ "prefs_dialog", &window,
+ "prefs_notebook", &notebook,
NULL);
id = gtk_notebook_get_current_page (GTK_NOTEBOOK (notebook));
@@ -243,13 +135,6 @@ prefs_dialog_show_help (EphyDialog *dialog)
}
static void
-css_checkbox_toggled (GtkToggleButton *button,
- GtkWidget *widget)
-{
- g_object_set (widget, "sensitive", gtk_toggle_button_get_active (button), NULL);
-}
-
-static void
css_edit_button_clicked_cb (GtkWidget *button,
PrefsDialog *pd)
{
@@ -264,12 +149,73 @@ css_edit_button_clicked_cb (GtkWidget *button,
g_object_unref (css_file);
}
+static gboolean
+combo_get_mapping (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
+{
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean valid = FALSE;
+ const char *settings_name;
+ int i;
+
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (user_data));
+ valid = gtk_tree_model_get_iter_first (model, &iter);
+ settings_name = g_variant_get_string (variant, NULL);
+ i = 0;
+
+ while (valid)
+ {
+ char *item_name;
+ gtk_tree_model_get (model, &iter, 1, &item_name, -1);
+
+ if (g_strcmp0 (item_name, settings_name) == 0)
+ {
+ g_value_set_int (value, i);
+ break;
+ }
+
+ i++;
+ valid = gtk_tree_model_iter_next (model, &iter);
+ g_free (item_name);
+ }
+
+ return TRUE;
+}
+
+static GVariant *
+combo_set_mapping (const GValue *value,
+ const GVariantType *expected_type,
+ gpointer user_data)
+{
+ GVariant *variant = NULL;
+ GtkTreeModel *model;
+ GtkTreeIter iter;
+ gboolean valid = FALSE;
+ int n;
+
+ n = g_value_get_int (value);
+ model = gtk_combo_box_get_model (GTK_COMBO_BOX (user_data));
+ valid = gtk_tree_model_iter_nth_child (model, &iter, NULL, n);
+
+ if (valid)
+ {
+ char *item_name;
+ gtk_tree_model_get (model, &iter, 1, &item_name, -1);
+
+ variant = g_variant_new_string (item_name);
+
+ g_free (item_name);
+ }
+
+ return variant;
+}
+
static void
create_node_combo (EphyDialog *dialog,
- int prop,
EphyEncodings *encodings,
EphyNode *node,
- const char *key,
const char *default_value)
{
EphyTreeModelNode *nodemodel;
@@ -279,15 +225,19 @@ create_node_combo (EphyDialog *dialog,
char *code;
int title_col, data_col;
- code = eel_gconf_get_string (key);
+ code = g_settings_get_string (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_DEFAULT_ENCODING);
if (code == NULL || ephy_encodings_get_node (encodings, code, FALSE) == NULL)
{
/* safe default */
- eel_gconf_set_string (key, default_value);
+ g_settings_set_string (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_DEFAULT_ENCODING,
+ default_value);
}
g_free (code);
- combo = GTK_COMBO_BOX (ephy_dialog_get_control (dialog, properties[prop].id));
+ combo = GTK_COMBO_BOX (ephy_dialog_get_control (dialog,
+ "default_encoding_combo"));
nodemodel = ephy_tree_model_node_new (node);
@@ -309,7 +259,14 @@ create_node_combo (EphyDialog *dialog,
"text", title_col,
NULL);
- ephy_dialog_set_data_column (dialog, properties[prop].id, data_col);
+ g_settings_bind_with_mapping (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_DEFAULT_ENCODING,
+ combo, "active",
+ G_SETTINGS_BIND_DEFAULT,
+ combo_get_mapping,
+ combo_set_mapping,
+ combo,
+ NULL);
g_object_unref (nodemodel);
g_object_unref (sortmodel);
@@ -358,10 +315,12 @@ static void
language_editor_update_pref (PrefsDialog *pd)
{
GtkTreeIter iter;
- GSList *codes = NULL;
+ GVariantBuilder builder;
if (gtk_tree_model_get_iter_first (pd->priv->lang_model, &iter))
{
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
+
do
{
char *code;
@@ -369,17 +328,15 @@ language_editor_update_pref (PrefsDialog *pd)
gtk_tree_model_get (pd->priv->lang_model, &iter,
COL_LANG_CODE, &code,
-1);
-
- codes = g_slist_prepend (codes, code);
+ g_variant_builder_add (&builder, "s", code);
+ g_free (code);
}
while (gtk_tree_model_iter_next (pd->priv->lang_model, &iter));
- }
- codes = g_slist_reverse (codes);
- eel_gconf_set_string_list (CONF_RENDERING_LANGUAGE, codes);
-
- g_slist_foreach (codes, (GFunc) g_free, NULL);
- g_slist_free (codes);
+ g_settings_set (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ "as", &builder);
+ }
}
static void
@@ -420,7 +377,7 @@ add_lang_dialog_selection_changed (GtkTreeSelection *selection,
GtkWidget *button;
int n_selected;
- button = ephy_dialog_get_control (dialog, add_lang_props[LANGUAGE_ACCEPT_BUTTON_PROP].id);
+ button = ephy_dialog_get_control (dialog, "add_button");
n_selected = gtk_tree_selection_count_selected_rows (selection);
gtk_widget_set_sensitive (button, n_selected > 0);
@@ -443,7 +400,7 @@ add_lang_dialog_response_cb (GtkWidget *widget,
if (response == GTK_RESPONSE_ACCEPT)
{
treeview = GTK_TREE_VIEW (ephy_dialog_get_control
- (dialog, add_lang_props[LANGUAGE_PROP].id));
+ (dialog, "languages_treeview"));
selection = gtk_tree_view_get_selection (treeview);
rows = gtk_tree_selection_get_selected_rows (selection, &model);
@@ -572,7 +529,7 @@ setup_add_language_dialog (PrefsDialog *pd)
GtkTreeIter iter;
int i;
- parent = ephy_dialog_get_control (EPHY_DIALOG (pd), properties[WINDOW_PROP].id);
+ parent = ephy_dialog_get_control (EPHY_DIALOG (pd), "prefs_dialog");
dialog = EPHY_DIALOG (g_object_new (EPHY_TYPE_DIALOG,
"parent-window", parent,
@@ -581,7 +538,6 @@ setup_add_language_dialog (PrefsDialog *pd)
NULL));
ephy_dialog_construct (dialog,
- add_lang_props,
ephy_file ("prefs-dialog.ui"),
"add_language_dialog",
NULL);
@@ -610,8 +566,8 @@ setup_add_language_dialog (PrefsDialog *pd)
(GTK_TREE_SORTABLE (sortmodel), COL_LANG_NAME, GTK_SORT_ASCENDING);
ephy_dialog_get_controls (dialog,
- add_lang_props[LANGUAGE_PROP].id, &treeview,
- add_lang_props[LANGUAGE_DIALOG].id, &window,
+ "languages_treeview", &treeview,
+ "add_language_dialog", &window,
NULL);
gtk_window_group_add_window (gtk_window_get_group (GTK_WINDOW (parent)),
@@ -776,18 +732,19 @@ create_language_section (EphyDialog *dialog)
GtkCellRenderer *renderer;
GtkTreeViewColumn *column;
GtkTreeSelection *selection;
- GSList *list, *l, *ulist = NULL;
+ char **list = NULL;
+ int i;
pd->priv->iso_639_table = ephy_langs_iso_639_table ();
pd->priv->iso_3166_table = ephy_langs_iso_3166_table ();
ephy_dialog_get_controls
(dialog,
- properties[LANGUAGE_TREEVIEW_PROP].id, &treeview,
- properties[LANGUAGE_ADD_BUTTON_PROP].id, &pd->priv->lang_add_button,
- properties[LANGUAGE_REMOVE_BUTTON_PROP].id, &pd->priv->lang_remove_button,
- properties[LANGUAGE_UP_BUTTON_PROP].id, &pd->priv->lang_up_button,
- properties[LANGUAGE_DOWN_BUTTON_PROP].id, &pd->priv->lang_down_button,
+ "lang_treeview", &treeview,
+ "lang_add_button", &pd->priv->lang_add_button,
+ "lang_remove_button", &pd->priv->lang_remove_button,
+ "lang_up_button", &pd->priv->lang_up_button,
+ "lang_down_button", &pd->priv->lang_down_button,
NULL);
g_signal_connect (pd->priv->lang_add_button, "clicked",
@@ -802,16 +759,13 @@ create_language_section (EphyDialog *dialog)
/* setup the languages treeview */
pd->priv->lang_treeview = treeview;
- gtk_tree_view_set_reorderable (GTK_TREE_VIEW (treeview), TRUE);
+ gtk_tree_view_set_reorderable (treeview, TRUE);
+ gtk_tree_view_set_headers_visible (treeview, FALSE);
store = gtk_list_store_new (2, G_TYPE_STRING, G_TYPE_STRING);
pd->priv->lang_model = GTK_TREE_MODEL (store);
-
gtk_tree_view_set_model (treeview, pd->priv->lang_model);
- g_object_unref (store);
-
- gtk_tree_view_set_headers_visible (treeview, FALSE);
renderer = gtk_cell_renderer_text_new ();
@@ -833,28 +787,13 @@ create_language_section (EphyDialog *dialog)
g_signal_connect (G_OBJECT (selection), "changed",
G_CALLBACK (language_editor_selection_changed_cb), pd);
- list = eel_gconf_get_string_list (CONF_RENDERING_LANGUAGE);
-
- /* uniquify list */
- for (l = list; l != NULL; l = l->next)
- {
- if (g_slist_find_custom (ulist, l->data, (GCompareFunc) strcmp) == NULL)
- {
- ulist = g_slist_prepend (ulist, g_strdup (l->data));
- }
- }
- ulist = g_slist_reverse (ulist);
-
- /* if modified, write back */
- if (g_slist_length (ulist) != g_slist_length (list))
- {
- eel_gconf_set_string_list (CONF_RENDERING_LANGUAGE, ulist);
- }
+ list = g_settings_get_strv (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE);
/* Fill languages editor */
- for (l = ulist; l != NULL; l = l->next)
+ for (i = 0; list[i]; i++)
{
- const char *code = (const char *) l->data;
+ const char *code = (const char *) list[i];
if (strcmp (code, "system") == 0)
{
@@ -869,24 +808,27 @@ create_language_section (EphyDialog *dialog)
g_free (text);
}
}
+ g_object_unref (store);
language_editor_update_buttons (pd);
+ g_strfreev (list);
/* Lockdown if key is not writable */
- if (eel_gconf_key_is_writable (CONF_RENDERING_LANGUAGE) == FALSE)
- {
- gtk_widget_set_sensitive (pd->priv->lang_add_button, FALSE);
- gtk_widget_set_sensitive (pd->priv->lang_remove_button, FALSE);
- gtk_widget_set_sensitive (pd->priv->lang_up_button, FALSE);
- gtk_widget_set_sensitive (pd->priv->lang_down_button, FALSE);
- gtk_widget_set_sensitive (GTK_WIDGET (pd->priv->lang_treeview), FALSE);
- }
-
- g_slist_foreach (list, (GFunc) g_free, NULL);
- g_slist_free (list);
-
- g_slist_foreach (ulist, (GFunc) g_free, NULL);
- g_slist_free (ulist);
+ g_settings_bind_writable (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ pd->priv->lang_add_button, "sensitive", FALSE);
+ g_settings_bind_writable (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ pd->priv->lang_remove_button, "sensitive", FALSE);
+ g_settings_bind_writable (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ pd->priv->lang_up_button, "sensitive", FALSE);
+ g_settings_bind_writable (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ pd->priv->lang_down_button, "sensitive", FALSE);
+ g_settings_bind_writable (EPHY_SETTINGS_WEB,
+ EPHY_PREFS_WEB_LANGUAGE,
+ pd->priv->lang_treeview, "sensitive", FALSE);
}
static void
@@ -909,15 +851,20 @@ download_path_changed_cb (GtkFileChooser *button)
* two ephy_file_ functions. */
if (strcmp (dir, downloads_dir) == 0)
{
- eel_gconf_set_string (CONF_STATE_DOWNLOAD_DIR, _("Downloads"));
+ g_settings_set_string (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_DOWNLOAD_DIR,
+ _("Downloads"));
}
else if (strcmp (dir, desktop_dir) == 0)
{
- eel_gconf_set_string (CONF_STATE_DOWNLOAD_DIR, _("Desktop"));
+ g_settings_set_string (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_DOWNLOAD_DIR,
+ _("Desktop"));
}
else
{
- eel_gconf_set_path (CONF_STATE_DOWNLOAD_DIR, dir);
+ g_settings_set_string (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_DOWNLOAD_DIR, dir);
}
g_free (dir);
@@ -935,9 +882,9 @@ create_download_path_button (EphyDialog *dialog)
dir = ephy_file_get_downloads_dir ();
ephy_dialog_get_controls (dialog,
- properties[DOWNLOAD_PATH_HBOX_PROP].id, &hbox,
- properties[DOWNLOAD_PATH_LABEL_PROP].id, &label,
- properties[WINDOW_PROP].id, &parent,
+ "download_button_hbox", &hbox,
+ "download_button_label", &label,
+ "prefs_dialog", &parent,
NULL);
fc = ephy_file_chooser_new (_("Select a Directory"),
@@ -945,7 +892,8 @@ create_download_path_button (EphyDialog *dialog)
GTK_FILE_CHOOSER_ACTION_SELECT_FOLDER,
NULL, EPHY_FILE_FILTER_NONE);
- /* Unset the destroy-with-parent, since gtkfilechooserbutton doesn't expect this */
+ /* Unset the destroy-with-parent, since gtkfilechooserbutton doesn't
+ * expect this */
gtk_window_set_destroy_with_parent (GTK_WINDOW (fc), FALSE);
button = gtk_file_chooser_button_new_with_dialog (GTK_WIDGET (fc));
@@ -958,7 +906,9 @@ create_download_path_button (EphyDialog *dialog)
gtk_box_pack_start (GTK_BOX (hbox), button, TRUE, TRUE, 0);
gtk_widget_show (button);
- gtk_widget_set_sensitive (button, eel_gconf_key_is_writable (CONF_STATE_DOWNLOAD_DIR));
+ g_settings_bind_writable (EPHY_SETTINGS_STATE,
+ EPHY_PREFS_STATE_DOWNLOAD_DIR,
+ button, "sensitive", FALSE);
g_free (dir);
}
@@ -977,37 +927,25 @@ prefs_dialog_response_cb (GtkDialog *widget,
}
static void
-prefs_clear_cache_button_clicked_cb (GtkWidget *button,
- PrefsDialog *dialog)
+clear_cache_button_clicked_cb (GtkWidget *button,
+ PrefsDialog *dialog)
{
GtkWidget *parent;
parent = ephy_dialog_get_control (EPHY_DIALOG (dialog),
- properties[WINDOW_PROP].id);
- pdm_dialog_show_clear_all_dialog (EPHY_DIALOG (dialog),
- parent,
+ "prefs_dialog");
+ pdm_dialog_show_clear_all_dialog (EPHY_DIALOG (dialog), parent,
CLEAR_ALL_CACHE);
}
static void
-set_homepage_entry (EphyDialog *dialog,
- const char *new_location)
-{
- GValue value = { 0, };
-
- g_value_init (&value, G_TYPE_STRING);
- g_value_set_string (&value, new_location);
- ephy_dialog_set_value (dialog, properties[HOMEPAGE_ENTRY_PROP].id, &value);
- g_value_unset (&value);
-}
-
-static void
-prefs_homepage_current_button_clicked_cb (GtkWidget *button,
- EphyDialog *dialog)
+homepage_current_button_clicked_cb (GtkWidget *button,
+ EphyDialog *dialog)
{
EphySession *session;
EphyWindow *window;
EphyEmbed *embed;
+ EphyWebView *view;
session = EPHY_SESSION (ephy_shell_get_session (ephy_shell_get_default ()));
window = ephy_session_get_active_window (session);
@@ -1019,16 +957,127 @@ prefs_homepage_current_button_clicked_cb (GtkWidget *button,
(EPHY_EMBED_CONTAINER (window));
g_return_if_fail (embed != NULL);
- set_homepage_entry (dialog, ephy_web_view_get_address (ephy_embed_get_web_view (embed)));
+ view = ephy_embed_get_web_view (embed);
+
+ g_settings_set_string (EPHY_SETTINGS_MAIN, EPHY_PREFS_HOMEPAGE_URL,
+ ephy_web_view_get_address (view));
}
static void
-prefs_homepage_blank_button_clicked_cb (GtkWidget *button,
- EphyDialog *dialog)
+homepage_blank_button_clicked_cb (GtkWidget *button,
+ EphyDialog *dialog)
+{
+ g_settings_set_string (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_HOMEPAGE_URL, "");
+}
+
+static gboolean
+cookies_get_mapping (GValue *value,
+ GVariant *variant,
+ gpointer user_data)
{
- set_homepage_entry (dialog, NULL);
+ const char *setting;
+ char *name;
+
+ setting = g_variant_get_string (variant, NULL);
+
+ g_object_get (user_data, "name", &name, NULL);
+
+ /* If the button name matches the setting, it should be active. */
+ if (g_strcmp0 (name, setting) == 0)
+ g_value_set_boolean (value, TRUE);
+
+ g_free (name);
+
+ return TRUE;
+}
+
+static GVariant *
+cookies_set_mapping (const GValue *value,
+ const GVariantType *expected_type,
+ gpointer user_data)
+{
+ GVariant *variant = NULL;
+ char *name;
+
+ /* Don't act unless the button has been activated (turned ON). */
+ if (!g_value_get_boolean (value))
+ return NULL;
+
+ g_object_get (user_data, "name", &name, NULL);
+ variant = g_variant_new_string (name);
+
+ g_free (name);
+
+ return variant;
}
+typedef struct
+{
+ char *obj;
+ char *prop;
+ char *schema;
+ char *key;
+ GSettingsBindFlags flags;
+ GSettingsBindGetMapping get_mapping;
+ GSettingsBindSetMapping set_mapping;
+} PrefsDialogPreference;
+
+static const PrefsDialogPreference preferences[] =
+{
+ { "homepage_entry", "text",
+ EPHY_PREFS_SCHEMA, EPHY_PREFS_HOMEPAGE_URL,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "automatic_downloads_checkbutton", "active",
+ EPHY_PREFS_SCHEMA, EPHY_PREFS_AUTO_DOWNLOADS,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "web_inspector_checkbutton", "active",
+ EPHY_PREFS_SCHEMA, EPHY_PREFS_ENABLE_WEB_INSPECTOR,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "remember_passwords_checkbutton", "active",
+ EPHY_PREFS_SCHEMA, EPHY_PREFS_REMEMBER_PASSWORDS,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+
+ { "disk_cache_spinbutton", "value",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_CACHE_SIZE,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "use_fonts_checkbutton", "active",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_USE_OWN_FONTS,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "min_size_spinbutton", "value",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_FONT_MIN_SIZE,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "use_colors_checkbutton", "active",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_USE_OWN_COLORS,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "popups_allow_checkbutton", "active",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_ENABLE_POPUPS,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "enable_plugins_checkbutton", "active",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_ENABLE_PLUGINS,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "enable_javascript_checkbutton", "active",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_ENABLE_JAVASCRIPT,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "css_checkbox", "active",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_ENABLE_USER_CSS,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+ { "css_edit_button", "sensitive",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_ENABLE_USER_CSS,
+ G_SETTINGS_BIND_DEFAULT, NULL, NULL },
+
+ /* Has mapping */
+ { "cookies_always_radiobutton", "active",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_COOKIES_POLICY,
+ G_SETTINGS_BIND_DEFAULT, cookies_get_mapping, cookies_set_mapping },
+ { "cookies_no_third_party_radiobutton", "active",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_COOKIES_POLICY,
+ G_SETTINGS_BIND_DEFAULT, cookies_get_mapping, cookies_set_mapping },
+ { "cookies_never_radiobutton", "active",
+ EPHY_PREFS_WEB_SCHEMA, EPHY_PREFS_WEB_COOKIES_POLICY,
+ G_SETTINGS_BIND_DEFAULT, cookies_get_mapping, cookies_set_mapping },
+};
+
static void
prefs_dialog_init (PrefsDialog *pd)
{
@@ -1036,31 +1085,42 @@ prefs_dialog_init (PrefsDialog *pd)
EphyEncodings *encodings;
GtkWidget *window, *curr_button, *blank_button;
GtkWidget *clear_cache_button;
- GtkWidget *css_checkbox, *css_edit_box, *css_edit_button, *css_container;
- gboolean sensitive;
+ GtkWidget *css_checkbox, *css_edit_button;
+ int i;
pd->priv = EPHY_PREFS_DIALOG_GET_PRIVATE (pd);
ephy_dialog_construct (dialog,
- properties,
ephy_file ("prefs-dialog.ui"),
"prefs_dialog",
NULL);
- ephy_dialog_add_enum (dialog, properties[ACCEPT_COOKIES_PROP].id,
- G_N_ELEMENTS (cookies_accept_enum), cookies_accept_enum);
+ for (i = 0; i < G_N_ELEMENTS (preferences); i++)
+ {
+ PrefsDialogPreference pref;
+ GtkWidget *widget;
+ GSettings *settings;
+
+ pref = preferences[i];
+ settings = ephy_settings_get (pref.schema);
+ widget = ephy_dialog_get_control (dialog, pref.obj);
+
+ g_settings_bind_with_mapping (settings, pref.key,
+ widget, pref.prop,
+ pref.flags,
+ pref.get_mapping,
+ pref.set_mapping,
+ widget, NULL);
+ }
- ephy_dialog_get_controls
- (dialog,
- properties[WINDOW_PROP].id, &window,
- properties[HOMEPAGE_CURRENT_PROP].id, &curr_button,
- properties[HOMEPAGE_BLANK_PROP].id, &blank_button,
- properties[CSS_CHECKBOX_PROP].id, &css_checkbox,
- properties[CSS_EDIT_BOX_PROP].id, &css_edit_box,
- properties[CSS_EDIT_BUTTON_PROP].id, &css_edit_button,
- properties[CSS_CONTAINER_PROP].id, &css_container,
- properties[CLEAR_CACHE_BUTTON_PROP].id, &clear_cache_button,
- NULL);
+ ephy_dialog_get_controls (dialog,
+ "prefs_dialog", &window,
+ "homepage_current_button", &curr_button,
+ "homepage_blank_button", &blank_button,
+ "css_checkbox", &css_checkbox,
+ "css_edit_button", &css_edit_button,
+ "clear_cache_button", &clear_cache_button,
+ NULL);
ephy_gui_ensure_window_group (GTK_WINDOW (window));
@@ -1068,31 +1128,31 @@ prefs_dialog_init (PrefsDialog *pd)
G_CALLBACK (prefs_dialog_response_cb), dialog);
g_signal_connect (curr_button, "clicked",
- G_CALLBACK (prefs_homepage_current_button_clicked_cb), dialog);
+ G_CALLBACK (homepage_current_button_clicked_cb),
+ dialog);
g_signal_connect (blank_button, "clicked",
- G_CALLBACK (prefs_homepage_blank_button_clicked_cb), dialog);
+ G_CALLBACK (homepage_blank_button_clicked_cb),
+ dialog);
/* set homepage button sensitivity */
- sensitive = eel_gconf_key_is_writable (CONF_GENERAL_HOMEPAGE);
- gtk_widget_set_sensitive (curr_button, sensitive);
- gtk_widget_set_sensitive (blank_button, sensitive);
-
- css_checkbox_toggled (GTK_TOGGLE_BUTTON (css_checkbox), css_edit_box);
- g_signal_connect (css_checkbox, "toggled",
- G_CALLBACK (css_checkbox_toggled), css_edit_box);
+ g_settings_bind_writable (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_HOMEPAGE_URL,
+ curr_button, "sensitive", FALSE);
+ g_settings_bind_writable (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_HOMEPAGE_URL,
+ blank_button, "sensitive", FALSE);
g_signal_connect (css_edit_button, "clicked",
G_CALLBACK (css_edit_button_clicked_cb), dialog);
g_signal_connect (clear_cache_button, "clicked",
- G_CALLBACK (prefs_clear_cache_button_clicked_cb), dialog);
+ G_CALLBACK (clear_cache_button_clicked_cb), dialog);
encodings = EPHY_ENCODINGS (ephy_embed_shell_get_encodings
(EPHY_EMBED_SHELL (ephy_shell)));
- create_node_combo (dialog, DEFAULT_ENCODING_PROP, encodings,
- ephy_encodings_get_all (encodings),
- CONF_LANGUAGE_DEFAULT_ENCODING, "ISO-8859-1");
+ create_node_combo (dialog, encodings,
+ ephy_encodings_get_all (encodings), "ISO-8859-1");
create_language_section (dialog);
diff --git a/src/window-commands.c b/src/window-commands.c
index 785990787..163f35a17 100644
--- a/src/window-commands.c
+++ b/src/window-commands.c
@@ -30,8 +30,8 @@
#include "ephy-embed-persist.h"
#include "ephy-debug.h"
#include "window-commands.h"
-#include "eel-gconf-extensions.h"
#include "ephy-prefs.h"
+#include "ephy-settings.h"
#include "ephy-embed-prefs.h"
#include "ephy-dialog.h"
#include "ephy-bookmarks-editor.h"
@@ -313,7 +313,7 @@ window_cmd_file_open (GtkAction *action,
dialog = ephy_file_chooser_new (_("Open"),
GTK_WIDGET (window),
GTK_FILE_CHOOSER_ACTION_OPEN,
- CONF_STATE_OPEN_DIR,
+ EPHY_PREFS_STATE_OPEN_DIR,
EPHY_FILE_FILTER_ALL_SUPPORTED);
g_signal_connect (dialog, "response",
@@ -343,7 +343,7 @@ window_cmd_file_save_as (GtkAction *action,
dialog = ephy_file_chooser_new (_("Save"),
GTK_WIDGET (window),
GTK_FILE_CHOOSER_ACTION_SAVE,
- CONF_STATE_SAVE_DIR,
+ EPHY_PREFS_STATE_SAVE_DIR,
EPHY_FILE_FILTER_ALL);
gtk_file_chooser_set_do_overwrite_confirmation (GTK_FILE_CHOOSER (dialog), TRUE);
@@ -396,7 +396,8 @@ window_cmd_file_close_window (GtkAction *action,
notebook = ephy_window_get_notebook (window);
- if (eel_gconf_get_boolean (CONF_LOCKDOWN_DISABLE_QUIT) &&
+ if (g_settings_get_boolean (EPHY_SETTINGS_LOCKDOWN,
+ EPHY_PREFS_LOCKDOWN_QUIT) &&
gtk_notebook_get_n_pages (GTK_NOTEBOOK (notebook)) == 1)
{
return;
@@ -1232,5 +1233,6 @@ window_cmd_browse_with_caret (GtkAction *action,
}
}
- eel_gconf_set_boolean (CONF_CARET_BROWSING_ENABLED, active);
+ g_settings_set_boolean (EPHY_SETTINGS_MAIN,
+ EPHY_PREFS_ENABLE_CARET_BROWSING, active);
}