From 4bd94fa2b86fb8464829c806ae517db113924bd2 Mon Sep 17 00:00:00 2001 From: Colin Guthrie Date: Mon, 16 Mar 2009 23:21:40 +0000 Subject: 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. --- src/sinkinputwidget.cc | 68 ++++++++++++++++---------------------------------- 1 file changed, 21 insertions(+), 47 deletions(-) (limited to 'src/sinkinputwidget.cc') 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& x) : StreamWidget(cobject, x), - titleMenuItem(_("_Move Stream..."), true), mpMainWindow(NULL) { directionLabel->set_label(_("Playing on ")); - - 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 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::iterator i = sinkMenuItems.begin(); - delete i->second; - sinkMenuItems.erase(i); - } -} - -void SinkInputWidget::buildMenu() { - for (std::map::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); } -- cgit