From 5432fed0239df3c35b9ae659d85a05746a569c38 Mon Sep 17 00:00:00 2001 From: Walter Bender Date: Sat, 13 Dec 2008 20:42:30 +0000 Subject: image caching --- (limited to 'tasetup.py') diff --git a/tasetup.py b/tasetup.py index 33ed561..8609928 100644 --- a/tasetup.py +++ b/tasetup.py @@ -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 + -- cgit v0.9.1