[Xfce4-commits] <xfce4-mixer:master> Handle read-only tracks or tracks with no mute/record functionality

Guido Berhoerster noreply at xfce.org
Thu Sep 27 16:46:29 CEST 2012


Updating branch refs/heads/master
         to 47d1cee0825f316b24ee826c5c2f1d6cd53b465d (commit)
       from 444b8b826fd6b2c3d27f5d57309c7e5d40e08ed2 (commit)

commit 47d1cee0825f316b24ee826c5c2f1d6cd53b465d
Author: Guido Berhoerster <guido+xfce at berhoerster.name>
Date:   Thu Sep 27 16:31:09 2012 +0200

    Handle read-only tracks or tracks with no mute/record functionality
    
    Handle tracks which are marked read-only by GStreamer by making the
    corresponding widgets insensitive in the mixer application and by preventing
    them from being selected in the panel plugin.
    Require GStreamer 0.10.25 in order avoid #ifdefs.
    Handle missing record/mute functionality by making the corresponding buttons in
    the mixer application UI insensitive and by disallowing mute actions in the
    panel plugin.

 NEWS                                   |    3 +
 configure.ac.in                        |    2 +-
 libxfce4mixer/libxfce4mixer.c          |   47 +++++++++++++++-----
 libxfce4mixer/xfce-mixer-track-combo.c |   16 +++++--
 panel-plugin/xfce-mixer-plugin.c       |   67 ++++++++++++++++++++++------
 panel-plugin/xfce-volume-button.c      |   76 ++++++++++++++++++++++++++++---
 panel-plugin/xfce-volume-button.h      |    3 +
 xfce4-mixer/xfce-mixer-option.c        |    3 +
 xfce4-mixer/xfce-mixer-switch.c        |    9 ++++
 xfce4-mixer/xfce-mixer-track.c         |   15 ++++++
 10 files changed, 201 insertions(+), 40 deletions(-)

diff --git a/NEWS b/NEWS
index 10f1d89..9798e77 100644
--- a/NEWS
+++ b/NEWS
@@ -41,6 +41,9 @@
 - Add runtime debugging mode to both the mixer and the panel plugin.
 - Add man page for xfce4-mixer.
 - Handle identically named tracks by making use of the track index property.
+- Handle tracks which are marked read-only by GStreamer or which have no mute
+  or record functionality by making the corresponding widgets insensitive.
+  Prevent read-only tracks from being selected in the panel-plugin.
 
 
 4.8.0
diff --git a/configure.ac.in b/configure.ac.in
index aa0b086..45fe951 100644
--- a/configure.ac.in
+++ b/configure.ac.in
@@ -96,7 +96,7 @@ dnl ***********************************
 XDT_CHECK_PACKAGE([GLIB], [glib-2.0], [2.24.0])
 XDT_CHECK_PACKAGE([GTHREAD], [gthread-2.0], [2.24.0])
 XDT_CHECK_PACKAGE([DBUS_GLIB], [dbus-glib-1], [0.84])
-XDT_CHECK_PACKAGE([GST_PLUGINS_BASE], [gstreamer-plugins-base-0.10], [0.10.23])
+XDT_CHECK_PACKAGE([GST_PLUGINS_BASE], [gstreamer-plugins-base-0.10], [0.10.25])
 XDT_CHECK_PACKAGE([GTK], [gtk+-2.0], [2.20.0])
 XDT_CHECK_PACKAGE([UNIQUE], [unique-1.0], [1.1])
 XDT_CHECK_PACKAGE([LIBXFCE4UTIL], [libxfce4util-1.0], [4.10.0])
diff --git a/libxfce4mixer/libxfce4mixer.c b/libxfce4mixer/libxfce4mixer.c
index c14ee27..451e1d8 100644
--- a/libxfce4mixer/libxfce4mixer.c
+++ b/libxfce4mixer/libxfce4mixer.c
@@ -224,31 +224,56 @@ xfce_mixer_get_track (GstElement  *card,
 GstMixerTrack *
 xfce_mixer_get_default_track (GstElement *card)
 {
-  GstMixerTrack *track = NULL;
-  const GList   *iter;
-  GstMixerTrack *track_tmp;
-  const GList   *tracks;
+  GstMixerTrack      *track = NULL;
+  XfceMixerTrackType  track_type = G_TYPE_INVALID;
+  const GList        *iter;
+  GstMixerTrack      *track_tmp;
+  XfceMixerTrackType  track_type_tmp;
 
   g_return_val_if_fail (GST_IS_MIXER (card), NULL);
 
-  /* Try to get the master track */
+  /*
+   * Try to get the master track if it is a playback or capture track and not
+   * read-only
+   */
   for (iter = gst_mixer_list_tracks (GST_MIXER (card)); iter != NULL; iter = g_list_next (iter))
     {
       track_tmp = GST_MIXER_TRACK (iter->data);
+      track_type_tmp = xfce_mixer_track_type_new (track_tmp);
 
-      if (GST_MIXER_TRACK_HAS_FLAG (track_tmp, GST_MIXER_TRACK_MASTER))
+      if (GST_MIXER_TRACK_HAS_FLAG (track_tmp, GST_MIXER_TRACK_MASTER) &&
+          (track_type_tmp == XFCE_MIXER_TRACK_TYPE_PLAYBACK ||
+           track_type_tmp == XFCE_MIXER_TRACK_TYPE_CAPTURE) &&
+          !GST_MIXER_TRACK_HAS_FLAG (track_tmp, GST_MIXER_TRACK_READONLY))
         {
           track = track_tmp;
+          track_type = track_type_tmp;
           break;
         }
     }
 
-  /* If there is no master track, try to get the first track */
-  if (!GST_IS_MIXER_TRACK (track))
+  /*
+   * If there is no master track, try to get the first track which is a
+   * playback or capture track and not read-only
+   */
+  if (!GST_IS_MIXER_TRACK (track) ||
+      (track_type != XFCE_MIXER_TRACK_TYPE_PLAYBACK &&
+       track_type != XFCE_MIXER_TRACK_TYPE_CAPTURE) ||
+      GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_READONLY))
     {
-      tracks = gst_mixer_list_tracks (GST_MIXER (card));
-      if (g_list_length (tracks) > 0)
-        track = g_list_first (tracks)->data;
+      for (iter = gst_mixer_list_tracks (GST_MIXER (card)); iter != NULL; iter = g_list_next (iter))
+        {
+          track_tmp = GST_MIXER_TRACK (iter->data);
+          track_type = xfce_mixer_track_type_new (track_tmp);
+
+          if ((track_type == XFCE_MIXER_TRACK_TYPE_PLAYBACK ||
+               track_type == XFCE_MIXER_TRACK_TYPE_CAPTURE) &&
+              !GST_MIXER_TRACK_HAS_FLAG (track_tmp, GST_MIXER_TRACK_READONLY))
+            {
+              track = track_tmp;
+              break;
+            }
+        }
     }
 
   return track;
diff --git a/libxfce4mixer/xfce-mixer-track-combo.c b/libxfce4mixer/xfce-mixer-track-combo.c
index a5e40f9..15fafcc 100644
--- a/libxfce4mixer/xfce-mixer-track-combo.c
+++ b/libxfce4mixer/xfce-mixer-track-combo.c
@@ -195,6 +195,7 @@ xfce_mixer_track_combo_set_soundcard (XfceMixerTrackCombo *combo,
   gint               counter;
   gint               active_index = 0;
   GstMixerTrack     *track;
+  GstMixerTrack     *track_new;
 
   g_return_if_fail (IS_XFCE_MIXER_TRACK_COMBO (combo));
 
@@ -217,16 +218,21 @@ xfce_mixer_track_combo_set_soundcard (XfceMixerTrackCombo *combo,
 
   for (iter = gst_mixer_list_tracks (GST_MIXER (combo->card)), counter = 0; iter != NULL; iter = g_list_next (iter))
     {
-      type = xfce_mixer_track_type_new (iter->data);
-
-      if (type == XFCE_MIXER_TRACK_TYPE_PLAYBACK || type == XFCE_MIXER_TRACK_TYPE_CAPTURE)
+      track_new = GST_MIXER_TRACK (iter->data);
+      type = xfce_mixer_track_type_new (track_new);
+
+      /* Only include writable playback or capture tracks */
+      if ((type == XFCE_MIXER_TRACK_TYPE_PLAYBACK &&
+           !GST_MIXER_TRACK_HAS_FLAG (track_new, GST_MIXER_TRACK_READONLY)) ||
+          (type == XFCE_MIXER_TRACK_TYPE_CAPTURE &&
+           !GST_MIXER_TRACK_HAS_FLAG (track_new, GST_MIXER_TRACK_READONLY)))
         {
           gtk_list_store_append (combo->list_store, &tree_iter);
           gtk_list_store_set (combo->list_store, &tree_iter, 
-                              NAME_COLUMN, xfce_mixer_get_track_label (GST_MIXER_TRACK (iter->data)), 
+                              NAME_COLUMN, xfce_mixer_get_track_label (track_new),
                               TRACK_COLUMN, GST_MIXER_TRACK (iter->data), -1);
 
-          if (G_UNLIKELY (track != NULL && track == GST_MIXER_TRACK (iter->data)))
+          if (G_UNLIKELY (GST_IS_MIXER_TRACK (track) && track == track_new))
             active_index = counter;
 
           ++counter;
diff --git a/panel-plugin/xfce-mixer-plugin.c b/panel-plugin/xfce-mixer-plugin.c
index 9029c29..0d2f854 100644
--- a/panel-plugin/xfce-mixer-plugin.c
+++ b/panel-plugin/xfce-mixer-plugin.c
@@ -347,12 +347,13 @@ xfce_mixer_plugin_set_property (GObject      *object,
                                 const GValue *value,
                                 GParamSpec   *pspec)
 {
-  XfceMixerPlugin *mixer_plugin = XFCE_MIXER_PLUGIN (object);
-  const gchar     *card_name;
-  GstElement      *card = NULL;
-  gchar           *track_label = NULL;
-  GstMixerTrack   *track = NULL;
-  gboolean         enable_keyboard_shortcuts;
+  XfceMixerPlugin    *mixer_plugin = XFCE_MIXER_PLUGIN (object);
+  const gchar        *card_name;
+  GstElement         *card = NULL;
+  gchar              *track_label = NULL;
+  GstMixerTrack      *track = NULL;
+  XfceMixerTrackType  track_type = G_TYPE_INVALID;
+  gboolean            enable_keyboard_shortcuts;
 
   switch(prop_id)
     {
@@ -408,8 +409,17 @@ xfce_mixer_plugin_set_property (GObject      *object,
             if (track_label != NULL)
               track = xfce_mixer_get_track (mixer_plugin->card, track_label);
 
-            /* If the given track label is invalid resort to the default */
-            if (!GST_IS_MIXER_TRACK (track))
+            if (GST_IS_MIXER_TRACK (track))
+              track_type = xfce_mixer_track_type_new (track);
+
+            /*
+             * If the given track is invalid or not a playback or capture track
+             * or read-only resort to the default
+             */
+            if (!GST_IS_MIXER_TRACK (track) ||
+                (track_type != XFCE_MIXER_TRACK_TYPE_PLAYBACK &&
+                 track_type != XFCE_MIXER_TRACK_TYPE_CAPTURE) ||
+                GST_MIXER_TRACK_HAS_FLAG (track, GST_MIXER_TRACK_READONLY))
               {
                 g_free (track_label);
                 track = xfce_mixer_get_default_track (mixer_plugin->card);
@@ -665,13 +675,22 @@ static void
 xfce_mixer_plugin_mute_changed (XfceMixerPlugin *mixer_plugin,
                                 gboolean         muted)
 {
+  XfceMixerTrackType track_type;
+
   g_return_if_fail (GST_IS_MIXER (mixer_plugin->card));
   g_return_if_fail (GST_IS_MIXER_TRACK (mixer_plugin->track));
 
-  mixer_plugin->ignore_bus_messages = TRUE;
+  track_type = xfce_mixer_track_type_new (mixer_plugin->track);
+
+  if ((track_type == XFCE_MIXER_TRACK_TYPE_PLAYBACK &&
+       GST_MIXER_TRACK_HAS_FLAG (mixer_plugin->track, GST_MIXER_TRACK_NO_MUTE)) ||
+      (track_type == XFCE_MIXER_TRACK_TYPE_CAPTURE &&
+       GST_MIXER_TRACK_HAS_FLAG (mixer_plugin->track, GST_MIXER_TRACK_NO_RECORD)))
+    return;
 
+  mixer_plugin->ignore_bus_messages = TRUE;
 
-  if (G_LIKELY (xfce_mixer_track_type_new (mixer_plugin->track) == XFCE_MIXER_TRACK_TYPE_PLAYBACK))
+  if (G_LIKELY (track_type == XFCE_MIXER_TRACK_TYPE_PLAYBACK))
     {
       /* Apply mute change to the sound card */
       gst_mixer_set_mute (GST_MIXER (mixer_plugin->card), mixer_plugin->track, muted);
@@ -795,14 +814,32 @@ xfce_mixer_plugin_update_track (XfceMixerPlugin *mixer_plugin)
   else if (track_type == XFCE_MIXER_TRACK_TYPE_CAPTURE)
     muted = !GST_MIXER_TRACK_HAS_FLAG (mixer_plugin->track, GST_MIXER_TRACK_RECORD);
 
-  /* Update the volume button */
+  /* Update the volume button and menu */
   xfce_volume_button_set_is_configured (XFCE_VOLUME_BUTTON (mixer_plugin->button), TRUE);
-  xfce_volume_button_set_volume (XFCE_VOLUME_BUTTON (mixer_plugin->button), volume);
-  xfce_volume_button_set_muted (XFCE_VOLUME_BUTTON (mixer_plugin->button), muted);
   xfce_volume_button_set_track_label (XFCE_VOLUME_BUTTON (mixer_plugin->button), xfce_mixer_get_track_label (mixer_plugin->track));
+  xfce_volume_button_set_volume (XFCE_VOLUME_BUTTON (mixer_plugin->button), volume);
 
-  /* Update mute menu item */
-  gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mixer_plugin->mute_menu_item), muted);
+  /*
+   * If the track does not support mute/record, disable the corresponding menu
+   * item and button functionality
+   */
+  if ((track_type == XFCE_MIXER_TRACK_TYPE_PLAYBACK &&
+       GST_MIXER_TRACK_HAS_FLAG (mixer_plugin->track, GST_MIXER_TRACK_NO_MUTE)) ||
+      (track_type == XFCE_MIXER_TRACK_TYPE_CAPTURE &&
+       GST_MIXER_TRACK_HAS_FLAG (mixer_plugin->track, GST_MIXER_TRACK_NO_RECORD)))
+    {
+      xfce_volume_button_set_no_mute (XFCE_VOLUME_BUTTON (mixer_plugin->button), TRUE);
+      xfce_volume_button_set_muted (XFCE_VOLUME_BUTTON (mixer_plugin->button), FALSE);
+      gtk_widget_set_sensitive (mixer_plugin->mute_menu_item, FALSE);
+      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mixer_plugin->mute_menu_item), FALSE);
+    }
+  else
+    {
+      xfce_volume_button_set_no_mute (XFCE_VOLUME_BUTTON (mixer_plugin->button), FALSE);
+      xfce_volume_button_set_muted (XFCE_VOLUME_BUTTON (mixer_plugin->button), muted);
+      gtk_widget_set_sensitive (mixer_plugin->mute_menu_item, TRUE);
+      gtk_check_menu_item_set_active (GTK_CHECK_MENU_ITEM (mixer_plugin->mute_menu_item), muted);
+    }
 
   /* Free volume array */
   g_free (volumes);
diff --git a/panel-plugin/xfce-volume-button.c b/panel-plugin/xfce-volume-button.c
index e3e11bd..188e4a6 100644
--- a/panel-plugin/xfce-volume-button.c
+++ b/panel-plugin/xfce-volume-button.c
@@ -51,6 +51,7 @@ enum
   PROP_0,
   PROP_TRACK_LABEL,
   PROP_IS_CONFIGURED,
+  PROP_NO_MUTE,
   PROP_IS_MUTED,
   PROP_SCREEN_POSITION,
   N_PROPERTIES,
@@ -167,6 +168,9 @@ struct _XfceVolumeButton
   /* Whether the button is configured */
   gboolean             is_configured;
 
+  /* Whether mute can be used */
+  gboolean             no_mute;
+
   /* Mute state of the button */
   gboolean             is_muted;
 };
@@ -248,6 +252,15 @@ xfce_volume_button_class_init (XfceVolumeButtonClass *klass)
                                                          G_PARAM_READABLE | G_PARAM_WRITABLE));
 
   g_object_class_install_property (gobject_class,
+                                   PROP_NO_MUTE,
+                                   g_param_spec_boolean ("no-mute",
+                                                         "no-mute",
+                                                         "no-mute",
+                                                         TRUE,
+                                                         G_PARAM_READABLE | G_PARAM_WRITABLE));
+
+
+  g_object_class_install_property (gobject_class,
                                    PROP_IS_MUTED,
                                    g_param_spec_boolean ("is-muted",
                                                          "is-muted",
@@ -300,6 +313,9 @@ xfce_volume_button_init (XfceVolumeButton *button)
   /* Create adjustment for the button (from 0.0 to 1.0 in 5% steps) */
   button->adjustment = gtk_adjustment_new (0.0, 0.0, 1.0, 0.01, 0.05, 0.0);
 
+  /* By default mute can be used */
+  button->no_mute = FALSE;
+
   /* Set to muted by default since the initial adjustment value is 0 */
   button->is_muted = TRUE;
 
@@ -368,6 +384,7 @@ static void xfce_volume_button_set_property (GObject      *object,
 {
   XfceVolumeButton *button = XFCE_VOLUME_BUTTON (object);
   gboolean          is_configured;
+  gboolean          no_mute;
   gboolean          is_muted;
 
   switch (prop_id)
@@ -378,9 +395,19 @@ static void xfce_volume_button_set_property (GObject      *object,
         if (button->is_configured)
           xfce_volume_button_update (button);
         break;
+      case PROP_NO_MUTE:
+        no_mute = g_value_get_boolean (value);
+        if (button->is_configured && button->no_mute != no_mute)
+          {
+            button->no_mute = no_mute;
+            if (no_mute)
+              button->is_muted = FALSE;
+            xfce_volume_button_update (button);
+          }
+        break;
       case PROP_IS_MUTED:
         is_muted = g_value_get_boolean (value);
-        if (button->is_configured && button->is_muted != is_muted)
+        if (button->is_configured && !button->no_mute && button->is_muted != is_muted)
           {
             button->is_muted = is_muted;
             xfce_volume_button_update (button);
@@ -423,6 +450,9 @@ static void xfce_volume_button_get_property (GObject      *object,
       case PROP_TRACK_LABEL:
         g_value_set_string (value, button->track_label);
         break;
+      case PROP_NO_MUTE:
+        g_value_set_boolean (value, button->no_mute);
+        break;
       case PROP_IS_MUTED:
         g_value_set_boolean (value, button->is_muted);
         break;
@@ -464,9 +494,9 @@ xfce_volume_button_scale_changed_value (XfceVolumeButton *button,
   if (fabs (new_value - old_value) > VOLUME_EPSILON)
     {
       /* Mute when volume reaches 0%, unmute if volume is raised from 0% */
-      if (new_value < VOLUME_EPSILON && !button->is_muted)
+      if (new_value < VOLUME_EPSILON && !button->is_muted && !button->no_mute)
         xfce_volume_button_set_muted (button, TRUE);
-      else if (old_value < VOLUME_EPSILON && button->is_muted)
+      else if (old_value < VOLUME_EPSILON && button->is_muted && !button->no_mute)
         xfce_volume_button_set_muted (button, FALSE);
       else
         {
@@ -740,8 +770,8 @@ xfce_volume_button_button_press_event (GtkWidget      *widget,
     }
   else if (event->button == 2)
     {
-      /* Only toggle mute if button is in configured state */
-      if (button->is_configured)
+      /* Only toggle mute if button is in configured state and can be muted */
+      if (button->is_configured && !button->no_mute)
         {
           /* Determine the new mute state by negating the current state */
           muted = !button->is_muted;
@@ -794,9 +824,9 @@ xfce_volume_button_scroll_event (GtkWidget      *widget,
   if (fabs (new_value - old_value) > VOLUME_EPSILON)
     {
       /* Mute when volume reaches 0%, unmute if volume is raised from 0% */
-      if (new_value < VOLUME_EPSILON && !button->is_muted)
+      if (new_value < VOLUME_EPSILON && !button->is_muted && !button->no_mute)
         xfce_volume_button_set_muted (button, TRUE);
-      else if (old_value < VOLUME_EPSILON && button->is_muted)
+      else if (old_value < VOLUME_EPSILON && button->is_muted && !button->no_mute)
         xfce_volume_button_set_muted (button, FALSE);
       else
         {
@@ -859,7 +889,7 @@ xfce_volume_button_update (XfceVolumeButton *button)
   else
     {
       /* Set tooltip (e.g. 'Master: 50% (muted)') */
-      if (button->is_muted)
+      if (button->is_muted && !button->no_mute)
         tip_text = g_strdup_printf (_("%s: muted"), button->track_label);
       else
         tip_text = g_strdup_printf (_("%s: %i%%"), button->track_label, (gint) round (value * 100));
@@ -984,6 +1014,36 @@ xfce_volume_button_dock_grab_broken (XfceVolumeButton *button,
 
 
 void
+xfce_volume_button_set_no_mute (XfceVolumeButton *button,
+                                gboolean          no_mute)
+{
+  GValue value = G_VALUE_INIT;
+
+  g_return_if_fail (IS_XFCE_VOLUME_BUTTON (button));
+
+  g_value_init (&value, G_TYPE_BOOLEAN);
+  g_value_set_boolean (&value, no_mute);
+  g_object_set_property (G_OBJECT (button), "no-mute", &value);
+}
+
+
+
+gboolean
+xfce_volume_button_get_no_mute (XfceVolumeButton *button)
+{
+  GValue value = G_VALUE_INIT;
+
+  g_return_val_if_fail (IS_XFCE_VOLUME_BUTTON (button), FALSE);
+
+  g_value_init (&value, G_TYPE_BOOLEAN);
+  g_object_get_property (G_OBJECT (button), "no-mute", &value);
+
+  return g_value_get_boolean (&value);
+}
+
+
+
+void
 xfce_volume_button_set_muted (XfceVolumeButton *button,
                               gboolean          is_muted)
 {
diff --git a/panel-plugin/xfce-volume-button.h b/panel-plugin/xfce-volume-button.h
index 6ab968b..2514d57 100644
--- a/panel-plugin/xfce-volume-button.h
+++ b/panel-plugin/xfce-volume-button.h
@@ -41,10 +41,13 @@ typedef struct _XfceVolumeButton      XfceVolumeButton;
 GType     xfce_volume_button_get_type           (void) G_GNUC_CONST;
 
 GtkWidget *        xfce_volume_button_new                 (void);
+void               xfce_volume_button_set_no_mute         (XfceVolumeButton   *button,
+                                                           gboolean            no_mute);
 void               xfce_volume_button_set_muted           (XfceVolumeButton   *button,
                                                            gboolean            is_muted);
 void               xfce_volume_button_set_volume          (XfceVolumeButton   *button,
                                                            gdouble             volume);
+gboolean           xfce_volume_button_get_no_mute         (XfceVolumeButton   *button);
 gboolean           xfce_volume_button_get_muted           (XfceVolumeButton   *button);
 void               xfce_volume_button_update              (XfceVolumeButton   *button);
 void               xfce_volume_button_set_icon_size       (XfceVolumeButton   *button,
diff --git a/xfce4-mixer/xfce-mixer-option.c b/xfce4-mixer/xfce-mixer-option.c
index 5f1c946..e965378 100644
--- a/xfce4-mixer/xfce-mixer-option.c
+++ b/xfce4-mixer/xfce-mixer-option.c
@@ -189,6 +189,9 @@ xfce_mixer_option_create_contents (XfceMixerOption *option)
     }
   
   gtk_box_pack_start (GTK_BOX (option), option->combo, FALSE, FALSE, 0);
+  /* Make read-only options insensitive */
+  if (GST_MIXER_TRACK_HAS_FLAG (option->track, GST_MIXER_TRACK_READONLY))
+    gtk_widget_set_sensitive (option->combo, FALSE);
   gtk_widget_show (option->combo);
 
   g_signal_connect (option->combo, "changed", G_CALLBACK (xfce_mixer_option_changed), option);
diff --git a/xfce4-mixer/xfce-mixer-switch.c b/xfce4-mixer/xfce-mixer-switch.c
index 8e4bd79..4babd6c 100644
--- a/xfce4-mixer/xfce-mixer-switch.c
+++ b/xfce4-mixer/xfce-mixer-switch.c
@@ -170,6 +170,15 @@ xfce_mixer_switch_create_contents (XfceMixerSwitch *mixer_switch)
 
   xfce_mixer_switch_update (mixer_switch);
 
+  /* Make read-only switches insensitive */
+  if ((GST_MIXER_TRACK_HAS_FLAG (mixer_switch->track, GST_MIXER_TRACK_INPUT) &&
+       (GST_MIXER_TRACK_HAS_FLAG (mixer_switch->track, GST_MIXER_TRACK_NO_RECORD) ||
+        GST_MIXER_TRACK_HAS_FLAG (mixer_switch->track, GST_MIXER_TRACK_READONLY))) ||
+      (GST_MIXER_TRACK_HAS_FLAG (mixer_switch->track, GST_MIXER_TRACK_OUTPUT) &&
+       (GST_MIXER_TRACK_HAS_FLAG (mixer_switch->track, GST_MIXER_TRACK_NO_MUTE) ||
+        GST_MIXER_TRACK_HAS_FLAG (mixer_switch->track, GST_MIXER_TRACK_READONLY))))
+    gtk_widget_set_sensitive (GTK_WIDGET (mixer_switch->check_button), FALSE);
+
   g_signal_connect (mixer_switch->check_button, "toggled", G_CALLBACK (xfce_mixer_switch_toggled), mixer_switch);
 }
 
diff --git a/xfce4-mixer/xfce-mixer-track.c b/xfce4-mixer/xfce-mixer-track.c
index 7143a4a..3c26195 100644
--- a/xfce4-mixer/xfce-mixer-track.c
+++ b/xfce4-mixer/xfce-mixer-track.c
@@ -220,6 +220,9 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
       gtk_range_set_inverted (GTK_RANGE (fader), TRUE);
       gtk_range_set_value (GTK_RANGE (fader), volumes[channel]);
       gtk_widget_set_tooltip_text (fader, tooltip_text);
+      /* Make read-only tracks insensitive */
+      if (GST_MIXER_TRACK_HAS_FLAG (track->gst_track, GST_MIXER_TRACK_READONLY))
+        gtk_widget_set_sensitive (fader, FALSE);
       g_signal_connect (fader, "value-changed", G_CALLBACK (xfce_mixer_track_fader_changed), track);
       gtk_table_attach (GTK_TABLE (track), fader, channel, channel + 1, 1, 2, GTK_SHRINK, GTK_FILL|GTK_EXPAND, 0, 0);
       gtk_widget_show (fader);
@@ -243,6 +246,10 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
       image = gtk_image_new_from_icon_name ("audio-volume-high", XFCE_MIXER_ICON_SIZE); 
       gtk_button_set_image (GTK_BUTTON (track->mute_button), image);
       gtk_widget_set_tooltip_text (track->mute_button, tooltip_text);
+      /* Make button insensitive for tracks without mute or read-only tracks */
+      if (GST_MIXER_TRACK_HAS_FLAG (track->gst_track, GST_MIXER_TRACK_READONLY) ||
+          GST_MIXER_TRACK_HAS_FLAG (track->gst_track, GST_MIXER_TRACK_NO_MUTE))
+        gtk_widget_set_sensitive (track->mute_button, FALSE);
       g_signal_connect (track->mute_button, "toggled", G_CALLBACK (xfce_mixer_track_mute_toggled), track);
       gtk_box_pack_start (GTK_BOX (button_box), track->mute_button, FALSE, FALSE, 0);
       gtk_widget_show (track->mute_button);
@@ -255,10 +262,14 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
       tooltip_text = g_strdup_printf (_("Lock channels for %s together"), track_label);
 
       track->lock_button = gtk_toggle_button_new ();
+      gtk_widget_set_size_request (GTK_WIDGET (track->lock_button), -1, XFCE_MIXER_ICON_SIZE);
       image = gtk_image_new_from_file (DATADIR "/pixmaps/xfce4-mixer/chain.png");
       gtk_button_set_image (GTK_BUTTON (track->lock_button), image);
       gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (track->lock_button), TRUE);
       gtk_widget_set_tooltip_text (track->lock_button, tooltip_text);
+      /* Make button insensitive for read-only tracks */
+      if (GST_MIXER_TRACK_HAS_FLAG (track->gst_track, GST_MIXER_TRACK_READONLY))
+        gtk_widget_set_sensitive (track->lock_button, FALSE);
       g_signal_connect (track->lock_button, "toggled", G_CALLBACK (xfce_mixer_track_lock_toggled), track);
       gtk_box_pack_start (GTK_BOX (button_box), track->lock_button, FALSE, FALSE, 0);
       gtk_widget_show (track->lock_button);
@@ -275,6 +286,10 @@ xfce_mixer_track_create_contents (XfceMixerTrack *track)
       image = gtk_image_new_from_icon_name ("audio-input-microphone-muted", XFCE_MIXER_ICON_SIZE);
       gtk_button_set_image (GTK_BUTTON (track->record_button), image);
       gtk_widget_set_tooltip_text (track->record_button, tooltip_text);
+      /* Make button insensitive for tracks without record or read-only tracks */
+      if (GST_MIXER_TRACK_HAS_FLAG (track->gst_track, GST_MIXER_TRACK_READONLY) ||
+          GST_MIXER_TRACK_HAS_FLAG (track->gst_track, GST_MIXER_TRACK_NO_RECORD))
+        gtk_widget_set_sensitive (track->record_button, FALSE);
       g_signal_connect (track->record_button, "toggled", G_CALLBACK (xfce_mixer_track_record_toggled), track);
       gtk_box_pack_start (GTK_BOX (button_box), track->record_button, FALSE, FALSE, 0);
       gtk_widget_show (track->record_button);


More information about the Xfce4-commits mailing list