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.
This commit is contained in:
Benjamin Berg 2019-05-22 14:32:23 +02:00
parent 5ec241aae2
commit 6872c767bb

View file

@ -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));