From 52fd538bd1d823b6263efa3526bab797f0ab0827 Mon Sep 17 00:00:00 2001 From: Michal Ratajsky Date: Wed, 12 Nov 2014 23:04:10 +0100 Subject: Make sure the selected card has a sink before providing speaker test --- mate-volume-control/src/gvc-mixer-dialog.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'mate-volume-control/src') diff --git a/mate-volume-control/src/gvc-mixer-dialog.c b/mate-volume-control/src/gvc-mixer-dialog.c index 8db0ebf..0e155e3 100644 --- a/mate-volume-control/src/gvc-mixer-dialog.c +++ b/mate-volume-control/src/gvc-mixer-dialog.c @@ -1552,6 +1552,9 @@ on_card_selection_changed (GtkTreeSelection *selection, GtkTreeModel *model; GtkTreeIter iter; const GList *profiles; + GSList *sinks; + gint card_index; + gboolean has_sink = FALSE; guint id; GvcMixerCard *card; GvcMixerCardProfile *current_profile; @@ -1590,9 +1593,23 @@ on_card_selection_changed (GtkTreeSelection *selection, gtk_box_pack_start (GTK_BOX (dialog->priv->hw_settings_box), dialog->priv->hw_profile_combo, TRUE, TRUE, 6); + + sinks = gvc_mixer_control_get_sinks (dialog->priv->mixer_control); + card_index = gvc_mixer_card_get_index (card); + while (sinks != NULL) { + GvcMixerStream *s = sinks->data; + + if (gvc_mixer_stream_get_card_index (s) == card_index) { + has_sink = TRUE; + break; + } + sinks = sinks->next; + } + g_object_set (G_OBJECT (dialog->priv->hw_profile_combo), - "show-button", current_profile->n_sinks == 1, + "show-button", has_sink, NULL); + gtk_widget_show (dialog->priv->hw_profile_combo); g_object_set_data (G_OBJECT (dialog->priv->hw_profile_combo), "card", card); -- cgit v1.2.1