Skip to content
This repository has been archived by the owner on Nov 1, 2024. It is now read-only.

Commit

Permalink
🐛 Fix crash on the settings
Browse files Browse the repository at this point in the history
Closes #108.
  • Loading branch information
Schmiddiii committed Nov 20, 2022
1 parent a294dab commit 26237d0
Showing 1 changed file with 1 addition and 20 deletions.
21 changes: 1 addition & 20 deletions src/gui/preferences_window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ pub mod imp {
use gtk::CompositeTemplate;
use libadwaita::subclass::prelude::AdwWindowImpl;
use libadwaita::subclass::prelude::PreferencesWindowImpl;
use libadwaita::traits::ActionRowExt;
use libadwaita::traits::PreferencesGroupExt;
use libadwaita::EntryRow;

Expand All @@ -50,30 +49,12 @@ pub mod imp {
self.group_programs.set_description(Some(&gettextrs::gettext("Note that on Flatpak, there are some more steps required when using a player external to the Flatpak. For more information, please consult the wiki.")));
}

fn init_string_setting(
&self,
env: &'static str,
settings: &'static str,
entry: EntryRow,
) {
fn init_string_setting(&self, env: &'static str, settings: &'static str, entry: EntryRow) {
let val_env = std::env::var_os(env);
let val_settings = self.settings.string(settings);
entry.set_text(&val_settings);
if val_env.is_some() && &val_env.unwrap() != val_settings.as_str() {
entry.set_editable(false);
// TODO: Not really nice to access the parents.
entry
.parent()
.expect("Settings entry to have parent")
.parent()
.expect("Settings entry to have parent")
.parent()
.expect("Settings entry to have parent")
.dynamic_cast::<libadwaita::ActionRow>()
.expect("Settings entry to have parent of thpe ActionRow")
.set_subtitle(&gettextrs::gettext(
"Overwritten by environmental variable.",
));
}
self.settings
.bind(settings, &entry, "text")
Expand Down

0 comments on commit 26237d0

Please sign in to comment.