summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Guthrie <cguthrie@mandriva.org>2009-03-16 12:59:01 +0000
committerColin Guthrie <cguthrie@mandriva.org>2009-03-16 12:59:01 +0000
commitdc5498f86a12c9c43db65f2fe646ce7118c859b4 (patch)
tree9a1e555102fa807b8a5d2366081ac82fbd3ee29a
parented4f413ec5a2bcfacc17d8430eabea488e81397d (diff)
Split sinkinputwidget into it's own files.
Also had to put mainwindow into it's own header for this to work. Full conversion of mainwindow will ultimately follow.
-rw-r--r--src/Makefile.am2
-rw-r--r--src/mainwindow.h99
-rw-r--r--src/pavucontrol.cc210
-rw-r--r--src/sinkinputwidget.cc128
-rw-r--r--src/sinkinputwidget.h70
5 files changed, 301 insertions, 208 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index 8de1b28..0e3560e 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -31,6 +31,8 @@ pavucontrol_SOURCES= \
cardwidget.h cardwidget.cc \
sinkwidget.h sinkwidget.cc \
sourcewidget.h sourcewidget.cc \
+ sinkinputwidget.h sinkinputwidget.cc \
+ mainwindow.h \
pavucontrol.h pavucontrol.cc \
i18n.h
diff --git a/src/mainwindow.h b/src/mainwindow.h
new file mode 100644
index 0000000..a9f0f64
--- /dev/null
+++ b/src/mainwindow.h
@@ -0,0 +1,99 @@
+/***
+ This file is part of pavucontrol.
+
+ Copyright 2006-2008 Lennart Poettering
+ Copyright 2009 Colin Guthrie
+
+ pavucontrol is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ pavucontrol is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with pavucontrol. If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#ifndef mainwindow_h
+#define mainwindow_h
+
+#include "pavucontrol.h"
+#include <pulse/ext-stream-restore.h>
+
+
+class CardWidget;
+class SinkWidget;
+class SourceWidget;
+class SinkInputWidget;
+class SourceOutputWidget;
+class RoleWidget;
+
+class MainWindow : public Gtk::Window {
+public:
+ MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
+ static MainWindow* create();
+ virtual ~MainWindow();
+
+ void updateCard(const pa_card_info &info);
+ void updateSink(const pa_sink_info &info);
+ void updateSource(const pa_source_info &info);
+ void updateSinkInput(const pa_sink_input_info &info);
+ void updateSourceOutput(const pa_source_output_info &info);
+ void updateClient(const pa_client_info &info);
+ void updateServer(const pa_server_info &info);
+ void updateVolumeMeter(uint32_t source_index, uint32_t sink_input_index, double v);
+ void updateRole(const pa_ext_stream_restore_info &info);
+
+ void removeCard(uint32_t index);
+ void removeSink(uint32_t index);
+ void removeSource(uint32_t index);
+ void removeSinkInput(uint32_t index);
+ void removeSourceOutput(uint32_t index);
+ void removeClient(uint32_t index);
+
+ Gtk::Notebook *notebook;
+ Gtk::VBox *streamsVBox, *recsVBox, *sinksVBox, *sourcesVBox, *cardsVBox;
+ Gtk::Label *noStreamsLabel, *noRecsLabel, *noSinksLabel, *noSourcesLabel, *noCardsLabel;
+ Gtk::ComboBox *sinkInputTypeComboBox, *sourceOutputTypeComboBox, *sinkTypeComboBox, *sourceTypeComboBox;
+
+ std::map<uint32_t, CardWidget*> cardWidgets;
+ std::map<uint32_t, SinkWidget*> sinkWidgets;
+ std::map<uint32_t, SourceWidget*> sourceWidgets;
+ std::map<uint32_t, SinkInputWidget*> sinkInputWidgets;
+ std::map<uint32_t, SourceOutputWidget*> sourceOutputWidgets;
+ std::map<uint32_t, char*> clientNames;
+
+ SinkInputType showSinkInputType;
+ SinkType showSinkType;
+ SourceOutputType showSourceOutputType;
+ SourceType showSourceType;
+
+ virtual void onSinkInputTypeComboBoxChanged();
+ virtual void onSourceOutputTypeComboBoxChanged();
+ virtual void onSinkTypeComboBoxChanged();
+ virtual void onSourceTypeComboBoxChanged();
+
+ void updateDeviceVisibility();
+ void reallyUpdateDeviceVisibility();
+ void createMonitorStreamForSource(uint32_t source_idx);
+ void createMonitorStreamForSinkInput(uint32_t sink_input_idx, uint32_t sink_idx);
+
+ void setIconFromProplist(Gtk::Image *icon, pa_proplist *l, const char *name);
+
+ RoleWidget *eventRoleWidget;
+
+ bool createEventRoleWidget();
+ void deleteEventRoleWidget();
+
+ Glib::ustring defaultSinkName, defaultSourceName;
+
+protected:
+ virtual void on_realize();
+};
+
+
+#endif
diff --git a/src/pavucontrol.cc b/src/pavucontrol.cc
index 96edf91..a123ca3 100644
--- a/src/pavucontrol.cc
+++ b/src/pavucontrol.cc
@@ -37,52 +37,12 @@
#include "cardwidget.h"
#include "sinkwidget.h"
#include "sourcewidget.h"
+#include "sinkinputwidget.h"
+#include "mainwindow.h"
static pa_context *context = NULL;
static int n_outstanding = 0;
-class MainWindow;
-
-class SinkInputWidget : public StreamWidget {
-public:
- SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
- static SinkInputWidget* create();
- virtual ~SinkInputWidget();
-
- SinkInputType type;
-
- uint32_t index, clientIndex, sinkIndex;
- virtual void executeVolumeUpdate();
- virtual void onMuteToggleButton();
- virtual void onKill();
- virtual void prepareMenu();
-
- MainWindow *mainWindow;
- Gtk::Menu submenu;
- Gtk::MenuItem titleMenuItem, killMenuItem;
-
- struct SinkMenuItem {
- SinkMenuItem(SinkInputWidget *w, const char *label, uint32_t i, bool active) :
- widget(w),
- menuItem(label),
- index(i) {
- menuItem.set_active(active);
- menuItem.set_draw_as_radio(true);
- menuItem.signal_toggled().connect(sigc::mem_fun(*this, &SinkMenuItem::onToggle));
- }
-
- SinkInputWidget *widget;
- Gtk::CheckMenuItem menuItem;
- uint32_t index;
- void onToggle();
- };
-
- std::map<uint32_t, SinkMenuItem*> sinkMenuItems;
-
- void clearMenu();
- void buildMenu();
-};
-
class SourceOutputWidget : public MinimalStreamWidget {
public:
SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
@@ -133,69 +93,6 @@ public:
virtual void executeVolumeUpdate();
};
-class MainWindow : public Gtk::Window {
-public:
- MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
- static MainWindow* create();
- virtual ~MainWindow();
-
- void updateCard(const pa_card_info &info);
- void updateSink(const pa_sink_info &info);
- void updateSource(const pa_source_info &info);
- void updateSinkInput(const pa_sink_input_info &info);
- void updateSourceOutput(const pa_source_output_info &info);
- void updateClient(const pa_client_info &info);
- void updateServer(const pa_server_info &info);
- void updateVolumeMeter(uint32_t source_index, uint32_t sink_input_index, double v);
- void updateRole(const pa_ext_stream_restore_info &info);
-
- void removeCard(uint32_t index);
- void removeSink(uint32_t index);
- void removeSource(uint32_t index);
- void removeSinkInput(uint32_t index);
- void removeSourceOutput(uint32_t index);
- void removeClient(uint32_t index);
-
- Gtk::Notebook *notebook;
- Gtk::VBox *streamsVBox, *recsVBox, *sinksVBox, *sourcesVBox, *cardsVBox;
- Gtk::Label *noStreamsLabel, *noRecsLabel, *noSinksLabel, *noSourcesLabel, *noCardsLabel;
- Gtk::ComboBox *sinkInputTypeComboBox, *sourceOutputTypeComboBox, *sinkTypeComboBox, *sourceTypeComboBox;
-
- std::map<uint32_t, CardWidget*> cardWidgets;
- std::map<uint32_t, SinkWidget*> sinkWidgets;
- std::map<uint32_t, SourceWidget*> sourceWidgets;
- std::map<uint32_t, SinkInputWidget*> sinkInputWidgets;
- std::map<uint32_t, SourceOutputWidget*> sourceOutputWidgets;
- std::map<uint32_t, char*> clientNames;
-
- SinkInputType showSinkInputType;
- SinkType showSinkType;
- SourceOutputType showSourceOutputType;
- SourceType showSourceType;
-
- virtual void onSinkInputTypeComboBoxChanged();
- virtual void onSourceOutputTypeComboBoxChanged();
- virtual void onSinkTypeComboBoxChanged();
- virtual void onSourceTypeComboBoxChanged();
-
- void updateDeviceVisibility();
- void reallyUpdateDeviceVisibility();
- void createMonitorStreamForSource(uint32_t source_idx);
- void createMonitorStreamForSinkInput(uint32_t sink_input_idx, uint32_t sink_idx);
-
- void setIconFromProplist(Gtk::Image *icon, pa_proplist *l, const char *name);
-
- RoleWidget *eventRoleWidget;
-
- bool createEventRoleWidget();
- void deleteEventRoleWidget();
-
- Glib::ustring defaultSinkName, defaultSourceName;
-
-protected:
- virtual void on_realize();
-};
-
void show_error(const char *txt) {
char buf[256];
@@ -208,109 +105,6 @@ void show_error(const char *txt) {
}
-SinkInputWidget::SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
- StreamWidget(cobject, x),
- mainWindow(NULL),
- titleMenuItem(_("_Move Stream..."), true),
- killMenuItem(_("_Terminate Stream"), true) {
-
- add_events(Gdk::BUTTON_PRESS_MASK);
-
- menu.append(titleMenuItem);
- titleMenuItem.set_submenu(submenu);
-
- menu.append(killMenuItem);
- killMenuItem.signal_activate().connect(sigc::mem_fun(*this, &SinkInputWidget::onKill));
-}
-
-SinkInputWidget::~SinkInputWidget() {
- clearMenu();
-}
-
-SinkInputWidget* SinkInputWidget::create() {
- SinkInputWidget* w;
- Glib::RefPtr<Gnome::Glade::Xml> x = Gnome::Glade::Xml::create(GLADE_FILE, "streamWidget");
- x->get_widget_derived("streamWidget", w);
- return w;
-}
-
-void SinkInputWidget::executeVolumeUpdate() {
- pa_operation* o;
-
- if (!(o = pa_context_set_sink_input_volume(context, index, &volume, NULL, NULL))) {
- show_error(_("pa_context_set_sink_input_volume() failed"));
- return;
- }
-
- pa_operation_unref(o);
-}
-
-void SinkInputWidget::onMuteToggleButton() {
- StreamWidget::onMuteToggleButton();
-
- if (updating)
- return;
-
- pa_operation* o;
- if (!(o = pa_context_set_sink_input_mute(context, index, muteToggleButton->get_active(), NULL, NULL))) {
- show_error(_("pa_context_set_sink_input_mute() failed"));
- return;
- }
-
- 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 = mainWindow->sinkWidgets.begin(); i != mainWindow->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);
- submenu.append(m->menuItem);
- }
-
- menu.show_all();
-}
-
-void SinkInputWidget::onKill() {
- pa_operation* o;
- if (!(o = pa_context_kill_sink_input(context, index, NULL, NULL))) {
- show_error(_("pa_context_kill_sink_input() failed"));
- return;
- }
-
- pa_operation_unref(o);
-}
-
-void SinkInputWidget::SinkMenuItem::onToggle() {
-
- if (widget->updating)
- return;
-
- if (!menuItem.get_active())
- return;
-
- pa_operation* o;
- if (!(o = pa_context_move_sink_input_by_index(context, widget->index, index, NULL, NULL))) {
- show_error(_("pa_context_move_sink_input_by_index() failed"));
- return;
- }
-
- pa_operation_unref(o);
-}
-
SourceOutputWidget::SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
MinimalStreamWidget(cobject, x),
mainWindow(NULL),
diff --git a/src/sinkinputwidget.cc b/src/sinkinputwidget.cc
new file mode 100644
index 0000000..1d5e951
--- /dev/null
+++ b/src/sinkinputwidget.cc
@@ -0,0 +1,128 @@
+/***
+ This file is part of pavucontrol.
+
+ Copyright 2006-2008 Lennart Poettering
+ Copyright 2009 Colin Guthrie
+
+ pavucontrol is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ pavucontrol is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with pavucontrol. If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#include "sinkinputwidget.h"
+#include "mainwindow.h"
+#include "sinkwidget.h"
+
+#include "i18n.h"
+
+SinkInputWidget::SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
+ StreamWidget(cobject, x),
+ mainWindow(NULL),
+ titleMenuItem(_("_Move Stream..."), true),
+ killMenuItem(_("_Terminate Stream"), true) {
+
+ add_events(Gdk::BUTTON_PRESS_MASK);
+
+ menu.append(titleMenuItem);
+ titleMenuItem.set_submenu(submenu);
+
+ menu.append(killMenuItem);
+ killMenuItem.signal_activate().connect(sigc::mem_fun(*this, &SinkInputWidget::onKill));
+}
+
+SinkInputWidget::~SinkInputWidget() {
+ clearMenu();
+}
+
+SinkInputWidget* SinkInputWidget::create() {
+ SinkInputWidget* w;
+ Glib::RefPtr<Gnome::Glade::Xml> x = Gnome::Glade::Xml::create(GLADE_FILE, "streamWidget");
+ x->get_widget_derived("streamWidget", w);
+ return w;
+}
+
+void SinkInputWidget::executeVolumeUpdate() {
+ pa_operation* o;
+
+ if (!(o = pa_context_set_sink_input_volume(get_context(), index, &volume, NULL, NULL))) {
+ show_error(_("pa_context_set_sink_input_volume() failed"));
+ return;
+ }
+
+ pa_operation_unref(o);
+}
+
+void SinkInputWidget::onMuteToggleButton() {
+ StreamWidget::onMuteToggleButton();
+
+ if (updating)
+ return;
+
+ pa_operation* o;
+ if (!(o = pa_context_set_sink_input_mute(get_context(), index, muteToggleButton->get_active(), NULL, NULL))) {
+ show_error(_("pa_context_set_sink_input_mute() failed"));
+ return;
+ }
+
+ 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 = mainWindow->sinkWidgets.begin(); i != mainWindow->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);
+ 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))) {
+ show_error(_("pa_context_kill_sink_input() failed"));
+ return;
+ }
+
+ pa_operation_unref(o);
+}
+
+void SinkInputWidget::SinkMenuItem::onToggle() {
+
+ if (widget->updating)
+ 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;
+ }
+
+ pa_operation_unref(o);
+}
diff --git a/src/sinkinputwidget.h b/src/sinkinputwidget.h
new file mode 100644
index 0000000..6db504b
--- /dev/null
+++ b/src/sinkinputwidget.h
@@ -0,0 +1,70 @@
+/***
+ This file is part of pavucontrol.
+
+ Copyright 2006-2008 Lennart Poettering
+ Copyright 2009 Colin Guthrie
+
+ pavucontrol is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 2 of the License, or
+ (at your option) any later version.
+
+ pavucontrol is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with pavucontrol. If not, see <http://www.gnu.org/licenses/>.
+***/
+
+#ifndef sinkinputwidget_h
+#define sinkinputwidget_h
+
+#include "pavucontrol.h"
+
+#include "streamwidget.h"
+
+class MainWindow;
+
+class SinkInputWidget : public StreamWidget {
+public:
+ SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
+ static SinkInputWidget* create();
+ virtual ~SinkInputWidget();
+
+ SinkInputType type;
+
+ uint32_t index, clientIndex, sinkIndex;
+ virtual void executeVolumeUpdate();
+ virtual void onMuteToggleButton();
+ virtual void onKill();
+ virtual void prepareMenu();
+
+ MainWindow *mainWindow;
+ Gtk::Menu submenu;
+ Gtk::MenuItem titleMenuItem, killMenuItem;
+
+ struct SinkMenuItem {
+ SinkMenuItem(SinkInputWidget *w, const char *label, uint32_t i, bool active) :
+ widget(w),
+ menuItem(label),
+ index(i) {
+ menuItem.set_active(active);
+ menuItem.set_draw_as_radio(true);
+ menuItem.signal_toggled().connect(sigc::mem_fun(*this, &SinkMenuItem::onToggle));
+ }
+
+ SinkInputWidget *widget;
+ Gtk::CheckMenuItem menuItem;
+ uint32_t index;
+ void onToggle();
+ };
+
+ std::map<uint32_t, SinkMenuItem*> sinkMenuItems;
+
+ void clearMenu();
+ void buildMenu();
+};
+
+#endif