diff options
author | Xavier Claessens <xclaesse@src.gnome.org> | 2008-01-23 21:16:06 +0800 |
---|---|---|
committer | Xavier Claessens <xclaesse@src.gnome.org> | 2008-01-23 21:16:06 +0800 |
commit | 61a627be9a0d353ee9fc4d8edecde948aab5d243 (patch) | |
tree | a2124b70f6f380cfd3a1be7963a42ad25cd97d4a /libempathy | |
parent | 84db00195ac91343c32c1d1e9e4301e8b0adc662 (diff) | |
download | gsoc2013-empathy-61a627be9a0d353ee9fc4d8edecde948aab5d243.tar gsoc2013-empathy-61a627be9a0d353ee9fc4d8edecde948aab5d243.tar.gz gsoc2013-empathy-61a627be9a0d353ee9fc4d8edecde948aab5d243.tar.bz2 gsoc2013-empathy-61a627be9a0d353ee9fc4d8edecde948aab5d243.tar.lz gsoc2013-empathy-61a627be9a0d353ee9fc4d8edecde948aab5d243.tar.xz gsoc2013-empathy-61a627be9a0d353ee9fc4d8edecde948aab5d243.tar.zst gsoc2013-empathy-61a627be9a0d353ee9fc4d8edecde948aab5d243.zip |
Move empathy-conf to libempathy-gtk. libempathy do not depend directly on gconf anymore.
svn path=/trunk/; revision=597
Diffstat (limited to 'libempathy')
-rw-r--r-- | libempathy/Makefile.am | 2 | ||||
-rw-r--r-- | libempathy/empathy-conf.c | 372 | ||||
-rw-r--r-- | libempathy/empathy-conf.h | 87 |
3 files changed, 0 insertions, 461 deletions
diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am index e6711c3c6..285dff185 100644 --- a/libempathy/Makefile.am +++ b/libempathy/Makefile.am @@ -16,7 +16,6 @@ BUILT_SOURCES = \ lib_LTLIBRARIES = libempathy.la libempathy_la_SOURCES = \ - empathy-conf.c \ empathy-avatar.c \ empathy-time.c \ empathy-presence.c \ @@ -54,7 +53,6 @@ libempathy_la_LDFLAGS = \ -version-info ${LIBEMPATHY_CURRENT}:${LIBEMPATHY_REVISION}:${LIBEMPATHY_AGE} libempathy_headers = \ - empathy-conf.h \ empathy-avatar.h \ empathy-time.h \ empathy-presence.h \ diff --git a/libempathy/empathy-conf.c b/libempathy/empathy-conf.c deleted file mode 100644 index 71e520f72..000000000 --- a/libempathy/empathy-conf.c +++ /dev/null @@ -1,372 +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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, USA. - * - * Authors: Richard Hult <richard@imendio.com> - */ - -#include "config.h" - -#include <string.h> - -#include <gconf/gconf-client.h> - -#include "empathy-conf.h" -#include "empathy-debug.h" - -#define DEBUG_DOMAIN "Config" - -#define EMPATHY_CONF_ROOT "/apps/empathy" -#define DESKTOP_INTERFACE_ROOT "/desktop/gnome/interface" - -#define GET_PRIV(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), EMPATHY_TYPE_CONF, EmpathyConfPriv)) - -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; - - priv = GET_PRIV (conf); - - 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); - - empathy_debug (DEBUG_DOMAIN, "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); - - empathy_debug (DEBUG_DOMAIN, "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); - - empathy_debug (DEBUG_DOMAIN, "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/empathy-conf.h b/libempathy/empathy-conf.h deleted file mode 100644 index 7e8e60e25..000000000 --- a/libempathy/empathy-conf.h +++ /dev/null @@ -1,87 +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., 59 Temple Place - Suite 330, - * Boston, MA 02111-1307, 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; -}; - -struct _EmpathyConfClass { - GObjectClass parent_class; -}; - -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__ */ - |