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();
Gtk::Label *nameLabel;
Gtk::ToggleButton *streamToggleButton;
Gtk::Menu menu;
Gtk::Image *iconImage;
Glib::ustring name;

View File

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

View File

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

View File

@ -19,6 +19,7 @@
***/
#include "devicewidget.h"
#include "channelwidget.h"
/*** DeviceWidget ***/
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->channel = i;
cw->can_decibel = can_decibel;
cw->streamWidget = this;
cw->minimalStreamWidget = this;
char text[64];
snprintf(text, sizeof(text), "<b>%s</b>", pa_channel_position_to_pretty_string(m.map[i]));
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));
sinkTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSinkTypeComboBoxChanged));
sourceTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSourceTypeComboBoxChanged));
sinkTree = Gtk::ListStore::create(deviceColumns);
sourceTree = Gtk::ListStore::create(deviceColumns);
}
MainWindow* MainWindow::create() {
@ -176,6 +179,29 @@ void MainWindow::updateCard(const pa_card_info &info) {
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) {
SinkWidget *w;
bool is_new = false;
@ -218,6 +244,7 @@ void MainWindow::updateSink(const pa_sink_info &info) {
w->updating = false;
rebuildSinkCombo();
if (is_new)
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) {
SourceWidget *w;
bool is_new = false;
@ -366,6 +416,7 @@ void MainWindow::updateSource(const pa_source_info &info) {
w->updating = false;
rebuildSourceCombo();
if (is_new)
updateDeviceVisibility();
}
@ -784,6 +835,7 @@ void MainWindow::removeSink(uint32_t index) {
delete sinkWidgets[index];
sinkWidgets.erase(index);
rebuildSinkCombo();
updateDeviceVisibility();
}
@ -793,6 +845,7 @@ void MainWindow::removeSource(uint32_t index) {
delete sourceWidgets[index];
sourceWidgets.erase(index);
rebuildSourceCombo();
updateDeviceVisibility();
}

View File

@ -91,8 +91,27 @@ public:
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:
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("nameLabel", nameLabel);
x->get_widget("boldNameLabel", boldNameLabel);
x->get_widget("streamToggle", streamToggleButton);
x->get_widget("iconImage", iconImage);
peakProgressBar.set_size_request(-1, 10);
channelsVBox->pack_end(peakProgressBar, false, false);
streamToggleButton->set_active(false);
streamToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &MinimalStreamWidget::onStreamToggleButton));
menu.signal_deactivate().connect(sigc::mem_fun(*this, &MinimalStreamWidget::onMenuDeactivated));
//menu.signal_deactivate().connect(sigc::mem_fun(*this, &MinimalStreamWidget::onMenuDeactivated));
peakProgressBar.hide();
}
@ -52,30 +49,34 @@ void MinimalStreamWidget::prepareMenu(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) {
/*
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 */
// 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 */
// 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) {

View File

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

View File

@ -613,13 +613,13 @@ Monitors</property>
</packing>
</child>
<child>
<widget class="GtkHBox" id="hbox2">
<widget class="GtkHBox" id="streamControlHBox">
<property name="visible">True</property>
<child>
<widget class="GtkLabel" id="directionLabel">
<property name="visible">True</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>
</widget>
<packing>

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -26,12 +26,18 @@
#include "channelwidget.h"
/*** StreamWidget ***/
StreamWidget::StreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gnome::Glade::Xml>& x) :
MinimalStreamWidget(cobject, x) {
x->get_widget("lockToggleButton", lockToggleButton);
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));
@ -47,7 +53,7 @@ void StreamWidget::setChannelMap(const pa_channel_map &m, bool can_decibel) {
cw->beepDevice = beepDevice;
cw->channel = i;
cw->can_decibel = can_decibel;
cw->streamWidget = this;
cw->minimalStreamWidget = this;
char text[64];
snprintf(text, sizeof(text), "<b>%s</b>", pa_channel_position_to_pretty_string(m.map[i]));
cw->channelLabel->set_markup(text);

View File

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