ocarina: Set and resize images atomically

Doing this all in one step prevents multiple threads from clashing with
each other.  I also add in clearing the old image before setting a new
one.
This commit is contained in:
Bryan Schumaker 2011-05-11 21:46:15 -04:00
parent 86f4aca8f3
commit 7a26110750
1 changed files with 3 additions and 3 deletions

View File

@ -19,19 +19,17 @@ def _resize(img, new_h):
buf = buf.scale_simple(new_w, new_h, gtk.gdk.INTERP_HYPER)
if buf == None:
return
img.clear()
img.set_from_pixbuf(buf)
def resize(img, new_h):
if new_h == 0:
return
new_h = int(new_h)
gtk.threads_enter()
try:
_resize(img, new_h)
except Exception, e:
print e
gtk.threads_leave()
class FileImage(gtk.Image):
@ -50,8 +48,10 @@ class FileImage(gtk.Image):
if path != None:
self.path = path
self.height = height
gtk.threads_enter()
self.set_from_file(path)
resize(self, height)
gtk.threads_leave()
def tooltip(self, image, x, y, keyboard, tip):
if self.path == None: