[kupfer] settings: Cleanup use of bool flags
- From: Ulrik Sverdrup <usverdrup src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [kupfer] settings: Cleanup use of bool flags
- Date: Mon, 29 Mar 2010 05:04:00 +0000 (UTC)
commit 65bb90c0d7d32944ce5e6eea4235123219544438
Author: Ulrik Sverdrup <ulrik sverdrup gmail com>
Date: Thu Apr 7 22:13:13 2005 +0200
settings: Cleanup use of bool flags
kupfer/core/settings.py | 9 +++++----
1 files changed, 5 insertions(+), 4 deletions(-)
---
diff --git a/kupfer/core/settings.py b/kupfer/core/settings.py
index e443de5..371a93f 100644
--- a/kupfer/core/settings.py
+++ b/kupfer/core/settings.py
@@ -11,7 +11,7 @@ import keyring
from kupfer import config, pretty, scheduler
def strbool(value, default=False):
- """Coarce bool from string value or bool"""
+ """Coerce bool from string value or bool"""
if value in (True, False):
return value
value = str(value).lower()
@@ -33,7 +33,7 @@ class SettingsController (gobject.GObject, pretty.OutputMixin):
"Kupfer": {
"keybinding" : "" ,
"magickeybinding": "",
- "showstatusicon" : "true"
+ "showstatusicon" : True,
},
"Directories" : { "direct" : default_directories, "catalog" : (), },
"DeepDirectories" : { "direct" : (), "catalog" : (), "depth" : 1, },
@@ -103,6 +103,8 @@ class SettingsController (gobject.GObject, pretty.OutputMixin):
retval = ()
else:
retval = [p.strip() for p in value.split(self.sep) if p]
+ elif isinstance(defval, bool):
+ retval = strbool(value)
elif isinstance(defval, int):
retval = type(defval)(value)
else:
@@ -228,8 +230,7 @@ class SettingsController (gobject.GObject, pretty.OutputMixin):
def get_show_status_icon(self):
"""Convenience: Show icon in notification area as bool"""
- return (self.get_config("Kupfer", "showstatusicon").lower()
- in ("true", "yes"))
+ return strbool(self.get_config("Kupfer", "showstatusicon"))
def set_show_status_icon(self, enabled):
"""Set config value and return success"""
return self._set_config("Kupfer", "showstatusicon", enabled)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]