aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libempathy-gtk/Makefile.am2
-rw-r--r--libempathy-gtk/empathy-avatar-chooser.c21
-rw-r--r--libempathy-gtk/empathy-chat-text-view.c53
-rw-r--r--libempathy-gtk/empathy-chat.c72
-rw-r--r--libempathy-gtk/empathy-conf.c371
-rw-r--r--libempathy-gtk/empathy-conf.h135
-rw-r--r--libempathy-gtk/empathy-location-manager.c84
-rw-r--r--libempathy-gtk/empathy-notify-manager.c34
-rw-r--r--libempathy-gtk/empathy-sound.c36
-rw-r--r--libempathy-gtk/empathy-spell.c24
-rw-r--r--libempathy-gtk/empathy-theme-adium.c38
-rw-r--r--libempathy-gtk/empathy-theme-boxes.c1
-rw-r--r--libempathy-gtk/empathy-theme-manager.c49
-rw-r--r--libempathy-gtk/empathy-ui-utils.c1
-rw-r--r--libempathy/Makefile.am1
-rw-r--r--libempathy/empathy-gsettings.h92
-rw-r--r--src/empathy-account-assistant.c1
-rw-r--r--src/empathy-accounts-dialog.c16
-rw-r--r--src/empathy-auto-salut-account-helper.c1
-rw-r--r--src/empathy-chat-window.c37
-rw-r--r--src/empathy-event-manager.c21
-rw-r--r--src/empathy-ft-manager.c1
-rw-r--r--src/empathy-main-window.c160
-rw-r--r--src/empathy-migrate-butterfly-logs.c22
-rw-r--r--src/empathy-preferences.c676
-rw-r--r--src/empathy-status-icon.c34
-rw-r--r--src/empathy.c46
27 files changed, 672 insertions, 1357 deletions
diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am
index 377929adc..c8a4cbb6a 100644
--- a/libempathy-gtk/Makefile.am
+++ b/libempathy-gtk/Makefile.am
@@ -42,7 +42,6 @@ libempathy_gtk_handwritten_source = \
empathy-chat-text-view.c \
empathy-chat-view.c \
empathy-chat.c \
- empathy-conf.c \
empathy-contact-dialogs.c \
empathy-contact-list-store.c \
empathy-contact-list-view.c \
@@ -89,7 +88,6 @@ libempathy_gtk_headers = \
empathy-chat-text-view.h \
empathy-chat-view.h \
empathy-chat.h \
- empathy-conf.h \
empathy-contact-dialogs.h \
empathy-contact-list-store.h \
empathy-contact-list-view.h \
diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c
index 7a39f65f1..552e45dfe 100644
--- a/libempathy-gtk/empathy-avatar-chooser.c
+++ b/libempathy-gtk/empathy-avatar-chooser.c
@@ -29,10 +29,10 @@
#include <gtk/gtk.h>
#include <gio/gio.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-utils.h>
#include "empathy-avatar-chooser.h"
-#include "empathy-conf.h"
#include "empathy-images.h"
#include "empathy-ui-utils.h"
@@ -895,10 +895,14 @@ avatar_chooser_response_cb (GtkWidget *widget,
path = gtk_file_chooser_get_current_folder (GTK_FILE_CHOOSER (widget));
if (path) {
- empathy_conf_set_string (empathy_conf_get (),
- EMPATHY_PREFS_UI_AVATAR_DIRECTORY,
- path);
+ GSettings *gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
+
+ g_settings_set_string (gsettings_ui,
+ EMPATHY_PREFS_UI_AVATAR_DIRECTORY,
+ path);
+
g_free (path);
+ g_object_unref (gsettings_ui);
}
}
else if (response == GTK_RESPONSE_NO) {
@@ -919,6 +923,7 @@ avatar_chooser_clicked_cb (GtkWidget *button,
const gchar *default_dir = DEFAULT_DIR;
const gchar *pics_dir;
GtkFileFilter *filter;
+ GSettings *gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
EmpathyAvatarChooserPriv *priv = GET_PRIV (chooser);
if (priv->chooser_dialog) {
@@ -941,9 +946,9 @@ avatar_chooser_clicked_cb (GtkWidget *button,
gtk_window_set_destroy_with_parent (GTK_WINDOW (chooser_dialog), TRUE);
/* Get special dirs */
- empathy_conf_get_string (empathy_conf_get (),
- EMPATHY_PREFS_UI_AVATAR_DIRECTORY,
- &saved_dir);
+ saved_dir = g_settings_get_string (gsettings_ui,
+ EMPATHY_PREFS_UI_AVATAR_DIRECTORY);
+
if (saved_dir && !g_file_test (saved_dir, G_FILE_TEST_IS_DIR)) {
g_free (saved_dir);
saved_dir = NULL;
@@ -1007,7 +1012,9 @@ avatar_chooser_clicked_cb (GtkWidget *button,
chooser);
gtk_widget_show (GTK_WIDGET (chooser_dialog));
+
g_free (saved_dir);
+ g_object_unref (gsettings_ui);
}
/**
diff --git a/libempathy-gtk/empathy-chat-text-view.c b/libempathy-gtk/empathy-chat-text-view.c
index 0f7400f1d..c05b92fb9 100644
--- a/libempathy-gtk/empathy-chat-text-view.c
+++ b/libempathy-gtk/empathy-chat-text-view.c
@@ -32,14 +32,15 @@
#include <glib/gi18n-lib.h>
#include <gtk/gtk.h>
+#include <gconf/gconf-client.h>
#include <telepathy-glib/util.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-utils.h>
#include "empathy-chat-text-view.h"
#include "empathy-chat.h"
-#include "empathy-conf.h"
#include "empathy-ui-utils.h"
#include "empathy-smiley-manager.h"
#include "empathy-string-parser.h"
@@ -68,6 +69,7 @@ typedef struct {
time_t last_timestamp;
gboolean allow_scrolling;
guint notify_system_fonts_id;
+ GConfClient *gconf_client;
EmpathySmileyManager *smiley_manager;
gboolean only_if_date;
} EmpathyChatTextViewPriv;
@@ -203,17 +205,20 @@ chat_text_view_create_tags (EmpathyChatTextView *view)
static void
chat_text_view_system_font_update (EmpathyChatTextView *view)
{
+ EmpathyChatTextViewPriv *priv = GET_PRIV (view);
PangoFontDescription *font_description = NULL;
gchar *font_name;
- if (empathy_conf_get_string (empathy_conf_get (),
- "/desktop/gnome/interface/document_font_name",
- &font_name) && font_name) {
- font_description = pango_font_description_from_string (font_name);
- g_free (font_name);
- } else {
- font_description = NULL;
- }
+ font_name = gconf_client_get_string (priv->gconf_client,
+ "/desktop/gnome/interface/document_font_name",
+ NULL);
+
+ if (font_name != NULL) {
+ font_description = pango_font_description_from_string (font_name);
+ g_free (font_name);
+ } else {
+ font_description = NULL;
+ }
gtk_widget_modify_font (GTK_WIDGET (view), font_description);
@@ -223,9 +228,10 @@ chat_text_view_system_font_update (EmpathyChatTextView *view)
}
static void
-chat_text_view_notify_system_font_cb (EmpathyConf *conf,
- const gchar *key,
- gpointer user_data)
+chat_text_view_notify_system_font_cb (GConfClient *conf,
+ guint id,
+ GConfEntry *entry,
+ gpointer user_data)
{
EmpathyChatTextView *view = user_data;
@@ -559,7 +565,9 @@ chat_text_view_finalize (GObject *object)
DEBUG ("%p", object);
- empathy_conf_notify_remove (empathy_conf_get (), priv->notify_system_fonts_id);
+ gconf_client_notify_remove (priv->gconf_client,
+ priv->notify_system_fonts_id);
+ g_object_unref (priv->gconf_client);
if (priv->last_contact) {
g_object_unref (priv->last_contact);
@@ -634,11 +642,16 @@ empathy_chat_text_view_init (EmpathyChatTextView *view)
"cursor-visible", FALSE,
NULL);
+ priv->gconf_client = gconf_client_get_default ();
+ gconf_client_add_dir (priv->gconf_client,
+ "/desktop/gnome/interface",
+ GCONF_CLIENT_PRELOAD_ONELEVEL,
+ NULL);
priv->notify_system_fonts_id =
- empathy_conf_notify_add (empathy_conf_get (),
+ gconf_client_notify_add (priv->gconf_client,
"/desktop/gnome/interface/document_font_name",
chat_text_view_notify_system_font_cb,
- view);
+ view, NULL, NULL);
chat_text_view_system_font_update (view);
chat_text_view_create_tags (view);
@@ -1405,11 +1418,13 @@ empathy_chat_text_view_append_body (EmpathyChatTextView *view,
GtkTextIter start_iter;
GtkTextIter iter;
GtkTextMark *mark;
+ GSettings *gsettings_chat;
/* Check if we have to parse smileys */
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_SHOW_SMILEYS,
- &use_smileys);
+ gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
+ use_smileys = g_settings_get_boolean (gsettings_chat,
+ EMPATHY_PREFS_CHAT_SHOW_SMILEYS);
+
if (use_smileys)
parsers = string_parsers_with_smiley;
else
@@ -1434,6 +1449,8 @@ empathy_chat_text_view_append_body (EmpathyChatTextView *view,
&iter);
gtk_text_buffer_delete_mark (priv->buffer, mark);
+
+ g_object_unref (gsettings_chat);
}
void
diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c
index ae78b52cb..e68b91dbe 100644
--- a/libempathy-gtk/empathy-chat.c
+++ b/libempathy-gtk/empathy-chat.c
@@ -43,11 +43,11 @@
#include <libempathy/empathy-log-manager.h>
#endif /* ENABLE_TPL */
#include <libempathy/empathy-contact-list.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-dispatcher.h>
#include "empathy-chat.h"
-#include "empathy-conf.h"
#include "empathy-spell.h"
#include "empathy-contact-list-store.h"
#include "empathy-contact-list-view.h"
@@ -77,6 +77,9 @@ typedef struct {
EmpathyContact *remote_contact;
gboolean show_contacts;
+ GSettings *gsettings_chat;
+ GSettings *gsettings_ui;
+
#ifdef ENABLE_TPL
TplLogManager *log_manager;
#else
@@ -104,10 +107,6 @@ typedef struct {
gulong delete_range_id;
gulong notify_cursor_position_id;
- /* This stores the id for the spell checking configuration setting
- * notification signal handler. */
- guint conf_notify_id;
-
GtkWidget *widget;
GtkWidget *hpaned;
GtkWidget *vbox_left;
@@ -1623,7 +1622,6 @@ chat_input_key_press_event_cb (GtkWidget *widget,
if (completed) {
guint len;
const gchar *text;
- gchar *complete_char = NULL;
GString *message = NULL;
GList *l;
@@ -1657,16 +1655,20 @@ chat_input_key_press_event_cb (GtkWidget *widget,
gtk_text_buffer_insert_at_cursor (buffer, text, strlen (text));
- if (len == 1 && is_start_of_buffer &&
- empathy_conf_get_string (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_NICK_COMPLETION_CHAR,
- &complete_char) &&
- complete_char != NULL) {
+ if (len == 1 && is_start_of_buffer) {
+ gchar *complete_char;
+
+ complete_char = g_settings_get_string (
+ priv->gsettings_chat,
+ EMPATHY_PREFS_CHAT_NICK_COMPLETION_CHAR);
+
+ if (complete_char != NULL) {
gtk_text_buffer_insert_at_cursor (buffer,
complete_char,
strlen (complete_char));
gtk_text_buffer_insert_at_cursor (buffer, " ", 1);
g_free (complete_char);
+ }
}
g_free (completed);
@@ -2386,7 +2388,7 @@ update_misspelled_words (gpointer data)
}
static void
-conf_spell_checking_cb (EmpathyConf *conf,
+conf_spell_checking_cb (GSettings *gsettings_chat,
const gchar *key,
gpointer user_data)
{
@@ -2398,8 +2400,8 @@ conf_spell_checking_cb (EmpathyConf *conf,
if (strcmp (key, EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED) != 0)
return;
- empathy_conf_get_bool (conf, EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
- &spell_checker);
+ spell_checker = g_settings_get_boolean (gsettings_chat,
+ EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED);
if (!empathy_spell_supported ()) {
spell_checker = FALSE;
@@ -2471,11 +2473,16 @@ conf_spell_checking_cb (EmpathyConf *conf,
static gboolean
chat_hpaned_pos_changed_cb (GtkWidget* hpaned, gpointer user_data)
{
+ GSettings *gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
gint hpaned_pos;
+
hpaned_pos = gtk_paned_get_position (GTK_PANED(hpaned));
- empathy_conf_set_int (empathy_conf_get (),
- EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS,
- hpaned_pos);
+ g_settings_set_int (gsettings_chat,
+ EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS,
+ hpaned_pos);
+
+ g_object_unref (gsettings_chat);
+
return TRUE;
}
@@ -2552,11 +2559,10 @@ chat_create_ui (EmpathyChat *chat)
tp_g_signal_connect_object (buffer, "changed",
G_CALLBACK (chat_input_text_buffer_changed_cb),
chat, 0);
- priv->conf_notify_id =
- empathy_conf_notify_add (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
- conf_spell_checking_cb, chat);
- conf_spell_checking_cb (empathy_conf_get (),
+ tp_g_signal_connect_object (priv->gsettings_chat,
+ "changed::" EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
+ G_CALLBACK (conf_spell_checking_cb), chat, 0);
+ conf_spell_checking_cb (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED, chat);
gtk_container_add (GTK_CONTAINER (priv->scrolled_window_input),
chat->input_text_view);
@@ -2577,10 +2583,9 @@ chat_create_ui (EmpathyChat *chat)
NULL);
/* Load the paned position */
- if (empathy_conf_get_int (empathy_conf_get (),
- EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS,
- &paned_pos)
- && paned_pos)
+ paned_pos = g_settings_get_int (priv->gsettings_ui,
+ EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS);
+ if (paned_pos != 0)
gtk_paned_set_position (GTK_PANED(priv->hpaned), paned_pos);
/* Set widget focus order */
@@ -2661,11 +2666,8 @@ chat_finalize (GObject *object)
DEBUG ("Finalized: %p", object);
- if (priv->conf_notify_id != 0) {
- empathy_conf_notify_remove (empathy_conf_get (),
- priv->conf_notify_id);
- priv->conf_notify_id = 0;
- }
+ g_object_unref (priv->gsettings_chat);
+ g_object_unref (priv->gsettings_ui);
g_list_foreach (priv->input_history, (GFunc) chat_input_history_entry_free, NULL);
g_list_free (priv->input_history);
@@ -2876,6 +2878,9 @@ empathy_chat_init (EmpathyChat *chat)
#else
priv->log_manager = tpl_log_manager_dup_singleton ();
#endif /* ENABLE_TPL */
+ priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
+ priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
+
priv->contacts_width = -1;
priv->input_history = NULL;
priv->input_history_current = NULL;
@@ -2884,9 +2889,8 @@ empathy_chat_init (EmpathyChat *chat)
tp_account_manager_prepare_async (priv->account_manager, NULL,
account_manager_prepared_cb, chat);
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS,
- &priv->show_contacts);
+ priv->show_contacts = g_settings_get_boolean (priv->gsettings_chat,
+ EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS);
/* Block events for some time to avoid having "has come online" or
* "joined" messages. */
diff --git a/libempathy-gtk/empathy-conf.c b/libempathy-gtk/empathy-conf.c
deleted file mode 100644
index 62efa60c6..000000000
--- a/libempathy-gtk/empathy-conf.c
+++ /dev/null
@@ -1,371 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2006 Imendio AB
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301 USA
- *
- * Authors: Richard Hult <richard@imendio.com>
- */
-
-#include "config.h"
-
-#include <string.h>
-
-#include <gconf/gconf-client.h>
-
-#include <libempathy/empathy-utils.h>
-#include "empathy-conf.h"
-
-#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
-#include <libempathy/empathy-debug.h>
-
-#define EMPATHY_CONF_ROOT "/apps/empathy"
-#define DESKTOP_INTERFACE_ROOT "/desktop/gnome/interface"
-
-#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyConf)
-typedef struct {
- GConfClient *gconf_client;
-} EmpathyConfPriv;
-
-typedef struct {
- EmpathyConf *conf;
- EmpathyConfNotifyFunc func;
- gpointer user_data;
-} EmpathyConfNotifyData;
-
-static void conf_finalize (GObject *object);
-
-G_DEFINE_TYPE (EmpathyConf, empathy_conf, G_TYPE_OBJECT);
-
-static EmpathyConf *global_conf = NULL;
-
-static void
-empathy_conf_class_init (EmpathyConfClass *class)
-{
- GObjectClass *object_class;
-
- object_class = G_OBJECT_CLASS (class);
-
- object_class->finalize = conf_finalize;
-
- g_type_class_add_private (object_class, sizeof (EmpathyConfPriv));
-}
-
-static void
-empathy_conf_init (EmpathyConf *conf)
-{
- EmpathyConfPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (conf,
- EMPATHY_TYPE_CONF, EmpathyConfPriv);
-
- conf->priv = priv;
- priv->gconf_client = gconf_client_get_default ();
-
- gconf_client_add_dir (priv->gconf_client,
- EMPATHY_CONF_ROOT,
- GCONF_CLIENT_PRELOAD_ONELEVEL,
- NULL);
- gconf_client_add_dir (priv->gconf_client,
- DESKTOP_INTERFACE_ROOT,
- GCONF_CLIENT_PRELOAD_NONE,
- NULL);
-}
-
-static void
-conf_finalize (GObject *object)
-{
- EmpathyConfPriv *priv;
-
- priv = GET_PRIV (object);
-
- gconf_client_remove_dir (priv->gconf_client,
- EMPATHY_CONF_ROOT,
- NULL);
- gconf_client_remove_dir (priv->gconf_client,
- DESKTOP_INTERFACE_ROOT,
- NULL);
-
- g_object_unref (priv->gconf_client);
-
- G_OBJECT_CLASS (empathy_conf_parent_class)->finalize (object);
-}
-
-EmpathyConf *
-empathy_conf_get (void)
-{
- if (!global_conf) {
- global_conf = g_object_new (EMPATHY_TYPE_CONF, NULL);
- }
-
- return global_conf;
-}
-
-void
-empathy_conf_shutdown (void)
-{
- if (global_conf) {
- g_object_unref (global_conf);
- global_conf = NULL;
- }
-}
-
-gboolean
-empathy_conf_set_int (EmpathyConf *conf,
- const gchar *key,
- gint value)
-{
- EmpathyConfPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
-
- DEBUG ("Setting int:'%s' to %d", key, value);
-
- priv = GET_PRIV (conf);
-
- return gconf_client_set_int (priv->gconf_client,
- key,
- value,
- NULL);
-}
-
-gboolean
-empathy_conf_get_int (EmpathyConf *conf,
- const gchar *key,
- gint *value)
-{
- EmpathyConfPriv *priv;
- GError *error = NULL;
-
- *value = 0;
-
- g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
- g_return_val_if_fail (value != NULL, FALSE);
-
- priv = GET_PRIV (conf);
-
- *value = gconf_client_get_int (priv->gconf_client,
- key,
- &error);
-
- if (error) {
- g_error_free (error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-empathy_conf_set_bool (EmpathyConf *conf,
- const gchar *key,
- gboolean value)
-{
- EmpathyConfPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
-
- DEBUG ("Setting bool:'%s' to %d ---> %s", key, value,
- value ? "true" : "false");
-
- priv = GET_PRIV (conf);
-
- return gconf_client_set_bool (priv->gconf_client,
- key,
- value,
- NULL);
-}
-
-gboolean
-empathy_conf_get_bool (EmpathyConf *conf,
- const gchar *key,
- gboolean *value)
-{
- EmpathyConfPriv *priv;
- GError *error = NULL;
-
- *value = FALSE;
-
- g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
- g_return_val_if_fail (value != NULL, FALSE);
-
- priv = GET_PRIV (conf);
-
- *value = gconf_client_get_bool (priv->gconf_client,
- key,
- &error);
-
- if (error) {
- g_error_free (error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-empathy_conf_set_string (EmpathyConf *conf,
- const gchar *key,
- const gchar *value)
-{
- EmpathyConfPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
-
- DEBUG ("Setting string:'%s' to '%s'", key, value);
-
- priv = GET_PRIV (conf);
-
- return gconf_client_set_string (priv->gconf_client,
- key,
- value,
- NULL);
-}
-
-gboolean
-empathy_conf_get_string (EmpathyConf *conf,
- const gchar *key,
- gchar **value)
-{
- EmpathyConfPriv *priv;
- GError *error = NULL;
-
- *value = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
-
- priv = GET_PRIV (conf);
-
- *value = gconf_client_get_string (priv->gconf_client,
- key,
- &error);
-
- if (error) {
- g_error_free (error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-gboolean
-empathy_conf_set_string_list (EmpathyConf *conf,
- const gchar *key,
- GSList *value)
-{
- EmpathyConfPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
-
- priv = GET_PRIV (conf);
-
- return gconf_client_set_list (priv->gconf_client,
- key,
- GCONF_VALUE_STRING,
- value,
- NULL);
-}
-
-gboolean
-empathy_conf_get_string_list (EmpathyConf *conf,
- const gchar *key,
- GSList **value)
-{
- EmpathyConfPriv *priv;
- GError *error = NULL;
-
- *value = NULL;
-
- g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
-
- priv = GET_PRIV (conf);
-
- *value = gconf_client_get_list (priv->gconf_client,
- key,
- GCONF_VALUE_STRING,
- &error);
- if (error) {
- g_error_free (error);
- return FALSE;
- }
-
- return TRUE;
-}
-
-static void
-conf_notify_data_free (EmpathyConfNotifyData *data)
-{
- g_object_unref (data->conf);
- g_slice_free (EmpathyConfNotifyData, data);
-}
-
-static void
-conf_notify_func (GConfClient *client,
- guint id,
- GConfEntry *entry,
- gpointer user_data)
-{
- EmpathyConfNotifyData *data;
-
- data = user_data;
-
- data->func (data->conf,
- gconf_entry_get_key (entry),
- data->user_data);
-}
-
-guint
-empathy_conf_notify_add (EmpathyConf *conf,
- const gchar *key,
- EmpathyConfNotifyFunc func,
- gpointer user_data)
-{
- EmpathyConfPriv *priv;
- guint id;
- EmpathyConfNotifyData *data;
-
- g_return_val_if_fail (EMPATHY_IS_CONF (conf), 0);
-
- priv = GET_PRIV (conf);
-
- data = g_slice_new (EmpathyConfNotifyData);
- data->func = func;
- data->user_data = user_data;
- data->conf = g_object_ref (conf);
-
- id = gconf_client_notify_add (priv->gconf_client,
- key,
- conf_notify_func,
- data,
- (GFreeFunc) conf_notify_data_free,
- NULL);
-
- return id;
-}
-
-gboolean
-empathy_conf_notify_remove (EmpathyConf *conf,
- guint id)
-{
- EmpathyConfPriv *priv;
-
- g_return_val_if_fail (EMPATHY_IS_CONF (conf), FALSE);
-
- priv = GET_PRIV (conf);
-
- gconf_client_notify_remove (priv->gconf_client, id);
-
- return TRUE;
-}
-
diff --git a/libempathy-gtk/empathy-conf.h b/libempathy-gtk/empathy-conf.h
deleted file mode 100644
index c418bb116..000000000
--- a/libempathy-gtk/empathy-conf.h
+++ /dev/null
@@ -1,135 +0,0 @@
-/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */
-/*
- * Copyright (C) 2006 Imendio AB
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of the
- * License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public
- * License along with this program; if not, write to the
- * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
- * Boston, MA 02110-1301 USA
- */
-
-#ifndef __EMPATHY_CONF_H__
-#define __EMPATHY_CONF_H__
-
-#include <glib-object.h>
-
-G_BEGIN_DECLS
-
-#define EMPATHY_TYPE_CONF (empathy_conf_get_type ())
-#define EMPATHY_CONF(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), EMPATHY_TYPE_CONF, EmpathyConf))
-#define EMPATHY_CONF_CLASS(k) (G_TYPE_CHECK_CLASS_CAST ((k), EMPATHY_TYPE_CONF, EmpathyConfClass))
-#define EMPATHY_IS_CONF(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), EMPATHY_TYPE_CONF))
-#define EMPATHY_IS_CONF_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), EMPATHY_TYPE_CONF))
-#define EMPATHY_CONF_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), EMPATHY_TYPE_CONF, EmpathyConfClass))
-
-typedef struct _EmpathyConf EmpathyConf;
-typedef struct _EmpathyConfClass EmpathyConfClass;
-
-struct _EmpathyConf {
- GObject parent;
- gpointer priv;
-};
-
-struct _EmpathyConfClass {
- GObjectClass parent_class;
-};
-
-#define EMPATHY_PREFS_PATH "/apps/empathy"
-#define EMPATHY_PREFS_NOTIFICATIONS_ENABLED EMPATHY_PREFS_PATH "/notifications/notifications_enabled"
-#define EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY EMPATHY_PREFS_PATH "/notifications/notifications_disabled_away"
-#define EMPATHY_PREFS_NOTIFICATIONS_FOCUS EMPATHY_PREFS_PATH "/notifications/notifications_focus"
-#define EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN EMPATHY_PREFS_PATH "/notifications/notifications_contact_signin"
-#define EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT EMPATHY_PREFS_PATH "/notifications/notifications_contact_signout"
-#define EMPATHY_PREFS_SOUNDS_ENABLED EMPATHY_PREFS_PATH "/sounds/sounds_enabled"
-#define EMPATHY_PREFS_SOUNDS_DISABLED_AWAY EMPATHY_PREFS_PATH "/sounds/sounds_disabled_away"
-#define EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE EMPATHY_PREFS_PATH "/sounds/sounds_incoming_message"
-#define EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE EMPATHY_PREFS_PATH "/sounds/sounds_outgoing_message"
-#define EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION EMPATHY_PREFS_PATH "/sounds/sounds_new_conversation"
-#define EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN EMPATHY_PREFS_PATH "/sounds/sounds_service_login"
-#define EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT EMPATHY_PREFS_PATH "/sounds/sounds_service_logout"
-#define EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN EMPATHY_PREFS_PATH "/sounds/sounds_contact_login"
-#define EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT EMPATHY_PREFS_PATH "/sounds/sounds_contact_logout"
-#define EMPATHY_PREFS_POPUPS_WHEN_AVAILABLE EMPATHY_PREFS_PATH "/notifications/popups_when_available"
-#define EMPATHY_PREFS_CHAT_SHOW_SMILEYS EMPATHY_PREFS_PATH "/conversation/graphical_smileys"
-#define EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS EMPATHY_PREFS_PATH "/conversation/show_contacts_in_rooms"
-#define EMPATHY_PREFS_CHAT_THEME EMPATHY_PREFS_PATH "/conversation/theme"
-#define EMPATHY_PREFS_CHAT_ADIUM_PATH EMPATHY_PREFS_PATH "/conversation/adium_path"
-#define EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES EMPATHY_PREFS_PATH "/conversation/spell_checker_languages"
-#define EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED EMPATHY_PREFS_PATH "/conversation/spell_checker_enabled"
-#define EMPATHY_PREFS_CHAT_NICK_COMPLETION_CHAR EMPATHY_PREFS_PATH "/conversation/nick_completion_char"
-#define EMPATHY_PREFS_CHAT_AVATAR_IN_ICON EMPATHY_PREFS_PATH "/conversation/avatar_in_icon"
-#define EMPATHY_PREFS_CHAT_WEBKIT_DEVELOPER_TOOLS EMPATHY_PREFS_PATH "/conversation/enable_webkit_developer_tools"
-#define EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS EMPATHY_PREFS_PATH "/ui/separate_chat_windows"
-#define EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN EMPATHY_PREFS_PATH "/ui/main_window_hidden"
-#define EMPATHY_PREFS_UI_AVATAR_DIRECTORY EMPATHY_PREFS_PATH "/ui/avatar_directory"
-#define EMPATHY_PREFS_UI_SHOW_AVATARS EMPATHY_PREFS_PATH "/ui/show_avatars"
-#define EMPATHY_PREFS_UI_SHOW_PROTOCOLS EMPATHY_PREFS_PATH "/ui/show_protocols"
-#define EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST EMPATHY_PREFS_PATH "/ui/compact_contact_list"
-#define EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS EMPATHY_PREFS_PATH "/ui/chat_window_paned_pos"
-#define EMPATHY_PREFS_UI_SHOW_OFFLINE EMPATHY_PREFS_PATH "/ui/show_offline"
-#define EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM EMPATHY_PREFS_PATH "/contacts/sort_criterium"
-#define EMPATHY_PREFS_HINTS_CLOSE_MAIN_WINDOW EMPATHY_PREFS_PATH "/hints/close_main_window"
-#define EMPATHY_PREFS_USE_CONN EMPATHY_PREFS_PATH "/use_conn"
-#define EMPATHY_PREFS_AUTOCONNECT EMPATHY_PREFS_PATH "/autoconnect"
-#define EMPATHY_PREFS_AUTOAWAY EMPATHY_PREFS_PATH "/autoaway"
-#define EMPATHY_PREFS_IMPORT_ASKED EMPATHY_PREFS_PATH "/import_asked"
-#define EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED EMPATHY_PREFS_PATH "/butterfly_logs_migrated"
-#define EMPATHY_PREFS_FILE_TRANSFER_DEFAULT_FOLDER EMPATHY_PREFS_PATH "/file_transfer/default_folder"
-#define EMPATHY_PREFS_LOCATION_PUBLISH EMPATHY_PREFS_PATH "/location/publish"
-#define EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK EMPATHY_PREFS_PATH "/location/resource_network"
-#define EMPATHY_PREFS_LOCATION_RESOURCE_CELL EMPATHY_PREFS_PATH "/location/resource_cell"
-#define EMPATHY_PREFS_LOCATION_RESOURCE_GPS EMPATHY_PREFS_PATH "/location/resource_gps"
-#define EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY EMPATHY_PREFS_PATH "/location/reduce_accuracy"
-
-typedef void (*EmpathyConfNotifyFunc) (EmpathyConf *conf,
- const gchar *key,
- gpointer user_data);
-
-GType empathy_conf_get_type (void) G_GNUC_CONST;
-EmpathyConf *empathy_conf_get (void);
-void empathy_conf_shutdown (void);
-guint empathy_conf_notify_add (EmpathyConf *conf,
- const gchar *key,
- EmpathyConfNotifyFunc func,
- gpointer data);
-gboolean empathy_conf_notify_remove (EmpathyConf *conf,
- guint id);
-gboolean empathy_conf_set_int (EmpathyConf *conf,
- const gchar *key,
- gint value);
-gboolean empathy_conf_get_int (EmpathyConf *conf,
- const gchar *key,
- gint *value);
-gboolean empathy_conf_set_bool (EmpathyConf *conf,
- const gchar *key,
- gboolean value);
-gboolean empathy_conf_get_bool (EmpathyConf *conf,
- const gchar *key,
- gboolean *value);
-gboolean empathy_conf_set_string (EmpathyConf *conf,
- const gchar *key,
- const gchar *value);
-gboolean empathy_conf_get_string (EmpathyConf *conf,
- const gchar *key,
- gchar **value);
-gboolean empathy_conf_set_string_list (EmpathyConf *conf,
- const gchar *key,
- GSList *value);
-gboolean empathy_conf_get_string_list (EmpathyConf *conf,
- const gchar *key,
- GSList **value);
-
-G_END_DECLS
-
-#endif /* __EMPATHY_CONF_H__ */
-
diff --git a/libempathy-gtk/empathy-location-manager.c b/libempathy-gtk/empathy-location-manager.c
index 89e0a014b..1c09c358c 100644
--- a/libempathy-gtk/empathy-location-manager.c
+++ b/libempathy-gtk/empathy-location-manager.c
@@ -34,9 +34,9 @@
#include <extensions/extensions.h>
#include "empathy-location-manager.h"
-#include "empathy-conf.h"
#include "libempathy/empathy-enum-types.h"
+#include "libempathy/empathy-gsettings.h"
#include "libempathy/empathy-location.h"
#include "libempathy/empathy-utils.h"
@@ -56,6 +56,8 @@ typedef struct {
*/
GHashTable *location;
+ GSettings *gsettings_loc;
+
GeoclueResourceFlags resources;
GeoclueMasterClient *gc_client;
GeocluePosition *gc_position;
@@ -106,6 +108,12 @@ location_manager_dispose (GObject *object)
priv->account_manager = NULL;
}
+ if (priv->gsettings_loc != NULL)
+ {
+ g_object_unref (priv->gsettings_loc);
+ priv->gsettings_loc = NULL;
+ }
+
if (priv->gc_client != NULL)
{
g_object_unref (priv->gc_client);
@@ -198,19 +206,14 @@ publish_location (EmpathyLocationManager *self,
{
EmpathyLocationManagerPriv *priv = GET_PRIV (self);
guint connection_status = -1;
- gboolean can_publish;
- EmpathyConf *conf = empathy_conf_get ();
if (!conn)
return;
if (!force_publication)
{
- if (!empathy_conf_get_bool (conf, EMPATHY_PREFS_LOCATION_PUBLISH,
- &can_publish))
- return;
-
- if (!can_publish)
+ if (!g_settings_get_boolean (priv->gsettings_loc,
+ EMPATHY_PREFS_LOCATION_PUBLISH))
return;
}
@@ -599,21 +602,16 @@ setup_geoclue (EmpathyLocationManager *self)
}
static void
-publish_cb (EmpathyConf *conf,
+publish_cb (GSettings *gsettings_loc,
const gchar *key,
gpointer user_data)
{
EmpathyLocationManager *manager = EMPATHY_LOCATION_MANAGER (user_data);
EmpathyLocationManagerPriv *priv = GET_PRIV (manager);
- gboolean can_publish;
DEBUG ("Publish Conf changed");
-
- if (!empathy_conf_get_bool (conf, key, &can_publish))
- return;
-
- if (can_publish)
+ if (g_settings_get_boolean (gsettings_loc, key))
{
if (!priv->geoclue_is_setup)
setup_geoclue (manager);
@@ -638,20 +636,16 @@ publish_cb (EmpathyConf *conf,
}
static void
-resource_cb (EmpathyConf *conf,
+resource_cb (GSettings *gsettings_loc,
const gchar *key,
gpointer user_data)
{
EmpathyLocationManager *manager = EMPATHY_LOCATION_MANAGER (user_data);
EmpathyLocationManagerPriv *priv = GET_PRIV (manager);
GeoclueResourceFlags resource = 0;
- gboolean resource_enabled;
DEBUG ("%s changed", key);
- if (!empathy_conf_get_bool (conf, key, &resource_enabled))
- return;
-
if (!tp_strdiff (key, EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK))
resource = GEOCLUE_RESOURCE_NETWORK;
if (!tp_strdiff (key, EMPATHY_PREFS_LOCATION_RESOURCE_CELL))
@@ -659,7 +653,7 @@ resource_cb (EmpathyConf *conf,
if (!tp_strdiff (key, EMPATHY_PREFS_LOCATION_RESOURCE_GPS))
resource = GEOCLUE_RESOURCE_GPS;
- if (resource_enabled)
+ if (g_settings_get_boolean (gsettings_loc, key))
priv->resources |= resource;
else
priv->resources &= ~resource;
@@ -669,20 +663,16 @@ resource_cb (EmpathyConf *conf,
}
static void
-accuracy_cb (EmpathyConf *conf,
+accuracy_cb (GSettings *gsettings_loc,
const gchar *key,
gpointer user_data)
{
EmpathyLocationManager *manager = EMPATHY_LOCATION_MANAGER (user_data);
EmpathyLocationManagerPriv *priv = GET_PRIV (manager);
- gboolean enabled;
-
DEBUG ("%s changed", key);
- if (!empathy_conf_get_bool (conf, key, &enabled))
- return;
- priv->reduce_accuracy = enabled;
+ priv->reduce_accuracy = g_settings_get_boolean (gsettings_loc, key);
if (!priv->geoclue_is_setup)
return;
@@ -724,7 +714,6 @@ account_manager_prepared_cb (GObject *source_object,
static void
empathy_location_manager_init (EmpathyLocationManager *self)
{
- EmpathyConf *conf;
EmpathyLocationManagerPriv *priv = G_TYPE_INSTANCE_GET_PRIVATE (self,
EMPATHY_TYPE_LOCATION_MANAGER, EmpathyLocationManagerPriv);
@@ -732,6 +721,7 @@ empathy_location_manager_init (EmpathyLocationManager *self)
priv->geoclue_is_setup = FALSE;
priv->location = g_hash_table_new_full (g_direct_hash, g_direct_equal,
g_free, (GDestroyNotify) tp_g_value_slice_free);
+ priv->gsettings_loc = g_settings_new (EMPATHY_PREFS_LOCATION_SCHEMA);
/* Setup account status callbacks */
priv->account_manager = tp_account_manager_dup ();
@@ -740,23 +730,29 @@ empathy_location_manager_init (EmpathyLocationManager *self)
account_manager_prepared_cb, self);
/* Setup settings status callbacks */
- conf = empathy_conf_get ();
- empathy_conf_notify_add (conf, EMPATHY_PREFS_LOCATION_PUBLISH, publish_cb,
+ g_signal_connect (priv->gsettings_loc,
+ "changed::" EMPATHY_PREFS_LOCATION_PUBLISH,
+ G_CALLBACK (publish_cb), self);
+ g_signal_connect (priv->gsettings_loc,
+ "changed::" EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK,
+ G_CALLBACK (resource_cb), self);
+ g_signal_connect (priv->gsettings_loc,
+ "changed::" EMPATHY_PREFS_LOCATION_RESOURCE_CELL,
+ G_CALLBACK (resource_cb), self);
+ g_signal_connect (priv->gsettings_loc,
+ "changed::" EMPATHY_PREFS_LOCATION_RESOURCE_GPS,
+ G_CALLBACK (resource_cb), self);
+ g_signal_connect (priv->gsettings_loc,
+ "changed::" EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY,
+ G_CALLBACK (accuracy_cb), self);
+
+ resource_cb (priv->gsettings_loc, EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK,
+ self);
+ resource_cb (priv->gsettings_loc, EMPATHY_PREFS_LOCATION_RESOURCE_CELL, self);
+ resource_cb (priv->gsettings_loc, EMPATHY_PREFS_LOCATION_RESOURCE_GPS, self);
+ accuracy_cb (priv->gsettings_loc, EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY,
self);
- empathy_conf_notify_add (conf, EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK,
- resource_cb, self);
- empathy_conf_notify_add (conf, EMPATHY_PREFS_LOCATION_RESOURCE_CELL,
- resource_cb, self);
- empathy_conf_notify_add (conf, EMPATHY_PREFS_LOCATION_RESOURCE_GPS,
- resource_cb, self);
- empathy_conf_notify_add (conf, EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY,
- accuracy_cb, self);
-
- resource_cb (conf, EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK, self);
- resource_cb (conf, EMPATHY_PREFS_LOCATION_RESOURCE_CELL, self);
- resource_cb (conf, EMPATHY_PREFS_LOCATION_RESOURCE_GPS, self);
- accuracy_cb (conf, EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY, self);
- publish_cb (conf, EMPATHY_PREFS_LOCATION_PUBLISH, self);
+ publish_cb (priv->gsettings_loc, EMPATHY_PREFS_LOCATION_PUBLISH, self);
}
EmpathyLocationManager *
diff --git a/libempathy-gtk/empathy-notify-manager.c b/libempathy-gtk/empathy-notify-manager.c
index 8f7991166..d0e0aadec 100644
--- a/libempathy-gtk/empathy-notify-manager.c
+++ b/libempathy-gtk/empathy-notify-manager.c
@@ -25,10 +25,10 @@
#include <telepathy-glib/account-manager.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-utils.h>
#include <libempathy-gtk/empathy-ui-utils.h>
-#include <libempathy-gtk/empathy-conf.h>
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
@@ -184,23 +184,20 @@ gboolean
empathy_notify_manager_notification_is_enabled (EmpathyNotifyManager *self)
{
EmpathyNotifyManagerPriv *priv = GET_PRIV (self);
- EmpathyConf *conf;
- gboolean res;
+ GSettings *gsettings = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA);
TpConnectionPresenceType presence;
+ gboolean ret = FALSE;
- conf = empathy_conf_get ();
- res = FALSE;
-
- empathy_conf_get_bool (conf, EMPATHY_PREFS_NOTIFICATIONS_ENABLED, &res);
-
- if (!res)
- return FALSE;
+ if (!g_settings_get_boolean (gsettings, EMPATHY_PREFS_NOTIFICATIONS_ENABLED))
+ goto finally;
if (!tp_account_manager_is_prepared (priv->account_manager,
TP_ACCOUNT_MANAGER_FEATURE_CORE))
{
DEBUG ("account manager is not ready yet; display the notification");
- return TRUE;
+ ret = TRUE;
+
+ goto finally;
}
presence = tp_account_manager_get_most_available_presence (
@@ -210,12 +207,15 @@ empathy_notify_manager_notification_is_enabled (EmpathyNotifyManager *self)
if (presence != TP_CONNECTION_PRESENCE_TYPE_AVAILABLE &&
presence != TP_CONNECTION_PRESENCE_TYPE_UNSET)
{
- empathy_conf_get_bool (conf, EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY,
- &res);
-
- if (res)
- return FALSE;
+ if (!g_settings_get_boolean (gsettings,
+ EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY))
+ goto finally;
}
- return TRUE;
+ ret = TRUE;
+
+finally:
+ g_object_unref (gsettings);
+
+ return ret;
}
diff --git a/libempathy-gtk/empathy-sound.c b/libempathy-gtk/empathy-sound.c
index 74dcf6a2e..03f041916 100644
--- a/libempathy-gtk/empathy-sound.c
+++ b/libempathy-gtk/empathy-sound.c
@@ -27,15 +27,14 @@
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-utils.h>
-#include "empathy-conf.h"
-
typedef struct {
EmpathySound sound_id;
const char * event_ca_id;
const char * event_ca_description;
- const char * gconf_key;
+ const char * key;
} EmpathySoundEntry;
typedef struct {
@@ -79,32 +78,37 @@ static gboolean
empathy_sound_pref_is_enabled (EmpathySound sound_id)
{
EmpathySoundEntry *entry;
- EmpathyConf *conf;
+ GSettings *gsettings = g_settings_new (EMPATHY_PREFS_SOUNDS_SCHEMA);
gboolean res;
entry = &(sound_entries[sound_id]);
g_return_val_if_fail (entry->sound_id == sound_id, FALSE);
- if (entry->gconf_key == NULL)
- return TRUE;
-
- conf = empathy_conf_get ();
- res = FALSE;
+ if (entry->key == NULL)
+ {
+ res = TRUE;
+ goto finally;
+ }
- empathy_conf_get_bool (conf, EMPATHY_PREFS_SOUNDS_ENABLED, &res);
+ res = g_settings_get_boolean (gsettings, EMPATHY_PREFS_SOUNDS_ENABLED);
if (!res)
- return FALSE;
+ goto finally;
if (!empathy_check_available_state ())
{
- empathy_conf_get_bool (conf, EMPATHY_PREFS_SOUNDS_DISABLED_AWAY, &res);
-
- if (res)
- return FALSE;
+ if (g_settings_get_boolean (gsettings,
+ EMPATHY_PREFS_SOUNDS_DISABLED_AWAY))
+ {
+ res = FALSE;
+ goto finally;
+ }
}
- empathy_conf_get_bool (conf, entry->gconf_key, &res);
+ res = g_settings_get_boolean (gsettings, entry->key);
+
+finally:
+ g_object_unref (gsettings);
return res;
}
diff --git a/libempathy-gtk/empathy-spell.c b/libempathy-gtk/empathy-spell.c
index 17c7f100e..ff94bb053 100644
--- a/libempathy-gtk/empathy-spell.c
+++ b/libempathy-gtk/empathy-spell.c
@@ -33,10 +33,10 @@
#endif
#include "empathy-spell.h"
-#include "empathy-conf.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
+#include <libempathy/empathy-gsettings.h>
#ifdef HAVE_ENCHANT
@@ -50,7 +50,6 @@ typedef struct {
static GHashTable *iso_code_names = NULL;
static GList *languages = NULL;
-static gboolean empathy_conf_notify_inited = FALSE;
static void
spell_iso_codes_parse_start_tag (GMarkupParseContext *ctx,
@@ -159,7 +158,7 @@ spell_iso_code_names_init (void)
}
static void
-spell_notify_languages_cb (EmpathyConf *conf,
+spell_notify_languages_cb (GSettings *gsettings,
const gchar *key,
gpointer user_data)
{
@@ -186,23 +185,26 @@ spell_notify_languages_cb (EmpathyConf *conf,
static void
spell_setup_languages (void)
{
+ static GSettings *gsettings = NULL;
gchar *str;
- if (!empathy_conf_notify_inited) {
- empathy_conf_notify_add (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES,
- spell_notify_languages_cb, NULL);
+ if (gsettings == NULL) {
+ /* FIXME: this is never uninitialised */
+ gsettings = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
- empathy_conf_notify_inited = TRUE;
+ g_signal_connect (gsettings,
+ "changed::" EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES,
+ G_CALLBACK (spell_notify_languages_cb), NULL);
}
if (languages) {
return;
}
- if (empathy_conf_get_string (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES,
- &str) && str) {
+ str = g_settings_get_string (gsettings,
+ EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES);
+
+ if (str != NULL) {
gchar **strv;
gint i;
diff --git a/libempathy-gtk/empathy-theme-adium.c b/libempathy-gtk/empathy-theme-adium.c
index ad174ce3b..e3582a7d4 100644
--- a/libempathy-gtk/empathy-theme-adium.c
+++ b/libempathy-gtk/empathy-theme-adium.c
@@ -32,12 +32,12 @@
#include <pango/pango.h>
#include <gdk/gdk.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-time.h>
#include <libempathy/empathy-utils.h>
#include "empathy-theme-adium.h"
#include "empathy-smiley-manager.h"
-#include "empathy-conf.h"
#include "empathy-ui-utils.h"
#include "empathy-plist.h"
#include "empathy-string-parser.h"
@@ -63,8 +63,8 @@ typedef struct {
gboolean last_is_backlog;
gboolean page_loaded;
GList *message_queue;
- guint notify_enable_webkit_developer_tools_id;
GtkWidget *inspector_window;
+ GSettings *gsettings_chat;
} EmpathyThemeAdiumPriv;
struct _EmpathyAdiumData {
@@ -111,14 +111,13 @@ G_DEFINE_TYPE_WITH_CODE (EmpathyThemeAdium, empathy_theme_adium,
static void
theme_adium_update_enable_webkit_developer_tools (EmpathyThemeAdium *theme)
{
+ EmpathyThemeAdiumPriv *priv = GET_PRIV (theme);
WebKitWebView *web_view = WEBKIT_WEB_VIEW (theme);
gboolean enable_webkit_developer_tools;
- if (!empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_WEBKIT_DEVELOPER_TOOLS,
- &enable_webkit_developer_tools)) {
- return;
- }
+ enable_webkit_developer_tools = g_settings_get_boolean (
+ priv->gsettings_chat,
+ EMPATHY_PREFS_CHAT_WEBKIT_DEVELOPER_TOOLS);
g_object_set (G_OBJECT (webkit_web_view_get_settings (web_view)),
"enable-developer-extras",
@@ -127,7 +126,7 @@ theme_adium_update_enable_webkit_developer_tools (EmpathyThemeAdium *theme)
}
static void
-theme_adium_notify_enable_webkit_developer_tools_cb (EmpathyConf *conf,
+theme_adium_notify_enable_webkit_developer_tools_cb (GSettings *gsettings,
const gchar *key,
gpointer user_data)
{
@@ -257,13 +256,10 @@ theme_adium_parse_body (const gchar *text)
{
EmpathyStringParser *parsers;
GString *string;
- gboolean use_smileys;
+ GSettings *gsettings = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
/* Check if we have to parse smileys */
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_SHOW_SMILEYS,
- &use_smileys);
- if (use_smileys)
+ if (g_settings_get_boolean (gsettings, EMPATHY_PREFS_CHAT_SHOW_SMILEYS))
parsers = string_parsers_with_smiley;
else
parsers = string_parsers;
@@ -274,6 +270,8 @@ theme_adium_parse_body (const gchar *text)
string = g_string_sized_new (strlen (text));
empathy_string_parser_substr (text, -1, parsers, string);
+ g_object_unref (gsettings);
+
return g_string_free (string, FALSE);
}
@@ -875,9 +873,7 @@ theme_adium_finalize (GObject *object)
EmpathyThemeAdiumPriv *priv = GET_PRIV (object);
empathy_adium_data_unref (priv->data);
-
- empathy_conf_notify_remove (empathy_conf_get (),
- priv->notify_enable_webkit_developer_tools_id);
+ g_object_unref (priv->gsettings_chat);
G_OBJECT_CLASS (empathy_theme_adium_parent_class)->finalize (object);
}
@@ -1154,11 +1150,11 @@ empathy_theme_adium_init (EmpathyThemeAdium *theme)
G_CALLBACK (theme_adium_navigation_policy_decision_requested_cb),
NULL);
- priv->notify_enable_webkit_developer_tools_id =
- empathy_conf_notify_add (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_WEBKIT_DEVELOPER_TOOLS,
- theme_adium_notify_enable_webkit_developer_tools_cb,
- theme);
+ priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
+ g_signal_connect (priv->gsettings_chat,
+ "changed::" EMPATHY_PREFS_CHAT_WEBKIT_DEVELOPER_TOOLS,
+ G_CALLBACK (theme_adium_notify_enable_webkit_developer_tools_cb),
+ theme);
theme_adium_update_enable_webkit_developer_tools (theme);
}
diff --git a/libempathy-gtk/empathy-theme-boxes.c b/libempathy-gtk/empathy-theme-boxes.c
index 29fb934f4..531f2baa6 100644
--- a/libempathy-gtk/empathy-theme-boxes.c
+++ b/libempathy-gtk/empathy-theme-boxes.c
@@ -33,7 +33,6 @@
#include <libempathy/empathy-utils.h>
#include "empathy-theme-boxes.h"
#include "empathy-ui-utils.h"
-#include "empathy-conf.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c
index 905e0bf1d..bcad60538 100644
--- a/libempathy-gtk/empathy-theme-manager.c
+++ b/libempathy-gtk/empathy-theme-manager.c
@@ -30,11 +30,12 @@
#include <gtk/gtk.h>
#include <telepathy-glib/util.h>
+
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-utils.h>
#include "empathy-theme-manager.h"
#include "empathy-chat-view.h"
-#include "empathy-conf.h"
#include "empathy-chat-text-view.h"
#include "empathy-theme-boxes.h"
#include "empathy-theme-irc.h"
@@ -48,10 +49,9 @@
#define GET_PRIV(obj) EMPATHY_GET_PRIV (obj, EmpathyThemeManager)
typedef struct {
+ GSettings *gsettings_chat;
gchar *name;
- guint name_notify_id;
gchar *adium_path;
- guint adium_path_notify_id;
GtkSettings *settings;
GList *boxes_views;
} EmpathyThemeManagerPriv;
@@ -393,16 +393,17 @@ theme_manager_ensure_theme_exists (const gchar *name)
}
static void
-theme_manager_notify_name_cb (EmpathyConf *conf,
+theme_manager_notify_name_cb (GSettings *gsettings_chat,
const gchar *key,
gpointer user_data)
{
EmpathyThemeManager *manager = EMPATHY_THEME_MANAGER (user_data);
EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
- gchar *name = NULL;
+ gchar *name;
+
+ name = g_settings_get_string (gsettings_chat, key);
- if (!empathy_conf_get_string (conf, key, &name) ||
- !theme_manager_ensure_theme_exists (name) ||
+ if (!theme_manager_ensure_theme_exists (name) ||
!tp_strdiff (priv->name, name)) {
if (!priv->name) {
priv->name = g_strdup ("classic");
@@ -431,7 +432,7 @@ theme_manager_notify_name_cb (EmpathyConf *conf,
}
static void
-theme_manager_notify_adium_path_cb (EmpathyConf *conf,
+theme_manager_notify_adium_path_cb (GSettings *gsettings_chat,
const gchar *key,
gpointer user_data)
{
@@ -439,8 +440,9 @@ theme_manager_notify_adium_path_cb (EmpathyConf *conf,
EmpathyThemeManagerPriv *priv = GET_PRIV (manager);
gchar *adium_path = NULL;
- if (!empathy_conf_get_string (conf, key, &adium_path) ||
- !tp_strdiff (priv->adium_path, adium_path)) {
+ adium_path = g_settings_get_string (gsettings_chat, key);
+
+ if (!tp_strdiff (priv->adium_path, adium_path)) {
g_free (adium_path);
return;
}
@@ -457,9 +459,8 @@ theme_manager_finalize (GObject *object)
EmpathyThemeManagerPriv *priv = GET_PRIV (object);
GList *l;
- empathy_conf_notify_remove (empathy_conf_get (), priv->name_notify_id);
+ g_object_unref (priv->gsettings_chat);
g_free (priv->name);
- empathy_conf_notify_remove (empathy_conf_get (), priv->adium_path_notify_id);
g_free (priv->adium_path);
for (l = priv->boxes_views; l; l = l->next) {
@@ -500,23 +501,23 @@ empathy_theme_manager_init (EmpathyThemeManager *manager)
manager->priv = priv;
+ priv->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
+
/* Take the theme name and track changes */
- priv->name_notify_id =
- empathy_conf_notify_add (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_THEME,
- theme_manager_notify_name_cb,
- manager);
- theme_manager_notify_name_cb (empathy_conf_get (),
+ g_signal_connect (priv->gsettings_chat,
+ "changed::" EMPATHY_PREFS_CHAT_THEME,
+ G_CALLBACK (theme_manager_notify_name_cb),
+ manager);
+ theme_manager_notify_name_cb (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_THEME,
manager);
/* Take the adium path and track changes */
- priv->adium_path_notify_id =
- empathy_conf_notify_add (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_ADIUM_PATH,
- theme_manager_notify_adium_path_cb,
- manager);
- theme_manager_notify_adium_path_cb (empathy_conf_get (),
+ g_signal_connect (priv->gsettings_chat,
+ "changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH,
+ G_CALLBACK (theme_manager_notify_adium_path_cb),
+ manager);
+ theme_manager_notify_adium_path_cb (priv->gsettings_chat,
EMPATHY_PREFS_CHAT_ADIUM_PATH,
manager);
}
diff --git a/libempathy-gtk/empathy-ui-utils.c b/libempathy-gtk/empathy-ui-utils.c
index b5e37cade..6339a891d 100644
--- a/libempathy-gtk/empathy-ui-utils.c
+++ b/libempathy-gtk/empathy-ui-utils.c
@@ -41,7 +41,6 @@
#include "empathy-ui-utils.h"
#include "empathy-images.h"
#include "empathy-smiley-manager.h"
-#include "empathy-conf.h"
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am
index 6d596beda..c8d362952 100644
--- a/libempathy/Makefile.am
+++ b/libempathy/Makefile.am
@@ -42,6 +42,7 @@ libempathy_headers = \
empathy-dispatcher.h \
empathy-ft-factory.h \
empathy-ft-handler.h \
+ empathy-gsettings.h \
empathy-handler.h \
empathy-idle.h \
empathy-irc-network-manager.h \
diff --git a/libempathy/empathy-gsettings.h b/libempathy/empathy-gsettings.h
new file mode 100644
index 000000000..1aef1e353
--- /dev/null
+++ b/libempathy/empathy-gsettings.h
@@ -0,0 +1,92 @@
+/*
+ * Copyright (C) 2010 Collabora Ltd.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * Authors: Danielle Madeley <danielle.madeley@collabora.co.uk>
+ */
+
+#ifndef __EMPATHY_GSETTINGS_H__
+#define __EMPATHY_GSETTINGS_H__
+
+#include <gio/gio.h>
+
+G_BEGIN_DECLS
+
+#define EMPATHY_PREFS_SCHEMA "org.gnome.Empathy"
+#define EMPATHY_PREFS_USE_CONN "use-conn"
+#define EMPATHY_PREFS_AUTOCONNECT "autoconnect"
+#define EMPATHY_PREFS_AUTOAWAY "autoaway"
+#define EMPATHY_PREFS_IMPORT_ASKED "import-asked"
+#define EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED "butterfly-logs-migrated"
+#define EMPATHY_PREFS_FILE_TRANSFER_DEFAULT_FOLDER "file-transfer-default-folder"
+
+#define EMPATHY_PREFS_NOTIFICATIONS_SCHEMA EMPATHY_PREFS_SCHEMA ".notifications"
+#define EMPATHY_PREFS_NOTIFICATIONS_ENABLED "notifications-enabled"
+#define EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY "notifications-disabled-away"
+#define EMPATHY_PREFS_NOTIFICATIONS_FOCUS "notifications-focus"
+#define EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN "notifications-contact-signin"
+#define EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT "notifications-contact-signout"
+#define EMPATHY_PREFS_NOTIFICATIONS_POPUPS_WHEN_AVAILABLE "popups-when-available"
+
+#define EMPATHY_PREFS_SOUNDS_SCHEMA EMPATHY_PREFS_SCHEMA ".sounds"
+#define EMPATHY_PREFS_SOUNDS_ENABLED "sounds-enabled"
+#define EMPATHY_PREFS_SOUNDS_DISABLED_AWAY "sounds-disabled-away"
+#define EMPATHY_PREFS_SOUNDS_INCOMING_MESSAGE "sounds-incoming-message"
+#define EMPATHY_PREFS_SOUNDS_OUTGOING_MESSAGE "sounds-outgoing-message"
+#define EMPATHY_PREFS_SOUNDS_NEW_CONVERSATION "sounds-new-conversation"
+#define EMPATHY_PREFS_SOUNDS_SERVICE_LOGIN "sounds-service-login"
+#define EMPATHY_PREFS_SOUNDS_SERVICE_LOGOUT "sounds-service-logout"
+#define EMPATHY_PREFS_SOUNDS_CONTACT_LOGIN "sounds-contact-login"
+#define EMPATHY_PREFS_SOUNDS_CONTACT_LOGOUT "sounds-contact-logout"
+
+#define EMPATHY_PREFS_CHAT_SCHEMA EMPATHY_PREFS_SCHEMA ".conversation"
+#define EMPATHY_PREFS_CHAT_SHOW_SMILEYS "graphical-smileys"
+#define EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS "show-contacts-in-rooms"
+#define EMPATHY_PREFS_CHAT_THEME "theme"
+#define EMPATHY_PREFS_CHAT_ADIUM_PATH "adium-path"
+#define EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES "spell-checker-languages"
+#define EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED "spell-checker-enabled"
+#define EMPATHY_PREFS_CHAT_NICK_COMPLETION_CHAR "nick-completion-char"
+#define EMPATHY_PREFS_CHAT_AVATAR_IN_ICON "avatar-in-icon"
+#define EMPATHY_PREFS_CHAT_WEBKIT_DEVELOPER_TOOLS "enable-webkit-developer-tools"
+
+#define EMPATHY_PREFS_UI_SCHEMA EMPATHY_PREFS_SCHEMA ".ui"
+#define EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS "separate-chat-windows"
+#define EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN "main-window-hidden"
+#define EMPATHY_PREFS_UI_AVATAR_DIRECTORY "avatar-directory"
+#define EMPATHY_PREFS_UI_SHOW_AVATARS "show-avatars"
+#define EMPATHY_PREFS_UI_SHOW_PROTOCOLS "show-protocols"
+#define EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST "compact-contact-list"
+#define EMPATHY_PREFS_UI_CHAT_WINDOW_PANED_POS "chat-window-paned-pos"
+#define EMPATHY_PREFS_UI_SHOW_OFFLINE "show-offline"
+
+#define EMPATHY_PREFS_CONTACTS_SCHEMA EMPATHY_PREFS_SCHEMA ".contacts"
+#define EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM "sort-criterium"
+
+#define EMPATHY_PREFS_HINTS_SCHEMA EMPATHY_PREFS_SCHEMA ".hints"
+#define EMPATHY_PREFS_HINTS_CLOSE_MAIN_WINDOW "close-main-window"
+
+#define EMPATHY_PREFS_LOCATION_SCHEMA EMPATHY_PREFS_SCHEMA ".location"
+#define EMPATHY_PREFS_LOCATION_PUBLISH "publish"
+#define EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK "resource-network"
+#define EMPATHY_PREFS_LOCATION_RESOURCE_CELL "resource-cell"
+#define EMPATHY_PREFS_LOCATION_RESOURCE_GPS "resource-gps"
+#define EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY "reduce-accuracy"
+
+G_END_DECLS
+
+#endif /* __EMPATHY_GSETTINGS_H__ */
+
diff --git a/src/empathy-account-assistant.c b/src/empathy-account-assistant.c
index 060345a9e..6ad475652 100644
--- a/src/empathy-account-assistant.c
+++ b/src/empathy-account-assistant.c
@@ -36,7 +36,6 @@
#include <libempathy-gtk/empathy-account-widget.h>
#include <libempathy-gtk/empathy-protocol-chooser.h>
#include <libempathy-gtk/empathy-ui-utils.h>
-#include <libempathy-gtk/empathy-conf.h>
#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
#include <libempathy/empathy-debug.h>
diff --git a/src/empathy-accounts-dialog.c b/src/empathy-accounts-dialog.c
index d81d3de2d..12ac5b244 100644
--- a/src/empathy-accounts-dialog.c
+++ b/src/empathy-accounts-dialog.c
@@ -39,14 +39,14 @@
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-connection-managers.h>
#include <libempathy/empathy-connectivity.h>
-#include <libempathy-gtk/empathy-ui-utils.h>
+#include <libempathy/empathy-gsettings.h>
+#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy-gtk/empathy-protocol-chooser.h>
#include <libempathy-gtk/empathy-account-widget.h>
#include <libempathy-gtk/empathy-account-widget-irc.h>
#include <libempathy-gtk/empathy-account-widget-sip.h>
#include <libempathy-gtk/empathy-cell-renderer-activatable.h>
-#include <libempathy-gtk/empathy-conf.h>
#include <libempathy-gtk/empathy-images.h>
#include "empathy-accounts-dialog.h"
@@ -2219,8 +2219,8 @@ do_constructed (GObject *object)
{
EmpathyAccountsDialog *dialog = EMPATHY_ACCOUNTS_DIALOG (object);
EmpathyAccountsDialogPriv *priv = GET_PRIV (dialog);
- gboolean import_asked;
GtkTreeModel *model;
+ GSettings *gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
accounts_dialog_build_ui (dialog);
accounts_dialog_model_setup (dialog);
@@ -2237,19 +2237,15 @@ do_constructed (GObject *object)
tp_account_manager_prepare_async (priv->account_manager, NULL,
accounts_dialog_manager_ready_cb, dialog);
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_IMPORT_ASKED, &import_asked);
-
if (empathy_import_accounts_to_import ())
{
gtk_widget_show (priv->button_import);
- if (!import_asked)
+ if (!g_settings_get_boolean (gsettings, EMPATHY_PREFS_IMPORT_ASKED))
{
GtkWidget *import_dialog;
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_IMPORT_ASKED, TRUE);
+ g_settings_set_boolean (gsettings, EMPATHY_PREFS_IMPORT_ASKED, TRUE);
import_dialog = empathy_import_dialog_new (GTK_WINDOW (dialog),
FALSE);
gtk_widget_show (import_dialog);
@@ -2257,6 +2253,8 @@ do_constructed (GObject *object)
}
priv->connectivity = empathy_connectivity_dup_singleton ();
+
+ g_object_unref (gsettings);
}
static void
diff --git a/src/empathy-auto-salut-account-helper.c b/src/empathy-auto-salut-account-helper.c
index 0a96316f1..23484dd45 100644
--- a/src/empathy-auto-salut-account-helper.c
+++ b/src/empathy-auto-salut-account-helper.c
@@ -29,7 +29,6 @@
#include <libebook/e-book.h>
#include <libempathy/empathy-account-settings.h>
-#include <libempathy-gtk/empathy-conf.h>
#define DEBUG_FLAG EMPATHY_DEBUG_ACCOUNT
#include <libempathy/empathy-debug.h>
diff --git a/src/empathy-chat-window.c b/src/empathy-chat-window.c
index 8a0502b26..a80d3fee5 100644
--- a/src/empathy-chat-window.c
+++ b/src/empathy-chat-window.c
@@ -41,12 +41,12 @@
#include <libempathy/empathy-contact.h>
#include <libempathy/empathy-message.h>
#include <libempathy/empathy-chatroom-manager.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-tp-contact-factory.h>
#include <libempathy/empathy-contact-list.h>
#include <libempathy-gtk/empathy-images.h>
-#include <libempathy-gtk/empathy-conf.h>
#include <libempathy-gtk/empathy-contact-dialogs.h>
#include <libempathy-gtk/empathy-log-window.h>
#include <libempathy-gtk/empathy-geometry.h>
@@ -519,9 +519,10 @@ chat_window_icon_update (EmpathyChatWindowPriv *priv)
gtk_window_set_icon_name (GTK_WINDOW (priv->dialog),
EMPATHY_IMAGE_MESSAGE);
} else {
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_AVATAR_IN_ICON,
- &avatar_in_icon);
+ GSettings *gsettings = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
+
+ avatar_in_icon = g_settings_get_boolean (gsettings,
+ EMPATHY_PREFS_CHAT_AVATAR_IN_ICON);
if (n_chats == 1 && avatar_in_icon) {
remote_contact = empathy_chat_get_remote_contact (priv->current_chat);
@@ -534,6 +535,8 @@ chat_window_icon_update (EmpathyChatWindowPriv *priv)
} else {
gtk_window_set_icon_name (GTK_WINDOW (priv->dialog), NULL);
}
+
+ g_object_unref (gsettings);
}
}
@@ -1264,8 +1267,14 @@ chat_window_show_or_update_notification (EmpathyChatWindow *window,
if (!empathy_notify_manager_notification_is_enabled (priv->notify_mgr)) {
return;
} else {
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_NOTIFICATIONS_FOCUS, &res);
+ GSettings *gsettings = g_settings_new (
+ EMPATHY_PREFS_NOTIFICATIONS_SCHEMA);
+
+ res = g_settings_get_boolean (gsettings,
+ EMPATHY_PREFS_NOTIFICATIONS_FOCUS);
+
+ g_object_unref (gsettings);
+
if (!res) {
return;
}
@@ -2068,12 +2077,14 @@ empathy_chat_window_new (void)
EmpathyChatWindow *
empathy_chat_window_get_default (gboolean room)
{
+ GSettings *gsettings = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
GList *l;
gboolean separate_windows = TRUE;
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
- &separate_windows);
+ separate_windows = g_settings_get_boolean (gsettings,
+ EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS);
+
+ g_object_unref (gsettings);
if (separate_windows) {
/* Always create a new window */
@@ -2141,12 +2152,14 @@ empathy_chat_window_add_chat (EmpathyChatWindow *window,
/* If this window has just been created, position it */
if (priv->chats == NULL) {
+ GSettings *gsettings = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
const gchar *name = "chat-window";
gboolean separate_windows;
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
- &separate_windows);
+ separate_windows = g_settings_get_boolean (gsettings,
+ EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS);
+
+ g_object_unref (gsettings);
if (separate_windows) {
name = empathy_chat_get_id (chat);
diff --git a/src/empathy-event-manager.c b/src/empathy-event-manager.c
index 2f269f573..14c52981b 100644
--- a/src/empathy-event-manager.c
+++ b/src/empathy-event-manager.c
@@ -37,10 +37,10 @@
#include <libempathy/empathy-tp-file.h>
#include <libempathy/empathy-utils.h>
#include <libempathy/empathy-call-factory.h>
+#include <libempathy/empathy-gsettings.h>
#include <extensions/extensions.h>
-#include <libempathy-gtk/empathy-conf.h>
#include <libempathy-gtk/empathy-images.h>
#include <libempathy-gtk/empathy-contact-dialogs.h>
#include <libempathy-gtk/empathy-sound.h>
@@ -837,8 +837,8 @@ event_manager_presence_changed_cb (EmpathyContact *contact,
{
TpAccount *account;
gchar *header = NULL;
- gboolean preference = FALSE;
EmpathyIdle *idle;
+ GSettings *gsettings = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA);
account = empathy_contact_get_account (contact);
idle = empathy_idle_dup_singleton ();
@@ -847,7 +847,7 @@ event_manager_presence_changed_cb (EmpathyContact *contact,
goto out;
if (tp_connection_presence_type_cmp_availability (previous,
- TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
+ TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
{
/* contact was online */
if (tp_connection_presence_type_cmp_availability (current,
@@ -857,9 +857,8 @@ event_manager_presence_changed_cb (EmpathyContact *contact,
empathy_sound_play (empathy_main_window_get (),
EMPATHY_SOUND_CONTACT_DISCONNECTED);
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT, &preference);
- if (preference)
+ if (g_settings_get_boolean (gsettings,
+ EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT))
{
header = g_strdup_printf (_("%s is now offline."),
empathy_contact_get_name (contact));
@@ -872,16 +871,15 @@ event_manager_presence_changed_cb (EmpathyContact *contact,
else
{
/* contact was offline */
- if (preference && tp_connection_presence_type_cmp_availability (current,
- TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
+ if (tp_connection_presence_type_cmp_availability (current,
+ TP_CONNECTION_PRESENCE_TYPE_OFFLINE) > 0)
{
/* someone is logging in */
empathy_sound_play (empathy_main_window_get (),
EMPATHY_SOUND_CONTACT_CONNECTED);
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN, &preference);
- if (preference)
+ if (g_settings_get_boolean (gsettings,
+ EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN))
{
header = g_strdup_printf (_("%s is now online."),
empathy_contact_get_name (contact));
@@ -895,6 +893,7 @@ event_manager_presence_changed_cb (EmpathyContact *contact,
out:
g_object_unref (idle);
+ g_object_unref (gsettings);
}
static void
diff --git a/src/empathy-ft-manager.c b/src/empathy-ft-manager.c
index e681f8441..34ac1adac 100644
--- a/src/empathy-ft-manager.c
+++ b/src/empathy-ft-manager.c
@@ -40,7 +40,6 @@
#include <libempathy/empathy-tp-file.h>
#include <libempathy/empathy-utils.h>
-#include <libempathy-gtk/empathy-conf.h>
#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy-gtk/empathy-geometry.h>
#include <libempathy-gtk/empathy-images.h>
diff --git a/src/empathy-main-window.c b/src/empathy-main-window.c
index 998c024fe..3a6bf0ae4 100644
--- a/src/empathy-main-window.c
+++ b/src/empathy-main-window.c
@@ -38,9 +38,9 @@
#include <libempathy/empathy-chatroom.h>
#include <libempathy/empathy-contact-list.h>
#include <libempathy/empathy-contact-manager.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-status-presets.h>
-#include <libempathy-gtk/empathy-conf.h>
#include <libempathy-gtk/empathy-contact-dialogs.h>
#include <libempathy-gtk/empathy-contact-list-store.h>
#include <libempathy-gtk/empathy-contact-list-view.h>
@@ -91,6 +91,9 @@ typedef struct {
guint flash_timeout_id;
gboolean flash_on;
+ GSettings *gsettings_ui;
+ GSettings *gsettings_contacts;
+
GtkWidget *window;
GtkWidget *main_vbox;
GtkWidget *throbber;
@@ -622,6 +625,9 @@ main_window_destroy_cb (GtkWidget *widget,
g_object_unref (window->ui_manager);
g_object_unref (window->chatroom_manager);
+ g_object_unref (window->gsettings_ui);
+ g_object_unref (window->gsettings_contacts);
+
g_free (window);
}
@@ -691,9 +697,9 @@ main_window_view_show_offline_cb (GtkToggleAction *action,
gboolean current;
current = gtk_toggle_action_get_active (action);
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_UI_SHOW_OFFLINE,
- current);
+ g_settings_set_boolean (window->gsettings_ui,
+ EMPATHY_PREFS_UI_SHOW_OFFLINE,
+ current);
/* Turn off sound just while we alter the contact list. */
// FIXME: empathy_sound_set_enabled (FALSE);
@@ -702,13 +708,15 @@ main_window_view_show_offline_cb (GtkToggleAction *action,
}
static void
-main_window_notify_sort_contact_cb (EmpathyConf *conf,
+main_window_notify_sort_contact_cb (GSettings *gsettings,
const gchar *key,
EmpathyMainWindow *window)
{
- gchar *str = NULL;
+ gchar *str;
- if (empathy_conf_get_string (conf, key, &str) && str) {
+ str = g_settings_get_string (gsettings, key);
+
+ if (str != NULL) {
GType type;
GEnumClass *enum_class;
GEnumValue *enum_value;
@@ -752,9 +760,9 @@ main_window_view_sort_contacts_cb (GtkRadioAction *action,
g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioAction index:%d",
g_slist_index (group, action));
} else {
- empathy_conf_set_string (empathy_conf_get (),
- EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
- enum_value->value_nick);
+ g_settings_set_string (window->gsettings_contacts,
+ EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
+ enum_value->value_nick);
}
empathy_contact_list_store_set_sort_criterium (window->list_store, value);
}
@@ -767,11 +775,11 @@ main_window_view_show_protocols_cb (GtkToggleAction *action,
value = gtk_toggle_action_get_active (action);
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
- value == TRUE);
+ g_settings_set_boolean (window->gsettings_ui,
+ EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
+ value);
empathy_contact_list_store_set_show_protocols (window->list_store,
- value == TRUE);
+ value);
}
/* Matches GtkRadioAction values set in empathy-main-window.ui */
@@ -788,12 +796,13 @@ main_window_view_contacts_list_size_cb (GtkRadioAction *action,
value = gtk_radio_action_get_current_value (action);
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_UI_SHOW_AVATARS,
- value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS);
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
- value == CONTACT_LIST_COMPACT_SIZE);
+ g_settings_set_boolean (window->gsettings_ui,
+ EMPATHY_PREFS_UI_SHOW_AVATARS,
+ value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS);
+
+ g_settings_set_boolean (window->gsettings_ui,
+ EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
+ value == CONTACT_LIST_COMPACT_SIZE);
empathy_contact_list_store_set_show_avatars (window->list_store,
value == CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS);
@@ -801,44 +810,33 @@ main_window_view_contacts_list_size_cb (GtkRadioAction *action,
value == CONTACT_LIST_COMPACT_SIZE);
}
-static void main_window_notify_show_protocols_cb (EmpathyConf *conf,
+static void main_window_notify_show_protocols_cb (GSettings *gsettings,
const gchar *key,
EmpathyMainWindow *window)
{
- gboolean show_protocols;
-
- if (empathy_conf_get_bool (conf,
- EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
- &show_protocols)) {
- gtk_toggle_action_set_active (window->show_protocols,
- show_protocols);
- }
+ gtk_toggle_action_set_active (window->show_protocols,
+ g_settings_get_boolean (gsettings,
+ EMPATHY_PREFS_UI_SHOW_PROTOCOLS));
}
static void
-main_window_notify_contact_list_size_cb (EmpathyConf *conf,
+main_window_notify_contact_list_size_cb (GSettings *gsettings,
const gchar *key,
EmpathyMainWindow *window)
{
- gboolean show_avatars;
- gboolean compact_contact_list;
gint value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS;
- if (empathy_conf_get_bool (conf,
- EMPATHY_PREFS_UI_SHOW_AVATARS,
- &show_avatars)
- && empathy_conf_get_bool (conf,
- EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
- &compact_contact_list)) {
- if (compact_contact_list) {
- value = CONTACT_LIST_COMPACT_SIZE;
- } else if (show_avatars) {
- value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS;
- } else {
- value = CONTACT_LIST_NORMAL_SIZE;
- }
+ if (g_settings_get_boolean (gsettings,
+ EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST)) {
+ value = CONTACT_LIST_COMPACT_SIZE;
+ } else if (g_settings_get_boolean (gsettings,
+ EMPATHY_PREFS_UI_SHOW_AVATARS)) {
+ value = CONTACT_LIST_NORMAL_SIZE_WITH_AVATARS;
+ } else {
+ value = CONTACT_LIST_NORMAL_SIZE;
}
+
/* By changing the value of the GtkRadioAction,
it emits a signal that calls main_window_view_contacts_list_size_cb
which updates the contacts list */
@@ -1277,15 +1275,12 @@ main_window_account_validity_changed_cb (TpAccountManager *manager,
}
static void
-main_window_notify_show_offline_cb (EmpathyConf *conf,
+main_window_notify_show_offline_cb (GSettings *gsettings,
const gchar *key,
gpointer toggle_action)
{
- gboolean show_offline;
-
- if (empathy_conf_get_bool (conf, key, &show_offline)) {
- gtk_toggle_action_set_active (toggle_action, show_offline);
- }
+ gtk_toggle_action_set_active (toggle_action,
+ g_settings_get_boolean (gsettings, key));
}
static void
@@ -1383,7 +1378,6 @@ empathy_main_window_show (void)
EmpathyMainWindow *window;
EmpathyContactList *list_iface;
GtkBuilder *gui;
- EmpathyConf *conf;
GtkWidget *sw;
GtkToggleAction *show_offline_widget;
GtkAction *show_map_widget;
@@ -1400,6 +1394,9 @@ empathy_main_window_show (void)
main_window = g_new0 (EmpathyMainWindow, 1);
window = main_window;
+ window->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
+ window->gsettings_contacts = g_settings_new (EMPATHY_PREFS_CONTACTS_SCHEMA);
+
/* Set up interface */
filename = empathy_file_lookup ("empathy-main-window.ui", "src");
gui = empathy_builder_get_file (filename,
@@ -1572,50 +1569,47 @@ empathy_main_window_show (void)
l = l->next;
}
- conf = empathy_conf_get ();
-
/* Show offline ? */
- empathy_conf_get_bool (conf,
- EMPATHY_PREFS_UI_SHOW_OFFLINE,
- &show_offline);
- empathy_conf_notify_add (conf,
- EMPATHY_PREFS_UI_SHOW_OFFLINE,
- main_window_notify_show_offline_cb,
- show_offline_widget);
+ show_offline = g_settings_get_boolean (window->gsettings_ui,
+ EMPATHY_PREFS_UI_SHOW_OFFLINE);
+ g_signal_connect (window->gsettings_ui,
+ "changed::" EMPATHY_PREFS_UI_SHOW_OFFLINE,
+ G_CALLBACK (main_window_notify_show_offline_cb),
+ show_offline_widget);
gtk_toggle_action_set_active (show_offline_widget, show_offline);
/* Show protocol ? */
- empathy_conf_notify_add (conf,
- EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
- (EmpathyConfNotifyFunc) main_window_notify_show_protocols_cb,
- window);
+ g_signal_connect (window->gsettings_ui,
+ "changed::" EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
+ G_CALLBACK (main_window_notify_show_protocols_cb),
+ window);
- main_window_notify_show_protocols_cb (conf,
- EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
- window);
+ main_window_notify_show_protocols_cb (window->gsettings_ui,
+ EMPATHY_PREFS_UI_SHOW_PROTOCOLS,
+ window);
/* Sort by name / by status ? */
- empathy_conf_notify_add (conf,
- EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
- (EmpathyConfNotifyFunc) main_window_notify_sort_contact_cb,
- window);
+ g_signal_connect (window->gsettings_contacts,
+ "changed::" EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
+ G_CALLBACK (main_window_notify_sort_contact_cb),
+ window);
- main_window_notify_sort_contact_cb (conf,
+ main_window_notify_sort_contact_cb (window->gsettings_contacts,
EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM,
window);
/* Contacts list size */
- empathy_conf_notify_add (conf,
- EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
- (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb,
- window);
- empathy_conf_notify_add (conf,
- EMPATHY_PREFS_UI_SHOW_AVATARS,
- (EmpathyConfNotifyFunc) main_window_notify_contact_list_size_cb,
- window);
-
- main_window_notify_contact_list_size_cb (conf,
+ g_signal_connect (window->gsettings_ui,
+ "changed::" EMPATHY_PREFS_UI_COMPACT_CONTACT_LIST,
+ G_CALLBACK (main_window_notify_contact_list_size_cb),
+ window);
+ g_signal_connect (window->gsettings_ui,
+ "changed::" EMPATHY_PREFS_UI_SHOW_AVATARS,
+ G_CALLBACK (main_window_notify_contact_list_size_cb),
+ window);
+
+ main_window_notify_contact_list_size_cb (window->gsettings_ui,
EMPATHY_PREFS_UI_SHOW_AVATARS,
window);
diff --git a/src/empathy-migrate-butterfly-logs.c b/src/empathy-migrate-butterfly-logs.c
index 9ee135ef0..4a8bf973c 100644
--- a/src/empathy-migrate-butterfly-logs.c
+++ b/src/empathy-migrate-butterfly-logs.c
@@ -22,8 +22,7 @@
#define DEBUG_FLAG EMPATHY_DEBUG_OTHER
#include <libempathy/empathy-debug.h>
-
-#include <libempathy-gtk/empathy-conf.h>
+#include <libempathy/empathy-gsettings.h>
#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
@@ -139,7 +138,7 @@ migration_account_manager_prepared_cb (GObject *source_object,
TpAccountManager *am = TP_ACCOUNT_MANAGER (source_object);
GError *error = NULL;
GList *accounts, *l;
- EmpathyConf *conf;
+ GSettings *gsettings;
if (!tp_account_manager_prepare_finish (am, result, &error))
{
@@ -175,8 +174,10 @@ migration_account_manager_prepared_cb (GObject *source_object,
DEBUG ("Finished all migrating");
- conf = empathy_conf_get ();
- empathy_conf_set_bool (conf, EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED, TRUE);
+ gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
+ g_settings_set_boolean (gsettings, EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED,
+ TRUE);
+ g_object_unref (gsettings);
g_list_free (accounts);
}
@@ -199,22 +200,15 @@ migrate_logs (gpointer data)
gboolean
empathy_migrate_butterfly_logs (EmpathyContact *contact)
{
- EmpathyConf *conf;
- gboolean logs_migrated;
+ GSettings *gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
gchar *cm;
- conf = empathy_conf_get ();
-
/* Already in progress. */
if (butterfly_log_migration_id != 0)
return FALSE;
/* Already done. */
- if (!empathy_conf_get_bool (conf, EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED,
- &logs_migrated))
- return FALSE;
-
- if (logs_migrated)
+ if (g_settings_get_boolean (gsettings, EMPATHY_PREFS_BUTTERFLY_LOGS_MIGRATED))
return FALSE;
tp_account_parse_object_path (
diff --git a/src/empathy-preferences.c b/src/empathy-preferences.c
index 993cf77d4..8192049e7 100644
--- a/src/empathy-preferences.c
+++ b/src/empathy-preferences.c
@@ -31,9 +31,9 @@
#include <telepathy-glib/dbus.h>
#include <telepathy-glib/util.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-utils.h>
-#include <libempathy-gtk/empathy-conf.h>
#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy-gtk/empathy-theme-manager.h>
#include <libempathy-gtk/empathy-spell.h>
@@ -75,7 +75,12 @@ typedef struct {
GtkWidget *checkbutton_location_resource_cell;
GtkWidget *checkbutton_location_resource_gps;
- GList *notify_ids;
+ GSettings *gsettings;
+ GSettings *gsettings_chat;
+ GSettings *gsettings_loc;
+ GSettings *gsettings_notify;
+ GSettings *gsettings_sound;
+ GSettings *gsettings_ui;
} EmpathyPreferences;
static void preferences_setup_widgets (EmpathyPreferences *preferences);
@@ -94,22 +99,6 @@ static gboolean preferences_languages_load_foreach (GtkTreeModel
static void preferences_languages_cell_toggled_cb (GtkCellRendererToggle *cell,
gchar *path_string,
EmpathyPreferences *preferences);
-static void preferences_widget_sync_bool (const gchar *key,
- GtkWidget *widget);
-static void preferences_notify_bool_cb (EmpathyConf *conf,
- const gchar *key,
- gpointer user_data);
-static void preferences_notify_sensitivity_cb (EmpathyConf *conf,
- const gchar *key,
- gpointer user_data);
-static void preferences_hookup_toggle_button (EmpathyPreferences *preferences,
- const gchar *key,
- GtkWidget *widget);
-static void preferences_hookup_sensitivity (EmpathyPreferences *preferences,
- const gchar *key,
- GtkWidget *widget);
-static void preferences_toggle_button_toggled_cb (GtkWidget *button,
- gpointer user_data);
static void preferences_destroy_cb (GtkWidget *widget,
EmpathyPreferences *preferences);
static void preferences_response_cb (GtkWidget *widget,
@@ -155,105 +144,149 @@ static SoundEventEntry sound_entries [] = {
};
static void
-preferences_add_id (EmpathyPreferences *preferences, guint id)
-{
- preferences->notify_ids = g_list_prepend (preferences->notify_ids,
- GUINT_TO_POINTER (id));
-}
-
-static void
preferences_setup_widgets (EmpathyPreferences *preferences)
{
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
- preferences->checkbutton_notifications_enabled);
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY,
- preferences->checkbutton_notifications_disabled_away);
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_NOTIFICATIONS_FOCUS,
- preferences->checkbutton_notifications_focus);
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN,
- preferences->checkbutton_notifications_contact_signin);
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT,
- preferences->checkbutton_notifications_contact_signout);
-
- preferences_hookup_sensitivity (preferences,
- EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
- preferences->checkbutton_notifications_disabled_away);
- preferences_hookup_sensitivity (preferences,
- EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
- preferences->checkbutton_notifications_focus);
- preferences_hookup_sensitivity (preferences,
- EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
- preferences->checkbutton_notifications_contact_signin);
- preferences_hookup_sensitivity (preferences,
- EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
- preferences->checkbutton_notifications_contact_signout);
-
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_SOUNDS_ENABLED,
- preferences->checkbutton_sounds_enabled);
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_SOUNDS_DISABLED_AWAY,
- preferences->checkbutton_sounds_disabled_away);
-
- preferences_hookup_sensitivity (preferences,
- EMPATHY_PREFS_SOUNDS_ENABLED,
- preferences->checkbutton_sounds_disabled_away);
- preferences_hookup_sensitivity (preferences,
- EMPATHY_PREFS_SOUNDS_ENABLED,
- preferences->treeview_sounds);
-
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
- preferences->checkbutton_separate_chat_windows);
-
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_CHAT_SHOW_SMILEYS,
- preferences->checkbutton_show_smileys);
-
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS,
- preferences->checkbutton_show_contacts_in_rooms);
-
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_AUTOCONNECT,
- preferences->checkbutton_autoconnect);
-
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_LOCATION_PUBLISH,
- preferences->checkbutton_location_publish);
-
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK,
- preferences->checkbutton_location_resource_network);
- preferences_hookup_sensitivity (preferences,
- EMPATHY_PREFS_LOCATION_PUBLISH,
- preferences->checkbutton_location_resource_network);
-
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_LOCATION_RESOURCE_CELL,
- preferences->checkbutton_location_resource_cell);
- preferences_hookup_sensitivity (preferences,
- EMPATHY_PREFS_LOCATION_PUBLISH,
- preferences->checkbutton_location_resource_cell);
-
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_LOCATION_RESOURCE_GPS,
- preferences->checkbutton_location_resource_gps);
- preferences_hookup_sensitivity (preferences,
- EMPATHY_PREFS_LOCATION_PUBLISH,
- preferences->checkbutton_location_resource_gps);
-
- preferences_hookup_toggle_button (preferences,
- EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY,
- preferences->checkbutton_location_reduce_accuracy);
- preferences_hookup_sensitivity (preferences,
- EMPATHY_PREFS_LOCATION_PUBLISH,
- preferences->checkbutton_location_reduce_accuracy);
+ g_settings_bind (preferences->gsettings_notify,
+ EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
+ preferences->checkbutton_notifications_enabled,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (preferences->gsettings_notify,
+ EMPATHY_PREFS_NOTIFICATIONS_DISABLED_AWAY,
+ preferences->checkbutton_notifications_disabled_away,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (preferences->gsettings_notify,
+ EMPATHY_PREFS_NOTIFICATIONS_FOCUS,
+ preferences->checkbutton_notifications_focus,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (preferences->gsettings_notify,
+ EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNIN,
+ preferences->checkbutton_notifications_contact_signin,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (preferences->gsettings_notify,
+ EMPATHY_PREFS_NOTIFICATIONS_CONTACT_SIGNOUT,
+ preferences->checkbutton_notifications_contact_signout,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_settings_bind (preferences->gsettings_notify,
+ EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
+ preferences->checkbutton_notifications_disabled_away,
+ "sensitive",
+ G_SETTINGS_BIND_GET);
+ g_settings_bind (preferences->gsettings_notify,
+ EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
+ preferences->checkbutton_notifications_focus,
+ "sensitive",
+ G_SETTINGS_BIND_GET);
+ g_settings_bind (preferences->gsettings_notify,
+ EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
+ preferences->checkbutton_notifications_contact_signin,
+ "sensitive",
+ G_SETTINGS_BIND_GET);
+ g_settings_bind (preferences->gsettings_notify,
+ EMPATHY_PREFS_NOTIFICATIONS_ENABLED,
+ preferences->checkbutton_notifications_contact_signout,
+ "sensitive",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (preferences->gsettings_sound,
+ EMPATHY_PREFS_SOUNDS_ENABLED,
+ preferences->checkbutton_sounds_enabled,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (preferences->gsettings_sound,
+ EMPATHY_PREFS_SOUNDS_DISABLED_AWAY,
+ preferences->checkbutton_sounds_disabled_away,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_settings_bind (preferences->gsettings_sound,
+ EMPATHY_PREFS_SOUNDS_ENABLED,
+ preferences->checkbutton_sounds_disabled_away,
+ "sensitive",
+ G_SETTINGS_BIND_GET);
+ g_settings_bind (preferences->gsettings_sound,
+ EMPATHY_PREFS_SOUNDS_ENABLED,
+ preferences->treeview_sounds,
+ "sensitive",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (preferences->gsettings_ui,
+ EMPATHY_PREFS_UI_SEPARATE_CHAT_WINDOWS,
+ preferences->checkbutton_separate_chat_windows,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_settings_bind (preferences->gsettings_chat,
+ EMPATHY_PREFS_CHAT_SHOW_SMILEYS,
+ preferences->checkbutton_show_smileys,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (preferences->gsettings_chat,
+ EMPATHY_PREFS_CHAT_SHOW_CONTACTS_IN_ROOMS,
+ preferences->checkbutton_show_contacts_in_rooms,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_settings_bind (preferences->gsettings,
+ EMPATHY_PREFS_AUTOCONNECT,
+ preferences->checkbutton_autoconnect,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_settings_bind (preferences->gsettings_loc,
+ EMPATHY_PREFS_LOCATION_PUBLISH,
+ preferences->checkbutton_location_publish,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+
+ g_settings_bind (preferences->gsettings_loc,
+ EMPATHY_PREFS_LOCATION_RESOURCE_NETWORK,
+ preferences->checkbutton_location_resource_network,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (preferences->gsettings_loc,
+ EMPATHY_PREFS_LOCATION_PUBLISH,
+ preferences->checkbutton_location_resource_network,
+ "sensitive",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (preferences->gsettings_loc,
+ EMPATHY_PREFS_LOCATION_RESOURCE_CELL,
+ preferences->checkbutton_location_resource_cell,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (preferences->gsettings_loc,
+ EMPATHY_PREFS_LOCATION_PUBLISH,
+ preferences->checkbutton_location_resource_cell,
+ "sensitive",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (preferences->gsettings_loc,
+ EMPATHY_PREFS_LOCATION_RESOURCE_GPS,
+ preferences->checkbutton_location_resource_gps,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (preferences->gsettings_loc,
+ EMPATHY_PREFS_LOCATION_PUBLISH,
+ preferences->checkbutton_location_resource_gps,
+ "sensitive",
+ G_SETTINGS_BIND_GET);
+
+ g_settings_bind (preferences->gsettings_loc,
+ EMPATHY_PREFS_LOCATION_REDUCE_ACCURACY,
+ preferences->checkbutton_location_reduce_accuracy,
+ "active",
+ G_SETTINGS_BIND_DEFAULT);
+ g_settings_bind (preferences->gsettings_loc,
+ EMPATHY_PREFS_LOCATION_PUBLISH,
+ preferences->checkbutton_location_reduce_accuracy,
+ "sensitive",
+ G_SETTINGS_BIND_GET);
}
static void
@@ -283,7 +316,7 @@ preferences_sound_cell_toggled_cb (GtkCellRendererToggle *toggle,
gtk_list_store_set (GTK_LIST_STORE (model), &iter,
COL_SOUND_ENABLED, instore, -1);
- empathy_conf_set_bool (empathy_conf_get (), key, instore);
+ g_settings_set_boolean (preferences->gsettings_sound, key, instore);
g_free (key);
gtk_tree_path_free (path);
@@ -297,14 +330,13 @@ preferences_sound_load (EmpathyPreferences *preferences)
GtkListStore *store;
GtkTreeIter iter;
gboolean set;
- EmpathyConf *conf;
view = GTK_TREE_VIEW (preferences->treeview_sounds);
store = GTK_LIST_STORE (gtk_tree_view_get_model (view));
- conf = empathy_conf_get ();
for (i = 0; i < G_N_ELEMENTS (sound_entries); i++) {
- empathy_conf_get_bool (conf, sound_entries[i].key, &set);
+ set = g_settings_get_boolean (preferences->gsettings_sound,
+ sound_entries[i].key);
gtk_list_store_insert_with_values (store, &iter, i,
COL_SOUND_NAME, gettext (sound_entries[i].name),
@@ -419,9 +451,9 @@ preferences_languages_add (EmpathyPreferences *preferences)
codes = empathy_spell_get_language_codes ();
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
- codes != NULL);
+ g_settings_set_boolean (preferences->gsettings_chat,
+ EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
+ codes != NULL);
if (!codes) {
gtk_widget_set_sensitive (preferences->treeview_spell_checker, FALSE);
}
@@ -463,13 +495,13 @@ preferences_languages_save (EmpathyPreferences *preferences)
&languages);
/* if user selects no languages, we don't want spell check */
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
- languages != NULL);
+ g_settings_set_boolean (preferences->gsettings_chat,
+ EMPATHY_PREFS_CHAT_SPELL_CHECKER_ENABLED,
+ languages != NULL);
- empathy_conf_set_string (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES,
- languages ? languages : "");
+ g_settings_set_string (preferences->gsettings_chat,
+ EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES,
+ languages != NULL ? languages : "");
g_free (languages);
}
@@ -518,11 +550,11 @@ preferences_languages_load (EmpathyPreferences *preferences)
gchar *value;
gchar **vlanguages;
- if (!empathy_conf_get_string (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES,
- &value) || !value) {
+ value = g_settings_get_string (preferences->gsettings_chat,
+ EMPATHY_PREFS_CHAT_SPELL_CHECKER_LANGUAGES);
+
+ if (value == NULL)
return;
- }
vlanguages = g_strsplit (value, ",", -1);
g_free (value);
@@ -598,316 +630,7 @@ preferences_languages_cell_toggled_cb (GtkCellRendererToggle *cell,
}
static void
-preferences_widget_sync_bool (const gchar *key, GtkWidget *widget)
-{
- gboolean value;
-
- if (empathy_conf_get_bool (empathy_conf_get (), key, &value)) {
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (widget), value);
- }
-}
-
-#if 0
-static void
-preferences_widget_sync_string (const gchar *key, GtkWidget *widget)
-{
- gchar *value;
-
- if (empathy_conf_get_string (empathy_conf_get (), key, &value) && value) {
- if (GTK_IS_ENTRY (widget)) {
- gtk_entry_set_text (GTK_ENTRY (widget), value);
- } else if (GTK_IS_RADIO_BUTTON (widget)) {
- if (!tp_strdiff (key, EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM)) {
- GType type;
- GEnumClass *enum_class;
- GEnumValue *enum_value;
- GSList *list;
- GtkWidget *toggle_widget;
-
- /* Get index from new string */
- type = empathy_contact_list_store_sort_get_type ();
- enum_class = G_ENUM_CLASS (g_type_class_peek (type));
- enum_value = g_enum_get_value_by_nick (enum_class, value);
-
- if (enum_value) {
- list = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
- toggle_widget = g_slist_nth_data (list, enum_value->value);
- gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (toggle_widget), TRUE);
- }
- } else {
- g_warning ("Unhandled key:'%s' just had string change", key);
- }
- }
-
- g_free (value);
- }
-}
-
-static void
-preferences_notify_string_cb (EmpathyConf *conf,
- const gchar *key,
- gpointer user_data)
-{
- preferences_widget_sync_string (key, user_data);
-}
-#endif
-
-static void
-preferences_notify_bool_cb (EmpathyConf *conf,
- const gchar *key,
- gpointer user_data)
-{
- preferences_widget_sync_bool (key, user_data);
-}
-
-static void
-preferences_notify_sensitivity_cb (EmpathyConf *conf,
- const gchar *key,
- gpointer user_data)
-{
- gboolean value;
-
- if (empathy_conf_get_bool (conf, key, &value)) {
- gtk_widget_set_sensitive (GTK_WIDGET (user_data), value);
- }
-}
-
-#if 0
-static void
-preferences_widget_sync_int (const gchar *key, GtkWidget *widget)
-{
- gint value;
-
- if (empathy_conf_get_int (empathy_conf_get (), key, &value)) {
- if (GTK_IS_SPIN_BUTTON (widget)) {
- gtk_spin_button_set_value (GTK_SPIN_BUTTON (widget), value);
- }
- }
-}
-
-static void
-preferences_notify_int_cb (EmpathyConf *conf,
- const gchar *key,
- gpointer user_data)
-{
- preferences_widget_sync_int (key, user_data);
-}
-
-static void
-preferences_hookup_spin_button (EmpathyPreferences *preferences,
- const gchar *key,
- GtkWidget *widget)
-{
- guint id;
-
- preferences_widget_sync_int (key, widget);
-
- g_object_set_data_full (G_OBJECT (widget), "key",
- g_strdup (key), g_free);
-
- g_signal_connect (widget,
- "value_changed",
- G_CALLBACK (preferences_spin_button_value_changed_cb),
- NULL);
-
- id = empathy_conf_notify_add (empathy_conf_get (),
- key,
- preferences_notify_int_cb,
- widget);
- if (id) {
- preferences_add_id (preferences, id);
- }
-}
-
-static void
-preferences_hookup_entry (EmpathyPreferences *preferences,
- const gchar *key,
- GtkWidget *widget)
-{
- guint id;
-
- preferences_widget_sync_string (key, widget);
-
- g_object_set_data_full (G_OBJECT (widget), "key",
- g_strdup (key), g_free);
-
- g_signal_connect (widget,
- "changed",
- G_CALLBACK (preferences_entry_value_changed_cb),
- NULL);
-
- id = empathy_conf_notify_add (empathy_conf_get (),
- key,
- preferences_notify_string_cb,
- widget);
- if (id) {
- preferences_add_id (preferences, id);
- }
-}
-
-static void
-preferences_spin_button_value_changed_cb (GtkWidget *button,
- gpointer user_data)
-{
- const gchar *key;
-
- key = g_object_get_data (G_OBJECT (button), "key");
-
- empathy_conf_set_int (empathy_conf_get (),
- key,
- gtk_spin_button_get_value (GTK_SPIN_BUTTON (button)));
-}
-
-static void
-preferences_entry_value_changed_cb (GtkWidget *entry,
- gpointer user_data)
-{
- const gchar *key;
-
- key = g_object_get_data (G_OBJECT (entry), "key");
-
- empathy_conf_set_string (empathy_conf_get (),
- key,
- gtk_entry_get_text (GTK_ENTRY (entry)));
-}
-#endif
-
-static void
-preferences_hookup_toggle_button (EmpathyPreferences *preferences,
- const gchar *key,
- GtkWidget *widget)
-{
- guint id;
-
- preferences_widget_sync_bool (key, widget);
-
- g_object_set_data_full (G_OBJECT (widget), "key",
- g_strdup (key), g_free);
-
- g_signal_connect (widget,
- "toggled",
- G_CALLBACK (preferences_toggle_button_toggled_cb),
- NULL);
-
- id = empathy_conf_notify_add (empathy_conf_get (),
- key,
- preferences_notify_bool_cb,
- widget);
- if (id) {
- preferences_add_id (preferences, id);
- }
-}
-
-#if 0
-static void
-preferences_hookup_radio_button (EmpathyPreferences *preferences,
- const gchar *key,
- GtkWidget *widget)
-{
- GSList *group, *l;
- guint id;
-
- preferences_widget_sync_string (key, widget);
-
- group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (widget));
- for (l = group; l; l = l->next) {
- g_signal_connect (l->data,
- "toggled",
- G_CALLBACK (preferences_radio_button_toggled_cb),
- NULL);
-
- g_object_set_data_full (G_OBJECT (l->data), "key",
- g_strdup (key), g_free);
- }
-
- id = empathy_conf_notify_add (empathy_conf_get (),
- key,
- preferences_notify_string_cb,
- widget);
- if (id) {
- preferences_add_id (preferences, id);
- }
-}
-#endif
-
-static void
-preferences_hookup_sensitivity (EmpathyPreferences *preferences,
- const gchar *key,
- GtkWidget *widget)
-{
- gboolean value;
- guint id;
-
- if (empathy_conf_get_bool (empathy_conf_get (), key, &value)) {
- gtk_widget_set_sensitive (widget, value);
- }
-
- id = empathy_conf_notify_add (empathy_conf_get (),
- key,
- preferences_notify_sensitivity_cb,
- widget);
- if (id) {
- preferences_add_id (preferences, id);
- }
-}
-
-static void
-preferences_toggle_button_toggled_cb (GtkWidget *button,
- gpointer user_data)
-{
- const gchar *key;
-
- key = g_object_get_data (G_OBJECT (button), "key");
-
- empathy_conf_set_bool (empathy_conf_get (),
- key,
- gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)));
-}
-
-#if 0
-static void
-preferences_radio_button_toggled_cb (GtkWidget *button,
- gpointer user_data)
-{
- const gchar *key;
- const gchar *value = NULL;
-
- if (!gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button))) {
- return;
- }
-
- key = g_object_get_data (G_OBJECT (button), "key");
-
- if (!tp_strdiff (key, EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM)) {
- GSList *group;
- GType type;
- GEnumClass *enum_class;
- GEnumValue *enum_value;
-
- group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (button));
-
- /* Get string from index */
- type = empathy_contact_list_store_sort_get_type ();
- enum_class = G_ENUM_CLASS (g_type_class_peek (type));
- enum_value = g_enum_get_value (enum_class, g_slist_index (group, button));
-
- if (!enum_value) {
- g_warning ("No GEnumValue for EmpathyContactListSort with GtkRadioButton index:%d",
- g_slist_index (group, button));
- return;
- }
-
- value = enum_value->value_nick;
- } else if (!tp_strdiff (key, EMPATHY_PREFS_CONTACTS_SORT_CRITERIUM)) {
- return;
- }
-
- empathy_conf_set_string (empathy_conf_get (), key, value);
-}
-#endif
-
-static void
-preferences_theme_notify_cb (EmpathyConf *conf,
+preferences_theme_notify_cb (GSettings *gsettings,
const gchar *key,
gpointer user_data)
{
@@ -919,14 +642,8 @@ preferences_theme_notify_cb (EmpathyConf *conf,
GtkTreeIter iter;
gboolean found = FALSE;
- if (!empathy_conf_get_string (conf, EMPATHY_PREFS_CHAT_THEME, &conf_name)) {
- return;
- }
-
- if (!empathy_conf_get_string (conf, EMPATHY_PREFS_CHAT_ADIUM_PATH, &conf_path)) {
- g_free (conf_name);
- return;
- }
+ conf_name = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_THEME);
+ conf_path = g_settings_get_string (gsettings, EMPATHY_PREFS_CHAT_ADIUM_PATH);
combo = GTK_COMBO_BOX (preferences->combobox_chat_theme);
model = gtk_combo_box_get_model (combo);
@@ -988,13 +705,13 @@ preferences_theme_changed_cb (GtkComboBox *combo,
COL_COMBO_PATH, &path,
-1);
- empathy_conf_set_string (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_THEME,
- name);
+ g_settings_set_string (preferences->gsettings_chat,
+ EMPATHY_PREFS_CHAT_THEME,
+ name);
if (is_adium == TRUE)
- empathy_conf_set_string (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_ADIUM_PATH,
- path);
+ g_settings_set_string (preferences->gsettings_chat,
+ EMPATHY_PREFS_CHAT_ADIUM_PATH,
+ path);
g_free (name);
g_free (path);
}
@@ -1010,7 +727,6 @@ preferences_themes_setup (EmpathyPreferences *preferences)
const gchar **themes;
GList *adium_themes;
gint i;
- guint id;
combo = GTK_COMBO_BOX (preferences->combobox_chat_theme);
cell_layout = GTK_CELL_LAYOUT (combo);
@@ -1071,24 +787,18 @@ preferences_themes_setup (EmpathyPreferences *preferences)
preferences);
/* Select the theme from the gconf key and track changes */
- preferences_theme_notify_cb (empathy_conf_get (),
+ preferences_theme_notify_cb (preferences->gsettings_chat,
EMPATHY_PREFS_CHAT_THEME,
preferences);
- id = empathy_conf_notify_add (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_THEME,
- preferences_theme_notify_cb,
- preferences);
- if (id) {
- preferences_add_id (preferences, id);
- }
+ g_signal_connect (preferences->gsettings_chat,
+ "changed::" EMPATHY_PREFS_CHAT_THEME,
+ G_CALLBACK (preferences_theme_notify_cb),
+ preferences);
- id = empathy_conf_notify_add (empathy_conf_get (),
- EMPATHY_PREFS_CHAT_ADIUM_PATH,
- preferences_theme_notify_cb,
- preferences);
- if (id) {
- preferences_add_id (preferences, id);
- }
+ g_signal_connect (preferences->gsettings_chat,
+ "changed::" EMPATHY_PREFS_CHAT_ADIUM_PATH,
+ G_CALLBACK (preferences_theme_notify_cb),
+ preferences);
}
static void
@@ -1103,16 +813,13 @@ static void
preferences_destroy_cb (GtkWidget *widget,
EmpathyPreferences *preferences)
{
- GList *l;
+ g_object_unref (preferences->gsettings);
+ g_object_unref (preferences->gsettings_chat);
+ g_object_unref (preferences->gsettings_loc);
+ g_object_unref (preferences->gsettings_notify);
+ g_object_unref (preferences->gsettings_sound);
+ g_object_unref (preferences->gsettings_ui);
- for (l = preferences->notify_ids; l; l = l->next) {
- guint id;
-
- id = GPOINTER_TO_UINT (l->data);
- empathy_conf_notify_remove (empathy_conf_get (), id);
- }
-
- g_list_free (preferences->notify_ids);
g_free (preferences);
}
@@ -1166,6 +873,13 @@ empathy_preferences_show (GtkWindow *parent)
g_object_add_weak_pointer (G_OBJECT (preferences->dialog), (gpointer) &preferences);
+ preferences->gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
+ preferences->gsettings_chat = g_settings_new (EMPATHY_PREFS_CHAT_SCHEMA);
+ preferences->gsettings_loc = g_settings_new (EMPATHY_PREFS_LOCATION_SCHEMA);
+ preferences->gsettings_notify = g_settings_new (EMPATHY_PREFS_NOTIFICATIONS_SCHEMA);
+ preferences->gsettings_sound = g_settings_new (EMPATHY_PREFS_SOUNDS_SCHEMA);
+ preferences->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
+
preferences_themes_setup (preferences);
preferences_setup_widgets (preferences);
diff --git a/src/empathy-status-icon.c b/src/empathy-status-icon.c
index 81409696e..a002a7fb7 100644
--- a/src/empathy-status-icon.c
+++ b/src/empathy-status-icon.c
@@ -35,10 +35,10 @@
#include <telepathy-glib/account-manager.h>
#include <telepathy-glib/util.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-utils.h>
#include <libempathy-gtk/empathy-presence-chooser.h>
-#include <libempathy-gtk/empathy-conf.h>
#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy-gtk/empathy-images.h>
#include <libempathy-gtk/empathy-new-message-dialog.h>
@@ -66,6 +66,7 @@ typedef struct {
EmpathyEventManager *event_manager;
EmpathyEvent *event;
NotifyNotification *notification;
+ GSettings *gsettings_ui;
GtkWindow *window;
GtkUIManager *ui_manager;
@@ -356,8 +357,9 @@ status_icon_set_visibility (EmpathyStatusIcon *icon,
EmpathyStatusIconPriv *priv = GET_PRIV (icon);
if (store) {
- empathy_conf_set_bool (empathy_conf_get (),
- EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN, !visible);
+ g_settings_set_boolean (priv->gsettings_ui,
+ EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN,
+ !visible);
}
if (!visible) {
@@ -368,16 +370,15 @@ status_icon_set_visibility (EmpathyStatusIcon *icon,
}
static void
-status_icon_notify_visibility_cb (EmpathyConf *conf,
+status_icon_notify_visibility_cb (GSettings *gsettings,
const gchar *key,
gpointer user_data)
{
EmpathyStatusIcon *icon = user_data;
gboolean hidden = FALSE;
- if (empathy_conf_get_bool (conf, key, &hidden)) {
- status_icon_set_visibility (icon, !hidden, FALSE);
- }
+ hidden = g_settings_get_boolean (gsettings, key);
+ status_icon_set_visibility (icon, !hidden, FALSE);
}
static void
@@ -571,6 +572,7 @@ status_icon_finalize (GObject *object)
g_object_unref (priv->event_manager);
g_object_unref (priv->ui_manager);
g_object_unref (priv->notify_mgr);
+ g_object_unref (priv->gsettings_ui);
}
static void
@@ -625,10 +627,11 @@ empathy_status_icon_init (EmpathyStatusIcon *icon)
account_manager_prepared_cb, icon);
/* make icon listen and respond to MAIN_WINDOW_HIDDEN changes */
- empathy_conf_notify_add (empathy_conf_get (),
- EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN,
- status_icon_notify_visibility_cb,
- icon);
+ priv->gsettings_ui = g_settings_new (EMPATHY_PREFS_UI_SCHEMA);
+ g_signal_connect (priv->gsettings_ui,
+ "changed::" EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN,
+ G_CALLBACK (status_icon_notify_visibility_cb),
+ icon);
status_icon_create_menu (icon);
@@ -678,13 +681,8 @@ empathy_status_icon_new (GtkWindow *window, gboolean hide_contact_list)
G_CALLBACK (status_icon_delete_event_cb),
icon);
- if (!hide_contact_list) {
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN,
- &should_hide);
- } else {
- should_hide = TRUE;
- }
+ should_hide = g_settings_get_boolean (priv->gsettings_ui,
+ EMPATHY_PREFS_UI_MAIN_WINDOW_HIDDEN);
if (gtk_window_is_active (priv->window) == should_hide) {
status_icon_set_visibility (icon, !should_hide, FALSE);
diff --git a/src/empathy.c b/src/empathy.c
index 9d59bba79..ac292fcff 100644
--- a/src/empathy.c
+++ b/src/empathy.c
@@ -61,10 +61,10 @@
#include <libempathy/empathy-dispatcher.h>
#include <libempathy/empathy-dispatch-operation.h>
#include <libempathy/empathy-ft-factory.h>
+#include <libempathy/empathy-gsettings.h>
#include <libempathy/empathy-tp-chat.h>
#include <libempathy/empathy-tp-call.h>
-#include <libempathy-gtk/empathy-conf.h>
#include <libempathy-gtk/empathy-ui-utils.h>
#include <libempathy-gtk/empathy-location-manager.h>
@@ -168,17 +168,14 @@ dispatch_cb (EmpathyDispatcher *dispatcher,
}
static void
-use_conn_notify_cb (EmpathyConf *conf,
+use_conn_notify_cb (GSettings *gsettings,
const gchar *key,
gpointer user_data)
{
EmpathyConnectivity *connectivity = user_data;
- gboolean use_conn;
- if (empathy_conf_get_bool (conf, key, &use_conn))
- {
- empathy_connectivity_set_use_conn (connectivity, use_conn);
- }
+ empathy_connectivity_set_use_conn (connectivity,
+ g_settings_get_boolean (gsettings, key));
}
static void
@@ -353,8 +350,8 @@ account_manager_ready_cb (GObject *source_object,
GError *error = NULL;
EmpathyIdle *idle;
EmpathyConnectivity *connectivity;
- gboolean autoconnect = TRUE;
TpConnectionPresenceType presence;
+ GSettings *gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
if (!tp_account_manager_prepare_finish (manager, result, &error))
{
@@ -370,9 +367,8 @@ account_manager_ready_cb (GObject *source_object,
presence = tp_account_manager_get_most_available_presence (manager, NULL,
NULL);
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_AUTOCONNECT, &autoconnect);
- if (autoconnect && !no_connect &&
+ if (g_settings_get_boolean (gsettings, EMPATHY_PREFS_AUTOCONNECT) &&
+ !no_connect &&
tp_connection_presence_type_cmp_availability
(presence, TP_CONNECTION_PRESENCE_TYPE_OFFLINE)
<= 0)
@@ -387,6 +383,7 @@ account_manager_ready_cb (GObject *source_object,
g_object_unref (idle);
g_object_unref (connectivity);
+ g_object_unref (gsettings);
}
static EmpathyDispatcher *
@@ -561,15 +558,14 @@ chatroom_manager_ready_cb (EmpathyChatroomManager *chatroom_manager,
}
static void
-empathy_idle_set_auto_away_cb (EmpathyConf *conf,
+empathy_idle_set_auto_away_cb (GSettings *gsettings,
const gchar *key,
gpointer user_data)
{
- gboolean autoaway;
EmpathyIdle *idle = user_data;
- empathy_conf_get_bool (conf, key, &autoaway);
- empathy_idle_set_auto_away (idle, autoaway);
+ empathy_idle_set_auto_away (idle,
+ g_settings_get_boolean (gsettings, key));
}
int
@@ -600,6 +596,7 @@ main (int argc, char *argv[])
#ifdef ENABLE_DEBUG
TpDebugSender *debug_sender;
#endif
+ GSettings *gsettings;
GOptionContext *optcontext;
GOptionEntry options[] = {
@@ -666,22 +663,22 @@ main (int argc, char *argv[])
/* Setting up Idle */
idle = empathy_idle_dup_singleton ();
- empathy_conf_get_bool (empathy_conf_get (),
- EMPATHY_PREFS_AUTOAWAY, &autoaway);
+ gsettings = g_settings_new (EMPATHY_PREFS_SCHEMA);
+ autoaway = g_settings_get_boolean (gsettings, EMPATHY_PREFS_AUTOAWAY);
- empathy_conf_notify_add (empathy_conf_get (),
- EMPATHY_PREFS_AUTOAWAY,
- empathy_idle_set_auto_away_cb,
- idle);
+ g_signal_connect (gsettings,
+ "changed::" EMPATHY_PREFS_AUTOAWAY,
+ G_CALLBACK (empathy_idle_set_auto_away_cb), idle);
empathy_idle_set_auto_away (idle, autoaway);
/* Setting up Connectivity */
connectivity = empathy_connectivity_dup_singleton ();
- use_conn_notify_cb (empathy_conf_get (), EMPATHY_PREFS_USE_CONN,
+ use_conn_notify_cb (gsettings, EMPATHY_PREFS_USE_CONN,
connectivity);
- empathy_conf_notify_add (empathy_conf_get (), EMPATHY_PREFS_USE_CONN,
- use_conn_notify_cb, connectivity);
+ g_signal_connect (gsettings,
+ "changed::" EMPATHY_PREFS_USE_CONN,
+ G_CALLBACK (use_conn_notify_cb), connectivity);
/* account management */
account_manager = tp_account_manager_dup ();
@@ -763,6 +760,7 @@ main (int argc, char *argv[])
#endif
g_object_unref (ft_factory);
g_object_unref (unique_app);
+ g_object_unref (gsettings);
notify_uninit ();
xmlCleanupParser ();