From c1954705fa0123dc91265098b3e375b4919572de Mon Sep 17 00:00:00 2001 From: Aleksey Lim Date: Sat, 07 Feb 2009 11:45:22 +0000 Subject: Mix in Documnt with more OOP; add id for all objects --- (limited to 'theme.py') diff --git a/theme.py b/theme.py index a43e58b..1d803a5 100644 --- a/theme.py +++ b/theme.py @@ -20,12 +20,6 @@ from math import ceil from sugar.activity.activity import get_bundle_path, get_activity_root from sugar.graphics import style -PREINSTALLED = 0 -CUSTOM = 1 -JOURNAL = 2 -RESTORED = 3 -EMPTY = 4 - SOUND_SPEAKER = 'images/sounds/speaker.png' SOUND_MUTE = 'images/sounds/custom.png' SOUND_CUSTOM = 'images/sounds/custom.png' @@ -112,7 +106,7 @@ EMPTY_THUMB = scale(EMPTY_ORIG) CUSTOM_FRAME_ORIG = pixbuf('images/pics/custom.png') CUSTOM_FRAME_THUMB = scale(CUSTOM_FRAME_ORIG) -def choose(out_fun): +def choose(out_fun, default=None): from sugar.graphics.objectchooser import ObjectChooser chooser = ObjectChooser() @@ -124,13 +118,13 @@ def choose(out_fun): if result == gtk.RESPONSE_ACCEPT: jobject = chooser.get_selected_object() if jobject and jobject.file_path: - return out_fun(jobject.metadata['title'], jobject.file_path) + return out_fun(jobject) finally: if jobject: jobject.destroy() chooser.destroy() del chooser - return None + return default def pixbuf2str(pixbuf): def push(data, buffer): @@ -144,7 +138,7 @@ def pixbuf2str(pixbuf): def str2pixbuf(data): tmpfile = os.path.join(SESSION_PATH, '.tmp.png') file(tmpfile, 'w').write(data) - out = theme.pixbuf(tmpfile) + out = pixbuf(tmpfile) os.unlink(tmpfile) return out -- cgit v0.9.1