From cfa1cd3d49a89b0b69956035416190533f724961 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Mon, 16 Mar 2009 21:06:33 +0000 Subject: Record in a map the combobox indexes vs. the sink/source indexes --- src/mainwindow.cc | 25 +++++++++---------------- src/mainwindow.h | 4 ++++ 2 files changed, 13 insertions(+), 16 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 6565b33..ff1d690 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -180,26 +180,23 @@ void MainWindow::updateCard(const pa_card_info &info) { } void MainWindow::rebuildSinkCombo() { - //int active_idx = -1; + uint32_t idx = 0; Gtk::TreeModel::Row row; - // Update our sinkTree sinkTree->clear(); + sinkTreeIndexes.clear(); + row = *(sinkTree->append()); + idx++; row[deviceColumns.index] = -1; row[deviceColumns.name] = "Default Output"; for (std::map::iterator i = sinkWidgets.begin(); i != sinkWidgets.end(); ++i) { Gtk::TreeModel::Row row = *(sinkTree->append()); + sinkTreeIndexes[i->first] = idx++; row[deviceColumns.index] = i->first; row[deviceColumns.name] = i->second->description.c_str(); - /*if (i->first == activeProfile) - active_idx = idx; - idx++;*/ } - - /*if (active_idx >= 0) - sinkTree->set_active(active_idx);*/ } void MainWindow::updateSink(const pa_sink_info &info) { @@ -351,26 +348,22 @@ void MainWindow::createMonitorStreamForSinkInput(uint32_t sink_input_idx, uint32 } void MainWindow::rebuildSourceCombo() { - //int active_idx = -1; + uint32_t idx = 0; Gtk::TreeModel::Row row; - // Update our sinkTree sourceTree->clear(); + sourceTreeIndexes.clear(); row = *(sourceTree->append()); + idx++; row[deviceColumns.index] = -1; row[deviceColumns.name] = "Default Input"; for (std::map::iterator i = sourceWidgets.begin(); i != sourceWidgets.end(); ++i) { Gtk::TreeModel::Row row = *(sourceTree->append()); + sourceTreeIndexes[i->first] = idx++; row[deviceColumns.index] = i->first; row[deviceColumns.name] = i->second->description.c_str(); - /*if (i->first == activeProfile) - active_idx = idx; - idx++;*/ } - - /*if (active_idx >= 0) - sourceTree->set_active(active_idx);*/ } void MainWindow::updateSource(const pa_source_info &info) { diff --git a/src/mainwindow.h b/src/mainwindow.h index 50a5956..48fcc76 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -103,8 +103,12 @@ public: }; DeviceColumns deviceColumns; + Glib::RefPtr sinkTree; + std::map sinkTreeIndexes; + Glib::RefPtr sourceTree; + std::map sourceTreeIndexes; protected: virtual void on_realize(); -- cgit