From: Xavier Claessens Date: Wed, 23 Jan 2008 13:16:06 +0000 (+0000) Subject: Move empathy-conf to libempathy-gtk. libempathy do not depend directly on gconf anymore. X-Git-Url: https://git.0d.be/?p=empathy.git;a=commitdiff_plain;h=61a627be9a0d353ee9fc4d8edecde948aab5d243 Move empathy-conf to libempathy-gtk. libempathy do not depend directly on gconf anymore. svn path=/trunk/; revision=597 --- diff --git a/configure.ac b/configure.ac index 1d0c5b13..3ed95165 100644 --- a/configure.ac +++ b/configure.ac @@ -73,7 +73,6 @@ PKG_CHECK_MODULES(LIBEMPATHY, [ glib-2.0 >= $GLIB_REQUIRED gobject-2.0 - gconf-2.0 >= $GCONF_REQUIRED libxml-2.0 libtelepathy >= $TELEPATHY_REQUIRED telepathy-glib >= $TELEPATHY_GLIB_REQUIRED diff --git a/docs/libempathy-gtk/libempathy-gtk-docs.sgml b/docs/libempathy-gtk/libempathy-gtk-docs.sgml index df56e278..774f0514 100644 --- a/docs/libempathy-gtk/libempathy-gtk-docs.sgml +++ b/docs/libempathy-gtk/libempathy-gtk-docs.sgml @@ -33,6 +33,7 @@ + diff --git a/docs/libempathy/libempathy-docs.sgml b/docs/libempathy/libempathy-docs.sgml index 5aa6819d..bcdc5d0f 100644 --- a/docs/libempathy/libempathy-docs.sgml +++ b/docs/libempathy/libempathy-docs.sgml @@ -20,7 +20,6 @@ - diff --git a/libempathy-gtk/Makefile.am b/libempathy-gtk/Makefile.am index 721bd82e..083065f8 100644 --- a/libempathy-gtk/Makefile.am +++ b/libempathy-gtk/Makefile.am @@ -15,6 +15,7 @@ libempathy_gtk_la_SOURCES = \ ephy-spinner.c ephy-spinner.h \ empathy-main-window.c \ empathy-status-icon.c \ + empathy-conf.c \ empathy-contact-widget.c \ empathy-contact-dialogs.c \ empathy-accounts-dialog.c \ @@ -69,6 +70,7 @@ libempathy_gtk_headers = \ empathy-images.h \ empathy-main-window.h \ empathy-status-icon.h \ + empathy-conf.h \ empathy-contact-widget.h \ empathy-contact-dialogs.h \ empathy-accounts-dialog.h \ diff --git a/libempathy-gtk/empathy-avatar-chooser.c b/libempathy-gtk/empathy-avatar-chooser.c index 348186a6..ba557787 100644 --- a/libempathy-gtk/empathy-avatar-chooser.c +++ b/libempathy-gtk/empathy-avatar-chooser.c @@ -30,9 +30,10 @@ #include #include -#include + #include "empathy-avatar-chooser.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-ui-utils.h" diff --git a/libempathy-gtk/empathy-chat-view.c b/libempathy-gtk/empathy-chat-view.c index d6c85606..f4ad7f31 100644 --- a/libempathy-gtk/empathy-chat-view.c +++ b/libempathy-gtk/empathy-chat-view.c @@ -44,10 +44,10 @@ #include #include -#include #include "empathy-chat-view.h" #include "empathy-chat.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-theme-manager.h" #include "empathy-ui-utils.h" diff --git a/libempathy-gtk/empathy-chat-window.c b/libempathy-gtk/empathy-chat-window.c index b6409f6a..5acddc1e 100644 --- a/libempathy-gtk/empathy-chat-window.c +++ b/libempathy-gtk/empathy-chat-window.c @@ -43,7 +43,6 @@ #include #include #include -#include #include #include "empathy-chat-window.h" @@ -52,6 +51,7 @@ #include "empathy-contact-dialogs.h" #include "empathy-log-window.h" #include "empathy-new-chatroom-dialog.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-private-chat.h" #include "empathy-group-chat.h" diff --git a/libempathy-gtk/empathy-chat.c b/libempathy-gtk/empathy-chat.c index d07b84b0..fbdf6df4 100644 --- a/libempathy-gtk/empathy-chat.c +++ b/libempathy-gtk/empathy-chat.c @@ -40,12 +40,12 @@ #include #include #include -#include #include #include "empathy-chat.h" #include "empathy-chat-window.h" #include "empathy-geometry.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-spell.h" #include "empathy-spell-dialog.h" diff --git a/libempathy-gtk/empathy-conf.c b/libempathy-gtk/empathy-conf.c new file mode 100644 index 00000000..1ec3feeb --- /dev/null +++ b/libempathy-gtk/empathy-conf.c @@ -0,0 +1,373 @@ +/* -*- 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 + */ + +#include "config.h" + +#include + +#include + +#include + +#include "empathy-conf.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-gtk/empathy-conf.h b/libempathy-gtk/empathy-conf.h new file mode 100644 index 00000000..7e8e60e2 --- /dev/null +++ b/libempathy-gtk/empathy-conf.h @@ -0,0 +1,87 @@ +/* -*- 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 + +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__ */ + diff --git a/libempathy-gtk/empathy-group-chat.c b/libempathy-gtk/empathy-group-chat.c index 534f66c2..4f86ef2b 100644 --- a/libempathy-gtk/empathy-group-chat.c +++ b/libempathy-gtk/empathy-group-chat.c @@ -40,7 +40,6 @@ #include #include #include -#include #include "empathy-group-chat.h" #include "empathy-chat.h" @@ -51,6 +50,7 @@ //#include "empathy-sound.h" #include "empathy-images.h" #include "empathy-ui-utils.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #define DEBUG_DOMAIN "GroupChat" diff --git a/libempathy-gtk/empathy-main-window.c b/libempathy-gtk/empathy-main-window.c index 6b51ecca..951b80e9 100644 --- a/libempathy-gtk/empathy-main-window.c +++ b/libempathy-gtk/empathy-main-window.c @@ -28,7 +28,6 @@ #include #include -#include #include #include #include @@ -47,6 +46,7 @@ #include "empathy-presence-chooser.h" #include "empathy-ui-utils.h" #include "empathy-geometry.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-accounts-dialog.h" #include "empathy-about-dialog.h" diff --git a/libempathy-gtk/empathy-preferences.c b/libempathy-gtk/empathy-preferences.c index d6e21a73..50c9d566 100644 --- a/libempathy-gtk/empathy-preferences.c +++ b/libempathy-gtk/empathy-preferences.c @@ -30,8 +30,7 @@ #include #include -#include - +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-ui-utils.h" #include "empathy-theme-manager.h" diff --git a/libempathy-gtk/empathy-spell.c b/libempathy-gtk/empathy-spell.c index 88696cca..b6620118 100644 --- a/libempathy-gtk/empathy-spell.c +++ b/libempathy-gtk/empathy-spell.c @@ -33,9 +33,9 @@ #endif #include -#include #include "empathy-spell.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #define DEBUG_DOMAIN "Spell" diff --git a/libempathy-gtk/empathy-status-icon.c b/libempathy-gtk/empathy-status-icon.c index 24132e65..9e62a1e1 100644 --- a/libempathy-gtk/empathy-status-icon.c +++ b/libempathy-gtk/empathy-status-icon.c @@ -35,13 +35,13 @@ #include #include #include -#include #include #include #include "empathy-status-icon.h" #include "empathy-contact-dialogs.h" #include "empathy-presence-chooser.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-ui-utils.h" #include "empathy-accounts-dialog.h" diff --git a/libempathy-gtk/empathy-theme-manager.c b/libempathy-gtk/empathy-theme-manager.c index 6bece750..94276c96 100644 --- a/libempathy-gtk/empathy-theme-manager.c +++ b/libempathy-gtk/empathy-theme-manager.c @@ -26,9 +26,9 @@ #include #include -#include #include "empathy-chat-view.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-theme.h" #include "empathy-theme-boxes.h" diff --git a/libempathy-gtk/empathy-theme.c b/libempathy-gtk/empathy-theme.c index 1895b8cc..c8a9a0d4 100644 --- a/libempathy-gtk/empathy-theme.c +++ b/libempathy-gtk/empathy-theme.c @@ -24,12 +24,12 @@ #include #include -#include #include #include #include #include "empathy-chat.h" +#include "empathy-conf.h" #include "empathy-preferences.h" #include "empathy-theme.h" #include "empathy-smiley-manager.h" diff --git a/libempathy/Makefile.am b/libempathy/Makefile.am index e6711c3c..285dff18 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 71e520f7..00000000 --- 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 - */ - -#include "config.h" - -#include - -#include - -#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 7e8e60e2..00000000 --- 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 - -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__ */ - diff --git a/python/pyempathy/pyempathy.defs b/python/pyempathy/pyempathy.defs index d98f2605..f6c7e0b8 100644 --- a/python/pyempathy/pyempathy.defs +++ b/python/pyempathy/pyempathy.defs @@ -21,13 +21,6 @@ (gtype-id "EMPATHY_TYPE_CHATROOM_MANAGER") ) -(define-object Conf - (in-module "Empathy") - (parent "GObject") - (c-name "EmpathyConf") - (gtype-id "EMPATHY_TYPE_CONF") -) - (define-object Contact (in-module "Empathy") (parent "GObject") @@ -233,23 +226,6 @@ -;; From empathy-chandler-glue.h - -(define-function dbus_glib_marshal_empathy_chandler_BOOLEAN__STRING_BOXED_STRING_BOXED_UINT_UINT_POINTER - (c-name "dbus_glib_marshal_empathy_chandler_BOOLEAN__STRING_BOXED_STRING_BOXED_UINT_UINT_POINTER") - (return-type "none") - (parameters - '("GClosure*" "closure") - '("GValue*-return_value" "G_GNUC_UNUSED") - '("guint" "n_param_values") - '("const-GValue*" "param_values") - '("gpointer-invocation_hint" "G_GNUC_UNUSED") - '("gpointer" "marshal_data") - ) -) - - - ;; From empathy-chandler.h (define-function empathy_chandler_get_type @@ -435,125 +411,6 @@ -;; From empathy-conf.h - -(define-function empathy_conf_get_type - (c-name "empathy_conf_get_type") - (return-type "GType") -) - -(define-function empathy_conf_get - (c-name "empathy_conf_get") - (return-type "EmpathyConf*") -) - -(define-function empathy_conf_shutdown - (c-name "empathy_conf_shutdown") - (return-type "none") -) - -(define-method notify_add - (of-object "EmpathyConf") - (c-name "empathy_conf_notify_add") - (return-type "guint") - (parameters - '("const-gchar*" "key") - '("EmpathyConfNotifyFunc" "func") - '("gpointer" "data") - ) -) - -(define-method notify_remove - (of-object "EmpathyConf") - (c-name "empathy_conf_notify_remove") - (return-type "gboolean") - (parameters - '("guint" "id") - ) -) - -(define-method set_int - (of-object "EmpathyConf") - (c-name "empathy_conf_set_int") - (return-type "gboolean") - (parameters - '("const-gchar*" "key") - '("gint" "value") - ) -) - -(define-method get_int - (of-object "EmpathyConf") - (c-name "empathy_conf_get_int") - (return-type "gboolean") - (parameters - '("const-gchar*" "key") - '("gint*" "value") - ) -) - -(define-method set_bool - (of-object "EmpathyConf") - (c-name "empathy_conf_set_bool") - (return-type "gboolean") - (parameters - '("const-gchar*" "key") - '("gboolean" "value") - ) -) - -(define-method get_bool - (of-object "EmpathyConf") - (c-name "empathy_conf_get_bool") - (return-type "gboolean") - (parameters - '("const-gchar*" "key") - '("gboolean*" "value") - ) -) - -(define-method set_string - (of-object "EmpathyConf") - (c-name "empathy_conf_set_string") - (return-type "gboolean") - (parameters - '("const-gchar*" "key") - '("const-gchar*" "value") - ) -) - -(define-method get_string - (of-object "EmpathyConf") - (c-name "empathy_conf_get_string") - (return-type "gboolean") - (parameters - '("const-gchar*" "key") - '("gchar**" "value") - ) -) - -(define-method set_string_list - (of-object "EmpathyConf") - (c-name "empathy_conf_set_string_list") - (return-type "gboolean") - (parameters - '("const-gchar*" "key") - '("GSList*" "value") - ) -) - -(define-method get_string_list - (of-object "EmpathyConf") - (c-name "empathy_conf_get_string_list") - (return-type "gboolean") - (parameters - '("const-gchar*" "key") - '("GSList**" "value") - ) -) - - - ;; From empathy-contact-factory.h (define-function empathy_contact_factory_get_type @@ -977,47 +834,6 @@ -;; From empathy-enum-types.h - -(define-function empathy_reg_ex_type_get_type - (c-name "empathy_reg_ex_type_get_type") - (return-type "GType") -) - -(define-function empathy_message_type_get_type - (c-name "empathy_message_type_get_type") - (return-type "GType") -) - -(define-function empathy_capabilities_get_type - (c-name "empathy_capabilities_get_type") - (return-type "GType") -) - -(define-function empathy_tp_call_status_get_type - (c-name "empathy_tp_call_status_get_type") - (return-type "GType") -) - - - -;; From empathy-filter-glue.h - -(define-function dbus_glib_marshal_empathy_filter_BOOLEAN__STRING_BOXED_STRING_BOXED_UINT_UINT_UINT_POINTER - (c-name "dbus_glib_marshal_empathy_filter_BOOLEAN__STRING_BOXED_STRING_BOXED_UINT_UINT_UINT_POINTER") - (return-type "none") - (parameters - '("GClosure*" "closure") - '("GValue*-return_value" "G_GNUC_UNUSED") - '("guint" "n_param_values") - '("const-GValue*" "param_values") - '("gpointer-invocation_hint" "G_GNUC_UNUSED") - '("gpointer" "marshal_data") - ) -) - - - ;; From empathy-filter.h (define-function empathy_filter_get_type @@ -1273,10 +1089,6 @@ -;; From empathy-marshal.h - - - ;; From empathy-message.h (define-function empathy_message_get_gtype @@ -2248,10 +2060,6 @@ -;; From stamp-empathy-enum-types.h - - - ;; From tp-stream-engine-gen.h (define-function dbus_g_proxy_begin_call diff --git a/python/pyempathy/pyempathy.override b/python/pyempathy/pyempathy.override index d1f43483..a21700fc 100644 --- a/python/pyempathy/pyempathy.override +++ b/python/pyempathy/pyempathy.override @@ -6,7 +6,6 @@ headers #include "empathy-chandler.h" #include "empathy-chatroom-manager.h" #include "empathy-chatroom.h" -#include "empathy-conf.h" #include "empathy-contact-groups.h" #include "empathy-contact-list.h" #include "empathy-contact-manager.h" diff --git a/python/pyempathygtk/pyempathygtk.defs b/python/pyempathygtk/pyempathygtk.defs index f63e16d4..a8412437 100644 --- a/python/pyempathygtk/pyempathygtk.defs +++ b/python/pyempathygtk/pyempathygtk.defs @@ -63,6 +63,13 @@ (gtype-id "EMPATHY_TYPE_CHAT_WINDOW") ) +(define-object Conf + (in-module "Empathy") + (parent "GObject") + (c-name "EmpathyConf") + (gtype-id "EMPATHY_TYPE_CONF") +) + (define-object ContactListStore (in-module "Empathy") (parent "GtkTreeStore") @@ -983,6 +990,125 @@ +;; From empathy-conf.h + +(define-function empathy_conf_get_type + (c-name "empathy_conf_get_type") + (return-type "GType") +) + +(define-function empathy_conf_get + (c-name "empathy_conf_get") + (return-type "EmpathyConf*") +) + +(define-function empathy_conf_shutdown + (c-name "empathy_conf_shutdown") + (return-type "none") +) + +(define-method notify_add + (of-object "EmpathyConf") + (c-name "empathy_conf_notify_add") + (return-type "guint") + (parameters + '("const-gchar*" "key") + '("EmpathyConfNotifyFunc" "func") + '("gpointer" "data") + ) +) + +(define-method notify_remove + (of-object "EmpathyConf") + (c-name "empathy_conf_notify_remove") + (return-type "gboolean") + (parameters + '("guint" "id") + ) +) + +(define-method set_int + (of-object "EmpathyConf") + (c-name "empathy_conf_set_int") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gint" "value") + ) +) + +(define-method get_int + (of-object "EmpathyConf") + (c-name "empathy_conf_get_int") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gint*" "value") + ) +) + +(define-method set_bool + (of-object "EmpathyConf") + (c-name "empathy_conf_set_bool") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gboolean" "value") + ) +) + +(define-method get_bool + (of-object "EmpathyConf") + (c-name "empathy_conf_get_bool") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gboolean*" "value") + ) +) + +(define-method set_string + (of-object "EmpathyConf") + (c-name "empathy_conf_set_string") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("const-gchar*" "value") + ) +) + +(define-method get_string + (of-object "EmpathyConf") + (c-name "empathy_conf_get_string") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("gchar**" "value") + ) +) + +(define-method set_string_list + (of-object "EmpathyConf") + (c-name "empathy_conf_set_string_list") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GSList*" "value") + ) +) + +(define-method get_string_list + (of-object "EmpathyConf") + (c-name "empathy_conf_get_string_list") + (return-type "gboolean") + (parameters + '("const-gchar*" "key") + '("GSList**" "value") + ) +) + + + ;; From empathy-contact-dialogs.h (define-function empathy_subscription_dialog_show @@ -1302,35 +1428,6 @@ -;; From empathy-gtk-enum-types.h - -(define-function empathy_contact_widget_flags_get_type - (c-name "empathy_contact_widget_flags_get_type") - (return-type "GType") -) - -(define-function empathy_contact_list_store_sort_get_type - (c-name "empathy_contact_list_store_sort_get_type") - (return-type "GType") -) - -(define-function empathy_contact_list_store_col_get_type - (c-name "empathy_contact_list_store_col_get_type") - (return-type "GType") -) - -(define-function empathy_contact_list_features_get_type - (c-name "empathy_contact_list_features_get_type") - (return-type "GType") -) - -(define-function empathy_chat_view_block_get_type - (c-name "empathy_chat_view_block_get_type") - (return-type "GType") -) - - - ;; From empathy-images.h @@ -2030,7 +2127,3 @@ ) - -;; From stamp-empathy-gtk-enum-types.h - - diff --git a/python/pyempathygtk/pyempathygtk.override b/python/pyempathygtk/pyempathygtk.override index f1515176..26eb1011 100644 --- a/python/pyempathygtk/pyempathygtk.override +++ b/python/pyempathygtk/pyempathygtk.override @@ -17,6 +17,7 @@ headers #include "empathy-chatrooms-window.h" #include "empathy-chat-view.h" #include "empathy-chat-window.h" +#include "empathy-conf.h" #include "empathy-contact-dialogs.h" #include "empathy-contact-list-store.h" #include "empathy-contact-list-view.h"