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/sourceoutputwidget.cc | 68 +++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 47 deletions(-) (limited to 'src/sourceoutputwidget.cc') diff --git a/src/sourceoutputwidget.cc b/src/sourceoutputwidget.cc index 64f3aad..19ecda7 100644 --- a/src/sourceoutputwidget.cc +++ b/src/sourceoutputwidget.cc @@ -30,15 +30,9 @@ SourceOutputWidget::SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr& x) : StreamWidget(cobject, x), - titleMenuItem(_("_Move Stream..."), true), mpMainWindow(NULL) { directionLabel->set_label(_("Recording from ")); - - add_events(Gdk::BUTTON_PRESS_MASK); - - menu.append(titleMenuItem); - titleMenuItem.set_submenu(submenu); } void SourceOutputWidget::init(MainWindow* mainWindow) { @@ -47,10 +41,6 @@ void SourceOutputWidget::init(MainWindow* mainWindow) { deviceCombo->pack_start(mpMainWindow->deviceColumns.name); } -SourceOutputWidget::~SourceOutputWidget() { - clearMenu(); -} - SourceOutputWidget* SourceOutputWidget::create(MainWindow* mainWindow) { SourceOutputWidget* w; Glib::RefPtr x = Gnome::Glade::Xml::create(GLADE_FILE, "streamWidget"); @@ -61,7 +51,10 @@ SourceOutputWidget* SourceOutputWidget::create(MainWindow* mainWindow) { void SourceOutputWidget::setSourceIndex(uint32_t idx) { mSourceIndex = idx; + + mSuppressDeviceChange = true; deviceCombo->set_active(mpMainWindow->sourceTreeIndexes[idx]); + mSuppressDeviceChange = false; } uint32_t SourceOutputWidget::sourceIndex() { @@ -78,46 +71,27 @@ void SourceOutputWidget::onKill() { pa_operation_unref(o); } -void SourceOutputWidget::clearMenu() { - - while (!sourceMenuItems.empty()) { - std::map::iterator i = sourceMenuItems.begin(); - delete i->second; - sourceMenuItems.erase(i); - } -} - -void SourceOutputWidget::buildMenu() { - for (std::map::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 == mSourceIndex); - submenu.append(m->menuItem); - } - - menu.show_all(); -} - -void SourceOutputWidget::prepareMenu(void) { - clearMenu(); - buildMenu(); -} - void SourceOutputWidget::onDeviceChange() { -} - -void SourceOutputWidget::SourceMenuItem::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_source_output_by_index(get_context(), widget->index, index, NULL, NULL))) { - show_error(_("pa_context_move_source_output_by_index() failed")); - return; + iter = deviceCombo->get_active(); + if (iter) + { + Gtk::TreeModel::Row row = *iter; + if (row) + { + pa_operation* o; + uint32_t source_index = row[mpMainWindow->deviceColumns.index]; + + if (!(o = pa_context_move_source_output_by_index(get_context(), source_index, index, NULL, NULL))) { + show_error(_("pa_context_move_source_output_by_index() failed")); + return; + } + + pa_operation_unref(o); + } } - - pa_operation_unref(o); } -- cgit