Mercurial > hg > Feedworm
annotate Preferences.py @ 55:0f9b3e57cff0
pull out FeedEntryItemDelegate into its own file
author | Dirk Olmes <dirk@xanthippe.ping.de> |
---|---|
date | Tue, 18 May 2010 03:17:06 +0200 |
parents | 03358c113170 |
children | db35ab7753f0 |
rev | line source |
---|---|
43
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
1 |
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
2 from Preference import Preference |
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
3 import util |
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
4 |
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
5 START_MAXIMIZED = "START_MAXIMIZED" |
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
6 |
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
7 class Preferences(object): |
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
8 def __init__(self, session): |
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
9 self.session = session |
44
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
10 self.cache = {} |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
11 |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
12 def _cachedPreference(self, key, defaultValue=None): |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
13 if self.cache.has_key(key): |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
14 return self.cache[key] |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
15 else: |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
16 pref = Preference.forKey(key, self.session) |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
17 if pref is None: |
46
03358c113170
Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
44
diff
changeset
|
18 pref = Preference(key, str(defaultValue)) |
44
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
19 self.session.add(pref) |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
20 self.cache[key] = pref |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
21 return pref |
43
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
22 |
12ed8b5fa08c
first system preference: configure app to stat maximized.
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
diff
changeset
|
23 def startMaximized(self): |
44
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
24 pref = self._cachedPreference(START_MAXIMIZED, False) |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
25 return util.str2bool(pref.value) |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
26 |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
27 def setStartMaximized(self, flag): |
be990ac6e478
saving the preference "start maximized" from GUI implemented
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
43
diff
changeset
|
28 pref = self._cachedPreference(START_MAXIMIZED) |
46
03358c113170
Better preferences handling: the GUI's responsibility is to convert the input from the event into a boolean value
Dirk Olmes <dirk@xanthippe.ping.de>
parents:
44
diff
changeset
|
29 pref.value = util.bool2str(flag) |