diff options
author | Stefano Karapetsas <stefano@karapetsas.com> | 2012-11-24 18:21:39 +0100 |
---|---|---|
committer | Stefano Karapetsas <stefano@karapetsas.com> | 2012-11-24 18:21:39 +0100 |
commit | 0c04e2ff1829d565de7032db4a92dc27fdae6042 (patch) | |
tree | 161a6ceca75efd0710fe66d17e01119c62b81d64 /mixer | |
parent | e41ba47bb489bb79ff8a3251fd896900bb3e42c3 (diff) | |
download | mate-applets-0c04e2ff1829d565de7032db4a92dc27fdae6042.tar.bz2 mate-applets-0c04e2ff1829d565de7032db4a92dc27fdae6042.tar.xz |
mixer: migrate to gsettings
Diffstat (limited to 'mixer')
-rw-r--r-- | mixer/Makefile.am | 22 | ||||
-rw-r--r-- | mixer/applet.c | 67 | ||||
-rw-r--r-- | mixer/applet.h | 8 | ||||
-rw-r--r-- | mixer/keys.h | 9 | ||||
-rw-r--r-- | mixer/mixer.schemas.in | 36 | ||||
-rw-r--r-- | mixer/org.mate.panel.applet.mixer.gschema.xml.in.in | 12 | ||||
-rw-r--r-- | mixer/preferences.c | 34 | ||||
-rw-r--r-- | mixer/preferences.h | 9 |
8 files changed, 64 insertions, 133 deletions
diff --git a/mixer/Makefile.am b/mixer/Makefile.am index 0278e7eb..e5880457 100644 --- a/mixer/Makefile.am +++ b/mixer/Makefile.am @@ -3,7 +3,7 @@ SUBDIRS = docs INCLUDES = -I. -I$(srcdir) \ -DMIXER_MENU_UI_DIR=\""$(uidir)"\" \ $(MIXER_CFLAGS) \ - $(MATE_APPLETS3_CFLAGS) \ + $(MATE_APPLETS4_CFLAGS) \ $(MATEDESKTOP_CFLAGS) libexec_PROGRAMS = mixer_applet2 @@ -22,7 +22,7 @@ noinst_HEADERS = \ mixer_applet2_LDADD = \ $(MIXER_LIBS) \ - $(MATE_APPLETS3_LIBS) \ + $(MATE_APPLETS4_LIBS) \ $(MATEDESKTOP_LIBS) \ -lm @@ -50,23 +50,19 @@ org.mate.panel.applet.MixerAppletFactory.service: $(service_in_files) uidir = $(datadir)/mate-2.0/ui ui_DATA = mixer-applet-menu.xml -schemasdir = @MATECONF_SCHEMA_FILE_DIR@ -schemas_in_files = mixer.schemas.in -schemas_DATA = $(schemas_in_files:.schemas.in=.schemas) +@INTLTOOL_XML_NOMERGE_RULE@ +gsettings_SCHEMAS = org.mate.panel.applet.mixer.gschema.xml +@GSETTINGS_RULES@ -@INTLTOOL_SCHEMAS_RULE@ +%.gschema.xml.in: %.gschema.xml.in.in Makefile + $(AM_V_GEN) $(SED) -e 's^\@GETTEXT_PACKAGE\@^$(GETTEXT_PACKAGE)^g' < $< > $@ EXTRA_DIST = \ org.mate.applets.MixerApplet.mate-panel-applet.in.in \ $(service_in_files) \ $(ui_DATA) \ - $(schemas_in_files) + $(gsettings_SCHEMAS_in_in) -CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(schemas_DATA) - -if MATECONF_SCHEMAS_INSTALL -install-data-local: - MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(schemas_DATA) ; -endif +CLEANFILES = $(applet_DATA) $(applet_DATA).in $(service_DATA) $(gsettings_SCHEMAS_in) $(gsettings_SCHEMAS) *.gschema.valid -include $(top_srcdir)/git.mk diff --git a/mixer/applet.c b/mixer/applet.c index a0f239d8..9ad53bb8 100644 --- a/mixer/applet.c +++ b/mixer/applet.c @@ -34,7 +34,7 @@ #include <gtk/gtk.h> -#include <mateconf/mateconf-client.h> +#include <gio/gio.h> #include "applet.h" #include "keys.h" @@ -87,9 +87,8 @@ static gboolean cb_check (gpointer data); static void cb_volume (GtkAdjustment *adj, gpointer data); -static void cb_mateconf (MateConfClient *client, - guint connection_id, - MateConfEntry *entry, +static void cb_gsettings (GSettings *settings, + gchar *key, gpointer data); static void cb_verb (GtkAction *action, @@ -171,7 +170,7 @@ mate_volume_applet_init (MateVolumeApplet *applet) applet->timeout = 0; applet->elements = NULL; - applet->client = mateconf_client_get_default (); + applet->settings = mate_panel_applet_settings_new (MATE_PANEL_APPLET (applet), "org.mate.panel.applet.mixer"); applet->mixer = NULL; applet->tracks = NULL; applet->lock = FALSE; @@ -210,9 +209,6 @@ mate_volume_applet_init (MateVolumeApplet *applet) applet); /* other stuff */ - mate_panel_applet_add_preferences (MATE_PANEL_APPLET (applet), - "/schemas/apps/mixer_applet/prefs", - NULL); mate_panel_applet_set_flags (MATE_PANEL_APPLET (applet), MATE_PANEL_APPLET_EXPAND_MINOR); @@ -228,7 +224,7 @@ mate_volume_applet_init (MateVolumeApplet *applet) } -/* Parse the list of tracks that are stored in MateConf */ +/* Parse the list of tracks that are stored in GSettings */ static char ** parse_track_list (const char *track_list) @@ -400,20 +396,17 @@ mate_volume_applet_setup (MateVolumeApplet *applet, G_CALLBACK (cb_verb), FALSE } }; - gchar *key; gchar *active_element_name; gchar *active_track_name; gchar *ui_path; GstMixerTrack *first_track; gboolean res; - active_element_name = mate_panel_applet_mateconf_get_string (MATE_PANEL_APPLET (applet), - MATE_VOLUME_APPLET_KEY_ACTIVE_ELEMENT, - NULL); + active_element_name = g_settings_get_string (applet->settings, + MATE_VOLUME_APPLET_KEY_ACTIVE_ELEMENT); - active_track_name = mate_panel_applet_mateconf_get_string (MATE_PANEL_APPLET (applet), - MATE_VOLUME_APPLET_KEY_ACTIVE_TRACK, - NULL); + active_track_name = g_settings_get_string (applet->settings, + MATE_VOLUME_APPLET_KEY_ACTIVE_TRACK); res = select_element_and_track (applet, elements, active_element_name, active_track_name); @@ -459,17 +452,11 @@ mate_volume_applet_setup (MateVolumeApplet *applet, if (res) { mate_volume_applet_setup_timeout (applet); - /* mateconf */ - key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (applet), - MATE_VOLUME_APPLET_KEY_ACTIVE_ELEMENT); - mateconf_client_notify_add (applet->client, key, - cb_mateconf, applet, NULL, NULL); - g_free (key); - key = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (applet), - MATE_VOLUME_APPLET_KEY_ACTIVE_TRACK); - mateconf_client_notify_add (applet->client, key, - cb_mateconf, applet, NULL, NULL); - g_free (key); + /* gsettings */ + g_signal_connect (applet->settings, "changed::" MATE_VOLUME_APPLET_KEY_ACTIVE_ELEMENT, + G_CALLBACK (cb_gsettings), applet); + g_signal_connect (applet->settings, "changed::" MATE_VOLUME_APPLET_KEY_ACTIVE_TRACK, + G_CALLBACK (cb_gsettings), applet); } gtk_widget_show (GTK_WIDGET (applet)); @@ -1317,40 +1304,23 @@ cb_check (gpointer data) } /* - * MateConf callback. + * GSettings callback. */ static void -cb_mateconf (MateConfClient *client, - guint connection_id, - MateConfEntry *entry, - gpointer data) +cb_gsettings (GSettings *settings, gchar *key, gpointer data) { MateVolumeApplet *applet = data; - MateConfValue *value; - const gchar *str, *key; + const gchar *str; const GList *item; gboolean newdevice = FALSE; - gchar *keyroot; GList *active_tracks; active_tracks = NULL; - keyroot = mate_panel_applet_mateconf_get_full_key (MATE_PANEL_APPLET (applet), ""); - key = mateconf_entry_get_key (entry); - if (strncmp (key, keyroot, strlen (keyroot))) { - g_free (keyroot); - return; - } - key += strlen (keyroot); - g_free (keyroot); - g_list_free(applet->elements); applet->elements = mate_volume_applet_create_mixer_collection (); - if ((value = mateconf_entry_get_value (entry)) != NULL && - (value->type == MATECONF_VALUE_STRING) && - (str = mateconf_value_get_string (value)) != NULL) { if (!strcmp (key, MATE_VOLUME_APPLET_KEY_ACTIVE_ELEMENT)) { for (item = applet->elements; item != NULL; item = item->next) { gchar *cur_el_str = g_object_get_data (item->data, @@ -1406,7 +1376,6 @@ cb_mateconf (MateConfClient *client, applet->force_next_update = TRUE; } } - } } /* @@ -1480,7 +1449,7 @@ cb_verb (GtkAction *action, g_list_free(applet->elements); applet->elements = mate_volume_applet_create_mixer_collection (); - applet->prefs = mate_volume_applet_preferences_new (MATE_PANEL_APPLET (applet), + applet->prefs = mate_volume_applet_preferences_new (applet, applet->elements, applet->mixer, applet->tracks); diff --git a/mixer/applet.h b/mixer/applet.h index f373f8ff..13fa0de9 100644 --- a/mixer/applet.h +++ b/mixer/applet.h @@ -27,8 +27,8 @@ #include <glib/gi18n.h> #include <gtk/gtk.h> -#include <mateconf/mateconf-client.h> -#include <mate-panel-applet-mateconf.h> +#include <gio/gio.h> +#include <mate-panel-applet-gsettings.h> #include <gst/gst.h> #include <gst/interfaces/mixer.h> @@ -67,8 +67,8 @@ struct _MateVolumeApplet { /* list of volume control elements */ GList *elements; - /* mateconf */ - MateConfClient *client; + /* gsettings */ + GSettings *settings; /* element */ GstMixer *mixer; diff --git a/mixer/keys.h b/mixer/keys.h index 724df3ed..acec5402 100644 --- a/mixer/keys.h +++ b/mixer/keys.h @@ -1,7 +1,7 @@ /* MATE Volume Applet * Copyright (C) 2004 Ronald Bultje <rbultje@ronald.bitfreak.net> * - * keys.h: MateConf key macros + * keys.h: GSettings key macros * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -24,11 +24,8 @@ G_BEGIN_DECLS -#define MATE_VOLUME_APPLET_KEY(x) x -#define MATE_VOLUME_APPLET_KEY_ACTIVE_ELEMENT \ - MATE_VOLUME_APPLET_KEY ("active-element") -#define MATE_VOLUME_APPLET_KEY_ACTIVE_TRACK \ - MATE_VOLUME_APPLET_KEY ("active-track") +#define MATE_VOLUME_APPLET_KEY_ACTIVE_ELEMENT "active-element" +#define MATE_VOLUME_APPLET_KEY_ACTIVE_TRACK "active-track" G_END_DECLS diff --git a/mixer/mixer.schemas.in b/mixer/mixer.schemas.in deleted file mode 100644 index 72d7d4e6..00000000 --- a/mixer/mixer.schemas.in +++ /dev/null @@ -1,36 +0,0 @@ -<mateconfschemafile> - <schemalist> - - <schema> - <key>/schemas/apps/mixer_applet/prefs/channel</key> - <owner>mixer-applet</owner> - <type>int</type> - <default>0</default> - <locale name="C"> - <short>Channel controlled by applet. Only for OSS setups</short> - </locale> - </schema> - - <schema> - <key>/schemas/apps/mixer_applet/prefs/mute</key> - <owner>mixer-applet</owner> - <type>bool</type> - <default>false</default> - <locale name="C"> - <short>Saved mute state</short> - </locale> - </schema> - - <schema> - <key>/schemas/apps/mixer_applet/prefs/vol</key> - <owner>mixer-applet</owner> - <type>int</type> - <default>-1</default> - <locale name="C"> - <short>Saved volume to restore on startup</short> - </locale> - </schema> - - </schemalist> - -</mateconfschemafile> diff --git a/mixer/org.mate.panel.applet.mixer.gschema.xml.in.in b/mixer/org.mate.panel.applet.mixer.gschema.xml.in.in new file mode 100644 index 00000000..1b81ba32 --- /dev/null +++ b/mixer/org.mate.panel.applet.mixer.gschema.xml.in.in @@ -0,0 +1,12 @@ +<schemalist gettext-domain="@GETTEXT_PACKAGE@"> + <schema id="org.mate.panel.applet.mixer"> + <key name="active-element" type="s"> + <default>''</default> + <_summary>Selected device</_summary> + </key> + <key name="active-track" type="s"> + <default>''</default> + <_summary>Selected track</_summary> + </key> + </schema> +</schemalist> diff --git a/mixer/preferences.c b/mixer/preferences.c index 2dc7973a..b3bfe122 100644 --- a/mixer/preferences.c +++ b/mixer/preferences.c @@ -155,7 +155,7 @@ mate_volume_applet_preferences_init (MateVolumeAppletPreferences *prefs) } GtkWidget * -mate_volume_applet_preferences_new (MatePanelApplet *applet, +mate_volume_applet_preferences_new (MateVolumeApplet *applet, GList *elements, GstMixer *mixer, GList *tracks) @@ -319,19 +319,15 @@ cb_dev_selected (GtkComboBox *box, if (gtk_combo_box_get_active_iter (box, &iter)) { gchar *label; - MateConfValue *value; gtk_tree_model_get (gtk_combo_box_get_model (box), &iter, COL_LABEL, &label, -1); - /* write to mateconf */ - value = mateconf_value_new (MATECONF_VALUE_STRING); - mateconf_value_set_string (value, label); - mate_panel_applet_mateconf_set_value (MATE_PANEL_APPLET (prefs->applet), + /* write to gsettings */ + g_settings_set_string (prefs->applet->settings, MATE_VOLUME_APPLET_KEY_ACTIVE_ELEMENT, - value, NULL); + label); g_free (label); - mateconf_value_free (value); } } @@ -367,9 +363,8 @@ cb_track_select (GtkTreeSelection *selection, MateVolumeAppletPreferences *prefs = data; GtkTreeIter iter; gchar *label; - MateConfValue *value; GtkTreeSelection *sel; - GString *mateconf_string; + GString *gsettings_string; GstMixerTrack *selected_track; /* the track just selected */ MateVolumeApplet *applet = (MateVolumeApplet*) prefs->applet; /* required to update the track settings */ int volume_percent; @@ -377,7 +372,7 @@ cb_track_select (GtkTreeSelection *selection, if (prefs->track_lock) return TRUE; - mateconf_string = g_string_new (""); + gsettings_string = g_string_new (""); /* get value */ gtk_tree_model_get_iter (model, &iter, path); @@ -409,9 +404,9 @@ cb_track_select (GtkTreeSelection *selection, applet->tracks = g_list_append (applet->tracks, curr); if (!path_selected) { - g_string_append_printf (mateconf_string, "%s:", curr->label); + g_string_append_printf (gsettings_string, "%s:", curr->label); } else { - mateconf_string = g_string_append (mateconf_string, curr->label); + gsettings_string = g_string_append (gsettings_string, curr->label); } } } @@ -426,7 +421,7 @@ cb_track_select (GtkTreeSelection *selection, gtk_tree_model_get_iter (model, &iter, path); gtk_tree_model_get (model, &iter, COL_TRACK, &curr, -1); - mateconf_string = g_string_append (mateconf_string, curr->label); + gsettings_string = g_string_append (gsettings_string, curr->label); applet->tracks = g_list_append (applet->tracks, curr); @@ -436,15 +431,12 @@ cb_track_select (GtkTreeSelection *selection, } } - /* write to mateconf */ - value = mateconf_value_new (MATECONF_VALUE_STRING); - mateconf_value_set_string (value, mateconf_string->str); - mate_panel_applet_mateconf_set_value (MATE_PANEL_APPLET (prefs->applet), + /* write to gsettings */ + g_settings_set_string (prefs->applet->settings, MATE_VOLUME_APPLET_KEY_ACTIVE_TRACK, - value, NULL); + gsettings_string->str); g_free (label); - g_string_free (mateconf_string, TRUE); - mateconf_value_free (value); + g_string_free (gsettings_string, TRUE); return TRUE; } diff --git a/mixer/preferences.h b/mixer/preferences.h index eca0715f..c126fea8 100644 --- a/mixer/preferences.h +++ b/mixer/preferences.h @@ -24,8 +24,9 @@ #include <glib.h> #include <gtk/gtk.h> +#include <gio/gio.h> #include <mate-panel-applet.h> -#include <mate-panel-applet-mateconf.h> +#include <mate-panel-applet-gsettings.h> #include <gst/interfaces/mixer.h> G_BEGIN_DECLS @@ -55,8 +56,8 @@ typedef struct _MateVolumeAppletPreferences { /* is the track list currently locked */ gboolean track_lock; - /* for mateconf */ - MatePanelApplet *applet; + /* for gsettings */ + MateVolumeApplet *applet; /* treeview inside us */ GtkWidget *optionmenu, *treeview; @@ -67,7 +68,7 @@ typedef struct _MateVolumeAppletPreferencesClass { } MateVolumeAppletPreferencesClass; GType mate_volume_applet_preferences_get_type (void); -GtkWidget *mate_volume_applet_preferences_new (MatePanelApplet *applet, +GtkWidget *mate_volume_applet_preferences_new (MateVolumeApplet *applet, GList *elements, GstMixer *mixer, GList *track); |