diff options
author | Colin Guthrie <cguthrie@mandriva.org> | 2009-06-27 18:14:05 +0100 |
---|---|---|
committer | Colin Guthrie <cguthrie@mandriva.org> | 2009-06-27 18:14:05 +0100 |
commit | 159609135f34c2791eee7f2d6576e50fff80fa6a (patch) | |
tree | 97e19ae990125a289394a04e88d0e668524b6713 /src/mainwindow.cc | |
parent | 7b3083df574d15941449ae8532fef472aedc1ae6 (diff) |
Add support for changing ports.
This commit adds a combo box for selecting ports.
Overall this implementation could have taken two paths:
* Implement port selection as combo box.
* Implement port selection as a button.
I went for the first option as is done in selecting card profiles over the
second method used for selecting devices for streams. This seems more like
how a config option should be presented as opposed to a runtime type thing.
Diffstat (limited to 'src/mainwindow.cc')
-rw-r--r-- | src/mainwindow.cc | 67 |
1 files changed, 56 insertions, 11 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 5e86a41..b1f33df 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -37,13 +37,31 @@ /* Used for profile sorting */ struct profile_prio_compare { - 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; - } + 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; + } +}; +struct sink_port_prio_compare { + bool operator() (const pa_sink_port_info& lhs, const pa_sink_port_info& rhs) const { + + if (lhs.priority == rhs.priority) + return strcmp(lhs.name, rhs.name) > 0; + + return lhs.priority > rhs.priority; + } +}; +struct source_port_prio_compare { + bool operator() (const pa_source_port_info& lhs, const pa_source_port_info& rhs) const { + + if (lhs.priority == rhs.priority) + return strcmp(lhs.name, rhs.name) > 0; + + return lhs.priority > rhs.priority; + } }; @@ -162,12 +180,11 @@ void MainWindow::updateCard(const pa_card_info &info) { } 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)); - w->activeProfile = info.active_profile->name; - + w->activeProfile = info.active_profile ? info.active_profile->name : ""; + w->updating = false; w->prepareMenu(); @@ -180,6 +197,7 @@ void MainWindow::updateSink(const pa_sink_info &info) { SinkWidget *w; bool is_new = false; const char *icon; + std::set<pa_sink_port_info,sink_port_prio_compare> port_priorities; if (sinkWidgets.count(info.index)) w = sinkWidgets[info.index]; @@ -216,8 +234,21 @@ void MainWindow::updateSink(const pa_sink_info &info) { w->setDefault(w->name == defaultSinkName); + port_priorities.clear(); + for (uint32_t i=0; i<info.n_ports; ++i) { + port_priorities.insert(*info.ports[i]); + } + + w->ports.clear(); + for (std::set<pa_sink_port_info>::iterator i = port_priorities.begin(); i != port_priorities.end(); ++i) + w->ports.push_back(std::pair<Glib::ustring,Glib::ustring>(i->name, i->description)); + + w->activePort = info.active_port ? info.active_port->name : ""; + w->updating = false; + w->prepareMenu(); + if (is_new) updateDeviceVisibility(); } @@ -327,7 +358,8 @@ void MainWindow::updateSource(const pa_source_info &info) { SourceWidget *w; bool is_new = false; const char *icon; - + std::set<pa_source_port_info,source_port_prio_compare> port_priorities; + if (sourceWidgets.count(info.index)) w = sourceWidgets[info.index]; else { @@ -364,8 +396,21 @@ void MainWindow::updateSource(const pa_source_info &info) { w->setDefault(w->name == defaultSourceName); + port_priorities.clear(); + for (uint32_t i=0; i<info.n_ports; ++i) { + port_priorities.insert(*info.ports[i]); + } + + w->ports.clear(); + for (std::set<pa_source_port_info>::iterator i = port_priorities.begin(); i != port_priorities.end(); ++i) + w->ports.push_back(std::pair<Glib::ustring,Glib::ustring>(i->name, i->description)); + + w->activePort = info.active_port ? info.active_port->name : ""; + w->updating = false; + w->prepareMenu(); + if (is_new) updateDeviceVisibility(); } |