Skip to content

Commit

Permalink
fix: improve profile combo box filter logic
Browse files Browse the repository at this point in the history
Don't show other profiles too if the selected one is experimental. Only
show the selected one.
  • Loading branch information
SeaDve committed Feb 13, 2024
1 parent f462ca5 commit ec68969
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/preferences_dialog.rs
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,14 @@ mod imp {
}
profiles_model.splice(profiles_model.n_items(), 0, profiles);

let is_using_experimental =
*IS_EXPERIMENTAL_MODE || active_profile.is_some_and(|p| p.is_experimental());
let filter = gtk::BoolFilter::new(Some(&gtk::ClosureExpression::new::<bool>(
&[] as &[&gtk::Expression],
closure!(|obj: glib::Object| {
profile_from_obj(&obj).map_or(true, |profile| {
(!profile.is_experimental() || is_using_experimental)
(*IS_EXPERIMENTAL_MODE
|| !profile.is_experimental()
|| active_profile
.is_some_and(|active_profile| active_profile == profile))
&& profile.is_available()
})
}),
Expand Down
2 changes: 1 addition & 1 deletion src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ impl Settings {
.unwrap();
}

pub fn profile(&self) -> Option<&Profile> {
pub fn profile(&self) -> Option<&'static Profile> {
let profile_id = self.0.get::<String>("profile-id");

if profile_id.is_empty() {
Expand Down

0 comments on commit ec68969

Please sign in to comment.