diff options
-rw-r--r-- | gst-mixer/org.mate.volume-control.gschema.xml.in.in | 5 | ||||
-rw-r--r-- | gst-mixer/src/element.c | 14 | ||||
-rw-r--r-- | gst-mixer/src/preferences.c | 42 | ||||
-rw-r--r-- | gst-mixer/src/schemas.c | 14 | ||||
-rw-r--r-- | gst-mixer/src/schemas.h | 1 |
5 files changed, 50 insertions, 26 deletions
diff --git a/gst-mixer/org.mate.volume-control.gschema.xml.in.in b/gst-mixer/org.mate.volume-control.gschema.xml.in.in index 2b3fe22..66e01ed 100644 --- a/gst-mixer/org.mate.volume-control.gschema.xml.in.in +++ b/gst-mixer/org.mate.volume-control.gschema.xml.in.in @@ -20,5 +20,10 @@ <_summary>Shown elements in volume control</_summary> <_description>Set the elements to show in volume control</_description> </key> + <key name="hidden-elements" type="as"> + <default>[]</default> + <_summary>Hidden elements in volume control</_summary> + <_description>Set the elements in whitelist to hide in volume control</_description> + </key> </schema> </schemalist> diff --git a/gst-mixer/src/element.c b/gst-mixer/src/element.c index 66a007c..aebdcbf 100644 --- a/gst-mixer/src/element.c +++ b/gst-mixer/src/element.c @@ -72,6 +72,8 @@ mate_volume_control_element_new () g_signal_connect (el->settings, "changed::" MATE_VOLUME_CONTROL_KEY_SHOWN_ELEMENTS, G_CALLBACK (cb_gsettings), el); + g_signal_connect (el->settings, "changed::" MATE_VOLUME_CONTROL_KEY_HIDDEN_ELEMENTS, + G_CALLBACK (cb_gsettings), el); return GTK_WIDGET (el); } @@ -190,20 +192,22 @@ mate_volume_control_element_is_to_show (GSettings *settings, mate_volume_control_element_whitelist (mixer, NULL); is_whitelist = mate_volume_control_element_whitelist (mixer, track); + name = get_gsettings_name (mixer, track); if (is_whitelist == TRUE) { - return TRUE; + /* if element is in whitelis, user can set it hidden */ + if (schemas_is_str_in_strv (settings, MATE_VOLUME_CONTROL_KEY_HIDDEN_ELEMENTS, name) == FALSE) + is_to_show = TRUE; } else { - name = get_gsettings_name (mixer, track); - /* if element is not in whitelist, user can be set it to show */ + /* if element is not in whitelist, user can 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; } + g_free (name); + return is_to_show; } /* diff --git a/gst-mixer/src/preferences.c b/gst-mixer/src/preferences.c index bc93af1..55dd6ad 100644 --- a/gst-mixer/src/preferences.c +++ b/gst-mixer/src/preferences.c @@ -52,7 +52,7 @@ static void mate_volume_control_preferences_response (GtkDialog *dialog, gint response_id); static void set_gsettings_track_active (GSettings *settings, GstMixer *mixer, - GstMixerTrack *track, gboolean active); + GstMixerTrack *track, gboolean active, gboolean is_whitelist); static void cb_toggle (GtkCellRendererToggle *cell, @@ -327,7 +327,7 @@ mate_volume_control_preferences_change (MateVolumeControlPreferences *prefs, static void set_gsettings_track_active(GSettings *settings, GstMixer *mixer, - GstMixerTrack *track, gboolean active) + GstMixerTrack *track, gboolean active, gboolean is_whitelist) { gchar *name; @@ -335,14 +335,31 @@ set_gsettings_track_active(GSettings *settings, GstMixer *mixer, if (active == TRUE) { + if (is_whitelist == TRUE) + { + schemas_gsettings_remove_all_from_strv (settings, MATE_VOLUME_CONTROL_KEY_HIDDEN_ELEMENTS, name); + } + else + { 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); + if (is_whitelist == TRUE) + { + if (schemas_is_str_in_strv (settings, MATE_VOLUME_CONTROL_KEY_HIDDEN_ELEMENTS, name) == FALSE) + { + schemas_gsettings_append_strv (settings, MATE_VOLUME_CONTROL_KEY_HIDDEN_ELEMENTS, name); + } + } + else + { + schemas_gsettings_remove_all_from_strv (settings, MATE_VOLUME_CONTROL_KEY_SHOWN_ELEMENTS, name); + } } g_free (name); @@ -395,13 +412,10 @@ cb_activated(GtkTreeView *view, GtkTreePath *path, is_whitelist = mate_volume_control_element_whitelist (prefs->mixer, track); - if (is_whitelist == FALSE) - { - active = !active; + active = !active; - gtk_list_store_set( GTK_LIST_STORE(model), &iter, COL_ACTIVE, active, -1); - set_gsettings_track_active(prefs->settings, 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, is_whitelist); } } @@ -426,14 +440,12 @@ cb_toggle (GtkCellRendererToggle *cell, mate_volume_control_element_whitelist (prefs->mixer, NULL); is_whitelist = mate_volume_control_element_whitelist (prefs->mixer, track); - if (is_whitelist == FALSE) - { - active = !active; + active = !active; - gtk_list_store_set (GTK_LIST_STORE (model), &iter, + gtk_list_store_set (GTK_LIST_STORE (model), &iter, COL_ACTIVE, active, -1); - set_gsettings_track_active(prefs->settings, prefs->mixer, track, active); - } + set_gsettings_track_active(prefs->settings, prefs->mixer, track, active, is_whitelist); + gtk_tree_path_free (path); } diff --git a/gst-mixer/src/schemas.c b/gst-mixer/src/schemas.c index a8277cc..599d4bc 100644 --- a/gst-mixer/src/schemas.c +++ b/gst-mixer/src/schemas.c @@ -67,10 +67,8 @@ schemas_gsettings_append_strv (GSettings *settings, const gchar *key, const gcha 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); @@ -84,6 +82,7 @@ schemas_gsettings_remove_all_from_strv (GSettings *settings, const gchar *key, c GArray *array; gchar **old; gint i; + gboolean changed = FALSE; gboolean retval; old = g_settings_get_strv (settings, key); @@ -92,12 +91,15 @@ schemas_gsettings_remove_all_from_strv (GSettings *settings, const gchar *key, c for (i = 0; old[i] != NULL; i++) { if (g_strcmp0 (old[i], value) != 0) array = g_array_append_val (array, old[i]); + else + changed = TRUE; } - g_settings_delay (settings); - retval = g_settings_set_strv (settings, key, - (const gchar **) array->data); - g_settings_apply (settings); + if (changed) + retval = g_settings_set_strv (settings, key, + (const gchar **) array->data); + else + retval = TRUE; g_strfreev (old); g_array_free (array, TRUE); diff --git a/gst-mixer/src/schemas.h b/gst-mixer/src/schemas.h index eee8588..2f338f2 100644 --- a/gst-mixer/src/schemas.h +++ b/gst-mixer/src/schemas.h @@ -27,6 +27,7 @@ G_BEGIN_DECLS #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_HIDDEN_ELEMENTS "hidden-elements" #define MATE_VOLUME_CONTROL_KEY_WINDOW_WIDTH "window-width" #define MATE_VOLUME_CONTROL_KEY_WINDOW_HEIGHT "window-height" |