diff options
author | Stefano Karapetsas <[email protected]> | 2012-08-03 12:26:32 +0200 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2012-08-03 12:26:32 +0200 |
commit | 2d7e34441f4d33dc1edb5e9871b66b4977069bae (patch) | |
tree | ba425475d77dcca3c86c22b13db0b44ba4912bd9 /src/daemon | |
parent | 597a9064e4d2df85d53726928e576a9be53d22fb (diff) | |
download | mate-notification-daemon-2d7e34441f4d33dc1edb5e9871b66b4977069bae.tar.bz2 mate-notification-daemon-2d7e34441f4d33dc1edb5e9871b66b4977069bae.tar.xz |
migrate to GSettings
Diffstat (limited to 'src/daemon')
-rw-r--r-- | src/daemon/daemon.c | 32 | ||||
-rw-r--r-- | src/daemon/daemon.h | 15 | ||||
-rw-r--r-- | src/daemon/engines.c | 11 |
3 files changed, 21 insertions, 37 deletions
diff --git a/src/daemon/daemon.c b/src/daemon/daemon.c index 7404f96..a0e1a50 100644 --- a/src/daemon/daemon.c +++ b/src/daemon/daemon.c @@ -105,8 +105,6 @@ struct _NotifyDaemonPrivate { GHashTable* notification_hash; gboolean url_clicked_lock; - guint mateconf_cnxn; - NotifyStackLocation stack_location; NotifyScreen** screens; int n_screens; @@ -318,15 +316,13 @@ static void create_screens(NotifyDaemon* daemon) } } -static void on_popup_location_changed(MateConfClient* client, guint cnxn_id, MateConfEntry* entry, NotifyDaemon* daemon) +static void on_popup_location_changed(GSettings *settings, gchar *key, NotifyDaemon* daemon) { NotifyStackLocation stack_location; const char* slocation; - MateConfValue* value; int i; - value = mateconf_entry_get_value(entry); - slocation = (value != NULL ? mateconf_value_get_string(value) : NULL); + slocation = g_settings_get_string(daemon->gsettings, key); if (slocation != NULL && *slocation != '\0') { @@ -334,7 +330,7 @@ static void on_popup_location_changed(MateConfClient* client, guint cnxn_id, Mat } else { - mateconf_client_set_string(client, MATECONF_KEY_POPUP_LOCATION, popup_stack_locations[POPUP_STACK_DEFAULT_INDEX].identifier, NULL); + g_settings_set_string (daemon->gsettings, GSETTINGS_KEY_POPUP_LOCATION, popup_stack_locations[POPUP_STACK_DEFAULT_INDEX].identifier); stack_location = NOTIFY_STACK_LOCATION_DEFAULT; } @@ -356,7 +352,6 @@ static void on_popup_location_changed(MateConfClient* client, guint cnxn_id, Mat static void notify_daemon_init(NotifyDaemon* daemon) { - MateConfClient* client; char* location; daemon->priv = G_TYPE_INSTANCE_GET_PRIVATE(daemon, NOTIFY_TYPE_DAEMON, NotifyDaemonPrivate); @@ -366,15 +361,13 @@ static void notify_daemon_init(NotifyDaemon* daemon) add_exit_timeout(daemon); - client = mateconf_client_get_default(); - mateconf_client_add_dir(client, MATECONF_KEY_DAEMON, MATECONF_CLIENT_PRELOAD_NONE, NULL); + daemon->gsettings = g_settings_new (GSETTINGS_SCHEMA); - location = mateconf_client_get_string(client, MATECONF_KEY_POPUP_LOCATION, NULL); + location = g_settings_get_string (daemon->gsettings, GSETTINGS_KEY_POPUP_LOCATION); daemon->priv->stack_location = get_stack_location_from_string(location); g_free(location); - daemon->priv->mateconf_cnxn = mateconf_client_notify_add(client, MATECONF_KEY_POPUP_LOCATION, (MateConfClientNotifyFunc) on_popup_location_changed, daemon, NULL, NULL); - g_object_unref(client); + g_signal_connect (daemon->gsettings, "changed::" GSETTINGS_KEY_POPUP_LOCATION, G_CALLBACK (on_popup_location_changed), daemon); daemon->priv->n_screens = 0; daemon->priv->screens = NULL; @@ -421,14 +414,9 @@ static void destroy_screens(NotifyDaemon* daemon) static void notify_daemon_finalize(GObject* object) { NotifyDaemon* daemon; - MateConfClient* client; daemon = NOTIFY_DAEMON(object); - client = mateconf_client_get_default(); - mateconf_client_notify_remove(client, daemon->priv->mateconf_cnxn); - g_object_unref(client); - if (g_hash_table_size(daemon->priv->monitored_window_hash) > 0) { gdk_window_remove_filter(NULL, (GdkFilterFunc) _notify_x11_filter, daemon); @@ -1333,7 +1321,7 @@ gboolean notify_daemon_notify_handler(NotifyDaemon* daemon, const char* app_name gboolean sound_enabled; gint i; GdkPixbuf* pixbuf; - MateConfClient* mateconf_client; + GSettings* gsettings; if (g_hash_table_size (priv->notification_hash) > MAX_NOTIFICATIONS) { @@ -1402,9 +1390,9 @@ gboolean notify_daemon_notify_handler(NotifyDaemon* daemon, const char* app_name } /* Deal with sound hints */ - mateconf_client = mateconf_client_get_default (); - sound_enabled = mateconf_client_get_bool (mateconf_client, MATECONF_KEY_SOUND_ENABLED, NULL); - g_object_unref (mateconf_client); + gsettings = g_settings_new (GSETTINGS_SCHEMA); + sound_enabled = g_settings_get_boolean (gsettings, GSETTINGS_KEY_SOUND_ENABLED); + g_object_unref (gsettings); data = (GValue *) g_hash_table_lookup (hints, "suppress-sound"); diff --git a/src/daemon/daemon.h b/src/daemon/daemon.h index 603ee22..b405fad 100644 --- a/src/daemon/daemon.h +++ b/src/daemon/daemon.h @@ -24,18 +24,18 @@ #ifndef NOTIFY_DAEMON_H #define NOTIFY_DAEMON_H -#include <mateconf/mateconf-client.h> #include <glib.h> #include <glib-object.h> +#include <gio/gio.h> #include <dbus/dbus-glib.h> #include <dbus/dbus-glib-lowlevel.h> -#define MATECONF_KEY_DAEMON "/apps/mate-notification-daemon" -#define MATECONF_KEY_THEME MATECONF_KEY_DAEMON "/theme" -#define MATECONF_KEY_POPUP_LOCATION MATECONF_KEY_DAEMON "/popup_location" -#define MATECONF_KEY_SOUND_ENABLED MATECONF_KEY_DAEMON "/sound_enabled" -#define MATECONF_KEY_DEFAULT_SOUND MATECONF_KEY_DAEMON "/default_sound" +#define GSETTINGS_SCHEMA "org.mate.NotificationDaemon" +#define GSETTINGS_KEY_THEME "theme" +#define GSETTINGS_KEY_POPUP_LOCATION "popup-location" +#define GSETTINGS_KEY_SOUND_ENABLED "sound-enabled" +#define GSETTINGS_KEY_DEFAULT_SOUND "default-sound" #define NOTIFY_TYPE_DAEMON (notify_daemon_get_type()) #define NOTIFY_DAEMON(obj) \ @@ -70,6 +70,7 @@ typedef struct _NotifyDaemonPrivate NotifyDaemonPrivate; struct _NotifyDaemon { GObject parent; + GSettings* gsettings; /*< private > */ NotifyDaemonPrivate* priv; @@ -95,8 +96,6 @@ gboolean notify_daemon_get_capabilities(NotifyDaemon* daemon, char*** out_caps); gboolean notify_daemon_get_server_information(NotifyDaemon* daemon, char** out_name, char** out_vendor, char** out_version, char** out_spec_ver); -MateConfClient* get_mateconf_client(void); - #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/src/daemon/engines.c b/src/daemon/engines.c index 6d30f94..23a2ade 100644 --- a/src/daemon/engines.c +++ b/src/daemon/engines.c @@ -23,7 +23,6 @@ #include "config.h" -#include <mateconf/mateconf-client.h> #include "daemon.h" #include "engines.h" @@ -155,7 +154,7 @@ static void theme_engine_unref(ThemeEngine* engine) } } -static void theme_changed_cb(MateConfClient* client, guint cnxn_id, MateConfEntry* entry, gpointer user_data) +static void theme_changed_cb(GSettings *settings, gchar *key, gpointer user_data) { if (active_engine == NULL) { @@ -172,16 +171,14 @@ static ThemeEngine* get_theme_engine(void) { if (active_engine == NULL) { - MateConfClient* client = mateconf_client_get_default(); - char* enginename = mateconf_client_get_string(client, MATECONF_KEY_THEME, NULL); + GSettings* gsettings = g_settings_new (GSETTINGS_SCHEMA); + char* enginename = g_settings_get_string(gsettings, GSETTINGS_KEY_THEME); if (theme_prop_notify_id == 0) { - theme_prop_notify_id = mateconf_client_notify_add(client, MATECONF_KEY_THEME, theme_changed_cb, NULL, NULL, NULL); + theme_prop_notify_id = g_signal_connect (gsettings, "changed::" GSETTINGS_KEY_THEME, G_CALLBACK (theme_changed_cb), NULL); } - g_object_unref(client); - if (enginename == NULL) { active_engine = load_theme_engine("standard"); |