diff options
author | Stefano Karapetsas <[email protected]> | 2012-11-07 17:39:29 +0100 |
---|---|---|
committer | Stefano Karapetsas <[email protected]> | 2012-11-07 17:39:29 +0100 |
commit | dfbc1cba50abc338d17394b702d05009fe9baa7c (patch) | |
tree | a24a8c9217440f4a662eb33abc5ebf6fe19c6c5b | |
parent | cf53f331edaf19d05a790d9334bfffc3c923c7ca (diff) | |
download | mate-media-dfbc1cba50abc338d17394b702d05009fe9baa7c.tar.bz2 mate-media-dfbc1cba50abc338d17394b702d05009fe9baa7c.tar.xz |
sound-theme: port to gsettings
-rw-r--r-- | sound-theme/gvc-sound-theme-chooser.c | 96 | ||||
-rw-r--r-- | sound-theme/gvc-sound-theme-editor.c | 100 |
2 files changed, 66 insertions, 130 deletions
diff --git a/sound-theme/gvc-sound-theme-chooser.c b/sound-theme/gvc-sound-theme-chooser.c index 75f23bb..6109737 100644 --- a/sound-theme/gvc-sound-theme-chooser.c +++ b/sound-theme/gvc-sound-theme-chooser.c @@ -29,12 +29,11 @@ #include <glib.h> #include <glib/gi18n.h> +#include <gio/gio.h> #include <gtk/gtk.h> #include <canberra-gtk.h> #include <libxml/tree.h> -#include <mateconf/mateconf-client.h> - #include "gvc-sound-theme-chooser.h" #include "sound-theme-file-utils.h" @@ -47,9 +46,8 @@ struct GvcSoundThemeChooserPrivate GtkWidget *theme_box; GtkWidget *selection_box; GtkWidget *click_feedback_button; - MateConfClient *client; - guint sounds_dir_id; - guint marco_dir_id; + GSettings *sound_settings; + GSettings *marco_settings; }; static void gvc_sound_theme_chooser_class_init (GvcSoundThemeChooserClass *klass); @@ -58,12 +56,12 @@ static void gvc_sound_theme_chooser_finalize (GObject *object); G_DEFINE_TYPE (GvcSoundThemeChooser, gvc_sound_theme_chooser, GTK_TYPE_VBOX) -#define KEY_SOUNDS_DIR "/desktop/mate/sound" -#define EVENT_SOUNDS_KEY KEY_SOUNDS_DIR "/event_sounds" -#define INPUT_SOUNDS_KEY KEY_SOUNDS_DIR "/input_feedback_sounds" -#define SOUND_THEME_KEY KEY_SOUNDS_DIR "/theme_name" -#define KEY_MARCO_DIR "/apps/marco/general" -#define AUDIO_BELL_KEY KEY_MARCO_DIR "/audible_bell" +#define KEY_SOUNDS_SCHEMA "org.mate.sound" +#define EVENT_SOUNDS_KEY "event-sounds" +#define INPUT_SOUNDS_KEY "input-feedback-sounds" +#define SOUND_THEME_KEY "theme-name" +#define KEY_MARCO_SCHEMA "org.mate.Marco.general" +#define AUDIO_BELL_KEY "audible-bell" #define DEFAULT_ALERT_ID "__default" #define CUSTOM_THEME_NAME "__custom" @@ -111,13 +109,13 @@ on_combobox_changed (GtkComboBox *widget, /* special case for no sounds */ if (strcmp (theme_name, NO_SOUNDS_THEME_NAME) == 0) { - mateconf_client_set_bool (chooser->priv->client, EVENT_SOUNDS_KEY, FALSE, NULL); + g_settings_set_boolean (chooser->priv->sound_settings, EVENT_SOUNDS_KEY, FALSE); return; } else { - mateconf_client_set_bool (chooser->priv->client, EVENT_SOUNDS_KEY, TRUE, NULL); + g_settings_set_boolean (chooser->priv->sound_settings, EVENT_SOUNDS_KEY, TRUE); } - mateconf_client_set_string (chooser->priv->client, SOUND_THEME_KEY, theme_name, NULL); + g_settings_set_string (chooser->priv->sound_settings, SOUND_THEME_KEY, theme_name); g_free (theme_name); @@ -949,15 +947,15 @@ update_theme (GvcSoundThemeChooser *chooser) gboolean bell_enabled; gboolean feedback_enabled; - bell_enabled = mateconf_client_get_bool (chooser->priv->client, AUDIO_BELL_KEY, NULL); + bell_enabled = g_settings_get_boolean (chooser->priv->marco_settings, AUDIO_BELL_KEY); //set_audible_bell_enabled (chooser, bell_enabled); - feedback_enabled = mateconf_client_get_bool (chooser->priv->client, INPUT_SOUNDS_KEY, NULL); + feedback_enabled = g_settings_get_boolean (chooser->priv->sound_settings, INPUT_SOUNDS_KEY); set_input_feedback_enabled (chooser, feedback_enabled); - events_enabled = mateconf_client_get_bool (chooser->priv->client, EVENT_SOUNDS_KEY, NULL); + events_enabled = g_settings_get_boolean (chooser->priv->sound_settings, EVENT_SOUNDS_KEY); if (events_enabled) { - theme_name = mateconf_client_get_string (chooser->priv->client, SOUND_THEME_KEY, NULL); + theme_name = g_settings_get_string (chooser->priv->sound_settings, SOUND_THEME_KEY); } else { theme_name = g_strdup (NO_SOUNDS_THEME_NAME); } @@ -1010,26 +1008,14 @@ on_click_feedback_toggled (GtkToggleButton *button, enabled = gtk_toggle_button_get_active (button); - mateconf_client_set_bool (chooser->priv->client, INPUT_SOUNDS_KEY, enabled, NULL); + g_settings_set_boolean (chooser->priv->sound_settings, INPUT_SOUNDS_KEY, enabled); } static void -on_key_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +on_key_changed (GSettings *settings, + gchar *key, GvcSoundThemeChooser *chooser) { - const char *key; - MateConfValue *value; - - key = mateconf_entry_get_key (entry); - - if (! g_str_has_prefix (key, KEY_SOUNDS_DIR) - && ! g_str_has_prefix (key, KEY_MARCO_DIR)) { - return; - } - - value = mateconf_entry_get_value (entry); if (strcmp (key, EVENT_SOUNDS_KEY) == 0) { update_theme (chooser); } else if (strcmp (key, SOUND_THEME_KEY) == 0) { @@ -1088,7 +1074,8 @@ gvc_sound_theme_chooser_init (GvcSoundThemeChooser *chooser) gtk_box_pack_start (GTK_BOX (chooser->priv->theme_box), chooser->priv->combo_box, FALSE, FALSE, 6); gtk_label_set_mnemonic_widget (GTK_LABEL (label), chooser->priv->combo_box); - chooser->priv->client = mateconf_client_get_default (); + chooser->priv->sound_settings = g_settings_new (KEY_SOUNDS_SCHEMA); + chooser->priv->marco_settings = g_settings_new (KEY_MARCO_SCHEMA); str = g_strdup_printf ("<b>%s</b>", _("C_hoose an alert sound:")); chooser->priv->selection_box = box = gtk_frame_new (str); @@ -1123,7 +1110,7 @@ gvc_sound_theme_chooser_init (GvcSoundThemeChooser *chooser) chooser->priv->click_feedback_button = gtk_check_button_new_with_mnemonic (_("Enable _window and button sounds")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (chooser->priv->click_feedback_button), - mateconf_client_get_bool (chooser->priv->client, INPUT_SOUNDS_KEY, NULL)); + g_settings_get_boolean (chooser->priv->sound_settings, INPUT_SOUNDS_KEY)); gtk_box_pack_start (GTK_BOX (chooser), chooser->priv->click_feedback_button, FALSE, FALSE, 0); @@ -1132,21 +1119,14 @@ gvc_sound_theme_chooser_init (GvcSoundThemeChooser *chooser) G_CALLBACK (on_click_feedback_toggled), chooser); - - mateconf_client_add_dir (chooser->priv->client, KEY_SOUNDS_DIR, - MATECONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - chooser->priv->sounds_dir_id = mateconf_client_notify_add (chooser->priv->client, - KEY_SOUNDS_DIR, - (MateConfClientNotifyFunc)on_key_changed, - chooser, NULL, NULL); - mateconf_client_add_dir (chooser->priv->client, KEY_MARCO_DIR, - MATECONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - chooser->priv->marco_dir_id = mateconf_client_notify_add (chooser->priv->client, - KEY_MARCO_DIR, - (MateConfClientNotifyFunc)on_key_changed, - chooser, NULL, NULL); + g_signal_connect (chooser->priv->sound_settings, + "changed", + G_CALLBACK (on_key_changed), + chooser); + g_signal_connect (chooser->priv->marco_settings, + "changed::" AUDIO_BELL_KEY, + G_CALLBACK (on_key_changed), + chooser); /* FIXME: should accept drag and drop themes. should also add an "Add Theme..." item to the theme combobox */ @@ -1163,18 +1143,10 @@ gvc_sound_theme_chooser_finalize (GObject *object) sound_theme_chooser = GVC_SOUND_THEME_CHOOSER (object); if (sound_theme_chooser->priv != NULL) { - if (sound_theme_chooser->priv->sounds_dir_id > 0) { - mateconf_client_notify_remove (sound_theme_chooser->priv->client, - sound_theme_chooser->priv->sounds_dir_id); - sound_theme_chooser->priv->sounds_dir_id = 0; - } - if (sound_theme_chooser->priv->marco_dir_id > 0) { - mateconf_client_notify_remove (sound_theme_chooser->priv->client, - sound_theme_chooser->priv->marco_dir_id); - sound_theme_chooser->priv->marco_dir_id = 0; - } - g_object_unref (sound_theme_chooser->priv->client); - sound_theme_chooser->priv->client = NULL; + g_object_unref (sound_theme_chooser->priv->sound_settings); + sound_theme_chooser->priv->sound_settings = NULL; + g_object_unref (sound_theme_chooser->priv->marco_settings); + sound_theme_chooser->priv->marco_settings = NULL; } G_OBJECT_CLASS (gvc_sound_theme_chooser_parent_class)->finalize (object); diff --git a/sound-theme/gvc-sound-theme-editor.c b/sound-theme/gvc-sound-theme-editor.c index 0453150..098fb76 100644 --- a/sound-theme/gvc-sound-theme-editor.c +++ b/sound-theme/gvc-sound-theme-editor.c @@ -27,11 +27,10 @@ #include <glib.h> #include <glib/gi18n.h> +#include <gio/gio.h> #include <gtk/gtk.h> #include <canberra-gtk.h> -#include <mateconf/mateconf-client.h> - #include "gvc-sound-theme-editor.h" #include "sound-theme-file-utils.h" @@ -43,9 +42,8 @@ struct GvcSoundThemeEditorPrivate GtkWidget *theme_box; GtkWidget *selection_box; GtkWidget *click_feedback_button; - MateConfClient *client; - guint sounds_dir_id; - guint marco_dir_id; + GSettings *sound_settings; + GSettings *marco_settings; }; static void gvc_sound_theme_editor_class_init (GvcSoundThemeEditorClass *klass); @@ -101,12 +99,12 @@ static struct { { -1, -1, NULL, { NULL } } }; -#define KEY_SOUNDS_DIR "/desktop/mate/sound" -#define EVENT_SOUNDS_KEY KEY_SOUNDS_DIR "/event_sounds" -#define INPUT_SOUNDS_KEY KEY_SOUNDS_DIR "/input_feedback_sounds" -#define SOUND_THEME_KEY KEY_SOUNDS_DIR "/theme_name" -#define KEY_MARCO_DIR "/apps/marco/general" -#define AUDIO_BELL_KEY KEY_MARCO_DIR "/audible_bell" +#define KEY_SOUNDS_SCHEMA "org.mate.sound" +#define EVENT_SOUNDS_KEY "event-sounds" +#define INPUT_SOUNDS_KEY "input-feedback-sounds" +#define SOUND_THEME_KEY "theme-name" +#define KEY_MARCO_SCHEMA "org.mate.Marco.general" +#define AUDIO_BELL_KEY "audible-bell" #define CUSTOM_THEME_NAME "__custom" #define NO_SOUNDS_THEME_NAME "__no_sounds" @@ -291,8 +289,6 @@ static void set_theme_name (GvcSoundThemeEditor *editor, const char *name) { - MateConfClient *client; - g_debug ("setting theme %s", name ? name : "(null)"); /* If the name is empty, use "freedesktop" */ @@ -300,7 +296,7 @@ set_theme_name (GvcSoundThemeEditor *editor, name = "freedesktop"; } - mateconf_client_set_string (editor->priv->client, SOUND_THEME_KEY, theme_name, NULL); + g_settings_set_string (editor->priv->sound_settings, SOUND_THEME_KEY, theme_name); } /* Functions to toggle whether the audible bell sound is editable */ @@ -437,20 +433,17 @@ update_theme (GvcSoundThemeEditor *editor) char *theme_name; gboolean events_enabled; gboolean bell_enabled; - MateConfClient *client; gboolean feedback_enabled; - client = editor->priv->client; - - bell_enabled = mateconf_client_get_bool (client, AUDIO_BELL_KEY, NULL); + bell_enabled = g_settings_get_boolean (editor->priv->marco_settings, AUDIO_BELL_KEY); set_audible_bell_enabled (editor, bell_enabled); - feedback_enabled = mateconf_client_get_bool (client, INPUT_SOUNDS_KEY, NULL); + feedback_enabled = g_settings_get_boolean (editor->priv->sound_settings, INPUT_SOUNDS_KEY); set_input_feedback_enabled (editor, feedback_enabled); - events_enabled = mateconf_client_get_bool (client, EVENT_SOUNDS_KEY, NULL); + events_enabled = g_settings_get_boolean (editor->priv->sound_settings, EVENT_SOUNDS_KEY); if (events_enabled) { - theme_name = mateconf_client_get_string (client, SOUND_THEME_KEY, NULL); + theme_name = g_settings_get_string (editor->priv->sound_settings, SOUND_THEME_KEY); } else { theme_name = g_strdup (NO_SOUNDS_THEME_NAME); } @@ -1212,33 +1205,18 @@ static void on_click_feedback_toggled (GtkToggleButton *button, GvcSoundThemeEditor *editor) { - MateConfClient *client; gboolean enabled; enabled = gtk_toggle_button_get_active (button); - client = mateconf_client_get_default (); - mateconf_client_set_bool (client, INPUT_SOUNDS_KEY, enabled, NULL); - g_object_unref (client); + g_settings_set_boolean (editor->priv->sound_settings, INPUT_SOUNDS_KEY, enabled); } static void -on_key_changed (MateConfClient *client, - guint cnxn_id, - MateConfEntry *entry, +on_key_changed (GSettings *settings, + gchar *key, GvcSoundThemeEditor *editor) { - const char *key; - MateConfValue *value; - - key = mateconf_entry_get_key (entry); - - if (! g_str_has_prefix (key, KEY_SOUNDS_DIR) - && ! g_str_has_prefix (key, KEY_MARCO_DIR)) { - return; - } - - value = mateconf_entry_get_value (entry); if (strcmp (key, EVENT_SOUNDS_KEY) == 0) { update_theme (editor); } else if (strcmp (key, SOUND_THEME_KEY) == 0) { @@ -1305,7 +1283,8 @@ gvc_sound_theme_editor_init (GvcSoundThemeEditor *editor) gtk_box_pack_start (GTK_BOX (editor->priv->theme_box), editor->priv->combo_box, FALSE, FALSE, 0); - editor->priv->client = mateconf_client_get_default (); + editor->priv->sound_settings = g_settings_new (KEY_SOUNDS_SCHEMA); + editor->priv->marco_settings = g_settings_new (KEY_MARCO_SCHEMA); editor->priv->selection_box = box = gtk_vbox_new (FALSE, 0); gtk_box_pack_start (GTK_BOX (editor), box, TRUE, TRUE, 0); @@ -1329,7 +1308,7 @@ gvc_sound_theme_editor_init (GvcSoundThemeEditor *editor) editor->priv->click_feedback_button = gtk_check_button_new_with_mnemonic (_("Enable window and button sounds")); gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (editor->priv->click_feedback_button), - mateconf_client_get_bool (editor->priv->client, INPUT_SOUNDS_KEY, NULL)); + g_settings_get_boolean (editor->priv->sound_settings, INPUT_SOUNDS_KEY)); gtk_box_pack_start (GTK_BOX (box), editor->priv->click_feedback_button, FALSE, FALSE, 0); @@ -1338,21 +1317,14 @@ gvc_sound_theme_editor_init (GvcSoundThemeEditor *editor) G_CALLBACK (on_click_feedback_toggled), editor); - - mateconf_client_add_dir (editor->priv->client, KEY_SOUNDS_DIR, - MATECONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - editor->priv->sounds_dir_id = mateconf_client_notify_add (editor->priv->client, - KEY_SOUNDS_DIR, - (MateConfClientNotifyFunc)on_key_changed, - editor, NULL, NULL); - mateconf_client_add_dir (editor->priv->client, KEY_MARCO_DIR, - MATECONF_CLIENT_PRELOAD_ONELEVEL, - NULL); - editor->priv->marco_dir_id = mateconf_client_notify_add (editor->priv->client, - KEY_MARCO_DIR, - (MateConfClientNotifyFunc)on_key_changed, - editor, NULL, NULL); + g_signal_connect (editor->priv->sound_settings, + "changed", + G_CALLBACK (on_key_changed), + editor); + g_signal_connect (editor->priv->marco_settings, + "changed::" AUDIO_BELL_KEY, + G_CALLBACK (on_key_changed), + editor); /* FIXME: should accept drag and drop themes. should also add an "Add Theme..." item to the theme combobox */ @@ -1369,18 +1341,10 @@ gvc_sound_theme_editor_finalize (GObject *object) sound_theme_editor = GVC_SOUND_THEME_EDITOR (object); if (sound_theme_editor->priv != NULL) { - if (sound_theme_editor->priv->sounds_dir_id > 0) { - mateconf_client_notify_remove (sound_theme_editor->priv->client, - sound_theme_editor->priv->sounds_dir_id); - sound_theme_editor->priv->sounds_dir_id = 0; - } - if (sound_theme_editor->priv->marco_dir_id > 0) { - mateconf_client_notify_remove (sound_theme_editor->priv->client, - sound_theme_editor->priv->marco_dir_id); - sound_theme_editor->priv->marco_dir_id = 0; - } - g_object_unref (sound_theme_editor->priv->client); - sound_theme_editor->priv->client = NULL; + g_object_unref (sound_theme_editor->priv->sound_settings); + sound_theme_editor->priv->sound_settings = NULL; + g_object_unref (sound_theme_editor->priv->marco_settings); + sound_theme_editor->priv->marco_settings = NULL; } G_OBJECT_CLASS (gvc_sound_theme_editor_parent_class)->finalize (object); |