Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Ground.py
diff options
context:
space:
mode:
authorAleksey Lim <alsroot@member.fsf.org>2009-01-31 23:12:05 (GMT)
committer Aleksey Lim <alsroot@member.fsf.org>2009-01-31 23:12:05 (GMT)
commit2c57833688b6cd36b284de7194fdad7c5571087d (patch)
tree6a63b94142354dffe72d39d52c2cc3b7c30e4585 /Ground.py
parentf3f438af59c69b584d84b27f103f9392fc8185f8 (diff)
implement load/save operations
Diffstat (limited to 'Ground.py')
-rw-r--r--Ground.py67
1 files changed, 39 insertions, 28 deletions
diff --git a/Ground.py b/Ground.py
index 512f2ad..a200281 100644
--- a/Ground.py
+++ b/Ground.py
@@ -18,20 +18,32 @@ from gettext import gettext as _
from sugar.graphics.objectchooser import ObjectChooser
import Theme
+from Document import Document
+
+PREINSTALLED = 0
+CUSTOM = 1
+TEMPORARY = 2
def load():
- ground = Document.ground()
- custom = Ground(ground[0], None, False)
- custom._pixbuf = ground[1]
- THEMES.insert(-1, custom)
+ if not Document.ground_filename:
+ custom = Ground(Document.ground_name, None, TEMPORARY)
+ custom._pixbuf = Document.ground_orig
+ THEMES.insert(-1, custom)
class Ground:
- def __init__(self, name, file, custom):
+ def __init__(self, name, file, type):
self.name = name
+ self._file = file
if file: self._pixbuf = Theme.pixbuf(file)
- self._custom = custom
+ self._type = type
self._thumb = None
+ def filename(self):
+ if self._type == PREINSTALLED:
+ return self._file
+ else:
+ return None
+
def thumb(self):
if not self._thumb:
self._thumb = Theme.scale(self._pixbuf)
@@ -41,28 +53,27 @@ class Ground:
return self._pixbuf
def change(self):
- if self._custom in (None, False):
+ if self._type != CUSTOM:
return self
- else:
- return Theme.choose(lambda title, file: Ground(title, file, False))
+ return Theme.choose(lambda title, file: Ground(title, file, TEMPORARY))
-THEMES = (
- Ground(_('Saturn'), 'images/backpics/bigbg01.gif', None),
- Ground(_('Snowflakes'), 'images/backpics/bigbg02.gif', None),
- Ground(_('Eye'), 'images/backpics/bigbg03.gif', None),
- Ground(_('Blobs'), 'images/backpics/bigbg04.gif', None),
- Ground(_('Star Night'), 'images/backpics/bigbg05.gif', None),
- Ground(_('Forest'), 'images/backpics/bigbg06.gif', None),
- Ground(_('Spiral'), 'images/backpics/bigbg07.gif', None),
- Ground(_('Beam'), 'images/backpics/bigbg08.gif', None),
- Ground(_('Cloth'), 'images/backpics/bigbg09.gif', None),
- Ground(_('Faces'), 'images/backpics/bigbg10.gif', None),
- Ground(_('Leaves'), 'images/backpics/bigbg11.gif', None),
- Ground(_('Vegetables'), 'images/backpics/bigbg12.gif', None),
- Ground(_('Spotlight'), 'images/backpics/bigbg13.gif', None),
- Ground(_('Strips'), 'images/backpics/bigbg14.gif', None),
- Ground(_('Scene'), 'images/backpics/bigbg15.gif', None),
- Ground(_('Rhombs'), 'images/backpics/bigbg16.gif', None),
- Ground(_('Milky Way'), 'images/backpics/bigbg17.gif', None),
+THEMES = [
+ Ground(_('Saturn'), 'images/backpics/bigbg01.gif', PREINSTALLED),
+ Ground(_('Snowflakes'), 'images/backpics/bigbg02.gif', PREINSTALLED),
+ Ground(_('Eye'), 'images/backpics/bigbg03.gif', PREINSTALLED),
+ Ground(_('Blobs'), 'images/backpics/bigbg04.gif', PREINSTALLED),
+ Ground(_('Star Night'), 'images/backpics/bigbg05.gif', PREINSTALLED),
+ Ground(_('Forest'), 'images/backpics/bigbg06.gif', PREINSTALLED),
+ Ground(_('Spiral'), 'images/backpics/bigbg07.gif', PREINSTALLED),
+ Ground(_('Beam'), 'images/backpics/bigbg08.gif', PREINSTALLED),
+ Ground(_('Cloth'), 'images/backpics/bigbg09.gif', PREINSTALLED),
+ Ground(_('Faces'), 'images/backpics/bigbg10.gif', PREINSTALLED),
+ Ground(_('Leaves'), 'images/backpics/bigbg11.gif', PREINSTALLED),
+ Ground(_('Vegetables'), 'images/backpics/bigbg12.gif', PREINSTALLED),
+ Ground(_('Spotlight'), 'images/backpics/bigbg13.gif', PREINSTALLED),
+ Ground(_('Strips'), 'images/backpics/bigbg14.gif', PREINSTALLED),
+ Ground(_('Scene'), 'images/backpics/bigbg15.gif', PREINSTALLED),
+ Ground(_('Rhombs'), 'images/backpics/bigbg16.gif', PREINSTALLED),
+ Ground(_('Milky Way'), 'images/backpics/bigbg17.gif', PREINSTALLED),
None,
- Ground(_('Custom'), 'images/backpics/custom.png', True) )
+ Ground(_('Custom'), 'images/backpics/custom.png', CUSTOM)]