diff options
author | Lennart Poettering <lennart@poettering.net> | 2009-06-17 02:34:22 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2009-06-17 02:34:22 +0200 |
commit | 4e73145363499f8e33d7a96902023f2785d44a21 (patch) | |
tree | a30e5efb6fbfb40916df8e1e6f0632d32af544fc | |
parent | 874ebedf163195c7d54d5f9da3ff1725c1e43aa2 (diff) |
make sure that two card profiles with the same priority don't collide with each other
-rw-r--r-- | src/mainwindow.cc | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 61156c4..4b56b61 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -37,8 +37,13 @@ /* Used for profile sorting */ struct profile_prio_compare { - bool operator() (const pa_card_profile_info& lhs, const pa_card_profile_info& rhs) const - {return lhs.priority>rhs.priority;} + bool operator() (const pa_card_profile_info& lhs, const pa_card_profile_info& rhs) const { + + if (lhs.priority == rhs.priority) + return strcmp(lhs.name, rhs.name) > 0; + + return lhs.priority > rhs.priority; + } }; @@ -155,10 +160,12 @@ void MainWindow::updateCard(const pa_card_info &info) { w->hasSources = w->hasSources || (info.profiles[i].n_sources > 0); profile_priorities.insert(info.profiles[i]); } + w->profiles.clear(); - for (std::set<pa_card_profile_info>::iterator i=profile_priorities.begin(); i != profile_priorities.end(); ++i) { - w->profiles.push_back(std::pair<Glib::ustring,Glib::ustring>(i->name,i->description)); - } + + for (std::set<pa_card_profile_info>::iterator i = profile_priorities.begin(); i != profile_priorities.end(); ++i) + w->profiles.push_back(std::pair<Glib::ustring,Glib::ustring>(i->name, i->description)); + w->activeProfile = info.active_profile->name; w->updating = false; |