summaryrefslogtreecommitdiff
path: root/gst-mixer
diff options
context:
space:
mode:
Diffstat (limited to 'gst-mixer')
-rw-r--r--gst-mixer/Makefile.am31
-rw-r--r--gst-mixer/mate-volume-control.schemas.in29
-rw-r--r--gst-mixer/org.mate.volume-control.gschema.xml.in.in24
-rw-r--r--gst-mixer/src/Makefile.am5
-rw-r--r--gst-mixer/src/element.c169
-rw-r--r--gst-mixer/src/element.h18
-rw-r--r--gst-mixer/src/main.c12
-rw-r--r--gst-mixer/src/preferences.c148
-rw-r--r--gst-mixer/src/preferences.h14
-rw-r--r--gst-mixer/src/schemas.c106
-rw-r--r--gst-mixer/src/schemas.h (renamed from gst-mixer/src/keys.h)26
-rw-r--r--gst-mixer/src/track.h1
-rw-r--r--gst-mixer/src/window.c53
-rw-r--r--gst-mixer/src/window.h6
14 files changed, 368 insertions, 274 deletions
diff --git a/gst-mixer/Makefile.am b/gst-mixer/Makefile.am
index 4767cef..9079f79 100644
--- a/gst-mixer/Makefile.am
+++ b/gst-mixer/Makefile.am
@@ -2,27 +2,28 @@ Desktopdir = $(datadir)/applications
SUBDIRS = doc icons pixmaps src
@INTLTOOL_DESKTOP_RULE@
-@INTLTOOL_SCHEMAS_RULE@
-
Desktop_in_files = mate-volume-control.desktop.in.in
Desktop_DATA = $(Desktop_in_files:.desktop.in.in=.desktop)
-schemadir=$(MATECONF_SCHEMA_FILE_DIR)
-schema_DATA=mate-volume-control.schemas
-install-schemas:
- MATECONF_CONFIG_SOURCE=$(MATECONF_SCHEMA_CONFIG_SOURCE) $(MATECONFTOOL) --makefile-install-rule $(schema_DATA) || true
+@INTLTOOL_XML_NOMERGE_RULE@
+gsettings_SCHEMAS = \
+ org.mate.volume-control.gschema.xml
+@GSETTINGS_RULES@
-if MATECONF_SCHEMAS_INSTALL
-install-data-local: install-schemas
-else
-install-data-local:
-endif
+%.gschema.xml.in: %.gschema.xml.in.in Makefile
+ $(AM_V_GEN) $(SED) -e 's^\@GETTEXT_PACKAGE\@^$(GETTEXT_PACKAGE)^g' < $< > $@
-EXTRA_DIST = $(Desktop_in_files) \
- mate-volume-control.schemas.in
+EXTRA_DIST = \
+ $(Desktop_in_files) \
+ $(gsettings_schemas_in_in)
+CLEANFILES = \
+ $(Desktop_DATA) \
+ $(gsettings_SCHEMAS_in) \
+ $(gsettings_SCHEMAS) \
+ *.gschema.valid
-CLEANFILES = $(Desktop_DATA) $(schema_DATA)
-DISTCLEANFILES = $(Desktop_in_files:.desktop.in.in=.desktop.in)
+DISTCLEANFILES = \
+ $(Desktop_in_files:.desktop.in.in=.desktop.in)
-include $(top_srcdir)/git.mk
diff --git a/gst-mixer/mate-volume-control.schemas.in b/gst-mixer/mate-volume-control.schemas.in
deleted file mode 100644
index 3caa8b1..0000000
--- a/gst-mixer/mate-volume-control.schemas.in
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0"?>
-<mateconfschemafile>
- <schemalist>
- <schema>
- <key>/schemas/apps/mate-volume-control/ui/window_height</key>
- <applyto>/apps/mate-volume-control/ui/window_height</applyto>
- <owner>mate-volume-control</owner>
- <type>int</type>
- <default>-1</default>
- <locale name="C">
- <short>Height of the Window</short>
- <long>Height of the window to be displayed.</long>
- </locale>
- </schema>
-
- <schema>
- <key>/schemas/apps/mate-volume-control/ui/window_width</key>
- <applyto>/apps/mate-volume-control/ui/window_width</applyto>
- <owner>mate-volume-control</owner>
- <type>int</type>
- <default>500</default>
- <locale name="C">
- <short>Width of the Window</short>
- <long>Width of the window to be displayed.</long>
- </locale>
- </schema>
-
- </schemalist>
-</mateconfschemafile>
diff --git a/gst-mixer/org.mate.volume-control.gschema.xml.in.in b/gst-mixer/org.mate.volume-control.gschema.xml.in.in
new file mode 100644
index 0000000..2b3fe22
--- /dev/null
+++ b/gst-mixer/org.mate.volume-control.gschema.xml.in.in
@@ -0,0 +1,24 @@
+<schemalist>
+ <schema id="org.mate.volume-control" path="/org/mate/volume-control/">
+ <key name="window-height" type="i">
+ <default>-1</default>
+ <_summary>Height of the Window</_summary>
+ <_description>Height of the window to be displayed.</_description>
+ </key>
+ <key name="window-width" type="i">
+ <default>500</default>
+ <_summary>Width of the Window</_summary>
+ <_description>Width of the window to be displayed.</_description>
+ </key>
+ <key name="active-element" type="s">
+ <default>''</default>
+ <_summary>Active element</_summary>
+ <_description>Active element set in volume control</_description>
+ </key>
+ <key name="shown-elements" type="as">
+ <default>[]</default>
+ <_summary>Shown elements in volume control</_summary>
+ <_description>Set the elements to show in volume control</_description>
+ </key>
+ </schema>
+</schemalist>
diff --git a/gst-mixer/src/Makefile.am b/gst-mixer/src/Makefile.am
index d85a6b9..e702eb7 100644
--- a/gst-mixer/src/Makefile.am
+++ b/gst-mixer/src/Makefile.am
@@ -22,12 +22,13 @@ mate_volume_control_SOURCES = \
track.c \
volume.c \
window.c \
- misc.c
+ misc.c \
+ schemas.c
noinst_HEADERS = \
button.h \
element.h \
- keys.h \
+ schemas.h \
preferences.h \
track.h \
volume.h \
diff --git a/gst-mixer/src/element.c b/gst-mixer/src/element.c
index a190582..66a007c 100644
--- a/gst-mixer/src/element.c
+++ b/gst-mixer/src/element.c
@@ -28,7 +28,7 @@
#include <gtk/gtk.h>
#include "element.h"
-#include "keys.h"
+#include "schemas.h"
#include "preferences.h"
#include "track.h"
#include "misc.h"
@@ -42,11 +42,9 @@ static void mate_volume_control_element_class_init (MateVolumeControlElementClas
static void mate_volume_control_element_init (MateVolumeControlElement *el);
static void mate_volume_control_element_dispose (GObject *object);
-static void cb_mateconf (MateConfClient *client,
- guint connection_id,
- MateConfEntry *entry,
- gpointer data);
-
+static void cb_gsettings (GSettings *settings,
+ gchar *key,
+ MateVolumeControlElement *el);
static void
mate_volume_control_element_class_init (MateVolumeControlElementClass *klass)
@@ -59,23 +57,21 @@ mate_volume_control_element_class_init (MateVolumeControlElementClass *klass)
static void
mate_volume_control_element_init (MateVolumeControlElement *el)
{
- el->client = NULL;
+ el->settings = NULL;
el->mixer = NULL;
}
GtkWidget *
-mate_volume_control_element_new (MateConfClient *client)
+mate_volume_control_element_new ()
{
MateVolumeControlElement *el;
/* element */
el = g_object_new (MATE_VOLUME_CONTROL_TYPE_ELEMENT, NULL);
- el->client = g_object_ref (G_OBJECT (client));
+ el->settings = g_settings_new (MATE_VOLUME_CONTROL_SCHEMA);
- mateconf_client_add_dir (el->client, MATE_VOLUME_CONTROL_KEY_DIR,
- MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL);
- mateconf_client_notify_add (el->client, MATE_VOLUME_CONTROL_KEY_DIR,
- cb_mateconf, el, NULL, NULL);
+ g_signal_connect (el->settings, "changed::" MATE_VOLUME_CONTROL_KEY_SHOWN_ELEMENTS,
+ G_CALLBACK (cb_gsettings), el);
return GTK_WIDGET (el);
}
@@ -85,9 +81,9 @@ mate_volume_control_element_dispose (GObject *object)
{
MateVolumeControlElement *el = MATE_VOLUME_CONTROL_ELEMENT (object);
- if (el->client) {
- g_object_unref (G_OBJECT (el->client));
- el->client = NULL;
+ if (el->settings) {
+ g_object_unref (G_OBJECT (el->settings));
+ el->settings = NULL;
}
if (el->mixer) {
@@ -180,6 +176,37 @@ mate_volume_control_element_whitelist (GstMixer *mixer,
}
/*
+ * Check if the element is to show
+ */
+
+gboolean
+mate_volume_control_element_is_to_show (GSettings *settings,
+ GstMixer *mixer,
+ GstMixerTrack *track)
+{
+ gboolean is_whitelist = FALSE;
+ gboolean is_to_show = FALSE;
+ gchar *name;
+
+ mate_volume_control_element_whitelist (mixer, NULL);
+ is_whitelist = mate_volume_control_element_whitelist (mixer, track);
+
+ if (is_whitelist == TRUE)
+ {
+ return TRUE;
+ }
+ else
+ {
+ name = get_gsettings_name (mixer, track);
+ /* if element is not in whitelist, user can be set it to show */
+ if (schemas_is_str_in_strv (settings, MATE_VOLUME_CONTROL_KEY_SHOWN_ELEMENTS, name))
+ is_to_show = TRUE;
+ g_free (name);
+ return is_to_show;
+ }
+}
+
+/*
* Hide/show notebook page.
*/
@@ -333,8 +360,7 @@ mate_volume_control_element_change (MateVolumeControlElement *el,
item != NULL; item = item->next) {
GstMixerTrack *track = item->data;
MateVolumeControlTrack *trkw;
- gchar *key;
- const MateConfValue *value;
+
gboolean active;
i = get_page_num (el->mixer, track);
@@ -353,13 +379,7 @@ mate_volume_control_element_change (MateVolumeControlElement *el,
}
/* visible? */
- active = mate_volume_control_element_whitelist (mixer, track);
- key = get_mateconf_key (el->mixer, track);
- if ((value = mateconf_client_get (el->client, key, NULL)) != NULL &&
- value->type == MATECONF_VALUE_BOOL) {
- active = mateconf_value_get_bool (value);
- }
- g_free (key);
+ active = mate_volume_control_element_is_to_show (el->settings, mixer, track);
/* Show left separator if we're not the first track */
if (active && content[i].use && content[i].old_sep) {
@@ -523,73 +543,56 @@ mate_volume_control_element_change (MateVolumeControlElement *el,
}
/*
- * MateConf callback.
+ * GSettings callback.
*/
static void
-cb_mateconf (MateConfClient *client,
- guint connection_id,
- MateConfEntry *entry,
- gpointer data)
+cb_gsettings (GSettings *settings,
+ gchar *key,
+ MateVolumeControlElement *el)
{
- MateVolumeControlElement *el = MATE_VOLUME_CONTROL_ELEMENT (data);
- gchar *keybase = get_mateconf_key (el->mixer, NULL);
-
- if (!strncmp (mateconf_entry_get_key (entry),
- keybase, strlen (keybase))) {
const GList *item;
- for (item = gst_mixer_list_tracks (el->mixer);
- item != NULL; item = item->next) {
- GstMixerTrack *track = item->data;
- MateVolumeControlTrack *trkw =
- g_object_get_data (G_OBJECT (track), "mate-volume-control-trkw");
- gchar *key = get_mateconf_key (el->mixer, track);
-
- g_return_if_fail (mateconf_entry_get_key (entry) != NULL);
- g_return_if_fail (key != NULL);
-
- if (g_str_equal (mateconf_entry_get_key (entry), key)) {
- MateConfValue *value = mateconf_entry_get_value (entry);
-
- if (value->type == MATECONF_VALUE_BOOL) {
- gboolean active = mateconf_value_get_bool (value),
- first[4] = { TRUE, TRUE, TRUE, TRUE };
- gint n, page = get_page_num (el->mixer, track);
-
- mate_volume_control_track_show (trkw, active);
-
- /* separators */
- for (item = gst_mixer_list_tracks (el->mixer);
- item != NULL; item = item->next) {
- GstMixerTrack *track = item->data;
- MateVolumeControlTrack *trkw =
- g_object_get_data (G_OBJECT (track), "mate-volume-control-trkw");
-
- n = get_page_num (el->mixer, track);
- if (trkw->visible && !first[n]) {
- if (trkw->left_separator) {
- if (n < 2 && track->num_channels == 0) {
- gtk_widget_hide (trkw->left_separator);
+ for (item = gst_mixer_list_tracks (el->mixer); item != NULL; item = item->next)
+ {
+ GstMixerTrack *track = item->data;
+ MateVolumeControlTrack *trkw =
+ g_object_get_data (G_OBJECT (track), "mate-volume-control-trkw");
+
+ gboolean active = mate_volume_control_element_is_to_show (el->settings, el->mixer, track);
+
+ if (active != trkw->visible) {
+ gboolean first[4] = { TRUE, TRUE, TRUE, TRUE };
+ gint n, page = get_page_num (el->mixer, track);
+
+ mate_volume_control_track_show (trkw, active);
+
+ /* separators */
+ for (item = gst_mixer_list_tracks (el->mixer); item != NULL; item = item->next)
+ {
+ GstMixerTrack *track = item->data;
+ MateVolumeControlTrack *trkw =
+ g_object_get_data (G_OBJECT (track), "mate-volume-control-trkw");
+
+ n = get_page_num (el->mixer, track);
+ if (trkw->visible && !first[n]) {
+ if (trkw->left_separator) {
+ if (n < 2 && track->num_channels == 0) {
+ gtk_widget_hide (trkw->left_separator);
+ } else {
+ gtk_widget_show (trkw->left_separator);
+ }
+ }
} else {
- gtk_widget_show (trkw->left_separator);
+ if (trkw->left_separator)
+ gtk_widget_hide (trkw->left_separator);
}
- }
- } else {
- if (trkw->left_separator)
- gtk_widget_hide (trkw->left_separator);
- }
- if (trkw->visible && first[n])
- first[n] = FALSE;
- }
- update_tab_visibility (el, page, page);
- break;
+ if (trkw->visible && first[n])
+ first[n] = FALSE;
+ }
+ update_tab_visibility (el, page, page);
+ break;
}
- }
-
- g_free (key);
}
- }
- g_free (keybase);
}
diff --git a/gst-mixer/src/element.h b/gst-mixer/src/element.h
index bb224a0..526fb1e 100644
--- a/gst-mixer/src/element.h
+++ b/gst-mixer/src/element.h
@@ -24,7 +24,7 @@
#include <glib.h>
#include <gtk/gtk.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#include <gst/interfaces/mixer.h>
G_BEGIN_DECLS
@@ -48,8 +48,8 @@ typedef struct _MateVolumeControlElement {
/* current element that we're working on */
GstMixer *mixer;
- /* mateconf client inherited from our parent */
- MateConfClient *client;
+ /* gsettings */
+ GSettings *settings;
} MateVolumeControlElement;
typedef struct _MateVolumeControlElementClass {
@@ -57,12 +57,14 @@ typedef struct _MateVolumeControlElementClass {
} MateVolumeControlElementClass;
GType mate_volume_control_element_get_type (void);
-GtkWidget * mate_volume_control_element_new (MateConfClient *client);
+GtkWidget * mate_volume_control_element_new ();
void mate_volume_control_element_change (MateVolumeControlElement *el,
- GstElement *element);
-gboolean mate_volume_control_element_whitelist (GstMixer *mixer,
- GstMixerTrack *track);
-
+ GstElement *element);
+gboolean mate_volume_control_element_whitelist (GstMixer *mixer,
+ GstMixerTrack *track);
+gboolean mate_volume_control_element_is_to_show (GSettings *settings,
+ GstMixer *mixer,
+ GstMixerTrack *track);
G_END_DECLS
#endif /* __GVC_ELEMENT_H__ */
diff --git a/gst-mixer/src/main.c b/gst-mixer/src/main.c
index f039af8..1e5e275 100644
--- a/gst-mixer/src/main.c
+++ b/gst-mixer/src/main.c
@@ -27,10 +27,11 @@
#include <glib.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
+#include <gio/gio.h>
#include <gst/gst.h>
#include <gst/audio/mixerutils.h>
-#include "keys.h"
+#include "schemas.h"
#include "window.h"
static gchar* page = NULL;
@@ -120,13 +121,14 @@ static void
cb_check_resize (GtkContainer *container,
gpointer user_data)
{
- MateConfClient *client;
+ GSettings *settings;
gint width, height;
- client = mateconf_client_get_default();
+ settings = g_settings_new (MATE_VOLUME_CONTROL_SCHEMA);
gtk_window_get_size (GTK_WINDOW (container), &width, &height);
- mateconf_client_set_int (client, PREF_UI_WINDOW_WIDTH, width, NULL);
- mateconf_client_set_int (client, PREF_UI_WINDOW_HEIGHT, height, NULL);
+ g_settings_set_int (settings, MATE_VOLUME_CONTROL_KEY_WINDOW_WIDTH, width);
+ g_settings_set_int (settings, MATE_VOLUME_CONTROL_KEY_WINDOW_HEIGHT, height);
+ g_object_unref (settings);
}
gint
diff --git a/gst-mixer/src/preferences.c b/gst-mixer/src/preferences.c
index 7b34085..bc93af1 100644
--- a/gst-mixer/src/preferences.c
+++ b/gst-mixer/src/preferences.c
@@ -26,11 +26,11 @@
#include <string.h>
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#include "element.h"
#include "preferences.h"
-#include "keys.h"
+#include "schemas.h"
#include "track.h"
#include "misc.h"
@@ -51,19 +51,18 @@ static void mate_volume_control_preferences_dispose (GObject *object);
static void mate_volume_control_preferences_response (GtkDialog *dialog,
gint response_id);
-static void set_mateconf_track_active (MateConfClient *client, GstMixer *mixer,
+static void set_gsettings_track_active (GSettings *settings, GstMixer *mixer,
GstMixerTrack *track, gboolean active);
static void cb_toggle (GtkCellRendererToggle *cell,
gchar *path_str,
- gpointer data);
+ MateVolumeControlPreferences *prefs);
static void cb_activated (GtkTreeView *view, GtkTreePath *path,
GtkTreeViewColumn *col, gpointer userdata);
-static void cb_mateconf (MateConfClient *client,
- guint connection_id,
- MateConfEntry *entry,
- gpointer userdata);
+static void cb_gsettings (GSettings *settings,
+ gchar *key,
+ MateVolumeControlPreferences *prefs);
static void
@@ -99,8 +98,7 @@ mate_volume_control_preferences_init (MateVolumeControlPreferences *prefs)
GtkTreeViewColumn *col;
GtkCellRenderer *render;
- prefs->client = NULL;
- prefs->client_cnxn = 0;
+ prefs->settings = NULL;
prefs->mixer = NULL;
/* make window look cute */
@@ -181,8 +179,7 @@ mate_volume_control_preferences_init (MateVolumeControlPreferences *prefs)
}
GtkWidget *
-mate_volume_control_preferences_new (GstElement *element,
- MateConfClient *client)
+mate_volume_control_preferences_new (GstElement *element)
{
MateVolumeControlPreferences *prefs;
@@ -190,14 +187,13 @@ mate_volume_control_preferences_new (GstElement *element,
/* element */
prefs = g_object_new (MATE_VOLUME_CONTROL_TYPE_PREFERENCES, NULL);
- prefs->client = g_object_ref (G_OBJECT (client));
+ prefs->settings = g_settings_new (MATE_VOLUME_CONTROL_SCHEMA);
mate_volume_control_preferences_change (prefs, element);
- /* mateconf */
- prefs->client_cnxn = mateconf_client_notify_add (prefs->client,
- MATE_VOLUME_CONTROL_KEY_DIR,
- cb_mateconf, prefs, NULL, NULL);
+ /* gsettings */
+ g_signal_connect (prefs->settings, "changed::" MATE_VOLUME_CONTROL_KEY_SHOWN_ELEMENTS,
+ G_CALLBACK (cb_gsettings), prefs);
return GTK_WIDGET (prefs);
}
@@ -209,10 +205,9 @@ mate_volume_control_preferences_dispose (GObject *object)
prefs = MATE_VOLUME_CONTROL_PREFERENCES (object);
- if (prefs->client) {
- mateconf_client_notify_remove (prefs->client, prefs->client_cnxn);
- g_object_unref (G_OBJECT (prefs->client));
- prefs->client = NULL;
+ if (prefs->settings) {
+ g_object_unref (G_OBJECT (prefs->settings));
+ prefs->settings = NULL;
}
if (prefs->mixer) {
@@ -241,11 +236,11 @@ mate_volume_control_preferences_response (GtkDialog *dialog,
}
/*
- * Hide non-alphanumeric characters, for saving in mateconf.
+ * Hide non-alphanumeric characters, for saving in gsettings.
*/
gchar *
-get_mateconf_key (GstMixer *mixer, GstMixerTrack *track)
+get_gsettings_name (GstMixer *mixer, GstMixerTrack *track)
{
const gchar *dev;
gchar *res;
@@ -262,9 +257,8 @@ get_mateconf_key (GstMixer *mixer, GstMixerTrack *track)
label = g_strdup ("");
}
- pos = strlen (MATE_VOLUME_CONTROL_KEY_DIR) + 1;
- res = g_new (gchar, pos + strlen (dev) + 1 + strlen (label) + 1);
- strcpy (res, MATE_VOLUME_CONTROL_KEY_DIR "/");
+ pos = 0;
+ res = g_new (gchar, strlen (dev) + 1 + strlen (label) + 1);
for (i = 0; dev[i] != '\0'; i++) {
if (g_ascii_isalnum (dev[i]))
@@ -313,15 +307,7 @@ mate_volume_control_preferences_change (MateVolumeControlPreferences *prefs,
for (item = gst_mixer_list_tracks (mixer);
item != NULL; item = item->next) {
GstMixerTrack *track = item->data;
- gchar *key = get_mateconf_key (mixer, track);
- MateConfValue *value;
- gboolean active = mate_volume_control_element_whitelist (mixer, track);
-
- if ((value = mateconf_client_get (prefs->client, key, NULL)) != NULL &&
- value->type == MATECONF_VALUE_BOOL) {
- active = mateconf_value_get_bool (value);
- }
- g_free (key);
+ gboolean active = mate_volume_control_element_is_to_show (prefs->settings, mixer, track);
pgnum = get_page_num (mixer, track);
gtk_list_store_append (store, &iter);
@@ -340,48 +326,48 @@ mate_volume_control_preferences_change (MateVolumeControlPreferences *prefs,
*/
static void
-set_mateconf_track_active(MateConfClient *client, GstMixer *mixer,
+set_gsettings_track_active(GSettings *settings, GstMixer *mixer,
GstMixerTrack *track, gboolean active)
{
- gchar *key;
+ gchar *name;
+
+ name = get_gsettings_name (mixer, track);
+
+ if (active == TRUE)
+ {
+ if (schemas_is_str_in_strv (settings, MATE_VOLUME_CONTROL_KEY_SHOWN_ELEMENTS, name) == FALSE)
+ {
+ schemas_gsettings_append_strv (settings, MATE_VOLUME_CONTROL_KEY_SHOWN_ELEMENTS, name);
+ }
+ }
+ else
+ {
+ schemas_gsettings_remove_all_from_strv (settings, MATE_VOLUME_CONTROL_KEY_SHOWN_ELEMENTS, name);
+ }
+
+ g_free (name);
- key = get_mateconf_key (mixer, track);
- mateconf_client_set_bool (client, key, active, NULL);
- g_free (key);
}
static void
-cb_mateconf(MateConfClient *client, guint connection_id,
- MateConfEntry *entry, gpointer userdata)
+cb_gsettings(GSettings *settings, gchar *key, MateVolumeControlPreferences *prefs)
{
- MateVolumeControlPreferences *prefs;
- MateConfValue *value;
GtkTreeIter iter;
GtkTreeModel *model;
- gchar *keybase;
gboolean active, valid;
GstMixerTrack *track;
- prefs = MATE_VOLUME_CONTROL_PREFERENCES (userdata);
model = gtk_tree_view_get_model (GTK_TREE_VIEW(prefs->treeview));
- keybase = get_mateconf_key (prefs->mixer, NULL);
-
- if (g_str_equal (mateconf_entry_get_key (entry), keybase) &&
- (value = mateconf_entry_get_value (entry)) != NULL &&
- (value->type == MATECONF_VALUE_BOOL)) {
- active = mateconf_value_get_bool (value);
- valid = gtk_tree_model_get_iter_first(model, &iter);
-
- while (valid == TRUE) {
- gtk_tree_model_get (model, &iter,
- COL_TRACK, &track,
- -1);
- if (g_str_equal (track->label, mateconf_entry_get_key (entry) + strlen (keybase))) {
- gtk_list_store_set( GTK_LIST_STORE(model), &iter, COL_ACTIVE, active, -1);
- break ;
- }
- valid = gtk_tree_model_iter_next(model, &iter);
- }
+
+ valid = gtk_tree_model_get_iter_first(model, &iter);
+
+ while (valid == TRUE) {
+ gtk_tree_model_get (model, &iter,
+ COL_TRACK, &track,
+ -1);
+ active = mate_volume_control_element_is_to_show (settings, prefs->mixer, track);
+ gtk_list_store_set( GTK_LIST_STORE(model), &iter, COL_ACTIVE, active, -1);
+ valid = gtk_tree_model_iter_next(model, &iter);
}
}
@@ -393,35 +379,42 @@ cb_activated(GtkTreeView *view, GtkTreePath *path,
GtkTreeModel *model;
GtkTreeIter iter;
gboolean active;
+ gboolean is_whitelist;
GstMixerTrack *track;
MateVolumeControlPreferences *prefs;
prefs = MATE_VOLUME_CONTROL_PREFERENCES (userdata);
model = gtk_tree_view_get_model(view);
+ mate_volume_control_element_whitelist (prefs->mixer, NULL);
if (gtk_tree_model_get_iter(model, &iter, path)) {
gtk_tree_model_get(model, &iter,
COL_ACTIVE, &active,
COL_TRACK, &track,
-1);
- active = !active;
+ is_whitelist = mate_volume_control_element_whitelist (prefs->mixer, track);
+
+ if (is_whitelist == FALSE)
+ {
+ active = !active;
- gtk_list_store_set( GTK_LIST_STORE(model), &iter, COL_ACTIVE, active, -1);
- set_mateconf_track_active(prefs->client, prefs->mixer, track, active);
+ gtk_list_store_set( GTK_LIST_STORE(model), &iter, COL_ACTIVE, active, -1);
+ set_gsettings_track_active(prefs->settings, prefs->mixer, track, active);
+ }
}
}
static void
cb_toggle (GtkCellRendererToggle *cell,
gchar *path_str,
- gpointer data)
+ MateVolumeControlPreferences *prefs)
{
- MateVolumeControlPreferences *prefs = data;
GtkTreeModel *model = gtk_tree_view_get_model (GTK_TREE_VIEW (prefs->treeview));
GtkTreePath *path = gtk_tree_path_new_from_string (path_str);
GtkTreeIter iter;
gboolean active;
+ gboolean is_whitelist;
GstMixerTrack *track;
gtk_tree_model_get_iter (model, &iter, path);
@@ -430,12 +423,17 @@ cb_toggle (GtkCellRendererToggle *cell,
COL_TRACK, &track,
-1);
- active = !active;
+ mate_volume_control_element_whitelist (prefs->mixer, NULL);
+ is_whitelist = mate_volume_control_element_whitelist (prefs->mixer, track);
+
+ if (is_whitelist == FALSE)
+ {
+ active = !active;
- gtk_list_store_set (GTK_LIST_STORE (model), &iter,
- COL_ACTIVE, active,
- -1);
+ gtk_list_store_set (GTK_LIST_STORE (model), &iter,
+ COL_ACTIVE, active,
+ -1);
+ set_gsettings_track_active(prefs->settings, prefs->mixer, track, active);
+ }
gtk_tree_path_free (path);
-
- set_mateconf_track_active(prefs->client, prefs->mixer, track, active);
}
diff --git a/gst-mixer/src/preferences.h b/gst-mixer/src/preferences.h
index d9850f4..ad43bb1 100644
--- a/gst-mixer/src/preferences.h
+++ b/gst-mixer/src/preferences.h
@@ -24,7 +24,7 @@
#include <glib.h>
#include <gtk/gtk.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#include <gst/interfaces/mixer.h>
G_BEGIN_DECLS
@@ -48,9 +48,8 @@ typedef struct _MateVolumeControlPreferences {
/* current element that we're working on */
GstMixer *mixer;
- /* mateconf client inherited from our parent */
- MateConfClient *client;
- guint client_cnxn;
+ /* gsettings */
+ GSettings *settings;
/* treeview inside us */
GtkWidget *treeview;
@@ -61,15 +60,14 @@ typedef struct _MateVolumeControlPreferencesClass {
} MateVolumeControlPreferencesClass;
GType mate_volume_control_preferences_get_type (void);
-GtkWidget *mate_volume_control_preferences_new (GstElement *element,
- MateConfClient *client);
+GtkWidget *mate_volume_control_preferences_new (GstElement *element);
void mate_volume_control_preferences_change (MateVolumeControlPreferences *prefs,
GstElement *element);
/*
- * MateConf thingy. Escapes spaces and such.
+ * GSettings thingy. Escapes spaces and such.
*/
-gchar * get_mateconf_key (GstMixer *mixer, GstMixerTrack *track);
+gchar * get_gsettings_name (GstMixer *mixer, GstMixerTrack *track);
G_END_DECLS
diff --git a/gst-mixer/src/schemas.c b/gst-mixer/src/schemas.c
new file mode 100644
index 0000000..a8277cc
--- /dev/null
+++ b/gst-mixer/src/schemas.c
@@ -0,0 +1,106 @@
+/* MATE Volume Control
+ * Copyright (C) 2012 Stefano Karapetsas <[email protected]>
+ *
+ * schemas.c: useful functions for gsettings
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library 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
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <gio/gio.h>
+
+gboolean
+schemas_is_str_in_strv (GSettings *settings, const gchar *key, const gchar *value)
+{
+ gboolean retval = FALSE;
+ gchar **array;
+ gint i;
+
+ array = g_settings_get_strv (settings, key);
+
+ if (array) {
+ for (i = 0; array[i] != NULL ; i++) {
+ if (g_strcmp0 (value, array[i]) == 0) {
+ retval = TRUE;
+ break;
+ }
+ }
+ g_strfreev (array);
+ }
+ return retval;
+}
+
+/* from gnome-panel */
+gboolean
+schemas_gsettings_append_strv (GSettings *settings, const gchar *key, const gchar *value)
+{
+ gchar **old;
+ gchar **new;
+ gint size;
+ gboolean retval;
+
+ old = g_settings_get_strv (settings, key);
+
+ for (size = 0; old[size] != NULL; size++);
+
+ size += 1; /* appended value */
+ size += 1; /* NULL */
+
+ new = g_realloc_n (old, size, sizeof (gchar *));
+
+ new[size - 2] = g_strdup (value);
+ new[size - 1] = NULL;
+
+ g_settings_delay (settings);
+ retval = g_settings_set_strv (settings, key,
+ (const gchar **) new);
+ g_settings_apply (settings);
+
+ g_strfreev (new);
+
+ return retval;
+}
+
+/* from gnome-panel */
+gboolean
+schemas_gsettings_remove_all_from_strv (GSettings *settings, const gchar *key, const gchar *value)
+{
+ GArray *array;
+ gchar **old;
+ gint i;
+ gboolean retval;
+
+ old = g_settings_get_strv (settings, key);
+ array = g_array_new (TRUE, TRUE, sizeof (gchar *));
+
+ for (i = 0; old[i] != NULL; i++) {
+ if (g_strcmp0 (old[i], value) != 0)
+ array = g_array_append_val (array, old[i]);
+ }
+
+ g_settings_delay (settings);
+ retval = g_settings_set_strv (settings, key,
+ (const gchar **) array->data);
+ g_settings_apply (settings);
+
+ g_strfreev (old);
+ g_array_free (array, TRUE);
+
+ return retval;
+}
diff --git a/gst-mixer/src/keys.h b/gst-mixer/src/schemas.h
index 809d507..eee8588 100644
--- a/gst-mixer/src/keys.h
+++ b/gst-mixer/src/schemas.h
@@ -1,7 +1,7 @@
/* MATE Volume Control
- * Copyright (C) 2003-2004 Ronald Bultje <[email protected]>
+ * Copyright (C) 2012 Stefano Karapetsas <[email protected]>
*
- * keys.h: MateConf key macros
+ * schemas.h: GSettings schemas and keys
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -19,21 +19,21 @@
* Boston, MA 02111-1307, USA.
*/
-#ifndef __GVC_KEYS_H__
-#define __GVC_KEYS_H__
+#ifndef __GVC_SCHEMAS_H__
+#define __GVC_SCHEMAS_H__
G_BEGIN_DECLS
-#define MATE_VOLUME_CONTROL_KEY_DIR \
- "/apps/mate-volume-control"
-#define MATE_VOLUME_CONTROL_KEY(key) \
- MATE_VOLUME_CONTROL_KEY_DIR "/" key
+#define MATE_VOLUME_CONTROL_SCHEMA "org.mate.volume-control"
+#define MATE_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT "active-element"
+#define MATE_VOLUME_CONTROL_KEY_SHOWN_ELEMENTS "shown-elements"
+#define MATE_VOLUME_CONTROL_KEY_WINDOW_WIDTH "window-width"
+#define MATE_VOLUME_CONTROL_KEY_WINDOW_HEIGHT "window-height"
-#define MATE_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT \
- MATE_VOLUME_CONTROL_KEY ("active-element")
-#define PREF_UI_WINDOW_WIDTH MATE_VOLUME_CONTROL_KEY ("ui/window_width")
-#define PREF_UI_WINDOW_HEIGHT MATE_VOLUME_CONTROL_KEY ("ui/window_height")
+gboolean schemas_is_str_in_strv (GSettings *settings, const gchar *key, const gchar *value);
+gboolean schemas_gsettings_append_strv (GSettings *settings, const gchar *key, const gchar *value);
+gboolean schemas_gsettings_remove_all_from_strv (GSettings *settings, const gchar *key, const gchar *value);
G_END_DECLS
-#endif /* __GVC_KEYS_H__ */
+#endif /* __GVC_SCHEMAS_H__ */
diff --git a/gst-mixer/src/track.h b/gst-mixer/src/track.h
index 1ace5f8..265f0c8 100644
--- a/gst-mixer/src/track.h
+++ b/gst-mixer/src/track.h
@@ -24,7 +24,6 @@
#include <glib.h>
#include <gtk/gtk.h>
-#include <mateconf/mateconf-client.h>
#include <gst/gst.h>
#include <gst/interfaces/mixer.h>
diff --git a/gst-mixer/src/window.c b/gst-mixer/src/window.c
index 19b9eed..9940421 100644
--- a/gst-mixer/src/window.c
+++ b/gst-mixer/src/window.c
@@ -25,10 +25,10 @@
#include <glib/gi18n.h>
#include <gtk/gtk.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#include <gdk/gdkkeysyms.h>
-#include "keys.h"
+#include "schemas.h"
#include "preferences.h"
#include "window.h"
@@ -64,7 +64,7 @@ cb_change (GtkComboBox *widget,
device_name = gtk_combo_box_get_active_text (widget);
g_return_if_fail (device_name != NULL);
- mateconf_client_set_string (win->client, MATE_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT, device_name, NULL);
+ g_settings_set_string (win->settings, MATE_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT, device_name);
g_free (device_name);
}
@@ -89,8 +89,7 @@ cb_preferences (GtkAction *action,
{
if (!win->prefs) {
- win->prefs = mate_volume_control_preferences_new (GST_ELEMENT (win->el->mixer),
- win->client);
+ win->prefs = mate_volume_control_preferences_new (GST_ELEMENT (win->el->mixer));
g_signal_connect (win->prefs, "destroy", G_CALLBACK (cb_preferences_destroy), win);
gtk_widget_show (win->prefs);
} else {
@@ -180,18 +179,12 @@ window_change_mixer_element (MateVolumeControlWindow *win,
}
static void
-cb_mateconf (MateConfClient *client,
- guint connection_id,
- MateConfEntry *entry,
+cb_gsettings_active_element (GSettings *settings,
+ gchar *key,
gpointer data)
{
- g_return_if_fail (mateconf_entry_get_key (entry) != NULL);
-
- if (g_str_equal (mateconf_entry_get_key (entry),
- MATE_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT)) {
window_change_mixer_element (MATE_VOLUME_CONTROL_WINDOW (data),
- mateconf_value_get_string (mateconf_entry_get_value (entry)));
- }
+ g_settings_get_string (settings, key));
}
/*
@@ -237,9 +230,9 @@ mate_volume_control_window_dispose (GObject *object)
win->elements = NULL;
}
- if (win->client) {
- g_object_unref (win->client);
- win->client = NULL;
+ if (win->settings) {
+ g_object_unref (win->settings);
+ win->settings = NULL;
}
G_OBJECT_CLASS (mate_volume_control_window_parent_class)->dispose (object);
@@ -262,7 +255,7 @@ mate_volume_control_window_init (MateVolumeControlWindow *win)
win->elements = NULL;
win->el = NULL;
- win->client = mateconf_client_get_default ();
+ win->settings = g_settings_new (MATE_VOLUME_CONTROL_SCHEMA);
win->prefs = NULL;
win->use_default_mixer = FALSE;
@@ -270,10 +263,10 @@ mate_volume_control_window_init (MateVolumeControlWindow *win)
gtk_window_set_title (GTK_WINDOW (win), _("Volume Control"));
/* To set the window according to previous geometry */
- width = mateconf_client_get_int (win->client, PREF_UI_WINDOW_WIDTH, NULL);
+ width = g_settings_get_int (win->settings, MATE_VOLUME_CONTROL_KEY_WINDOW_WIDTH);
if (width < 250)
width = 250;
- height = mateconf_client_get_int (win->client, PREF_UI_WINDOW_HEIGHT, NULL);
+ height = g_settings_get_int (win->settings, MATE_VOLUME_CONTROL_KEY_WINDOW_HEIGHT);
if (height < 100)
height = -1;
gtk_window_set_default_size (GTK_WINDOW (win), width, height);
@@ -314,9 +307,8 @@ mate_volume_control_window_new (GList *elements)
g_cclosure_new_swap (G_CALLBACK (cb_show_about), win, NULL));
/* get active element, if any (otherwise we use the default) */
- active_el_str = mateconf_client_get_string (win->client,
- MATE_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT,
- NULL);
+ active_el_str = g_settings_get_string (win->settings,
+ MATE_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT);
if (active_el_str != NULL && *active_el_str != '\0') {
for (count = 0, item = elements; item != NULL; item = item->next, count++) {
cur_el_str = g_object_get_data (item->data, "mate-volume-control-name");
@@ -334,11 +326,10 @@ mate_volume_control_window_new (GList *elements)
active_element = elements->data;
/* If there's a default but it doesn't match what we have available,
* reset the default */
- mateconf_client_set_string (win->client,
+ g_settings_set_string (win->settings,
MATE_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT,
g_object_get_data (G_OBJECT (active_element),
- "mate-volume-control-name"),
- NULL);
+ "mate-volume-control-name"));
}
/* default element to first */
if (!active_element)
@@ -365,11 +356,9 @@ mate_volume_control_window_new (GList *elements)
g_signal_connect (combo_box, "changed", G_CALLBACK (cb_change), win);
- /* mateconf */
- mateconf_client_add_dir (win->client, MATE_VOLUME_CONTROL_KEY_DIR,
- MATECONF_CLIENT_PRELOAD_RECURSIVE, NULL);
- mateconf_client_notify_add (win->client, MATE_VOLUME_CONTROL_KEY_DIR,
- cb_mateconf, win, NULL, NULL);
+ /* gsettings */
+ g_signal_connect (win->settings, "changed::" MATE_VOLUME_CONTROL_KEY_ACTIVE_ELEMENT,
+ G_CALLBACK (cb_gsettings_active_element), win);
win->use_default_mixer = (active_el_str == NULL);
@@ -383,7 +372,7 @@ mate_volume_control_window_new (GList *elements)
gtk_box_pack_start (GTK_BOX (hbox), combo_box, TRUE, TRUE, 0);
/* add content for this element */
- el = mate_volume_control_element_new (win->client);
+ el = mate_volume_control_element_new ();
win->el = MATE_VOLUME_CONTROL_ELEMENT (el);
/* create the buttons box */
diff --git a/gst-mixer/src/window.h b/gst-mixer/src/window.h
index e108d75..cbd1901 100644
--- a/gst-mixer/src/window.h
+++ b/gst-mixer/src/window.h
@@ -23,7 +23,7 @@
#define __GVC_WINDOW_H__
#include <glib.h>
-#include <mateconf/mateconf-client.h>
+#include <gio/gio.h>
#include <gst/gst.h>
#include "element.h"
@@ -49,8 +49,8 @@ typedef struct {
/* element list */
GList *elements;
- /* mateconf client */
- MateConfClient *client;
+ /* gsettings */
+ GSettings *settings;
/* contents */
MateVolumeControlElement *el;