devicewidget, streamwidget: Show only one volume slider when channels are locked

This commit is contained in:
Ivan Ivanov 2014-11-09 00:55:51 +02:00 committed by Peter Meerwald
parent ed140c230c
commit dd0ccda382
5 changed files with 33 additions and 0 deletions

View File

@ -46,6 +46,7 @@ DeviceWidget::DeviceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Buil
this->signal_button_press_event().connect(sigc::mem_fun(*this, &DeviceWidget::onContextTriggerEvent));
muteToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &DeviceWidget::onMuteToggleButton));
lockToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &DeviceWidget::onLockToggleButton));
defaultToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &DeviceWidget::onDefaultToggleButton));
rename.set_label(_("Rename Device..."));
@ -94,6 +95,7 @@ void DeviceWidget::setChannelMap(const pa_channel_map &m, bool can_decibel) {
channelWidgets[m.channels-1]->last = true;
lockToggleButton->set_sensitive(m.channels > 1);
hideLockedChannels(lockToggleButton->get_active());
}
void DeviceWidget::setVolume(const pa_cvolume &v, bool force) {
@ -123,6 +125,13 @@ void DeviceWidget::updateChannelVolume(int channel, pa_volume_t v) {
timeoutConnection = Glib::signal_timeout().connect(sigc::mem_fun(*this, &DeviceWidget::timeoutEvent), 100);
}
void DeviceWidget::hideLockedChannels(bool hide) {
for (int i = 0; i < channelMap.channels - 1; i++)
channelWidgets[i]->set_visible(!hide);
channelWidgets[channelMap.channels - 1]->channelLabel->set_visible(!hide);
}
void DeviceWidget::onMuteToggleButton() {
lockToggleButton->set_sensitive(!muteToggleButton->get_active());
@ -131,6 +140,10 @@ void DeviceWidget::onMuteToggleButton() {
channelWidgets[i]->set_sensitive(!muteToggleButton->get_active());
}
void DeviceWidget::onLockToggleButton() {
hideLockedChannels(lockToggleButton->get_active());
}
void DeviceWidget::onDefaultToggleButton() {
}

View File

@ -37,6 +37,8 @@ public:
void setVolume(const pa_cvolume &volume, bool force = false);
virtual void updateChannelVolume(int channel, pa_volume_t v);
void hideLockedChannels(bool hide = true);
Glib::ustring name;
Glib::ustring description;
uint32_t index, card_index;
@ -52,6 +54,7 @@ public:
ChannelWidget *channelWidgets[PA_CHANNELS_MAX];
virtual void onMuteToggleButton();
virtual void onLockToggleButton();
virtual void onDefaultToggleButton();
virtual void setDefault(bool isDefault);
virtual bool onContextTriggerEvent(GdkEventButton*);

View File

@ -36,6 +36,7 @@ public:
bool updating;
virtual void onMuteToggleButton() = 0;
virtual void onLockToggleButton() = 0;
virtual void updateChannelVolume(int channel, pa_volume_t v) = 0;
bool volumeMeterEnabled;

View File

@ -41,6 +41,7 @@ StreamWidget::StreamWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Buil
this->signal_button_press_event().connect(sigc::mem_fun(*this, &StreamWidget::onContextTriggerEvent));
muteToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &StreamWidget::onMuteToggleButton));
lockToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &StreamWidget::onLockToggleButton));
deviceButton->signal_clicked().connect(sigc::mem_fun(*this, &StreamWidget::onDeviceChangePopup));
terminate.set_label(_("Terminate"));
@ -83,6 +84,7 @@ void StreamWidget::setChannelMap(const pa_channel_map &m, bool can_decibel) {
channelWidgets[m.channels-1]->setBaseVolume(PA_VOLUME_NORM);
lockToggleButton->set_sensitive(m.channels > 1);
hideLockedChannels(lockToggleButton->get_active());
}
void StreamWidget::setVolume(const pa_cvolume &v, bool force) {
@ -113,6 +115,13 @@ void StreamWidget::updateChannelVolume(int channel, pa_volume_t v) {
timeoutConnection = Glib::signal_timeout().connect(sigc::mem_fun(*this, &StreamWidget::timeoutEvent), 100);
}
void StreamWidget::hideLockedChannels(bool hide) {
for (int i = 0; i < channelMap.channels - 1; i++)
channelWidgets[i]->set_visible(!hide);
channelWidgets[channelMap.channels - 1]->channelLabel->set_visible(!hide);
}
void StreamWidget::onMuteToggleButton() {
lockToggleButton->set_sensitive(!muteToggleButton->get_active());
@ -121,6 +130,10 @@ void StreamWidget::onMuteToggleButton() {
channelWidgets[i]->set_sensitive(!muteToggleButton->get_active());
}
void StreamWidget::onLockToggleButton() {
hideLockedChannels(lockToggleButton->get_active());
}
bool StreamWidget::timeoutEvent() {
executeVolumeUpdate();
return false;

View File

@ -37,6 +37,8 @@ public:
void setVolume(const pa_cvolume &volume, bool force = false);
virtual void updateChannelVolume(int channel, pa_volume_t v);
void hideLockedChannels(bool hide = true);
Gtk::ToggleButton *lockToggleButton, *muteToggleButton;
Gtk::Label *directionLabel;
Gtk::Button *deviceButton;
@ -48,6 +50,7 @@ public:
ChannelWidget *channelWidgets[PA_CHANNELS_MAX];
virtual void onMuteToggleButton();
virtual void onLockToggleButton();
virtual void onDeviceChangePopup();
virtual bool onContextTriggerEvent(GdkEventButton*);