From e6846ac8ac595194c0dfd2543f76b1b9773761e3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Fri, 31 Aug 2007 01:16:50 +0000 Subject: add a combobox to the streams page, to filter application streams git-svn-id: file:///home/lennart/svn/public/pavucontrol/trunk@59 c17c95f2-f111-0410-90bf-f30a9569010c --- src/pavucontrol.cc | 74 ++++++++++++++++++------ src/pavucontrol.glade | 157 +++++++++++++++++++++++++++++++++++++++----------- 2 files changed, 179 insertions(+), 52 deletions(-) diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc index 754cb40..0804cb1 100644 --- a/src/pavucontrol.cc +++ b/src/pavucontrol.cc @@ -38,6 +38,12 @@ static pa_context *context = NULL; static int n_outstanding = 0; +enum SinkInputType { + SINK_INPUT_ALL, + SINK_INPUT_CLIENT, + SINK_INPUT_VIRTUAL +}; + enum SinkType { SINK_ALL, SINK_HARDWARE, @@ -135,6 +141,8 @@ public: static SinkInputWidget* create(); virtual ~SinkInputWidget(); + SinkInputType type; + uint32_t index, clientIndex, sinkIndex; virtual void executeVolumeUpdate(); virtual void onMuteToggleButton(); @@ -186,16 +194,18 @@ public: Gtk::VBox *streamsVBox, *sinksVBox, *sourcesVBox; Gtk::EventBox *titleEventBox; Gtk::Label *noStreamsLabel, *noSinksLabel, *noSourcesLabel; - Gtk::ComboBox *sinkTypeComboBox, *sourceTypeComboBox; + Gtk::ComboBox *sinkInputTypeComboBox, *sinkTypeComboBox, *sourceTypeComboBox; std::map sinkWidgets; std::map sourceWidgets; - std::map streamWidgets; + std::map sinkInputWidgets; std::map clientNames; + SinkInputType showSinkInputType; SinkType showSinkType; SourceType showSourceType; - + + virtual void onSinkInputTypeComboBoxChanged(); virtual void onSinkTypeComboBoxChanged(); virtual void onSourceTypeComboBoxChanged(); @@ -522,6 +532,7 @@ void SinkInputWidget::SinkMenuItem::onToggle() { MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr& x) : Gtk::Window(cobject), + showSinkInputType(SINK_INPUT_CLIENT), showSinkType(SINK_ALL), showSourceType(SOURCE_NO_MONITOR) { @@ -532,6 +543,7 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtrget_widget("noStreamsLabel", noStreamsLabel); x->get_widget("noSinksLabel", noSinksLabel); x->get_widget("noSourcesLabel", noSourcesLabel); + x->get_widget("sinkInputTypeComboBox", sinkInputTypeComboBox); x->get_widget("sinkTypeComboBox", sinkTypeComboBox); x->get_widget("sourceTypeComboBox", sourceTypeComboBox); @@ -539,9 +551,11 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtrset_reallocate_redraws(true); sinksVBox->set_reallocate_redraws(true); + sinkInputTypeComboBox->set_active((int) showSinkInputType); sinkTypeComboBox->set_active((int) showSinkType); sourceTypeComboBox->set_active((int) showSourceType); + sinkInputTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSinkInputTypeComboBoxChanged)); sinkTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSinkTypeComboBoxChanged)); sourceTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSourceTypeComboBoxChanged)); @@ -637,20 +651,24 @@ void MainWindow::updateSource(const pa_source_info &info) { void MainWindow::updateSinkInput(const pa_sink_input_info &info) { SinkInputWidget *w; + bool is_new = false; - if (streamWidgets.count(info.index)) - w = streamWidgets[info.index]; + if (sinkInputWidgets.count(info.index)) + w = sinkInputWidgets[info.index]; else { - streamWidgets[info.index] = w = SinkInputWidget::create(); + sinkInputWidgets[info.index] = w = SinkInputWidget::create(); w->setChannelMap(info.channel_map); streamsVBox->pack_start(*w, false, false, 0); w->index = info.index; w->clientIndex = info.client; w->mainWindow = this; + is_new = true; } w->updating = true; + w->type = info.client != PA_INVALID_INDEX ? SINK_INPUT_CLIENT : SINK_INPUT_VIRTUAL; + w->sinkIndex = info.sink; char *txt; @@ -664,11 +682,11 @@ void MainWindow::updateSinkInput(const pa_sink_input_info &info) { w->nameLabel->set_label(info.name); } - w->muteToggleButton->set_active(info.mute); w->setVolume(info.volume); + w->muteToggleButton->set_active(info.mute); - w->show(); - updateDeviceVisibility(); + if (is_new) + updateDeviceVisibility(); w->updating = false; } @@ -678,7 +696,7 @@ void MainWindow::updateClient(const pa_client_info &info) { g_free(clientNames[info.index]); clientNames[info.index] = g_strdup(info.name); - for (std::map::iterator i = streamWidgets.begin(); i != streamWidgets.end(); ++i) { + for (std::map::iterator i = sinkInputWidgets.begin(); i != sinkInputWidgets.end(); ++i) { SinkInputWidget *w = i->second; if (!w) @@ -694,16 +712,26 @@ void MainWindow::updateClient(const pa_client_info &info) { void MainWindow::updateDeviceVisibility() { - if (streamWidgets.empty()) - noStreamsLabel->show(); - else - noStreamsLabel->hide(); - + streamsVBox->hide_all(); sourcesVBox->hide_all(); sinksVBox->hide_all(); bool is_empty = true; + for (std::map::iterator i = sinkInputWidgets.begin(); i != sinkInputWidgets.end(); ++i) { + SinkInputWidget* w = i->second; + + if (showSinkInputType == SINK_INPUT_ALL || w->type == showSinkInputType) { + w->show_all(); + is_empty = false; + } + } + + if (is_empty) + noStreamsLabel->show(); + + is_empty = true; + for (std::map::iterator i = sinkWidgets.begin(); i != sinkWidgets.end(); ++i) { SinkWidget* w = i->second; @@ -734,6 +762,7 @@ void MainWindow::updateDeviceVisibility() { sourcesVBox->show(); sinksVBox->show(); + streamsVBox->show(); } void MainWindow::removeSink(uint32_t index) { @@ -755,11 +784,11 @@ void MainWindow::removeSource(uint32_t index) { } void MainWindow::removeSinkInput(uint32_t index) { - if (!streamWidgets.count(index)) + if (!sinkInputWidgets.count(index)) return; - delete streamWidgets[index]; - streamWidgets.erase(index); + delete sinkInputWidgets[index]; + sinkInputWidgets.erase(index); updateDeviceVisibility(); } @@ -786,6 +815,15 @@ void MainWindow::onSourceTypeComboBoxChanged() { updateDeviceVisibility(); } +void MainWindow::onSinkInputTypeComboBoxChanged() { + showSinkInputType = (SinkInputType) sinkInputTypeComboBox->get_active_row_number(); + + if (showSinkInputType == (SinkInputType) -1) + sinkInputTypeComboBox->set_active((int) SINK_INPUT_CLIENT); + + updateDeviceVisibility(); +} + static void dec_outstanding(MainWindow *w) { if (n_outstanding <= 0) return; diff --git a/src/pavucontrol.glade b/src/pavucontrol.glade index 296a91e..8bd353f 100644 --- a/src/pavucontrol.glade +++ b/src/pavucontrol.glade @@ -100,6 +100,7 @@ True + GTK_SHADOW_NONE True @@ -133,34 +134,60 @@ True - True + 6 - + True - 6 - - - True - 1 - 6 - gtk-dialog-info - - + 1 + gtk-dialog-info + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 True 0 - <b>Hint:</b> Right click on a playback stream to move it to another output device. + <b>Hint:</b> <i>Right click on a playback stream to move it to another output device.</i> True - - 1 - False - False + 1 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 1 + <b>_Show:</b> + True + True + + + 2 + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + All Streams +Applications +Virtual Streams + + + False + 3 @@ -180,7 +207,7 @@ True - S_treams + _Playback True @@ -202,6 +229,7 @@ True + GTK_SHADOW_NONE True @@ -236,28 +264,58 @@ True 6 + + + True + 1 + gtk-dialog-info + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + 0 + <b>Hint:</b> <i>Right click on an output device to make it the default.</i> + True + + + + + False + 1 + + True + 1 <b>S_how:</b> True True sinkTypeComboBox - False - False + 2 True - All Sinks -Hardware Sinks -Virtual Sinks + All Output Devices +Hardware Output Devices +Virtual Output Devices - 1 + False + 3 @@ -277,7 +335,7 @@ Virtual Sinks True - S_inks + _Output Devices True @@ -300,6 +358,7 @@ Virtual Sinks True + GTK_SHADOW_NONE True @@ -334,30 +393,60 @@ Virtual Sinks True 6 + + + True + 1 + gtk-dialog-info + + + False + + + + + True + GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK | GDK_BUTTON_RELEASE_MASK + 12 + + + True + 0 + <b>Hint:</b> <i>Right click on an input device to make it the default.</i> + True + + + + + False + 1 + + True - <b>Sh_ow:</b> + 1 + <b>Sho_w:</b> True True sourceTypeComboBox - False - False + 2 True - All Sources -All Except Monitor Sources -Hardware Sources -Virtual Sources -Monitor Sources + All Input Devices +All Except Monitors +Hardware Input Devices +Virtual Input Devices +Monitors - 1 + False + 3 @@ -377,7 +466,7 @@ Monitor Sources True - S_ources + _Input Devices True -- cgit