Adapt to new UI

The actual wiring up of events and clearing out of old, unused elements is
not complete yet, so this is completely non-functional at present.
This commit is contained in:
Colin Guthrie 2009-03-16 19:57:31 +00:00
parent e509205be2
commit 7b7a12f1d2
17 changed files with 129 additions and 26 deletions

View File

@ -29,7 +29,6 @@ public:
static CardWidget* create(); static CardWidget* create();
Gtk::Label *nameLabel; Gtk::Label *nameLabel;
Gtk::ToggleButton *streamToggleButton;
Gtk::Menu menu; Gtk::Menu menu;
Gtk::Image *iconImage; Gtk::Image *iconImage;
Glib::ustring name; Glib::ustring name;

View File

@ -23,7 +23,7 @@
#endif #endif
#include "channelwidget.h" #include "channelwidget.h"
#include "streamwidget.h" #include "minimalstreamwidget.h"
#include "i18n.h" #include "i18n.h"
@ -83,11 +83,11 @@ void ChannelWidget::onVolumeScaleValueChanged() {
if (!volumeScaleEnabled) if (!volumeScaleEnabled)
return; return;
if (streamWidget->updating) if (minimalStreamWidget->updating)
return; return;
pa_volume_t volume = (pa_volume_t) ((volumeScale->get_value() * PA_VOLUME_NORM) / 100); pa_volume_t volume = (pa_volume_t) ((volumeScale->get_value() * PA_VOLUME_NORM) / 100);
streamWidget->updateChannelVolume(channel, volume); minimalStreamWidget->updateChannelVolume(channel, volume);
if (beepDevice != "") { if (beepDevice != "") {
ca_context_change_device(ca_gtk_context_get(), beepDevice.c_str()); ca_context_change_device(ca_gtk_context_get(), beepDevice.c_str());

View File

@ -25,7 +25,7 @@
#include <canberra-gtk.h> #include <canberra-gtk.h>
class StreamWidget; class MinimalStreamWidget;
class ChannelWidget : public Gtk::EventBox { class ChannelWidget : public Gtk::EventBox {
public: public:
@ -39,7 +39,7 @@ public:
Gtk::HScale *volumeScale; Gtk::HScale *volumeScale;
int channel; int channel;
StreamWidget *streamWidget; MinimalStreamWidget *minimalStreamWidget;
void onVolumeScaleValueChanged(); void onVolumeScaleValueChanged();

View File

@ -19,6 +19,7 @@
***/ ***/
#include "devicewidget.h" #include "devicewidget.h"
#include "channelwidget.h"
/*** DeviceWidget ***/ /*** DeviceWidget ***/
DeviceWidget::DeviceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) : DeviceWidget::DeviceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
@ -41,7 +42,7 @@ void DeviceWidget::setChannelMap(const pa_channel_map &m, bool can_decibel) {
cw->beepDevice = beepDevice; cw->beepDevice = beepDevice;
cw->channel = i; cw->channel = i;
cw->can_decibel = can_decibel; cw->can_decibel = can_decibel;
cw->streamWidget = this; cw->minimalStreamWidget = this;
char text[64]; char text[64];
snprintf(text, sizeof(text), "<b>%s</b>", pa_channel_position_to_pretty_string(m.map[i])); snprintf(text, sizeof(text), "<b>%s</b>", pa_channel_position_to_pretty_string(m.map[i]));
cw->channelLabel->set_markup(text); cw->channelLabel->set_markup(text);

View File

@ -86,6 +86,9 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
sourceOutputTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSourceOutputTypeComboBoxChanged)); sourceOutputTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSourceOutputTypeComboBoxChanged));
sinkTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSinkTypeComboBoxChanged)); sinkTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSinkTypeComboBoxChanged));
sourceTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSourceTypeComboBoxChanged)); sourceTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSourceTypeComboBoxChanged));
sinkTree = Gtk::ListStore::create(deviceColumns);
sourceTree = Gtk::ListStore::create(deviceColumns);
} }
MainWindow* MainWindow::create() { MainWindow* MainWindow::create() {
@ -176,6 +179,29 @@ void MainWindow::updateCard(const pa_card_info &info) {
updateDeviceVisibility(); updateDeviceVisibility();
} }
void MainWindow::rebuildSinkCombo() {
//int active_idx = -1;
Gtk::TreeModel::Row row;
// Update our sinkTree
sinkTree->clear();
row = *(sinkTree->append());
row[deviceColumns.index] = -1;
row[deviceColumns.name] = "Default Output";
for (std::map<uint32_t, SinkWidget*>::iterator i = sinkWidgets.begin(); i != sinkWidgets.end(); ++i) {
Gtk::TreeModel::Row row = *(sinkTree->append());
row[deviceColumns.index] = i->first;
row[deviceColumns.name] = i->second->description.c_str();
/*if (i->first == activeProfile)
active_idx = idx;
idx++;*/
}
/*if (active_idx >= 0)
sinkTree->set_active(active_idx);*/
}
void MainWindow::updateSink(const pa_sink_info &info) { void MainWindow::updateSink(const pa_sink_info &info) {
SinkWidget *w; SinkWidget *w;
bool is_new = false; bool is_new = false;
@ -218,6 +244,7 @@ void MainWindow::updateSink(const pa_sink_info &info) {
w->updating = false; w->updating = false;
rebuildSinkCombo();
if (is_new) if (is_new)
updateDeviceVisibility(); updateDeviceVisibility();
} }
@ -323,6 +350,29 @@ void MainWindow::createMonitorStreamForSinkInput(uint32_t sink_input_idx, uint32
} }
} }
void MainWindow::rebuildSourceCombo() {
//int active_idx = -1;
Gtk::TreeModel::Row row;
// Update our sinkTree
sourceTree->clear();
row = *(sourceTree->append());
row[deviceColumns.index] = -1;
row[deviceColumns.name] = "Default Input";
for (std::map<uint32_t, SourceWidget*>::iterator i = sourceWidgets.begin(); i != sourceWidgets.end(); ++i) {
Gtk::TreeModel::Row row = *(sourceTree->append());
row[deviceColumns.index] = i->first;
row[deviceColumns.name] = i->second->description.c_str();
/*if (i->first == activeProfile)
active_idx = idx;
idx++;*/
}
/*if (active_idx >= 0)
sourceTree->set_active(active_idx);*/
}
void MainWindow::updateSource(const pa_source_info &info) { void MainWindow::updateSource(const pa_source_info &info) {
SourceWidget *w; SourceWidget *w;
bool is_new = false; bool is_new = false;
@ -366,6 +416,7 @@ void MainWindow::updateSource(const pa_source_info &info) {
w->updating = false; w->updating = false;
rebuildSourceCombo();
if (is_new) if (is_new)
updateDeviceVisibility(); updateDeviceVisibility();
} }
@ -784,6 +835,7 @@ void MainWindow::removeSink(uint32_t index) {
delete sinkWidgets[index]; delete sinkWidgets[index];
sinkWidgets.erase(index); sinkWidgets.erase(index);
rebuildSinkCombo();
updateDeviceVisibility(); updateDeviceVisibility();
} }
@ -793,6 +845,7 @@ void MainWindow::removeSource(uint32_t index) {
delete sourceWidgets[index]; delete sourceWidgets[index];
sourceWidgets.erase(index); sourceWidgets.erase(index);
rebuildSourceCombo();
updateDeviceVisibility(); updateDeviceVisibility();
} }

