Add setter/getter methods for sink/source indexes so we can update our combo boxes current item

This commit is contained in:
Colin Guthrie 2009-03-16 20:47:57 +00:00
parent 255defb371
commit 903c26bd44
5 changed files with 29 additions and 7 deletions

View File

@ -484,7 +484,7 @@ void MainWindow::updateSinkInput(const pa_sink_input_info &info) {
w->type = info.client != PA_INVALID_INDEX ? SINK_INPUT_CLIENT : SINK_INPUT_VIRTUAL;
w->sinkIndex = info.sink;
w->setSinkIndex(info.sink);
char *txt;
if (clientNames.count(info.client)) {
@ -530,7 +530,7 @@ void MainWindow::updateSourceOutput(const pa_source_output_info &info) {
w->type = info.client != PA_INVALID_INDEX ? SOURCE_OUTPUT_CLIENT : SOURCE_OUTPUT_VIRTUAL;
w->sourceIndex = info.source;
w->setSourceIndex(info.source);
char *txt;
if (clientNames.count(info.client)) {
@ -694,7 +694,7 @@ void MainWindow::updateVolumeMeter(uint32_t source_index, uint32_t sink_input_id
for (std::map<uint32_t, SourceOutputWidget*>::iterator i = sourceOutputWidgets.begin(); i != sourceOutputWidgets.end(); ++i) {
SourceOutputWidget* w = i->second;
if (w->sourceIndex == source_index)
if (w->sourceIndex() == source_index)
w->updatePeak(v);
}
}

View File

@ -59,6 +59,14 @@ SinkInputWidget* SinkInputWidget::create(MainWindow* mainWindow) {
return w;
}
void SinkInputWidget::setSinkIndex(uint32_t idx) {
mSinkIndex = idx;
}
uint32_t SinkInputWidget::sinkIndex() {
return mSinkIndex;
}
void SinkInputWidget::executeVolumeUpdate() {
pa_operation* o;
@ -102,7 +110,7 @@ void SinkInputWidget::clearMenu() {
void SinkInputWidget::buildMenu() {
for (std::map<uint32_t, SinkWidget*>::iterator i = mpMainWindow->sinkWidgets.begin(); i != mpMainWindow->sinkWidgets.end(); ++i) {
SinkMenuItem *m;
sinkMenuItems[i->second->index] = m = new SinkMenuItem(this, i->second->description.c_str(), i->second->index, i->second->index == sinkIndex);
sinkMenuItems[i->second->index] = m = new SinkMenuItem(this, i->second->description.c_str(), i->second->index, i->second->index == mSinkIndex);
submenu.append(m->menuItem);
}

View File

@ -37,7 +37,9 @@ public:
SinkInputType type;
uint32_t index, clientIndex, sinkIndex;
uint32_t index, clientIndex;
void setSinkIndex(uint32_t idx);
uint32_t sinkIndex();
virtual void executeVolumeUpdate();
virtual void onDeviceChange();
virtual void onMuteToggleButton();
@ -70,6 +72,7 @@ public:
private:
MainWindow *mpMainWindow;
uint32_t mSinkIndex;
};

View File

@ -59,6 +59,14 @@ SourceOutputWidget* SourceOutputWidget::create(MainWindow* mainWindow) {
return w;
}
void SourceOutputWidget::setSourceIndex(uint32_t idx) {
mSourceIndex = idx;
}
uint32_t SourceOutputWidget::sourceIndex() {
return mSourceIndex;
}
void SourceOutputWidget::onKill() {
pa_operation* o;
if (!(o = pa_context_kill_source_output(get_context(), index, NULL, NULL))) {
@ -81,7 +89,7 @@ void SourceOutputWidget::clearMenu() {
void SourceOutputWidget::buildMenu() {
for (std::map<uint32_t, SourceWidget*>::iterator i = mpMainWindow->sourceWidgets.begin(); i != mpMainWindow->sourceWidgets.end(); ++i) {
SourceMenuItem *m;
sourceMenuItems[i->second->index] = m = new SourceMenuItem(this, i->second->description.c_str(), i->second->index, i->second->index == sourceIndex);
sourceMenuItems[i->second->index] = m = new SourceMenuItem(this, i->second->description.c_str(), i->second->index, i->second->index == mSourceIndex);
submenu.append(m->menuItem);
}

View File

@ -37,7 +37,9 @@ public:
SourceOutputType type;
uint32_t index, clientIndex, sourceIndex;
uint32_t index, clientIndex;
void setSourceIndex(uint32_t idx);
uint32_t sourceIndex();
virtual void onDeviceChange();
virtual void onKill();
@ -68,6 +70,7 @@ public:
private:
MainWindow *mpMainWindow;
uint32_t mSourceIndex;
};