From 3978a402ba1bdef5bf21772e6fa59364807c8c97 Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Tue, 20 Jan 2009 04:08:48 +0000 Subject: ... --- (limited to 'Ground.py') diff --git a/Ground.py b/Ground.py index 844b56d..6a62e30 100644 --- a/Ground.py +++ b/Ground.py @@ -19,80 +19,59 @@ from sugar.graphics.objectchooser import ObjectChooser import Theme -THEMES = ( - { 'name' : _('Saturn'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg01.gif'), - 'custom': None }, - { 'name' : _('Snowflakes'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg02.gif'), - 'custom': None }, - { 'name' : _('Eye'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg03.gif'), - 'custom': None }, - { 'name' : _('Blobs'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg04.gif'), - 'custom': None }, - { 'name' : _('Star Night'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg05.gif'), - 'custom': None }, - { 'name' : _('Forest'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg06.gif'), - 'custom': None }, - { 'name' : _('Spiral'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg07.gif'), - 'custom': None }, - { 'name' : _('Beam'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg08.gif'), - 'custom': None }, - { 'name' : _('Cloth'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg09.gif'), - 'custom': None }, - { 'name' : _('Faces'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg10.gif'), - 'custom': None }, - { 'name' : _('Leaves'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg11.gif'), - 'custom': None }, - { 'name' : _('Vegetables'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg12.gif'), - 'custom': None }, - { 'name' : _('Spotlight'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg13.gif'), - 'custom': None }, - { 'name' : _('Strips'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg14.gif'), - 'custom': None }, - { 'name' : _('Scene'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg15.gif'), - 'custom': None }, - { 'name' : _('Rhombs'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg16.gif'), - 'custom': None }, - { 'name' : _('Milky Way'), - 'pixbuf': Theme.pixmap('images/backpics/bigbg17.gif'), - 'custom': None }, - None, - { 'name' : _('Custom'), - 'pixbuf': Theme.pixmap('images/backpics/custom.png'), - 'custom': True } ) +class Ground: + def __init__(self, name, file, custom): + self.name = name + self._pixbuf = Theme.pixbuf(file) + self._custom = custom + self._thumb = None + + def thumb(self): + if not self._thumb: + self._thumb = self._pixbuf.scale_simple(Theme.THUMB_SIZE, + Theme.THUMB_SIZE, gtk.gdk.INTERP_BILINEAR) + return self._thumb + + def orig(self): + return self._pixbuf -def change(theme): - if theme['custom'] == None or theme['custom'] == False: - return theme + def change(self): + if self._custom in (None, False): + return self - chooser = ObjectChooser(_('Choose background image'), None, - gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) - try: - result = chooser.run() + chooser = ObjectChooser(_('Choose background image'), None, + gtk.DIALOG_MODAL | gtk.DIALOG_DESTROY_WITH_PARENT) + try: + result = chooser.run() - if result == gtk.RESPONSE_ACCEPT: - jobject = chooser.get_selected_object() - if jobject and jobject.file_path: - return { 'name' : jobject.metadata['title'], - 'pixbuf': Theme.pixmap(jobject.file_path), - 'custom': False } - finally: - chooser.destroy() - del chooser + if result == gtk.RESPONSE_ACCEPT: + jobject = chooser.get_selected_object() + if jobject and jobject.file_path: + return Ground(jobject.metadata['title'], + jobject.file_path, False) + finally: + chooser.destroy() + del chooser - return None + return None + +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), + None, + Ground(_('Custom'), 'images/backpics/custom.png', True) ) -- cgit v0.9.1