summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorColin Guthrie <cguthrie@mandriva.org>2009-03-16 23:21:40 +0000
committerColin Guthrie <cguthrie@mandriva.org>2009-06-17 08:54:12 +0100
commit4bd94fa2b86fb8464829c806ae517db113924bd2 (patch)
tree2d7d0e6b9b80ea9a86c02d888fd228e2b10fc48f /src
parent4c3acd35e5d406846c6f9d0596ce4f834e373bd8 (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')
-rw-r--r--src/mainwindow.cc13
-rw-r--r--src/minimalstreamwidget.cc49
-rw-r--r--src/minimalstreamwidget.h9
-rw-r--r--src/pavucontrol.glade4
-rw-r--r--src/sinkinputwidget.cc68
-rw-r--r--src/sinkinputwidget.h26
-rw-r--r--src/sinkwidget.cc14
-rw-r--r--src/sinkwidget.h4
-rw-r--r--src/sourceoutputwidget.cc68
-rw-r--r--src/sourceoutputwidget.h26
-rw-r--r--src/sourcewidget.cc14
-rw-r--r--src/sourcewidget.h4
-rw-r--r--src/streamwidget.cc3
-rw-r--r--src/streamwidget.h6
14 files changed, 69 insertions, 239 deletions
diff --git a/src/mainwindow.cc b/src/mainwindow.cc
index de7aab8..f76f37a 100644
--- a/src/mainwindow.cc
+++ b/src/mainwindow.cc
@@ -245,7 +245,8 @@ void MainWindow::updateSink(const pa_sink_info &info) {
w->setVolume(info.volume);
w->muteToggleButton->set_active(info.mute);
- w->defaultMenuItem.set_active(w->name == defaultSinkName);
+ w->defaultToggleButton->set_active(w->name == defaultSinkName);
+ w->defaultToggleButton->set_sensitive(w->name != defaultSinkName);
w->updating = false;
@@ -422,7 +423,8 @@ void MainWindow::updateSource(const pa_source_info &info) {
w->setVolume(info.volume);
w->muteToggleButton->set_active(info.mute);
- w->defaultMenuItem.set_active(w->name == defaultSourceName);
+ w->defaultToggleButton->set_active(w->name == defaultSourceName);
+ w->defaultToggleButton->set_sensitive(w->name != defaultSourceName);
w->updating = false;
@@ -592,7 +594,9 @@ void MainWindow::updateServer(const pa_server_info &info) {
continue;
w->updating = true;
- w->defaultMenuItem.set_active(w->name == defaultSinkName);
+ w->defaultToggleButton->set_active(w->name == defaultSinkName);
+ w->defaultToggleButton->set_sensitive(w->name != defaultSinkName);
+
w->updating = false;
}
@@ -603,7 +607,8 @@ void MainWindow::updateServer(const pa_server_info &info) {
continue;
w->updating = true;
- w->defaultMenuItem.set_active(w->name == defaultSourceName);
+ w->defaultToggleButton->set_active(w->name == defaultSourceName);
+ w->defaultToggleButton->set_sensitive(w->name != defaultSourceName);
w->updating = false;
}
}
diff --git a/src/minimalstreamwidget.cc b/src/minimalstreamwidget.cc
index b38bb47..ac665de 100644
--- a/src/minimalstreamwidget.cc
+++ b/src/minimalstreamwidget.cc
@@ -40,58 +40,9 @@ MinimalStreamWidget::MinimalStreamWidget(BaseObjectType* cobject, const Glib::Re
peakProgressBar.set_size_request(-1, 10);
channelsVBox->pack_end(peakProgressBar, false, false);
- //menu.signal_deactivate().connect(sigc::mem_fun(*this, &MinimalStreamWidget::onMenuDeactivated));
-
peakProgressBar.hide();
}
-void MinimalStreamWidget::prepareMenu(void) {
-}
-
-void MinimalStreamWidget::onMenuDeactivated(void) {
- //streamToggleButton->set_active(false);
-}
-
-void MinimalStreamWidget::popupMenuPosition(int& x, int& y, bool& push_in G_GNUC_UNUSED) {
-/*
- Gtk::Requisition r;
-
- streamToggleButton->get_window()->get_origin(x, y);
- r = menu.size_request();
-
- // Align the right side of the menu with the right side of the togglebutton
- x += streamToggleButton->get_allocation().get_x();
- x += streamToggleButton->get_allocation().get_width();
- x -= r.width;
-
- // Align the top of the menu with the buttom of the togglebutton
- y += streamToggleButton->get_allocation().get_y();
- y += streamToggleButton->get_allocation().get_height();
-*/
-}
-
-void MinimalStreamWidget::onStreamToggleButton(void) {
-/*
- if (streamToggleButton->get_active()) {
- prepareMenu();
- menu.popup(sigc::mem_fun(*this, &MinimalStreamWidget::popupMenuPosition), 0, gtk_get_current_event_time());
- }
-*/
-}
-
-bool MinimalStreamWidget::on_button_press_event (GdkEventButton* event) {
- if (Gtk::VBox::on_button_press_event(event))
- return TRUE;
-
- if (event->type == GDK_BUTTON_PRESS && event->button == 3) {
- prepareMenu();
- menu.popup(0, event->time);
- return TRUE;
- }
-
- return FALSE;
-}
-
#define DECAY_STEP .04
void MinimalStreamWidget::updatePeak(double v) {
diff --git a/src/minimalstreamwidget.h b/src/minimalstreamwidget.h
index 0fcae59..55cf6f3 100644
--- a/src/minimalstreamwidget.h
+++ b/src/minimalstreamwidget.h
@@ -29,29 +29,20 @@ public:
Gtk::VBox *channelsVBox;
Gtk::Label *nameLabel, *boldNameLabel;
- Gtk::Menu menu;
Gtk::Image *iconImage;
Gtk::ProgressBar peakProgressBar;
double lastPeak;
bool updating;
- /**/void onStreamToggleButton();
- /**/void onMenuDeactivated();
- /**/void popupMenuPosition(int& x, int& y, bool& push_in);
-
virtual void onMuteToggleButton() = 0;
virtual void updateChannelVolume(int channel, pa_volume_t v) = 0;
- virtual void prepareMenu(void);
bool volumeMeterEnabled;
void enableVolumeMeter();
void updatePeak(double v);
Glib::ustring beepDevice;
-
-protected:
- virtual bool on_button_press_event(GdkEventButton* event);
};
#endif
diff --git a/src/pavucontrol.glade b/src/pavucontrol.glade
index 657ab3f..f45cef7 100644
--- a/src/pavucontrol.glade
+++ b/src/pavucontrol.glade
@@ -786,11 +786,11 @@ Monitors</property>
</packing>
</child>
<child>
- <widget class="GtkToggleButton" id="defaultToggle">
+ <widget class="GtkToggleButton" id="defaultToggleButton">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="receives_default">False</property>
- <property name="tooltip" translatable="yes">Open menu</property>
+ <property name="tooltip" translatable="yes">Set as default</property>
<child>
<widget class="GtkHBox" id="hbox2">
<property name="visible">True</property>
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);
}
diff --git a/src/sinkinputwidget.h b/src/sinkinputwidget.h
index bf65108..503c67c 100644
--- a/src/sinkinputwidget.h
+++ b/src/sinkinputwidget.h
@@ -31,7 +31,6 @@ class SinkInputWidget : public StreamWidget {
public:
SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
static SinkInputWidget* create(MainWindow* mainWindow);
- virtual ~SinkInputWidget();
void init(MainWindow* mainWindow);
@@ -44,31 +43,6 @@ public:
virtual void onDeviceChange();
virtual void onMuteToggleButton();
virtual void onKill();
- virtual void prepareMenu();
-
- Gtk::Menu submenu;
- Gtk::MenuItem titleMenuItem;
-
- 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();
private:
MainWindow *mpMainWindow;
diff --git a/src/sinkwidget.cc b/src/sinkwidget.cc
index fa90a75..e0fcdde 100644
--- a/src/sinkwidget.cc
+++ b/src/sinkwidget.cc
@@ -27,15 +27,7 @@
#include "i18n.h"
SinkWidget::SinkWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
- DeviceWidget(cobject, x),
- defaultMenuItem("_Default", true){
-
- add_events(Gdk::BUTTON_PRESS_MASK);
-
- defaultMenuItem.set_active(false);
- defaultMenuItem.signal_toggled().connect(sigc::mem_fun(*this, &SinkWidget::onDefaultToggle));
- menu.append(defaultMenuItem);
- menu.show_all();
+ DeviceWidget(cobject, x) {
}
SinkWidget* SinkWidget::create() {
@@ -71,9 +63,11 @@ void SinkWidget::onMuteToggleButton() {
pa_operation_unref(o);
}
-void SinkWidget::onDefaultToggle() {
+void SinkWidget::onDefaultToggleButton() {
pa_operation* o;
+ DeviceWidget::onDefaultToggleButton();
+
if (updating)
return;
diff --git a/src/sinkwidget.h b/src/sinkwidget.h
index c833e78..6c6186b 100644
--- a/src/sinkwidget.h
+++ b/src/sinkwidget.h
@@ -36,11 +36,9 @@ public:
uint32_t index, monitor_index, card_index;
bool can_decibel;
- Gtk::CheckMenuItem defaultMenuItem;
-
virtual void onMuteToggleButton();
virtual void executeVolumeUpdate();
- virtual void onDefaultToggle();
+ virtual void onDefaultToggleButton();
};
#endif
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<Gnome::Glade::Xml>& x) :
StreamWidget(cobject, x),
- titleMenuItem(_("_Move Stream..."), true),
mpMainWindow(NULL) {
directionLabel->set_label(_("<i>Recording from </i> "));
-
- 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<Gnome::Glade::Xml> 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<uint32_t, SourceMenuItem*>::iterator i = sourceMenuItems.begin();
- delete i->second;
- sourceMenuItems.erase(i);
- }
-}
-
-void SourceOutputWidget::buildMenu() {
- for (std::map<uint32_t, SourceWidget*>::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);
}
diff --git a/src/sourceoutputwidget.h b/src/sourceoutputwidget.h
index 46df6e1..0d43cc9 100644
--- a/src/sourceoutputwidget.h
+++ b/src/sourceoutputwidget.h
@@ -31,7 +31,6 @@ class SourceOutputWidget : public StreamWidget {
public:
SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
static SourceOutputWidget* create(MainWindow* mainWindow);
- virtual ~SourceOutputWidget();
void init(MainWindow* mainWindow);
@@ -43,31 +42,6 @@ public:
virtual void onDeviceChange();
virtual void onKill();
- Gtk::Menu submenu;
- Gtk::MenuItem titleMenuItem;
-
- struct SourceMenuItem {
- SourceMenuItem(SourceOutputWidget *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, &SourceMenuItem::onToggle));
- }
-
- SourceOutputWidget *widget;
- Gtk::CheckMenuItem menuItem;
- uint32_t index;
- void onToggle();
- };
-
- std::map<uint32_t, SourceMenuItem*> sourceMenuItems;
-
- void clearMenu();
- void buildMenu();
- virtual void prepareMenu();
-
private:
MainWindow *mpMainWindow;
uint32_t mSourceIndex;
diff --git a/src/sourcewidget.cc b/src/sourcewidget.cc
index c77f4f2..cef0a3e 100644
--- a/src/sourcewidget.cc
+++ b/src/sourcewidget.cc
@@ -27,15 +27,7 @@
#include "i18n.h"
SourceWidget::SourceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
- DeviceWidget(cobject, x),
- defaultMenuItem(_("_Default"), true){
-
- add_events(Gdk::BUTTON_PRESS_MASK);
-
- defaultMenuItem.set_active(false);
- defaultMenuItem.signal_toggled().connect(sigc::mem_fun(*this, &SourceWidget::onDefaultToggle));
- menu.append(defaultMenuItem);
- menu.show_all();
+ DeviceWidget(cobject, x) {
}
SourceWidget* SourceWidget::create() {
@@ -71,9 +63,11 @@ void SourceWidget::onMuteToggleButton() {
pa_operation_unref(o);
}
-void SourceWidget::onDefaultToggle() {
+void SourceWidget::onDefaultToggleButton() {
pa_operation* o;
+ DeviceWidget::onDefaultToggleButton();
+
if (updating)
return;
diff --git a/src/sourcewidget.h b/src/sourcewidget.h
index 04ee4af..81bd44c 100644
--- a/src/sourcewidget.h
+++ b/src/sourcewidget.h
@@ -36,11 +36,9 @@ public:
uint32_t index, card_index;
bool can_decibel;
- Gtk::CheckMenuItem defaultMenuItem;
-
virtual void onMuteToggleButton();
virtual void executeVolumeUpdate();
- virtual void onDefaultToggle();
+ virtual void onDefaultToggleButton();
};
#endif
diff --git a/src/streamwidget.cc b/src/streamwidget.cc
index 43e4221..b7b23dc 100644
--- a/src/streamwidget.cc
+++ b/src/streamwidget.cc
@@ -27,7 +27,8 @@
/*** StreamWidget ***/
StreamWidget::StreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
- MinimalStreamWidget(cobject, x) {
+ MinimalStreamWidget(cobject, x),
+ mSuppressDeviceChange(false) {
x->get_widget("lockToggleButton", lockToggleButton);
x->get_widget("muteToggleButton", muteToggleButton);
diff --git a/src/streamwidget.h b/src/streamwidget.h
index c7d68d9..56b95d0 100644
--- a/src/streamwidget.h
+++ b/src/streamwidget.h
@@ -45,9 +45,9 @@ public:
ChannelWidget *channelWidgets[PA_CHANNELS_MAX];
- virtual void onKill();
- virtual void onDeviceChange() = 0;
virtual void onMuteToggleButton();
+ virtual void onDeviceChange() = 0;
+ virtual void onKill();
sigc::connection timeoutConnection;
@@ -59,6 +59,8 @@ public:
protected:
Gtk::ComboBox *deviceCombo;
+
+ bool mSuppressDeviceChange;
};
#endif