diff options
Diffstat (limited to 'components/config/pref_util.rs')
-rw-r--r-- | components/config/pref_util.rs | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/components/config/pref_util.rs b/components/config/pref_util.rs index 8a3fde0c99b..ba4dd78f6e8 100644 --- a/components/config/pref_util.rs +++ b/components/config/pref_util.rs @@ -220,6 +220,17 @@ impl<'m, P: Clone> Preferences<'m, P> { } } + /// Has the preference been modified from its original value? + pub fn is_default(&self, key: &str) -> Result<bool, PrefError> { + if let Some(accessor) = self.accessors.get(key) { + let user = (accessor.getter)(&self.default_prefs); + let default = (accessor.getter)(&self.user_prefs.read().unwrap()); + Ok(default == user) + } else { + Err(PrefError::NoSuchPref(String::from(key))) + } + } + /// Creates an iterator over all keys and values pub fn iter<'a>(&'a self) -> impl Iterator<Item = (String, PrefValue)> + 'a { let prefs = self.user_prefs.read().unwrap(); |