[gcompris] mining: move tool classes to separate python file



commit 87df2c0f131a03b7b26de580f387479adbfeb2bb
Author: Peter Albrecht <pa-dev gmx de>
Date:   Sat Sep 22 10:06:30 2012 +0200

    mining: move tool classes to separate python file
    
    Since we need the BlockingArea also in mining_tutorial.py, we have to
    move it to a separate python file.
    Since the Area class also is kind of a general helper class, too, we
    also move it to the external class.

 src/mining-activity/mining.py       |   33 +---------------------
 src/mining-activity/mining_tools.py |   51 +++++++++++++++++++++++++++++++++++
 2 files changed, 53 insertions(+), 31 deletions(-)
---
diff --git a/src/mining-activity/mining.py b/src/mining-activity/mining.py
index d509cbc..f3574da 100644
--- a/src/mining-activity/mining.py
+++ b/src/mining-activity/mining.py
@@ -32,6 +32,8 @@ import pango
 import random
 import cairo
 
+from mining_tools import Area, BlockingArea
+
 from gcompris import gcompris_gettext as _
 
 class Gcompris_mining:
@@ -1078,34 +1080,3 @@ class Sparkling:
   def __is_animation_playing(self):
     """ Tells us, if there is an animation running at the moment """
     return self.timer != None
-
-
-class Area:
-  """ A class for comfortable working with goocanvas.Bounds """
-
-  def __init__(self, bounds):
-    self.x1 = bounds.x1
-    self.x2 = bounds.x2
-    self.y1 = bounds.y1
-    self.y2 = bounds.y2
-
-    self.width = self.x2 - self.x1
-    self.height = self.y2 - self.y1
-
-    self.center_x = self.x1 + self.width / 2.0
-    self.center_y = self.y1 + self.height / 2.0
-
-
-class BlockingArea:
-  """ This class defines a blocking area, where no nugget should be put """
-
-  def __init__(self, x1, y1, x2, y2):
-    """
-    Constructor:
-      x1, y1, x2, y2 : bounding box of the blocker in canvas coordinates (0 - 800 / 0 - 520)
-    """
-    self.bounds = goocanvas.Bounds(x1, y1, x2, y2)
-
-  def get_bounds(self):
-    """ Return the bounds, defined in the constructor """
-    return self.bounds
diff --git a/src/mining-activity/mining_tools.py b/src/mining-activity/mining_tools.py
new file mode 100644
index 0000000..26a540b
--- /dev/null
+++ b/src/mining-activity/mining_tools.py
@@ -0,0 +1,51 @@
+#  gcompris - mining_tools.py
+#
+# Copyright (C) 2012 Peter Albrecht
+#
+#   This program is free software; you can redistribute it and/or modify
+#   it under the terms of the GNU General Public License as published by
+#   the Free Software Foundation; either version 3 of the License, or
+#   (at your option) any later version.
+#
+#   This program is distributed in the hope that it will be useful,
+#   but WITHOUT ANY WARRANTY; without even the implied warranty of
+#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#   GNU General Public License for more details.
+#
+#   You should have received a copy of the GNU General Public License
+#   along with this program; if not, see <http://www.gnu.org/licenses/>.
+#
+
+import goocanvas
+
+
+class Area:
+  """ A class for comfortable working with goocanvas.Bounds """
+
+  def __init__(self, bounds):
+    self.x1 = bounds.x1
+    self.x2 = bounds.x2
+    self.y1 = bounds.y1
+    self.y2 = bounds.y2
+
+    self.width = self.x2 - self.x1
+    self.height = self.y2 - self.y1
+
+    self.center_x = self.x1 + self.width / 2.0
+    self.center_y = self.y1 + self.height / 2.0
+
+
+class BlockingArea:
+  """ This class defines a blocking area, where no nugget should be put """
+
+  def __init__(self, x1, y1, x2, y2):
+    """
+    Constructor:
+      x1, y1, x2, y2 : bounding box of the blocker in canvas coordinates (0 - 800 / 0 - 520)
+    """
+    self.bounds = goocanvas.Bounds(x1, y1, x2, y2)
+
+
+  def get_bounds(self):
+    """ Return the bounds, defined in the constructor """
+    return self.bounds



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