[gcompris/gcomprixogoo] Added rotation of the wind farm.



commit 029dd16cb2603d34daa1f1f7e46c76f04a688c5d
Author: Bruno Coudoin <bruno coudoin free fr>
Date:   Sat Dec 25 15:52:53 2010 +0100

    Added rotation of the wind farm.

 src/hydroelectric-activity/hydroelectric.py |   14 ++++++++++++++
 1 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/src/hydroelectric-activity/hydroelectric.py b/src/hydroelectric-activity/hydroelectric.py
index d5ec643..b25eb40 100644
--- a/src/hydroelectric-activity/hydroelectric.py
+++ b/src/hydroelectric-activity/hydroelectric.py
@@ -774,8 +774,18 @@ class Producer:
     self.power = False
     # Is the run is switched on
     self.is_on = False
+    # The animation timer
+    self.timer = 0
+
+  def __del__(self):
+    if self.timer:
+      gobject.source_remove(self.timer)
 
   def update_run(self):
+    if self.is_on and self.energy \
+          and len(self.prod_items) > 2 \
+          and self.timer == 0:
+      self.rotate_item()
     if self.is_on and self.power:
       self.production = self.power_count
     else:
@@ -833,6 +843,10 @@ class Producer:
       self.current_prod_item = 0
     self.prod_items[self.current_prod_item].props.visibility = \
         goocanvas.ITEM_VISIBLE
+    if self.is_on and self.energy:
+      self.timer = gobject.timeout_add(150, self.rotate_item)
+    else:
+      self.timer = 0
 
 class Counter:
   # Pass the SVG IDs of the stuff to act on



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]