Mercurial > hg > Feedworm
comparison Preferences.py @ 46:03358c113170
Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Sun, 16 May 2010 07:54:24 +0200 |
parents | be990ac6e478 |
children | db35ab7753f0 |
comparison
equal
deleted
inserted
replaced
45:0604e374c1d6 | 46:03358c113170 |
---|---|
13 if self.cache.has_key(key): | 13 if self.cache.has_key(key): |
14 return self.cache[key] | 14 return self.cache[key] |
15 else: | 15 else: |
16 pref = Preference.forKey(key, self.session) | 16 pref = Preference.forKey(key, self.session) |
17 if pref is None: | 17 if pref is None: |
18 pref = Preference(key, defaultValue) | 18 pref = Preference(key, str(defaultValue)) |
19 self.session.add(pref) | 19 self.session.add(pref) |
20 self.cache[key] = pref | 20 self.cache[key] = pref |
21 return pref | 21 return pref |
22 | 22 |
23 def startMaximized(self): | 23 def startMaximized(self): |
24 pref = self._cachedPreference(START_MAXIMIZED, False) | 24 pref = self._cachedPreference(START_MAXIMIZED, False) |
25 return util.str2bool(pref.value) | 25 return util.str2bool(pref.value) |
26 | 26 |
27 def setStartMaximized(self, flag): | 27 def setStartMaximized(self, flag): |
28 """ Convert flag to boolean so that a defined value is stored in the DB """ | |
29 boolValue = False | |
30 if flag: | |
31 boolValue = True | |
32 pref = self._cachedPreference(START_MAXIMIZED) | 28 pref = self._cachedPreference(START_MAXIMIZED) |
33 pref.value = boolValue | 29 pref.value = util.bool2str(flag) |