summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2010-02-20 02:59:35 +0100
committerLennart Poettering <lennart@poettering.net>2010-02-20 02:59:35 +0100
commit29dc790c690117771429bc3b1e585fa6f45310a9 (patch)
treeded5cd7d11a6ee286ea05c49425bf55965003728
parent77f9dda5ab6065619cee95282755806dff401d6c (diff)
be a little smarter when selecting the initial device to show
-rw-r--r--gnome-speaker-setup.vala58
1 files changed, 26 insertions, 32 deletions
diff --git a/gnome-speaker-setup.vala b/gnome-speaker-setup.vala
index fea5eeb..d00dc1c 100644
--- a/gnome-speaker-setup.vala
+++ b/gnome-speaker-setup.vala
@@ -522,21 +522,12 @@ public class SpeakerSetupWindow : Window {
bool select_card(uint32 index) {
TreeIter iter;
- if (!cards.get_iter_first(out iter))
- return false;
-
- do {
- uint32 j;
- cards.get(iter, 1, out j);
- if (j == index) {
- card_combo_box.set_active_iter(iter);
- return true;
- }
-
- } while (cards.iter_next(ref iter));
+ if (!find_card_iter(index, out iter))
+ return false;
- return false;
+ card_combo_box.set_active_iter(iter);
+ return true;
}
bool select_device(uint32 index) {
@@ -559,21 +550,12 @@ public class SpeakerSetupWindow : Window {
}
TreeIter iter;
- if (!devices->get_iter_first(out iter))
- return false;
-
- do {
- uint32 j;
- devices->get(iter, 1, out j);
-
- if (j == index) {
- device_combo_box.set_active_iter(iter);
- return true;
- }
- } while (devices->iter_next(ref iter));
+ if (!find_device_iter(devices, index, out iter))
+ return false;
- return false;
+ device_combo_box.set_active_iter(iter);
+ return true;
}
bool pick_initial_selection() {
@@ -605,15 +587,27 @@ public class SpeakerSetupWindow : Window {
card_combo_box.set_sensitive(!lock_selection);
} else {
+
if (card_combo_box.get_active() >= 0)
return true;
- TreeIter i;
- if (cards.get_iter_first(out i) &&
- cards.iter_next(ref i))
- card_combo_box.set_active_iter(i);
- else
- card_combo_box.set_active(0);
+ /* Select a device if there is one */
+ MapIterator<uint32,DeviceData*> diter = device_lookup.map_iterator();
+ if (diter.first()) {
+ DeviceData *d = diter.get_value();
+ if (select_device(d->index))
+ return true;
+ }
+
+ /* No device, so let's startup with a card if there is one */
+ MapIterator<uint32,CardData*> citer = card_lookup.map_iterator();
+ if (citer.first()) {
+ CardData *d = citer.get_value();
+ if (select_card(d->index))
+ return true;
+ }
+
+ card_combo_box.set_active(0);
}
return true;