diff options
author | Gonzalo Odiard <godiard@gmail.com> | 2012-04-16 19:00:09 (GMT) |
---|---|---|
committer | Gonzalo Odiard <godiard@gmail.com> | 2012-04-17 18:11:36 (GMT) |
commit | 7ed15ed98ee5f2a53a5dac8a75381bac6196c19e (patch) | |
tree | ef01c2e006c97cd6ae4daac6004239aa1a6e7a6d /model.py | |
parent | 862171dbe24dbf6e877a672b22c14ac493bb096a (diff) |
Add combos to enable the user to change the font used in the cards. v2
This work is based in the contributions of
Flavio Danesse <fdanesse@activitycentral.com>
and Ariel Calzada <ariel.calzada@gmail.com>
The fonts are saved in the game file.
v2: Solve error in add-pair, and initialization of card font in the CardEditor
Signed-of-by: Gonzalo Odiard <gonzalo@laptop.org>
Diffstat (limited to 'model.py')
-rw-r--r-- | model.py | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -28,6 +28,8 @@ from sugar.activity.activity import get_bundle_path, get_activity_root _logger = logging.getLogger('model') +DEFAULT_FONT = 'Sans' + class Pair(gobject.GObject): __gproperties__ = { @@ -118,6 +120,8 @@ class Model(object): self.data['align'] = '1' self.data['divided'] = '0' self.data['equal_pairs'] = '0' + self.data['font_name1'] = DEFAULT_FONT + self.data['font_name2'] = DEFAULT_FONT try: self.dtd = libxml2.parseDTD(None, join(get_bundle_path(), @@ -218,6 +222,10 @@ class Model(object): self.data['align'] = attribute.content elif(attribute.name == 'equal_pairs'): self.data['equal_pairs'] = attribute.content + elif(attribute.name == 'font_name1'): + self.data['font_name1'] = attribute.content + elif(attribute.name == 'font_name2'): + self.data['font_name2'] = attribute.content xpa.xpathFreeContext() else: _logger.error('Read: Error in validation of the file') @@ -246,7 +254,10 @@ class Model(object): if(self.data.get('equal_pairs', None) != None): root.setProp('equal_pairs', self.data['equal_pairs']) - + if(self.data.get('font_name1', None) != None): + root.setProp('font_name1', self.data['font_name1']) + if(self.data.get('font_name2', None) != None): + root.setProp('font_name2', self.data['font_name2']) if(self.data.get('scoresnd', None) != None): root.setProp("scoresnd", self.data['scoresnd']) if(self.data.get('winsnd', None) != None): |