From a5fd5e62187effad8be1ca96614ed993367c0553 Mon Sep 17 00:00:00 2001 From: David Henningsson Date: Tue, 2 Oct 2012 13:21:07 +0200 Subject: [PATCH] sound: Fix default selection on startup Sometimes there is only one available device, but it is not possible to select it. This verifies that the first device gets selected. --- panels/sound/gvc-mixer-dialog.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/panels/sound/gvc-mixer-dialog.c b/panels/sound/gvc-mixer-dialog.c index ea95825..e8f733c 100644 --- a/panels/sound/gvc-mixer-dialog.c +++ b/panels/sound/gvc-mixer-dialog.c @@ -1268,14 +1268,23 @@ on_control_input_added (GvcMixerControl *control, guint id, GvcMixerDialog *dialog) { - GvcMixerUIDevice* in = NULL; + gboolean is_first_device; + GtkTreeModel *model; + GtkTreeIter iter; + GvcMixerUIDevice *in = NULL; in = gvc_mixer_control_lookup_input_id (control, id); if (in == NULL) { g_warning ("on_control_input_added - tried to fetch an input of id %u but got nothing", id); return; } + + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->input_treeview)); + is_first_device = !gtk_tree_model_get_iter_first (model, &iter); + add_input_ui_entry (dialog, in); + if (is_first_device) + active_input_update (dialog, in); } static void @@ -1312,7 +1321,10 @@ on_control_output_added (GvcMixerControl *control, guint id, GvcMixerDialog *dialog) { - GvcMixerUIDevice* out = NULL; + gboolean is_first_device; + GtkTreeModel *model; + GtkTreeIter iter; + GvcMixerUIDevice *out = NULL; out = gvc_mixer_control_lookup_output_id (control, id); if (out == NULL) { @@ -1320,7 +1332,12 @@ on_control_output_added (GvcMixerControl *control, return; } + model = gtk_tree_view_get_model (GTK_TREE_VIEW (dialog->priv->output_treeview)); + is_first_device = !gtk_tree_model_get_iter_first (model, &iter); + add_output_ui_entry (dialog, out); + if (is_first_device) + active_output_update (dialog, out); } static void -- 1.7.9.5