diff options
author | Walter Bender <walter@walter-laptop.(none)> | 2008-12-13 20:42:30 (GMT) |
---|---|---|
committer | Walter Bender <walter@walter-laptop.(none)> | 2008-12-13 20:42:30 (GMT) |
commit | 5432fed0239df3c35b9ae659d85a05746a569c38 (patch) | |
tree | 623e28542bb3aaba583c5d50ab08fc1f3bf032c6 /tasetup.py | |
parent | 99ef99cfa63a19920eadaa6d20932944c3e013f2 (diff) |
image caching
Diffstat (limited to 'tasetup.py')
-rw-r--r-- | tasetup.py | 11 |
1 files changed, 10 insertions, 1 deletions
@@ -187,4 +187,13 @@ def setup_tool(tw,x,y,name): return who def load_image(path, dir, file): - return gtk.gdk.pixbuf_new_from_file(os.path.join(path,dir,file+'.svg')) + from sugar.activity import activity + + # first try to open the cached image + # if you fail, open the .svg file and cache the result + try: return gtk.gdk.pixbuf_new_from_file(os.path.join(activity.get_activity_root(),"data",file+'.png')) + except: + foo = gtk.gdk.pixbuf_new_from_file(os.path.join(path,dir,file+'.svg')) + foo.save(os.path.join(activity.get_activity_root(),"data",file+'.png'), "png") + return foo + |