Disable animation when doing config.
[drlaunch] / src / icongrid.py
index be097d0..ed592e6 100755 (executable)
@@ -64,6 +64,9 @@ class IconGrid(object):       #(gobject.GObject):
 
        self.mode=None
 
+       # If this is False then animations are forcefully disabled
+       self.do_animations=True
+
     def do_realize(self, config):
        self.config=config
 
@@ -106,7 +109,7 @@ class IconGrid(object):     #(gobject.GObject):
        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)
@@ -118,7 +121,19 @@ class IconGrid(object):    #(gobject.GObject):
 
            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
@@ -295,10 +310,13 @@ class IconGrid(object):   #(gobject.GObject):
 #      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)