view Preferences.py @ 47:a8442c3487b5

add an option to Feed that allows loading an entry's link right away instead of displaying a feed's summary
author Dirk Olmes <dirk@xanthippe.ping.de>
date Sun, 16 May 2010 08:13:07 +0200
parents 03358c113170
children db35ab7753f0
line wrap: on
line source


from Preference import Preference
import util

START_MAXIMIZED = "START_MAXIMIZED"

class Preferences(object):
    def __init__(self, session):
        self.session = session
        self.cache = {}
        
    def _cachedPreference(self, key, defaultValue=None):
        if self.cache.has_key(key):
            return self.cache[key]
        else:
            pref = Preference.forKey(key, self.session)
            if pref is None:
                pref = Preference(key, str(defaultValue))
                self.session.add(pref)
            self.cache[key] = pref
            return pref
        
    def startMaximized(self):
        pref = self._cachedPreference(START_MAXIMIZED, False)
        return util.str2bool(pref.value)

    def setStartMaximized(self, flag):
        pref = self._cachedPreference(START_MAXIMIZED)
        pref.value = util.bool2str(flag)