diff --git a/src/devicewidget.cc b/src/devicewidget.cc index b7405bb..e1b1869 100644 --- a/src/devicewidget.cc +++ b/src/devicewidget.cc @@ -33,7 +33,8 @@ /*** DeviceWidget ***/ DeviceWidget::DeviceWidget(BaseObjectType* cobject, const Glib::RefPtr& x) : MinimalStreamWidget(cobject), - offsetButtonEnabled(false) { + offsetButtonEnabled(false), + mDigital(false) { /* MinimalStreamWidget member variables. */ x->get_widget("deviceChannelsVBox", channelsVBox); @@ -211,19 +212,17 @@ void DeviceWidget::prepareMenu() { if (ports.size() > 0) { portSelect->show(); - if (pa_context_get_server_protocol_version(get_context()) >= 27) { + if (pa_context_get_server_protocol_version(get_context()) >= 27) offsetSelect->show(); - advancedOptions->set_sensitive(true); - } else { - /* advancedOptions has sensitive=false by default */ + else offsetSelect->hide(); - } } else { portSelect->hide(); - advancedOptions->set_sensitive(false); offsetSelect->hide(); } + + updateAdvancedOptionsVisibility(); } bool DeviceWidget::onContextTriggerEvent(GdkEventButton* event) { @@ -276,3 +275,22 @@ void DeviceWidget::renamePopup() { } delete dialog; } + +void DeviceWidget::updateAdvancedOptionsVisibility() { + bool visible = false; + + if (mDigital) { + /* We need to show the format configuration options. */ + visible = true; + } + + if (ports.size() > 0) { + /* We need to show the latency offset spin button. */ + visible = true; + } + + if (visible) + advancedOptions->show(); + else + advancedOptions->hide(); +} diff --git a/src/devicewidget.h b/src/devicewidget.h index 30a6672..862834d 100644 --- a/src/devicewidget.h +++ b/src/devicewidget.h @@ -78,6 +78,11 @@ public: protected: MainWindow *mpMainWindow; + /* Shows or hides the advanced options expander depending on whether it's + * useful or not. This is called always after ports or mDigital have been + * updated. */ + void updateAdvancedOptionsVisibility(); + virtual void onPortChange() = 0; Gtk::Menu contextMenu; @@ -103,6 +108,10 @@ protected: Glib::RefPtr treeModel; Glib::RefPtr offsetAdjustment; + /* Set to true for "digital" sinks (in practice this means those sinks that + * support format configuration). */ + bool mDigital; + private: Glib::ustring mDeviceType; diff --git a/src/pavucontrol.glade b/src/pavucontrol.glade index 96c35be..a66e193 100644 --- a/src/pavucontrol.glade +++ b/src/pavucontrol.glade @@ -419,8 +419,6 @@ - True - False True diff --git a/src/sinkwidget.cc b/src/sinkwidget.cc index f682cf2..b9002dd 100644 --- a/src/sinkwidget.cc +++ b/src/sinkwidget.cc @@ -168,14 +168,15 @@ void SinkWidget::onPortChange() { } void SinkWidget::setDigital(bool digital) { + mDigital = digital; + #if HAVE_EXT_DEVICE_RESTORE_API - if (digital) { + if (digital) encodingSelect->show(); - advancedOptions->set_sensitive(true); - } else { - /* advancedOptions has sensitive=false by default */ + else encodingSelect->hide(); - } + + updateAdvancedOptionsVisibility(); #endif }