diff options
author | Colin Guthrie <cguthrie@mandriva.org> | 2009-03-16 23:21:40 +0000 |
---|---|---|
committer | Colin Guthrie <cguthrie@mandriva.org> | 2009-06-17 08:54:12 +0100 |
commit | 4bd94fa2b86fb8464829c806ae517db113924bd2 (patch) | |
tree | 2d7d0e6b9b80ea9a86c02d888fd228e2b10fc48f /src/sinkinputwidget.cc | |
parent | 4c3acd35e5d406846c6f9d0596ce4f834e373bd8 (diff) |
Wire up all the new UI code.
This makes the default button work on sinks/sources, allows the drop
down to actually change the sink/source and removes the old menu code.
Some names and such are fixed in the glade file too.
Diffstat (limited to 'src/sinkinputwidget.cc')
-rw-r--r-- | src/sinkinputwidget.cc | 68 |
1 files changed, 21 insertions, 47 deletions
diff --git a/src/sinkinputwidget.cc b/src/sinkinputwidget.cc index b49ba41..012e834 100644 --- a/src/sinkinputwidget.cc +++ b/src/sinkinputwidget.cc @@ -30,15 +30,9 @@ SinkInputWidget::SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) : StreamWidget(cobject, x), - titleMenuItem(_("_Move Stream..."), true), mpMainWindow(NULL) { directionLabel->set_label(_("<i>Playing on </i> ")); - - add_events(Gdk::BUTTON_PRESS_MASK); - - menu.append(titleMenuItem); - titleMenuItem.set_submenu(submenu); } void SinkInputWidget::init(MainWindow* mainWindow) { @@ -47,10 +41,6 @@ void SinkInputWidget::init(MainWindow* mainWindow) { deviceCombo->pack_start(mpMainWindow->deviceColumns.name); } -SinkInputWidget::~SinkInputWidget() { - clearMenu(); -} - SinkInputWidget* SinkInputWidget::create(MainWindow* mainWindow) { SinkInputWidget* w; Glib::RefPtr<Gnome::Glade::Xml> x = Gnome::Glade::Xml::create(GLADE_FILE, "streamWidget"); @@ -61,7 +51,10 @@ SinkInputWidget* SinkInputWidget::create(MainWindow* mainWindow) { void SinkInputWidget::setSinkIndex(uint32_t idx) { mSinkIndex = idx; + + mSuppressDeviceChange = true; deviceCombo->set_active(mpMainWindow->sinkTreeIndexes[idx]); + mSuppressDeviceChange = false; } uint32_t SinkInputWidget::sinkIndex() { @@ -94,30 +87,6 @@ void SinkInputWidget::onMuteToggleButton() { pa_operation_unref(o); } -void SinkInputWidget::prepareMenu() { - clearMenu(); - buildMenu(); -} - -void SinkInputWidget::clearMenu() { - - while (!sinkMenuItems.empty()) { - std::map<uint32_t, SinkMenuItem*>::iterator i = sinkMenuItems.begin(); - delete i->second; - sinkMenuItems.erase(i); - } -} - -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 == mSinkIndex); - submenu.append(m->menuItem); - } - - menu.show_all(); -} - void SinkInputWidget::onKill() { pa_operation* o; if (!(o = pa_context_kill_sink_input(get_context(), index, NULL, NULL))) { @@ -129,21 +98,26 @@ void SinkInputWidget::onKill() { } void SinkInputWidget::onDeviceChange() { -} - -void SinkInputWidget::SinkMenuItem::onToggle() { + Gtk::TreeModel::iterator iter; - if (widget->updating) + if (updating || mSuppressDeviceChange) return; - if (!menuItem.get_active()) - return; - - pa_operation* o; - if (!(o = pa_context_move_sink_input_by_index(get_context(), widget->index, index, NULL, NULL))) { - show_error(_("pa_context_move_sink_input_by_index() failed")); - return; + iter = deviceCombo->get_active(); + if (iter) + { + Gtk::TreeModel::Row row = *iter; + if (row) + { + pa_operation* o; + uint32_t sink_index = row[mpMainWindow->deviceColumns.index]; + + if (!(o = pa_context_move_sink_input_by_index(get_context(), index, sink_index, NULL, NULL))) { + show_error(_("pa_context_move_sink_input_by_index() failed")); + return; + } + + pa_operation_unref(o); + } } - - pa_operation_unref(o); } |