[pitivi] Allow reading values from settings config file at runtime
- From: Jean-FranÃois Fortin Tam <jfft src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pitivi] Allow reading values from settings config file at runtime
- Date: Thu, 8 Nov 2012 21:57:44 +0000 (UTC)
commit 451dd755b98f2599b079febe0db51d887c4d3f6c
Author: Luis de Bethencourt <luis debethencourt collabora com>
Date: Wed Nov 7 17:47:16 2012 -0500
Allow reading values from settings config file at runtime
pitivi/settings.py | 14 ++++++++++++++
pitivi/tabsmanager.py | 17 ++++++++++-------
2 files changed, 24 insertions(+), 7 deletions(-)
---
diff --git a/pitivi/settings.py b/pitivi/settings.py
index 27c07d1..00d0ea3 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -186,6 +186,20 @@ class GlobalSettings(Signallable):
value = self._config.get(section, key)
setattr(self, attrname, value)
+ @classmethod
+ def readSettingSectionFromFile(self, cls, section, attrname, typ, key):
+ if cls._config.has_section(section):
+ if cls._config.has_option(section, key):
+ if typ == int or typ == long:
+ value = cls._config.getint(section, key)
+ elif typ == float:
+ value = cls._config.getfloat(section, key)
+ elif typ == bool:
+ value = cls._config.getboolean(section, key)
+ else:
+ value = cls._config.get(section, key)
+ setattr(cls, attrname, value)
+
def _readSettingsFromEnvironmentVariables(self):
for (section, attrname, typ, key, env, value) in self.iterAllOptions():
var = get_env_by_type(typ, env)
diff --git a/pitivi/tabsmanager.py b/pitivi/tabsmanager.py
index f330928..83f1772 100644
--- a/pitivi/tabsmanager.py
+++ b/pitivi/tabsmanager.py
@@ -42,13 +42,10 @@ class BaseTabs(Gtk.Notebook):
child.show()
label.show()
- try:
- docked = getattr(self.settings, child_name + "Docked")
- if not docked:
- self.createWindow(child)
- except AttributeError:
- # Create the default config ONLY if keys don't already exist
- self._createDefaultConfig(child_name)
+ self._createDefaultConfig(child_name)
+ docked = getattr(self.settings, child_name + "Docked")
+ if not docked:
+ self.createWindow(child)
def _set_child_properties(self, child, label):
self.child_set_property(child, "detachable", True)
@@ -145,3 +142,9 @@ class BaseTabs(Gtk.Notebook):
section="tabs - " + child_name,
key="y-pos",
default=0)
+
+ GlobalSettings.readSettingSectionFromFile(self.settings, "tabs - " + child_name, child_name + "Docked", bool, "docked")
+ GlobalSettings.readSettingSectionFromFile(self.settings, "tabs - " + child_name, child_name + "Width", int, "width")
+ GlobalSettings.readSettingSectionFromFile(self.settings, "tabs - " + child_name, child_name + "Height", int, "height")
+ GlobalSettings.readSettingSectionFromFile(self.settings, "tabs - " + child_name, child_name + "X", int, "x-pos")
+ GlobalSettings.readSettingSectionFromFile(self.settings, "tabs - " + child_name, child_name + "Y", int, "y-pos")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]