self.mode=None
+ # If this is False then animations are forcefully disabled
+ self.do_animations=True
+
+ self.angle_timer_start=0
+
+ # Duration of the rotation effect
+ self.rotation_time=0.8
+
def do_realize(self, config):
self.config=config
except TypeError:
do_draw=True
- if do_draw and self.config.getAnimate():
+ if do_draw and self.config.getAnimate() and self.do_animations:
#self.queue_draw()
- self.angle_timer_start=time.time()
- gobject.timeout_add(20, self.timerAngle)
+ # Don't start another timer
+ # Instead adjust the time start to produce a nice effect ;-)
+ if self.angle_timer_start==0:
+ self.angle_timer_start=time.time()
+ gobject.timeout_add(20, self.timerAngle)
+ else:
+ dt=time.time()-self.angle_timer_start
+ da=90.0*dt/self.rotation_time
+
+ da2=90.0-da
+ dt2=da2*self.rotation_time/90.0
+ self.angle_timer_start=time.time()-dt2
else:
if self.mode=='l':
self.setAngle(0)
if do_draw:
self.queue_draw()
-
+
+ def disableAnimation(self):
+ self.do_animations=False
+
+ def enableAnimation(self):
+ self.do_animations=True
+
+ def setAnimationEnable(self, value):
+ if value:
+ self.enableAnimation()
+ else:
+ self.disableAnimation()
+
def timerAngle(self):
if self.angle_timer_start==0:
self.angle_timer_start=time.time()-0.05
dt=time.time()-self.angle_timer_start
- # Duration of the rotation effect
- rotation_time=0.8
-
- da=90.0*dt/rotation_time
+ da=90.0*dt/self.rotation_time
if self.mode=='l':
angle=90-da
return(ret)
+ def clearAnimationCache(self):
+ """ Clear animation cache, freeing memory """
+ for x,y in self.icons:
+ ic=self.icons.get(x,y)
+ ic.clearAnimationCache()
+
def do_expose_event(self, event):
cr=self.window.cairo_create()
# self.setMode(o)
class IconGridWidget(IconGrid, gtk.Widget):
- def __init__(self, isconfig, config):
+ def __init__(self, isconfig, config, animation=True):
IconGrid.__init__(self, isconfig)
gtk.Widget.__init__(self)
+ # This must be called before do_realize
+ self.setAnimationEnable(animation)
+
self.config=config
IconGrid.do_realize(self, self.config)