Fix the double-rotation bug.
authorStefanos Harhalakis <v13@v13.gr>
Sun, 8 Aug 2010 15:19:23 +0000 (15:19 +0000)
committerStefanos Harhalakis <v13@v13.gr>
Sun, 8 Aug 2010 15:19:23 +0000 (15:19 +0000)
src/icongrid.py

index fab0898..d5c458e 100755 (executable)
@@ -67,6 +67,11 @@ class IconGrid(object):      #(gobject.GObject):
        # 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
 
@@ -111,8 +116,18 @@ class IconGrid(object):    #(gobject.GObject):
 
        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)
@@ -140,10 +155,7 @@ class IconGrid(object):    #(gobject.GObject):
 
        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