From 2d7e34441f4d33dc1edb5e9871b66b4977069bae Mon Sep 17 00:00:00 2001 From: Stefano Karapetsas Date: Fri, 3 Aug 2012 12:26:32 +0200 Subject: migrate to GSettings --- configure.ac | 16 +++--- data/Makefile.am | 19 ++----- data/mate-notification-daemon.schemas.in | 53 -------------------- data/org.mate.NotificationDaemon.gschema.xml | 24 +++++++++ src/capplet/mate-notification-properties.c | 75 ++++++---------------------- src/daemon/daemon.c | 32 ++++-------- src/daemon/daemon.h | 15 +++--- src/daemon/engines.c | 11 ++-- 8 files changed, 72 insertions(+), 173 deletions(-) delete mode 100644 data/mate-notification-daemon.schemas.in create mode 100644 data/org.mate.NotificationDaemon.gschema.xml diff --git a/configure.ac b/configure.ac index 14a185f..05e7494 100644 --- a/configure.ac +++ b/configure.ac @@ -3,7 +3,7 @@ dnl Process this file with autoconf to create configure. dnl ################################################################ dnl # Initialize autoconf dnl ################################################################ -AC_INIT([mate-notification-daemon], [1.4.0], [http://www.mate-desktop.org]) +AC_INIT([mate-notification-daemon], [1.5.0], [http://www.mate-desktop.org]) AC_PREREQ(2.63) AC_CONFIG_HEADERS([config.h]) @@ -111,17 +111,18 @@ dnl --------------------------------------------------------------------------- dnl Requirements for the daemon dnl --------------------------------------------------------------------------- REQ_GLIB_VERSION=2.18.0 +REQ_GIO_VERSION=2.25.0 REQ_DBUS_VERSION=0.78 REQ_LIBCANBERRA_GTK_VERSION=0.4 PKG_CHECK_MODULES(GMODULE,gmodule-2.0,[GMODULE_ADD="gmodule-2.0"],[GMODULE_ADD=""]) pkg_modules=" gtk+-$GTK_API_VERSION >= $GTK_REQUIRED, \ glib-2.0 >= $REQ_GLIB_VERSION, \ + gio-2.0 >= $REQ_GIO_VERSION, \ $GMODULE_ADD \ dbus-1 >= $REQ_DBUS_VERSION, \ dbus-glib-1 >= $REQ_DBUS_VERSION, \ libcanberra-gtk >= $REQ_LIBCANBERRA_GTK_VERSION, \ - mateconf-2.0, \ libmatewnck \ x11 \ " @@ -132,7 +133,7 @@ AC_SUBST(NOTIFICATION_DAEMON_LIBS) dnl --------------------------------------------------------------------------- dnl Requirements for the setup tool dnl --------------------------------------------------------------------------- -PKG_CHECK_MODULES(NOTIFICATION_CAPPLET, glib-2.0 >= $REQ_GLIB_VERSION gtk+-$GTK_API_VERSION >= $GTK_REQUIRED mateconf-2.0 libmatenotify dbus-1 dbus-glib-1) +PKG_CHECK_MODULES(NOTIFICATION_CAPPLET, glib-2.0 >= $REQ_GLIB_VERSION gio-2.0 >= $REQ_GIO_VERSION gtk+-$GTK_API_VERSION >= $GTK_REQUIRED libmatenotify dbus-1 dbus-glib-1) AC_SUBST(NOTIFICATION_CAPPLET_CFLAGS) AC_SUBST(NOTIFICATION_CAPPLET_LIBS) @@ -151,12 +152,11 @@ AM_CONDITIONAL(HAVE_GDK, test "x$have_gdk" = "xyes") AC_SUBST(GDK_CFLAGS) AC_SUBST(GDK_LIBS) -AM_MATECONF_SOURCE_2 -AC_PATH_PROG(MATECONFTOOL, mateconftool-2, no) +dnl +dnl Enable gsettigns schema macros +dnl -if test "x$MATECONFTOOL" = "xno"; then - AC_MSG_ERROR([mateconftool-2 executable not found in your path - should be installed with Gconf]) -fi +GLIB_GSETTINGS dnl dnl Check the D-BUS version. diff --git a/data/Makefile.am b/data/Makefile.am index 4a80715..32e1d94 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -16,21 +16,11 @@ iconscalable_DATA = icons/scalable/mate-notification-properties.svg servicedir = $(DBUS_SERVICES_DIR) service_DATA = org.freedesktop.mate.Notifications.service -schemasdir = $(MATECONF_SCHEMA_FILE_DIR) -schemas_in_files = mate-notification-daemon.schemas.in -schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) - -@INTLTOOL_SCHEMAS_RULE@ - -if MATECONF_SCHEMAS_INSTALL -install-data-local: - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(schemas_DATA) -else -install-data-local: -endif +gsettings_SCHEMAS = org.mate.NotificationDaemon.gschema.xml +@GSETTINGS_RULES@ EXTRA_DIST = \ - $(schemas_in_files) \ + $(gsettings_SCHEMAS) \ $(service_DATA) \ $(icon16_DATA) \ $(icon22_DATA) \ @@ -39,9 +29,6 @@ EXTRA_DIST = \ $(icon48_DATA) \ $(iconscalable_DATA) -CLEANFILES = $(schemas_DATA) - - gtk_update_icon_cache = gtk-update-icon-cache -f -t $(datadir)/icons/hicolor install-data-hook: update-icon-cache diff --git a/data/mate-notification-daemon.schemas.in b/data/mate-notification-daemon.schemas.in deleted file mode 100644 index 117d144..0000000 --- a/data/mate-notification-daemon.schemas.in +++ /dev/null @@ -1,53 +0,0 @@ - - - - - /schemas/apps/mate-notification-daemon/popup_location - /apps/mate-notification-daemon/popup_location - mate-notification-daemon - string - bottom_right - - Popup location - Default popup location on the workspace for stack notifications. Allowed values: "top_left","top_right","bottom_left" and "bottom_right" - - - - - /schemas/apps/mate-notification-daemon/theme - /apps/mate-notification-daemon/theme - mate-notification-daemon - string - default - - Current theme - The theme used when displaying notifications. - - - - - /schemas/apps/mate-notification-daemon/sound_enabled - /apps/mate-notification-daemon/sound_enabled - mate-notification-daemon - bool - 1 - - Sound Enabled - Turns on and off sound support for notifications. - - - - - /schemas/apps/mate-notification-daemon/default_sound - /apps/mate-notification-daemon/default_sound - mate-notification-daemon - string - - - Default Sound - The default sound file used unless a notification supplies the 'sound-file' or 'suppress-sound' hint. Leave empty for no default sound. - - - - - diff --git a/data/org.mate.NotificationDaemon.gschema.xml b/data/org.mate.NotificationDaemon.gschema.xml new file mode 100644 index 0000000..14c2bd2 --- /dev/null +++ b/data/org.mate.NotificationDaemon.gschema.xml @@ -0,0 +1,24 @@ + + + + 'bottom_right' + Popup location + Default popup location on the workspace for stack notifications. Allowed values: "top_left","top_right","bottom_left" and "bottom_right" + + + 'default' + Current theme + The theme used when displaying notifications. + + + true + Sound Enabled + Turns on and off sound support for notifications. + + + '' + Default Sound + The default sound file used unless a notification supplies the 'sound-file' or 'suppress-sound' hint. Leave empty for no default sound. + + + diff --git a/src/capplet/mate-notification-properties.c b/src/capplet/mate-notification-properties.c index 5cd07bb..2c5612e 100644 --- a/src/capplet/mate-notification-properties.c +++ b/src/capplet/mate-notification-properties.c @@ -24,22 +24,20 @@ #include #include #include -#include +#include #include #include #include "stack.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 N_LISTENERS 2 +#define GSETTINGS_SCHEMA "org.mate.NotificationDaemon" +#define GSETTINGS_KEY_THEME "theme" +#define GSETTINGS_KEY_POPUP_LOCATION "popup-location" #define NOTIFICATION_UI_FILE "mate-notification-properties.ui" typedef struct { - MateConfClient* client; + GSettings* gsettings; GtkWidget* dialog; GtkWidget* position_combo; @@ -47,10 +45,6 @@ typedef struct { GtkWidget* preview_button; NotifyNotification* preview; - - guint listeners[N_LISTENERS]; - int n_listeners; - int expected_listeners; } NotificationAppletDialog; enum { @@ -66,19 +60,14 @@ enum { N_COLUMNS_THEME }; -static void notification_properties_location_notify(MateConfClient* client, guint cnx_id, MateConfEntry* entry, NotificationAppletDialog* dialog) +static void notification_properties_location_notify(GSettings *settings, gchar *key, NotificationAppletDialog* dialog) { GtkTreeModel* model; GtkTreeIter iter; const char* location; gboolean valid; - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - { - return; - } - - location = mateconf_value_get_string(entry->value); + location = g_settings_get_string(dialog->gsettings, key); model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->position_combo)); valid = gtk_tree_model_get_iter_first(model, &iter); @@ -114,7 +103,7 @@ static void notification_properties_location_changed(GtkComboBox* widget, Notifi gtk_tree_model_get(model, &iter, NOTIFY_POSITION_NAME, &location, -1); - mateconf_client_set_string(dialog->client, MATECONF_KEY_POPUP_LOCATION, location, NULL); + g_settings_set_string (dialog->gsettings, GSETTINGS_KEY_POPUP_LOCATION, location); g_free(location); } @@ -128,7 +117,7 @@ static void notification_properties_dialog_setup_positions(NotificationAppletDia model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->position_combo)); g_signal_connect(dialog->position_combo, "changed", G_CALLBACK(notification_properties_location_changed), dialog); - location = mateconf_client_get_string(dialog->client, MATECONF_KEY_POPUP_LOCATION, NULL); + location = g_settings_get_string(dialog->gsettings, GSETTINGS_KEY_POPUP_LOCATION); for (valid = gtk_tree_model_get_iter_first(model, &iter); valid; valid = gtk_tree_model_iter_next(model, &iter)) { @@ -146,19 +135,13 @@ static void notification_properties_dialog_setup_positions(NotificationAppletDia g_free(key); } - dialog->listeners[dialog->n_listeners] = mateconf_client_notify_add(dialog->client, MATECONF_KEY_POPUP_LOCATION, (MateConfClientNotifyFunc) notification_properties_location_notify, dialog, NULL, NULL); - dialog->n_listeners++; + g_signal_connect (dialog->gsettings, "changed::" GSETTINGS_KEY_POPUP_LOCATION, G_CALLBACK (notification_properties_location_notify), dialog); g_free(location); } -static void notification_properties_theme_notify(MateConfClient* client, guint cnx_id, MateConfEntry* entry, NotificationAppletDialog* dialog) +static void notification_properties_theme_notify(GSettings *settings, gchar *key, NotificationAppletDialog* dialog) { - if (!entry->value || entry->value->type != MATECONF_VALUE_STRING) - { - return; - } - - const char* theme = mateconf_value_get_string(entry->value); + const char* theme = g_settings_get_string(dialog->gsettings, key); GtkTreeModel* model = gtk_combo_box_get_model(GTK_COMBO_BOX(dialog->theme_combo)); @@ -195,7 +178,7 @@ static void notification_properties_theme_changed(GtkComboBox* widget, Notificat } gtk_tree_model_get(model, &iter, NOTIFY_THEME_NAME, &theme, -1); - mateconf_client_set_string(dialog->client, MATECONF_KEY_THEME, theme, NULL); + g_settings_set_string(dialog->gsettings, GSETTINGS_KEY_THEME, theme); g_free(theme); } @@ -267,8 +250,7 @@ static void notification_properties_dialog_setup_themes(NotificationAppletDialog g_warning("Error opening themes dir"); } - - theme = mateconf_client_get_string(dialog->client, MATECONF_KEY_THEME, NULL); + theme = g_settings_get_string(dialog->gsettings, GSETTINGS_KEY_THEME); for (valid = gtk_tree_model_get_iter_first(GTK_TREE_MODEL(store), &iter); valid; valid = gtk_tree_model_iter_next(GTK_TREE_MODEL(store), &iter)) { @@ -286,8 +268,7 @@ static void notification_properties_dialog_setup_themes(NotificationAppletDialog g_free(key); } - dialog->listeners[dialog->n_listeners] = mateconf_client_notify_add(dialog->client, MATECONF_KEY_THEME, (MateConfClientNotifyFunc) notification_properties_theme_notify, dialog, NULL, NULL); - dialog->n_listeners++; + g_signal_connect (dialog->gsettings, "changed::" GSETTINGS_KEY_THEME, G_CALLBACK (notification_properties_theme_notify), dialog); g_free(theme); } @@ -408,16 +389,11 @@ static gboolean notification_properties_dialog_init(NotificationAppletDialog* di g_signal_connect(dialog->dialog, "response", G_CALLBACK(notification_properties_dialog_response), dialog); g_signal_connect(dialog->dialog, "destroy", G_CALLBACK(notification_properties_dialog_destroyed), dialog); - dialog->client = mateconf_client_get_default(); - mateconf_client_add_dir(dialog->client, MATECONF_KEY_DAEMON, MATECONF_CLIENT_PRELOAD_ONELEVEL, NULL); - - dialog->expected_listeners = N_LISTENERS; - dialog->n_listeners = 0; + dialog->gsettings = g_settings_new (GSETTINGS_SCHEMA); notification_properties_dialog_setup_themes(dialog); notification_properties_dialog_setup_positions(dialog); - g_assert(dialog->n_listeners == dialog->expected_listeners); gtk_widget_show(dialog->dialog); dialog->preview = NULL; @@ -433,25 +409,6 @@ static void notification_properties_dialog_finalize(NotificationAppletDialog* di dialog->dialog = NULL; } - if (dialog->client != NULL) - { - int i; - - for (i = 0; i < dialog->n_listeners; i++) - { - if (dialog->listeners[i]) - { - mateconf_client_notify_remove(dialog->client, dialog->listeners[i]); - dialog->listeners[i] = 0; - } - } - - dialog->n_listeners = 0; - mateconf_client_remove_dir(dialog->client, MATECONF_KEY_DAEMON, NULL); - g_object_unref(dialog->client); - dialog->client = NULL; - } - if (dialog->preview) { notify_notification_close(dialog->preview, NULL); 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 #include #include +#include #include #include -#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 #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"); -- cgit v1.2.1