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:
parent
86f4aca8f3
commit
7a26110750
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue