[Xfce4-commits] r29442 - in xfce4-mixer/trunk: . panel-plugin xfce4-mixer

Jannis Pohlmann jannis at xfce.org
Tue Feb 3 12:16:51 CET 2009


Author: jannis
Date: 2009-02-03 11:16:51 +0000 (Tue, 03 Feb 2009)
New Revision: 29442

Modified:
   xfce4-mixer/trunk/ChangeLog
   xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c
   xfce4-mixer/trunk/xfce4-mixer/xfce-mixer-track.c
   xfce4-mixer/trunk/xfce4-mixer/xfce-mixer.c
Log:
	* panel-plugin/xfce-mixer-plugin.c: Use the GstMixerTrack "label"
	  property instead of the struct member to access the name of a track.
	  Toggle record for capture tracks instead of trying to mute them.
	  Capture tracks don't support muting (bug #4777).
	* xfce4-mixer/xfce-mixer-track.c: Don't show the mute button for
	  capture tracks (follow up of bug #4777).
	* xfce4-mixer/xfce-mixer.c: Use the "label" property everywhere. I
	  missed a few appearances of the struct member in the previous commit.
	  Copy track labels for the hash table keys. The previous commit b0rked
	  this (follow up of bug #4521).

Modified: xfce4-mixer/trunk/ChangeLog
===================================================================
--- xfce4-mixer/trunk/ChangeLog	2009-02-03 00:19:14 UTC (rev 29441)
+++ xfce4-mixer/trunk/ChangeLog	2009-02-03 11:16:51 UTC (rev 29442)
@@ -1,3 +1,16 @@
+2009-02-03	Jannis Pohlmann <jannis at xfce.org>
+
+	* panel-plugin/xfce-mixer-plugin.c: Use the GstMixerTrack "label"
+	  property instead of the struct member to access the name of a track.
+	  Toggle record for capture tracks instead of trying to mute them.
+	  Capture tracks don't support muting (bug #4777).
+	* xfce4-mixer/xfce-mixer-track.c: Don't show the mute button for 
+	  capture tracks (follow up of bug #4777). 
+	* xfce4-mixer/xfce-mixer.c: Use the "label" property everywhere. I 
+	  missed a few appearances of the struct member in the previous commit.
+	  Copy track labels for the hash table keys. The previous commit b0rked
+	  this (follow up of bug #4521).
+
 2009-02-01	Jannis Pohlmann <jannis at xfce.org>
 
 	* libxfce4mixer/libxfce4mixer.c,

Modified: xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c
===================================================================
--- xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c	2009-02-03 00:19:14 UTC (rev 29441)
+++ xfce4-mixer/trunk/panel-plugin/xfce-mixer-plugin.c	2009-02-03 11:16:51 UTC (rev 29442)
@@ -63,6 +63,7 @@
 
   /* Mixer track being used */
   GstMixerTrack   *track;
+  gchar           *track_label;
 
   /* Mixer command */
   gchar           *command;
@@ -131,6 +132,7 @@
   /* Initialize some of the plugin variables */
   mixer_plugin->card = NULL;
   mixer_plugin->track = NULL;
+  mixer_plugin->track_label = NULL;
   mixer_plugin->command = g_strdup (DEFAULT_COMMAND);
 
 #ifdef HAVE_GST_MIXER_NOTIFICATION
@@ -170,6 +172,7 @@
 {
   /* Free card and track names */
   g_free (mixer_plugin->command);
+  g_free (mixer_plugin->track_label);
 
 #ifdef HAVE_GST_MIXER_NOTIFICATION
   /* Disconnect from GstBus */
@@ -268,7 +271,7 @@
 #endif
 
   /* Set tooltip (e.g. 'Master: 50%') */
-  tip_text = g_strdup_printf (_("%s: %i%%"), GST_MIXER_TRACK (mixer_plugin->track)->label, (gint) (volume * 100));
+  tip_text = g_strdup_printf (_("%s: %i%%"), mixer_plugin->track_label, (gint) (volume * 100));
   gtk_tooltips_set_tip (mixer_plugin->tooltips, mixer_plugin->button, tip_text, "test");
   g_free (tip_text);
 
@@ -281,12 +284,6 @@
   /* Determine new volume */
   new_volume = mixer_plugin->track->min_volume + (volume * volume_range);
 
-#if 0
-  g_message ("Volume changed for %s (%s):", xfce_mixer_card_get_display_name (mixer_plugin->card), GST_MIXER_TRACK (mixer_plugin->track)->label);
-  g_message ("  min_volume = %i, max_volume = %i, volume_range = %i, new_volume = %i", 
-             mixer_plugin->track->min_volume, mixer_plugin->track->max_volume, volume_range, new_volume);
-#endif
-
   /* Set all channel volumes to the new volume */
   for (i = 0; i < mixer_plugin->track->num_channels; ++i)
     volumes[i] = new_volume;
@@ -294,11 +291,6 @@
   /* Apply volume change to the sound card */
   gst_mixer_set_volume (GST_MIXER (mixer_plugin->card), mixer_plugin->track, volumes);
 
-#if 0
-  xfce_mixer_card_get_track_volume (mixer_plugin->card, mixer_plugin->track, volumes);
-  g_message ("After the change: volume = %i", volumes[0]);
-#endif
-
   /* Free volume array */
   g_free (volumes);
 
@@ -321,8 +313,16 @@
   mixer_plugin->ignore_bus_messages = TRUE;
 #endif
 
-  /* Apply mute change to the sound card */
-  gst_mixer_set_mute (GST_MIXER (mixer_plugin->card), mixer_plugin->track, mute);
+  if (G_LIKELY (xfce_mixer_track_type_new (mixer_plugin->track) == XFCE_MIXER_TRACK_TYPE_PLAYBACK))
+    {
+      /* Apply mute change to the sound card */
+      gst_mixer_set_mute (GST_MIXER (mixer_plugin->card), mixer_plugin->track, mute);
+    }
+  else
+    {
+      /* Toggle capture */
+      gst_mixer_set_record (GST_MIXER (mixer_plugin->card), mixer_plugin->track, !mute);
+    }
 
 #ifdef HAVE_GST_MIXER_NOTIFICATION
   mixer_plugin->ignore_bus_messages = FALSE;
@@ -513,7 +513,7 @@
     {
       /* Write plugin values to the config file */
       xfce_rc_write_entry (rc, "card", xfce_mixer_get_card_internal_name (mixer_plugin->card));
-      xfce_rc_write_entry (rc, "track", GST_MIXER_TRACK (mixer_plugin->track)->label);
+      xfce_rc_write_entry (rc, "track", mixer_plugin->track_label);
       xfce_rc_write_entry (rc, "command", mixer_plugin->command);
 
       /* Close the rc handle */
@@ -545,7 +545,7 @@
   volume = ((gdouble) xfce_mixer_get_max_volume (volumes, mixer_plugin->track->num_channels)) / mixer_plugin->track->max_volume;
 
   /* Set tooltip (e.g. 'Master: 50%') */
-  tip_text = g_strdup_printf (_("%s: %i%%"), GST_MIXER_TRACK (mixer_plugin->track)->label, (gint) (volume * 100));
+  tip_text = g_strdup_printf (_("%s: %i%%"), mixer_plugin->track_label, (gint) (volume * 100));
   gtk_tooltips_set_tip (mixer_plugin->tooltips, mixer_plugin->button, tip_text, "test");
   g_free (tip_text);
 
@@ -566,9 +566,11 @@
 {
   GstMixerTrack      *track = NULL;
   gdouble             volume;
+  gchar              *label;
   gint               *volumes;
   gint                num_channels;
   gboolean            mute;
+  gboolean            record;
 
   /* Don't do anything if GstBus messages are to be ignored */
   if (G_UNLIKELY (mixer_plugin->ignore_bus_messages))
@@ -582,19 +584,35 @@
       case GST_MIXER_MESSAGE_VOLUME_CHANGED:
         /* Get the track of the volume changed message */
         gst_mixer_message_parse_volume_changed (message, &track, NULL, NULL);
+        g_object_get (track, "label", &label, NULL);
 
         /* Update the volume button if the message belongs to the current mixer track */
-        if (G_UNLIKELY (g_utf8_collate (track->label, mixer_plugin->track->label) == 0))
+        if (G_UNLIKELY (g_utf8_collate (label, mixer_plugin->track_label) == 0))
           xfce_mixer_plugin_update_track (mixer_plugin);
+
+        g_free (label);
         break;
       case GST_MIXER_MESSAGE_MUTE_TOGGLED:
         /* Parse the mute message */
         gst_mixer_message_parse_mute_toggled (message, &track, &mute);
+        g_object_get (track, "label", &label, NULL);
 
         /* Update the volume button if the message belongs to the current mixer track */
-        if (G_UNLIKELY (g_utf8_collate (track->label, mixer_plugin->track->label) == 0))
+        if (G_UNLIKELY (g_utf8_collate (label, mixer_plugin->track_label) == 0))
           xfce_volume_button_set_muted (XFCE_VOLUME_BUTTON (mixer_plugin->button), mute);
+
+        g_free (label);
         break;
+      case GST_MIXER_MESSAGE_RECORD_TOGGLED:
+        /* Parse the record message */
+        gst_mixer_message_parse_record_toggled (message, &track, &record);
+        g_object_get (track, "label", &label, NULL);
+
+        /* Update the volume button if the message belongs to the current mixer track */
+        if (G_UNLIKELY (g_utf8_collate (label, mixer_plugin->track_label) == 0))
+          xfce_volume_button_set_muted (XFCE_VOLUME_BUTTON (mixer_plugin->button), !record);
+
+        g_free (label);
       default:
         break;
     }
@@ -629,6 +647,10 @@
   g_return_if_fail (GST_IS_MIXER_TRACK (track));
 
   mixer_plugin->track = track;
+
+  /* Replace the track label */
+  g_free (mixer_plugin->track_label);
+  g_object_get (track, "label", &mixer_plugin->track_label, NULL);
 }
 
 

Modified: xfce4-mixer/trunk/xfce4-mixer/xfce-mixer-track.c
===================================================================
--- xfce4-mixer/trunk/xfce4-mixer/xfce-mixer-track.c	2009-02-03 00:19:14 UTC (rev 29441)
+++ xfce4-mixer/trunk/xfce4-mixer/xfce-mixer-track.c	2009-02-03 11:16:51 UTC (rev 29442)
@@ -229,13 +229,16 @@
   gtk_table_attach (GTK_TABLE (track), button_box, 0, columns, 2, 3, GTK_FILL, GTK_SHRINK, 0, 0);
   gtk_widget_show (button_box);
 
-  /* Create the control buttons. Depending on the type (playback/capture) these may differ */
-  track->mute_button = gtk_toggle_button_new ();
-  image = gtk_image_new_from_icon_name ("xfce4-mixer-no-muted", XFCE_MIXER_ICON_SIZE); 
-  gtk_button_set_image (GTK_BUTTON (track->mute_button), image);
-  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);
+  /* Create mute button for playback tracks */
+  if (G_LIKELY (xfce_mixer_track_type_new (track->gst_track) == XFCE_MIXER_TRACK_TYPE_PLAYBACK))
+    {
+      track->mute_button = gtk_toggle_button_new ();
+      image = gtk_image_new_from_icon_name ("xfce4-mixer-no-muted", XFCE_MIXER_ICON_SIZE); 
+      gtk_button_set_image (GTK_BUTTON (track->mute_button), image);
+      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);
+    }
 
   if (G_LIKELY (track->gst_track->num_channels >= 2))
     {
@@ -248,6 +251,7 @@
       gtk_widget_show (track->lock_button);
     }
 
+  /* Create record button for capture tracks */
   if (G_UNLIKELY (xfce_mixer_track_type_new (track->gst_track) == XFCE_MIXER_TRACK_TYPE_CAPTURE))
     {
       track->record_button = gtk_toggle_button_new ();
@@ -420,6 +424,9 @@
 
   g_return_if_fail (IS_XFCE_MIXER_TRACK (track));
 
+  if (G_UNLIKELY (xfce_mixer_track_type_new (track->gst_track) == XFCE_MIXER_TRACK_TYPE_CAPTURE))
+    return;
+
   muted = GST_MIXER_TRACK_HAS_FLAG (track->gst_track, GST_MIXER_TRACK_MUTE);
   gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (track->mute_button), muted);
 }

Modified: xfce4-mixer/trunk/xfce4-mixer/xfce-mixer.c
===================================================================
--- xfce4-mixer/trunk/xfce4-mixer/xfce-mixer.c	2009-02-03 00:19:14 UTC (rev 29441)
+++ xfce4-mixer/trunk/xfce4-mixer/xfce-mixer.c	2009-02-03 11:16:51 UTC (rev 29442)
@@ -147,7 +147,7 @@
 static void
 xfce_mixer_instance_init (XfceMixer *mixer)
 {
-  mixer->widgets = g_hash_table_new_full (g_str_hash, g_str_equal, NULL, NULL);
+  mixer->widgets = g_hash_table_new_full (g_str_hash, g_str_equal, g_free, NULL);
   mixer->message_handler_id = 0;
 }
 
@@ -174,6 +174,8 @@
   guint                 num_children[4] = { 0, 0, 0, 0 };
   gint                  i;
 
+  g_hash_table_remove_all (mixer->widgets);
+
   preferences = xfce_mixer_preferences_get ();
 
   /* Create widgets for all four tabs */
@@ -231,7 +233,7 @@
           num_children[0]++;
 
           /* Add the track to the hash table */
-          g_hash_table_insert (mixer->widgets, label, track_widget);
+          g_hash_table_insert (mixer->widgets, g_strdup (label), track_widget);
           break;
 
         case XFCE_MIXER_TRACK_TYPE_CAPTURE:
@@ -250,7 +252,7 @@
           num_children[1]++;
 
           /* Add the track to the hash table */
-          g_hash_table_insert (mixer->widgets, label, track_widget);
+          g_hash_table_insert (mixer->widgets, g_strdup (label), track_widget);
           break;
 
         case XFCE_MIXER_TRACK_TYPE_SWITCH:
@@ -260,7 +262,7 @@
           num_children[2]++;
 
           /* Add the track to the hash table */
-          g_hash_table_insert (mixer->widgets, label, track_widget);
+          g_hash_table_insert (mixer->widgets, g_strdup (label), track_widget);
           break;
 
         case XFCE_MIXER_TRACK_TYPE_OPTIONS:
@@ -270,7 +272,7 @@
           num_children[3]++;
 
           /* Add the track to the hash table */
-          g_hash_table_insert (mixer->widgets, label, track_widget);
+          g_hash_table_insert (mixer->widgets, g_strdup (label), track_widget);
           break;
         }
 
@@ -394,7 +396,7 @@
 
 #ifdef HAVE_GST_MIXER_NOTIFICATION
 static void
-xfce_mixer_bus_message (GstBus *bus,
+xfce_mixer_bus_message (GstBus     *bus,
                         GstMessage *message,
                         XfceMixer  *mixer)
 {
@@ -405,6 +407,7 @@
   gboolean            muted;
   gboolean            record;
   const gchar        *option;
+  gchar              *label;
   gint               *volumes;
   gint                num_channels;
 
@@ -418,9 +421,10 @@
   if (type == GST_MIXER_MESSAGE_MUTE_TOGGLED)
     {
       gst_mixer_message_parse_mute_toggled (message, &track, &muted);
-      DBG ("Track '%s' was %s", track->label, muted ? "muted" : "unmuted");
-  
-      widget = g_hash_table_lookup (mixer->widgets, track->label);
+      g_object_get (track, "label", &label, NULL);
+      DBG ("Track '%s' was %s", label, muted ? "muted" : "unmuted");
+      widget = g_hash_table_lookup (mixer->widgets, label);
+      g_free (label);
 
       if (IS_XFCE_MIXER_TRACK (widget))
         xfce_mixer_track_update_mute (XFCE_MIXER_TRACK (widget));
@@ -430,10 +434,11 @@
   else if (type == GST_MIXER_MESSAGE_RECORD_TOGGLED)
     {
       gst_mixer_message_parse_record_toggled (message, &track, &record);
-      DBG ("Recording on track '%s' was %s", track->label, record ? "turned on" : "turned off");
+      g_object_get (track, "label", &label, NULL);
+      DBG ("Recording on track '%s' was %s", label, record ? "turned on" : "turned off");
+      widget = g_hash_table_lookup (mixer->widgets, label);
+      g_free (label);
 
-      widget = g_hash_table_lookup (mixer->widgets, track->label);
-
       if (IS_XFCE_MIXER_TRACK (widget))
         xfce_mixer_track_update_record (XFCE_MIXER_TRACK (widget));
       else if (IS_XFCE_MIXER_SWITCH (widget))
@@ -442,20 +447,22 @@
   else if (type == GST_MIXER_MESSAGE_VOLUME_CHANGED)
     {
       gst_mixer_message_parse_volume_changed (message, &track, &volumes, &num_channels);
-      DBG ("Volume on track '%s' changed to %i", track->label, volumes[0]);
+      g_object_get (track, "label", &label, NULL);
+      DBG ("Volume on track '%s' changed to %i", label, volumes[0]);
+      widget = g_hash_table_lookup (mixer->widgets, label);
+      g_free (label);
 
-      widget = g_hash_table_lookup (mixer->widgets, track->label);
-
       if (IS_XFCE_MIXER_TRACK (widget))
         xfce_mixer_track_update_volume (XFCE_MIXER_TRACK (widget));
     }
   else if (type == GST_MIXER_MESSAGE_OPTION_CHANGED)
     {
       gst_mixer_message_parse_option_changed (message, &options, &option);
-      DBG ("Option '%s' was set to '%s'", GST_MIXER_TRACK (options)->label, option);
+      g_object_get (GST_MIXER_TRACK (options), "label", &label, NULL);
+      DBG ("Option '%s' was set to '%s'", label, option);
+      widget = g_hash_table_lookup (mixer->widgets, label);
+      g_free (label);
 
-      widget = g_hash_table_lookup (mixer->widgets, GST_MIXER_TRACK (options)->label);
-
       if (IS_XFCE_MIXER_OPTION (widget))
         xfce_mixer_option_update (XFCE_MIXER_OPTION (widget));
     }




More information about the Xfce4-commits mailing list