devicewidget: fix the enabling logic of the advanced options expander
The old logic disabled the expander always when a sink didn't have any ports. That's bad if the sink has no ports but supports configuring formats. That hasn't caused problems so far, but I have a patch for module-null-sink that will enable format configuration support, and the null sink has no ports, so it's affected by this issue. This patch also changes things so that the expander is completely hidden when it's disabled instead just setting it non-sensitive. I think that's better (at least it saves some space).
This commit is contained in:
parent
0dd27ba347
commit
2a1072cc2b
|
@ -33,7 +33,8 @@
|
||||||
/*** DeviceWidget ***/
|
/*** DeviceWidget ***/
|
||||||
DeviceWidget::DeviceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& x) :
|
DeviceWidget::DeviceWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>& x) :
|
||||||
MinimalStreamWidget(cobject),
|
MinimalStreamWidget(cobject),
|
||||||
offsetButtonEnabled(false) {
|
offsetButtonEnabled(false),
|
||||||
|
mDigital(false) {
|
||||||
|
|
||||||
/* MinimalStreamWidget member variables. */
|
/* MinimalStreamWidget member variables. */
|
||||||
x->get_widget("deviceChannelsVBox", channelsVBox);
|
x->get_widget("deviceChannelsVBox", channelsVBox);
|
||||||
|
@ -211,19 +212,17 @@ void DeviceWidget::prepareMenu() {
|
||||||
if (ports.size() > 0) {
|
if (ports.size() > 0) {
|
||||||
portSelect->show();
|
portSelect->show();
|
||||||
|
|
||||||
if (pa_context_get_server_protocol_version(get_context()) >= 27) {
|
if (pa_context_get_server_protocol_version(get_context()) >= 27)
|
||||||
offsetSelect->show();
|
offsetSelect->show();
|
||||||
advancedOptions->set_sensitive(true);
|
else
|
||||||
} else {
|
|
||||||
/* advancedOptions has sensitive=false by default */
|
|
||||||
offsetSelect->hide();
|
offsetSelect->hide();
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
portSelect->hide();
|
portSelect->hide();
|
||||||
advancedOptions->set_sensitive(false);
|
|
||||||
offsetSelect->hide();
|
offsetSelect->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
updateAdvancedOptionsVisibility();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceWidget::onContextTriggerEvent(GdkEventButton* event) {
|
bool DeviceWidget::onContextTriggerEvent(GdkEventButton* event) {
|
||||||
|
@ -276,3 +275,22 @@ void DeviceWidget::renamePopup() {
|
||||||
}
|
}
|
||||||
delete dialog;
|
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();
|
||||||
|
}
|
||||||
|
|
|
@ -78,6 +78,11 @@ public:
|
||||||
protected:
|
protected:
|
||||||
MainWindow *mpMainWindow;
|
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;
|
virtual void onPortChange() = 0;
|
||||||
|
|
||||||
Gtk::Menu contextMenu;
|
Gtk::Menu contextMenu;
|
||||||
|
@ -103,6 +108,10 @@ protected:
|
||||||
Glib::RefPtr<Gtk::ListStore> treeModel;
|
Glib::RefPtr<Gtk::ListStore> treeModel;
|
||||||
Glib::RefPtr<Gtk::Adjustment> offsetAdjustment;
|
Glib::RefPtr<Gtk::Adjustment> offsetAdjustment;
|
||||||
|
|
||||||
|
/* Set to true for "digital" sinks (in practice this means those sinks that
|
||||||
|
* support format configuration). */
|
||||||
|
bool mDigital;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Glib::ustring mDeviceType;
|
Glib::ustring mDeviceType;
|
||||||
|
|
||||||
|
|
|
@ -419,8 +419,6 @@
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkExpander" id="advancedOptions">
|
<object class="GtkExpander" id="advancedOptions">
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="sensitive">False</property>
|
|
||||||
<property name="can_focus">True</property>
|
<property name="can_focus">True</property>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkVBox" id="vbox1">
|
<object class="GtkVBox" id="vbox1">
|
||||||
|
|
|
@ -168,14 +168,15 @@ void SinkWidget::onPortChange() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void SinkWidget::setDigital(bool digital) {
|
void SinkWidget::setDigital(bool digital) {
|
||||||
|
mDigital = digital;
|
||||||
|
|
||||||
#if HAVE_EXT_DEVICE_RESTORE_API
|
#if HAVE_EXT_DEVICE_RESTORE_API
|
||||||
if (digital) {
|
if (digital)
|
||||||
encodingSelect->show();
|
encodingSelect->show();
|
||||||
advancedOptions->set_sensitive(true);
|
else
|
||||||
} else {
|
|
||||||
/* advancedOptions has sensitive=false by default */
|
|
||||||
encodingSelect->hide();
|
encodingSelect->hide();
|
||||||
}
|
|
||||||
|
updateAdvancedOptionsVisibility();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue