[gnome-control-center/gnome-3-32] sound: Clean up labels of devices without origin



commit eaa4dd4aa31986390b8820a3296a102d1875e225
Author: Benjamin Berg <bberg redhat com>
Date:   Wed May 22 14:32:23 2019 +0200

    sound: Clean up labels of devices without origin
    
    Sound devices may not have an origin, in that case we ended up with a
    trailing " - " in the label which should not be there. Add a check that
    the origin is non-null and not an empty string and only show the devices
    description otherwise.
    
    (cherry picked from commit 6872c767bbc2f60cb15d7eddff4dc1c37fe17f15)

 panels/sound/cc-device-combo-box.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)
---
diff --git a/panels/sound/cc-device-combo-box.c b/panels/sound/cc-device-combo-box.c
index a4dc3b951..85537efbc 100644
--- a/panels/sound/cc-device-combo-box.c
+++ b/panels/sound/cc-device-combo-box.c
@@ -41,6 +41,7 @@ device_added_cb (CcDeviceComboBox *self,
   GvcMixerUIDevice *device = NULL;
   g_autofree gchar *label = NULL;
   g_autofree gchar *icon_name = NULL;
+  const gchar *origin;
   GtkTreeIter iter;
 
   if (self->is_output)
@@ -50,7 +51,18 @@ device_added_cb (CcDeviceComboBox *self,
   if (device == NULL)
     return;
 
-  label = g_strdup_printf ("%s - %s", gvc_mixer_ui_device_get_description (device), 
gvc_mixer_ui_device_get_origin (device));
+  origin = gvc_mixer_ui_device_get_origin (device);
+  if (origin && origin[0] != '\0')
+    {
+      label = g_strdup_printf ("%s - %s",
+                               gvc_mixer_ui_device_get_description (device),
+                               origin);
+    }
+  else
+    {
+      label = g_strdup (gvc_mixer_ui_device_get_description (device));
+    }
+
   if (gvc_mixer_ui_device_get_icon_name (device) != NULL)
     icon_name = g_strdup_printf ("%s-symbolic", gvc_mixer_ui_device_get_icon_name (device));
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]