View File

@ -91,8 +91,27 @@ public:
Glib::ustring defaultSinkName, defaultSourceName; Glib::ustring defaultSinkName, defaultSourceName;
class DeviceColumns : public Gtk::TreeModel::ColumnRecord
{
public:
DeviceColumns()
{ add(index); add(name); }
Gtk::TreeModelColumn<uint32_t> index;
Gtk::TreeModelColumn<Glib::ustring> name;
};
DeviceColumns deviceColumns;
Glib::RefPtr<Gtk::ListStore> sinkTree;
Glib::RefPtr<Gtk::ListStore> sourceTree;
protected: protected:
virtual void on_realize(); virtual void on_realize();
private:
void rebuildSinkCombo();
void rebuildSourceCombo();
}; };

View File

@ -35,15 +35,12 @@ MinimalStreamWidget::MinimalStreamWidget(BaseObjectType* cobject, const Glib::Re
x->get_widget("channelsVBox", channelsVBox); x->get_widget("channelsVBox", channelsVBox);
x->get_widget("nameLabel", nameLabel); x->get_widget("nameLabel", nameLabel);
x->get_widget("boldNameLabel", boldNameLabel); x->get_widget("boldNameLabel", boldNameLabel);
x->get_widget("streamToggle", streamToggleButton);
x->get_widget("iconImage", iconImage); x->get_widget("iconImage", iconImage);
peakProgressBar.set_size_request(-1, 10); peakProgressBar.set_size_request(-1, 10);
channelsVBox->pack_end(peakProgressBar, false, false); channelsVBox->pack_end(peakProgressBar, false, false);
streamToggleButton->set_active(false); //menu.signal_deactivate().connect(sigc::mem_fun(*this, &MinimalStreamWidget::onMenuDeactivated));
streamToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &MinimalStreamWidget::onStreamToggleButton));
menu.signal_deactivate().connect(sigc::mem_fun(*this, &MinimalStreamWidget::onMenuDeactivated));
peakProgressBar.hide(); peakProgressBar.hide();
} }
@ -52,30 +49,34 @@ void MinimalStreamWidget::prepareMenu(void) {
} }
void MinimalStreamWidget::onMenuDeactivated(void) { void MinimalStreamWidget::onMenuDeactivated(void) {
streamToggleButton->set_active(false); //streamToggleButton->set_active(false);
} }
void MinimalStreamWidget::popupMenuPosition(int& x, int& y, bool& push_in G_GNUC_UNUSED) { void MinimalStreamWidget::popupMenuPosition(int& x, int& y, bool& push_in G_GNUC_UNUSED) {
/*
Gtk::Requisition r; Gtk::Requisition r;
streamToggleButton->get_window()->get_origin(x, y); streamToggleButton->get_window()->get_origin(x, y);
r = menu.size_request(); r = menu.size_request();
/* Align the right side of the menu with the right side of the togglebutton */ // 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_x();
x += streamToggleButton->get_allocation().get_width(); x += streamToggleButton->get_allocation().get_width();
x -= r.width; x -= r.width;
/* Align the top of the menu with the buttom of the togglebutton */ // Align the top of the menu with the buttom of the togglebutton
y += streamToggleButton->get_allocation().get_y(); y += streamToggleButton->get_allocation().get_y();
y += streamToggleButton->get_allocation().get_height(); y += streamToggleButton->get_allocation().get_height();
*/
} }
void MinimalStreamWidget::onStreamToggleButton(void) { void MinimalStreamWidget::onStreamToggleButton(void) {
/*
if (streamToggleButton->get_active()) { if (streamToggleButton->get_active()) {
prepareMenu(); prepareMenu();
menu.popup(sigc::mem_fun(*this, &MinimalStreamWidget::popupMenuPosition), 0, gtk_get_current_event_time()); menu.popup(sigc::mem_fun(*this, &MinimalStreamWidget::popupMenuPosition), 0, gtk_get_current_event_time());
} }
*/
} }
bool MinimalStreamWidget::on_button_press_event (GdkEventButton* event) { bool MinimalStreamWidget::on_button_press_event (GdkEventButton* event) {

View File

@ -29,7 +29,6 @@ public:
Gtk::VBox *channelsVBox; Gtk::VBox *channelsVBox;
Gtk::Label *nameLabel, *boldNameLabel; Gtk::Label *nameLabel, *boldNameLabel;
Gtk::ToggleButton *streamToggleButton;
Gtk::Menu menu; Gtk::Menu menu;
Gtk::Image *iconImage; Gtk::Image *iconImage;
Gtk::ProgressBar peakProgressBar; Gtk::ProgressBar peakProgressBar;
@ -37,10 +36,12 @@ public:
bool updating; bool updating;
void onStreamToggleButton(); /**/void onStreamToggleButton();
void onMenuDeactivated(); /**/void onMenuDeactivated();
void popupMenuPosition(int& x, int& y, bool& push_in); /**/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); virtual void prepareMenu(void);
bool volumeMeterEnabled; bool volumeMeterEnabled;

View File

@ -613,13 +613,13 @@ Monitors</property>
</packing> </packing>
</child> </child>
<child> <child>
<widget class="GtkHBox" id="hbox2"> <widget class="GtkHBox" id="streamControlHBox">
<property name="visible">True</property> <property name="visible">True</property>
<child> <child>
<widget class="GtkLabel" id="directionLabel"> <widget class="GtkLabel" id="directionLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="xalign">0</property> <property name="xalign">0</property>
<property name="label" translatable="yes">&lt;i&gt;Playing on &lt;/i&gt;</property> <property name="label" translatable="yes">direction</property>
<property name="use_markup">True</property> <property name="use_markup">True</property>
</widget> </widget>
<packing> <packing>

View File

@ -32,7 +32,7 @@ RoleWidget::RoleWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade:
StreamWidget(cobject, x) { StreamWidget(cobject, x) {
lockToggleButton->hide(); lockToggleButton->hide();
streamToggleButton->hide(); streamControlHBox->hide();
} }
RoleWidget* RoleWidget::create() { RoleWidget* RoleWidget::create() {
@ -48,6 +48,9 @@ void RoleWidget::onMuteToggleButton() {
executeVolumeUpdate(); executeVolumeUpdate();
} }
void RoleWidget::onDeviceChange() {
}
void RoleWidget::executeVolumeUpdate() { void RoleWidget::executeVolumeUpdate() {
pa_ext_stream_restore_info info; pa_ext_stream_restore_info info;

View File

@ -33,6 +33,7 @@ public:
Glib::ustring role; Glib::ustring role;
Glib::ustring device; Glib::ustring device;
virtual void onDeviceChange();
virtual void onMuteToggleButton(); virtual void onMuteToggleButton();
virtual void executeVolumeUpdate(); virtual void executeVolumeUpdate();
}; };

View File

@ -34,6 +34,8 @@ SinkInputWidget::SinkInputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gno
titleMenuItem(_("_Move Stream..."), true), titleMenuItem(_("_Move Stream..."), true),
killMenuItem(_("_Terminate Stream"), true) { killMenuItem(_("_Terminate Stream"), true) {
directionLabel->set_label(_("<i>Playing on </i> "));
add_events(Gdk::BUTTON_PRESS_MASK); add_events(Gdk::BUTTON_PRESS_MASK);
menu.append(titleMenuItem); menu.append(titleMenuItem);
@ -114,6 +116,9 @@ void SinkInputWidget::onKill() {
pa_operation_unref(o); pa_operation_unref(o);
} }
void SinkInputWidget::onDeviceChange() {
}
void SinkInputWidget::SinkMenuItem::onToggle() { void SinkInputWidget::SinkMenuItem::onToggle() {
if (widget->updating) if (widget->updating)

View File

@ -37,6 +37,7 @@ public:
uint32_t index, clientIndex, sinkIndex; uint32_t index, clientIndex, sinkIndex;
virtual void executeVolumeUpdate(); virtual void executeVolumeUpdate();
virtual void onDeviceChange();
virtual void onMuteToggleButton(); virtual void onMuteToggleButton();
virtual void onKill(); virtual void onKill();
virtual void prepareMenu(); virtual void prepareMenu();

View File

@ -29,11 +29,13 @@
#include "i18n.h" #include "i18n.h"
SourceOutputWidget::SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) : SourceOutputWidget::SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
MinimalStreamWidget(cobject, x), StreamWidget(cobject, x),
mainWindow(NULL), mainWindow(NULL),
titleMenuItem(_("_Move Stream..."), true), titleMenuItem(_("_Move Stream..."), true),
killMenuItem(_("_Terminate Stream"), true) { killMenuItem(_("_Terminate Stream"), true) {
directionLabel->set_label(_("<i>Recording from </i> "));
add_events(Gdk::BUTTON_PRESS_MASK); add_events(Gdk::BUTTON_PRESS_MASK);
menu.append(titleMenuItem); menu.append(titleMenuItem);
@ -88,6 +90,9 @@ void SourceOutputWidget::prepareMenu(void) {
buildMenu(); buildMenu();
} }
void SourceOutputWidget::onDeviceChange() {
}
void SourceOutputWidget::SourceMenuItem::onToggle() { void SourceOutputWidget::SourceMenuItem::onToggle() {
if (widget->updating) if (widget->updating)

View File

@ -23,11 +23,11 @@
#include "pavucontrol.h" #include "pavucontrol.h"
#include "minimalstreamwidget.h" #include "streamwidget.h"
class MainWindow; class MainWindow;
class SourceOutputWidget : public MinimalStreamWidget { class SourceOutputWidget : public StreamWidget {
public: public:
SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x); SourceOutputWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x);
static SourceOutputWidget* create(); static SourceOutputWidget* create();
@ -36,6 +36,7 @@ public:
SourceOutputType type; SourceOutputType type;
uint32_t index, clientIndex, sourceIndex; uint32_t index, clientIndex, sourceIndex;
virtual void onDeviceChange();
virtual void onKill(); virtual void onKill();
MainWindow *mainWindow; MainWindow *mainWindow;

View File

@ -26,12 +26,18 @@
#include "channelwidget.h" #include "channelwidget.h"
/*** StreamWidget ***/ /*** StreamWidget ***/
StreamWidget::StreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) : StreamWidget::StreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
MinimalStreamWidget(cobject, x) { MinimalStreamWidget(cobject, x) {
x->get_widget("lockToggleButton", lockToggleButton); x->get_widget("lockToggleButton", lockToggleButton);
x->get_widget("muteToggleButton", muteToggleButton); x->get_widget("muteToggleButton", muteToggleButton);
x->get_widget("deviceCombo", deviceCombo);
x->get_widget("terminateButton", terminateButton);
x->get_widget("directionLabel", directionLabel);
x->get_widget("streamControlHBox", streamControlHBox);
//deviceCombo->set_active(false);
//deviceCombo->signal_clicked().connect(sigc::mem_fun(*this, &MinimalStreamWidget::onDeviceChange));
muteToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &StreamWidget::onMuteToggleButton)); muteToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &StreamWidget::onMuteToggleButton));
@ -47,7 +53,7 @@ void StreamWidget::setChannelMap(const pa_channel_map &m, bool can_decibel) {
cw->beepDevice = beepDevice; cw->beepDevice = beepDevice;
cw->channel = i; cw->channel = i;
cw->can_decibel = can_decibel; cw->can_decibel = can_decibel;
cw->streamWidget = this; cw->minimalStreamWidget = this;
char text[64]; char text[64];
snprintf(text, sizeof(text), "<b>%s</b>", pa_channel_position_to_pretty_string(m.map[i])); snprintf(text, sizeof(text), "<b>%s</b>", pa_channel_position_to_pretty_string(m.map[i]));
cw->channelLabel->set_markup(text); cw->channelLabel->set_markup(text);

View File

@ -36,12 +36,16 @@ public:
virtual void updateChannelVolume(int channel, pa_volume_t v); virtual void updateChannelVolume(int channel, pa_volume_t v);
Gtk::ToggleButton *lockToggleButton, *muteToggleButton; Gtk::ToggleButton *lockToggleButton, *muteToggleButton;
Gtk::Button *terminateButton;
Gtk::Label *directionLabel;
Gtk::HBox *streamControlHBox;
pa_channel_map channelMap; pa_channel_map channelMap;
pa_cvolume volume; pa_cvolume volume;
ChannelWidget *channelWidgets[PA_CHANNELS_MAX]; ChannelWidget *channelWidgets[PA_CHANNELS_MAX];
virtual void onDeviceChange() = 0;
virtual void onMuteToggleButton(); virtual void onMuteToggleButton();
sigc::connection timeoutConnection; sigc::connection timeoutConnection;
@ -51,6 +55,9 @@ public:
virtual void executeVolumeUpdate(); virtual void executeVolumeUpdate();
virtual void setBaseVolume(pa_volume_t v); virtual void setBaseVolume(pa_volume_t v);
virtual void setSteps(unsigned n); virtual void setSteps(unsigned n);
protected:
Gtk::ComboBox *deviceCombo;
}; };
#endif #endif