summaryrefslogtreecommitdiff
path: root/portato
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2008-11-24 21:11:08 +0100
committerRené 'Necoro' Neumann <necoro@necoro.net>2008-11-24 21:11:08 +0100
commitc5b56f88132d45481137645b03ac0d3321fb9ce4 (patch)
tree1bacb018c4cfae2e95e536e2eed8ec6436ee57ce /portato
parent99fc5dcfc3e4b07dab56899f7d86b0d88e147e93 (diff)
downloadportato-c5b56f88132d45481137645b03ac0d3321fb9ce4.tar.gz
portato-c5b56f88132d45481137645b03ac0d3321fb9ce4.tar.bz2
portato-c5b56f88132d45481137645b03ac0d3321fb9ce4.zip
Allow session stuff being stored in the config
Diffstat (limited to 'portato')
-rw-r--r--portato/gui/utils.py12
-rw-r--r--portato/gui/windows/main.py16
2 files changed, 28 insertions, 0 deletions
diff --git a/portato/gui/utils.py b/portato/gui/utils.py
index 3e46361..d8af545 100644
--- a/portato/gui/utils.py
+++ b/portato/gui/utils.py
@@ -76,6 +76,9 @@ class Config (ConfigParser):
# local configs
self.local = {}
+ # session configs
+ self.session = {}
+
def modify_flags_config (self):
"""Sets the internal config of the L{flags}-module.
@see: L{flags.set_config()}"""
@@ -140,6 +143,15 @@ class Config (ConfigParser):
return self.local[cpv][name]
+ def set_session (self, name, cat, val):
+ self.session[(cat, name)] = val
+
+ def get_session (self, name, cat):
+ v = self.session.get((cat, name), None)
+
+ if v == "": v = None
+ return v
+
def write(self):
"""Writes to the config file and modify any external configs."""
ConfigParser.write(self)
diff --git a/portato/gui/windows/main.py b/portato/gui/windows/main.py
index d2949e7..ee723b5 100644
--- a/portato/gui/windows/main.py
+++ b/portato/gui/windows/main.py
@@ -1171,6 +1171,22 @@ class MainWindow (Window):
for p in queue.get_plugins():
self.session.add_handler(([(p.name.replace(" ","_"), "plugins")], load_plugin(p), save_plugin(p)))
+ # the other things
+ def load_cfg ((name, cat)):
+ def load (v):
+ self.cfg.set_session(name, cat, v)
+
+ def save ():
+ v = self.cfg.get_session(name, cat)
+ if v is None:
+ return ""
+ else:
+ return v
+
+ self.session.add_handler(([(name, cat)], load, save))
+
+ map(load_cfg, [("prefheight", "window"), ("prefwidth", "window")])
+
# now we have the handlers -> load
self.session.load(defaults_only)