mirror of
https://gitlab.freedesktop.org/pulseaudio/pavucontrol.git
synced 2025-12-28 21:00:07 +01:00
Add a checkbox to hide unavailable profiles
This commit is contained in:
parent
34e364b880
commit
c46fbee81c
5 changed files with 35 additions and 1 deletions
|
|
@ -52,6 +52,7 @@ CardWidget::CardWidget(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
|
|||
codecList->signal_changed().connect( sigc::mem_fun(*this, &CardWidget::onCodecChange));
|
||||
|
||||
hasProfileLock = false;
|
||||
hideUnavailableProfiles = false;
|
||||
|
||||
profileLockToggleButton->signal_clicked().connect(sigc::mem_fun(*this, &CardWidget::onProfileLockToggleButton));
|
||||
profileLockToggleButton->set_sensitive(true);
|
||||
|
|
@ -74,6 +75,9 @@ void CardWidget::prepareMenu() {
|
|||
active_idx = -1;
|
||||
/* Fill the ComboBox's Tree Model */
|
||||
for (uint32_t i = 0; i < profiles.size(); ++i) {
|
||||
if (hideUnavailableProfiles && !availableProfiles[profiles[i].first])
|
||||
continue;
|
||||
|
||||
Gtk::TreeModel::Row row = *(profileListStore->append());
|
||||
row[profileModel.name] = profiles[i].first;
|
||||
row[profileModel.desc] = profiles[i].second;
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ public:
|
|||
|
||||
// each entry in profiles is a pair of profile name and profile description
|
||||
std::vector<std::pair<Glib::ustring, Glib::ustring>> profiles;
|
||||
std::map<Glib::ustring, bool> availableProfiles;
|
||||
std::map<Glib::ustring, PortInfo> ports;
|
||||
Glib::ustring activeProfile;
|
||||
bool hasSinks;
|
||||
|
|
@ -60,6 +61,7 @@ public:
|
|||
Glib::ustring activeCodec;
|
||||
|
||||
bool hasProfileLock;
|
||||
bool hideUnavailableProfiles;
|
||||
|
||||
void prepareMenu();
|
||||
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
|
|||
sourceTypeComboBox = x->get_widget<Gtk::ComboBox>("sourceTypeComboBox");
|
||||
notebook = x->get_widget<Gtk::Notebook>("notebook");
|
||||
showVolumeMetersCheckButton = x->get_widget<Gtk::CheckButton>("showVolumeMetersCheckButton");
|
||||
hideUnavailableCardProfilesCheckButton = x->get_widget<Gtk::CheckButton>("hideUnavailableCardProfilesCheckButton");
|
||||
|
||||
sinkInputTypeComboBox->set_active((int) showSinkInputType);
|
||||
sourceOutputTypeComboBox->set_active((int) showSourceOutputType);
|
||||
|
|
@ -108,6 +109,7 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
|
|||
sinkTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSinkTypeComboBoxChanged));
|
||||
sourceTypeComboBox->signal_changed().connect(sigc::mem_fun(*this, &MainWindow::onSourceTypeComboBoxChanged));
|
||||
showVolumeMetersCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::onShowVolumeMetersCheckButtonToggled));
|
||||
hideUnavailableCardProfilesCheckButton->signal_toggled().connect(sigc::mem_fun(*this, &MainWindow::onHideUnavailableCardProfilesCheckButtonToggled));
|
||||
|
||||
auto event_controller_key = Gtk::EventControllerKey::create();
|
||||
event_controller_key->signal_key_pressed().connect(sigc::mem_fun(*this, &MainWindow::on_key_press_event), false);
|
||||
|
|
@ -130,6 +132,9 @@ MainWindow::MainWindow(BaseObjectType* cobject, const Glib::RefPtr<Gtk::Builder>
|
|||
if (g_key_file_has_key(config, "window", "showVolumeMeters", NULL)) {
|
||||
showVolumeMetersCheckButton->set_active(g_key_file_get_boolean(config, "window", "showVolumeMeters", NULL));
|
||||
}
|
||||
if (g_key_file_has_key(config, "window", "hideUnavailableCardProfiles", NULL)) {
|
||||
hideUnavailableCardProfilesCheckButton->set_active(g_key_file_get_boolean(config, "window", "hideUnavailableCardProfiles", NULL));
|
||||
}
|
||||
|
||||
int default_width, default_height;
|
||||
get_default_size(default_width, default_height);
|
||||
|
|
@ -237,6 +242,7 @@ MainWindow::~MainWindow() {
|
|||
g_key_file_set_integer(config, "window", "sinkType", sinkTypeComboBox->get_active_row_number());
|
||||
g_key_file_set_integer(config, "window", "sourceType", sourceTypeComboBox->get_active_row_number());
|
||||
g_key_file_set_integer(config, "window", "showVolumeMeters", showVolumeMetersCheckButton->get_active());
|
||||
g_key_file_set_integer(config, "window", "hideUnavailableCardProfiles", hideUnavailableCardProfilesCheckButton->get_active());
|
||||
|
||||
gsize filelen;
|
||||
GError *err = NULL;
|
||||
|
|
@ -360,6 +366,8 @@ void MainWindow::updateCard(const pa_card_info &info) {
|
|||
cardsVBox->append(*w);
|
||||
w->unreference();
|
||||
w->index = info.index;
|
||||
w->hideUnavailableProfiles = hideUnavailableCardProfilesCheckButton->get_active();
|
||||
w->prepareMenu();
|
||||
is_new = true;
|
||||
}
|
||||
|
||||
|
|
@ -426,6 +434,7 @@ void MainWindow::updateCard(const pa_card_info &info) {
|
|||
desc += _(" (unavailable)");
|
||||
|
||||
w->profiles.push_back(std::pair<Glib::ustring, Glib::ustring>(profileIt->name, desc));
|
||||
w->availableProfiles[profileIt->name] = hasOther && profileIt->available;
|
||||
}
|
||||
|
||||
w->activeProfile = info.active_profile ? info.active_profile->name : "";
|
||||
|
|
@ -1422,3 +1431,14 @@ void MainWindow::onShowVolumeMetersCheckButtonToggled() {
|
|||
sw->setVolumeMeterVisible(state);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::onHideUnavailableCardProfilesCheckButtonToggled() {
|
||||
bool state = hideUnavailableCardProfilesCheckButton->get_active();
|
||||
|
||||
for (std::map<uint32_t, CardWidget*>::iterator it = cardWidgets.begin() ; it != cardWidgets.end(); it++) {
|
||||
CardWidget *cw = it->second;
|
||||
cw->hideUnavailableProfiles = state;
|
||||
cw->prepareMenu();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public:
|
|||
Gtk::Box *streamsVBox, *recsVBox, *sinksVBox, *sourcesVBox, *cardsVBox;
|
||||
Gtk::Label *noStreamsLabel, *noRecsLabel, *noSinksLabel, *noSourcesLabel, *noCardsLabel, *connectingLabel;
|
||||
Gtk::ComboBox *sinkInputTypeComboBox, *sourceOutputTypeComboBox, *sinkTypeComboBox, *sourceTypeComboBox;
|
||||
Gtk::CheckButton *showVolumeMetersCheckButton;
|
||||
Gtk::CheckButton *showVolumeMetersCheckButton, *hideUnavailableCardProfilesCheckButton;
|
||||
|
||||
std::map<uint32_t, CardWidget*> cardWidgets;
|
||||
std::map<uint32_t, SinkWidget*> sinkWidgets;
|
||||
|
|
@ -102,6 +102,7 @@ public:
|
|||
virtual void onSinkTypeComboBoxChanged();
|
||||
virtual void onSourceTypeComboBoxChanged();
|
||||
virtual void onShowVolumeMetersCheckButtonToggled();
|
||||
virtual void onHideUnavailableCardProfilesCheckButtonToggled();
|
||||
|
||||
void setConnectionState(gboolean connected);
|
||||
void updateDeviceVisibility();
|
||||
|
|
|
|||
|
|
@ -433,6 +433,13 @@
|
|||
<property name="active">1</property>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkCheckButton" id="hideUnavailableCardProfilesCheckButton">
|
||||
<property name="label" translatable="yes">Hide unavailable card profiles</property>
|
||||
<property name="focusable">1</property>
|
||||
<property name="active">0</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue