diff options
Diffstat (limited to 'src/cardwidget.cc')
-rw-r--r-- | src/cardwidget.cc | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/src/cardwidget.cc b/src/cardwidget.cc index 7deba33..6f6ed76 100644 --- a/src/cardwidget.cc +++ b/src/cardwidget.cc @@ -73,19 +73,25 @@ void CardWidget::prepareMenu() { profileListStore->clear(); active_idx = -1; + /* Fill the ComboBox's Tree Model */ - for (uint32_t i = 0; i < profiles.size(); ++i) { + for (uint32_t i = 0, idx = 0; i < profiles.size(); ++i) { if (hideUnavailableProfiles && !availableProfiles[profiles[i].first]) continue; Gtk::TreeModel::Row row = *(profileListStore->append()); row[profileModel.name] = profiles[i].first; row[profileModel.desc] = profiles[i].second; + if (profiles[i].first == activeProfile) - active_idx = i; + active_idx = idx; + + /* Track the index in the list store, as we might have few entries than + * all the profiles if unavailable profiles are hidden. */ + idx++; } - if (active_idx >= 0) + if (profiles.size()) profileList->set_active(active_idx); codecListStore->clear(); |