[pitivi] ui.prefs: add font preference option and test case
- From: Edward Hervey <edwardrv src gnome org>
- To: svn-commits-list gnome org
- Subject: [pitivi] ui.prefs: add font preference option and test case
- Date: Thu, 30 Apr 2009 12:20:20 -0400 (EDT)
commit 1b7e8a2a20aedb0c4ad552bbbefa4ca5bd0875ff
Author: Brandon Lewis <brandon lewis berkeley edu>
Date: Wed Apr 29 23:24:49 2009 -0700
ui.prefs: add font preference option and test case
---
pitivi/settings.py | 2 +-
pitivi/ui/prefs.py | 25 +++++++++++++++++++++++++
2 files changed, 26 insertions(+), 1 deletions(-)
diff --git a/pitivi/settings.py b/pitivi/settings.py
index 6734d1a..03ce3f5 100644
--- a/pitivi/settings.py
+++ b/pitivi/settings.py
@@ -328,13 +328,13 @@ class GlobalSettings(object, Signallable):
if notify:
setattr(cls, attrname, Notification(attrname))
setattr(cls, "_" + attrname, default)
- cls.defaults[attrname] = default
cls.__signals__[attrname + 'Changed'] = []
else:
setattr(cls, attrname, default)
if section and key:
cls.options[section][attrname] = type_, key, environment
cls.environment.add(environment)
+ cls.defaults[attrname] = default
@classmethod
def addConfigSection(cls, section):
diff --git a/pitivi/ui/prefs.py b/pitivi/ui/prefs.py
index bdcfde3..f33daf2 100644
--- a/pitivi/ui/prefs.py
+++ b/pitivi/ui/prefs.py
@@ -274,6 +274,25 @@ class PreferencesDialog(gtk.Window):
cls.addPreference(attrname, label, description, section,
dynamic.ColorWidget, value_type=value_type)
+ @classmethod
+ def addFontPreference(cls, attrname, label, description, section=None):
+ """
+ Add an auto-generated user preference that will show up as a
+ font selector.
+
+ @param label: user-visible name for this option
+ @type label: C{str}
+ @param desc: a user-visible description documenting this option
+ (ignored unless prefs_label is non-null)
+ @type desc: C{str}
+ @param section: user-visible category to which this option
+ belongs (ignored unless prefs_label is non-null)
+ @type section: C{str}
+ """
+ cls.addPreference(attrname, label, description, section,
+ dynamic.FontWidget)
+
+
## Implementation
def _fillContents(self):
@@ -401,6 +420,7 @@ if False:
('aChoicePreference', 42),
('aLongChoicePreference', "Mauve"),
('aTogglePreference', True),
+ ('aFontPreference', "Sans 9"),
)
for attrname, default in options:
@@ -468,3 +488,8 @@ if False:
label = "Test Toggle",
section = "Test",
description = "Test the toggle widget")
+
+ PreferencesDialog.addFontPreference('aFontPreference',
+ label = "Foo Font",
+ section = "Test",
+ description = "Test the font widget")
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]