[gnome-games/applygsoc2009: 36/76] XXX: Simple refactoring



commit 447071481de52ce9ecf4b7d93081a61f6393880b
Author: Pablo Castellano <pablog src gnome org>
Date:   Thu Aug 26 15:38:39 2010 +0200

    XXX: Simple refactoring
    
    * Change a method to function
    * Useless import (for now)
    * Define attributes in __init__

 gnome-sudoku/src/lib/tracker_box.py |   38 +++++++++++++++++++---------------
 1 files changed, 21 insertions(+), 17 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/tracker_box.py b/gnome-sudoku/src/lib/tracker_box.py
index 39da95e..a4fbd4b 100644
--- a/gnome-sudoku/src/lib/tracker_box.py
+++ b/gnome-sudoku/src/lib/tracker_box.py
@@ -8,7 +8,6 @@ import gobject
 from gettext import gettext as _
 
 import defaults
-from gtk_goodies import Undo
 
 ICON_FACTORY = gtk.IconFactory()
 STOCK_PIXBUFS = {}
@@ -28,6 +27,21 @@ gtk.stock_add([('tracks',
                 _('Track moves'),
                 0, 0, ""), ])
 
+def _pixbuf_transform_color(pixbuf, color):
+    """Return new pixbuf with color changed to color"""
+    pixbuf_str = pixbuf.get_pixels()
+    pixbuf_str_new = ""
+
+    for alpha in pixbuf_str[3::4]:
+        pixbuf_str_new += chr(int(color[0]*255))
+        pixbuf_str_new += chr(int(color[1]*255))
+        pixbuf_str_new += chr(int(color[2]*255))
+        pixbuf_str_new += alpha
+
+    return gtk.gdk.pixbuf_new_from_data(pixbuf_str_new, gtk.gdk.COLORSPACE_RGB,
+            True, 8, pixbuf.get_width(), pixbuf.get_height(),
+            pixbuf.get_rowstride())
+
 
 class TrackerBox (gtk.VBox):
 
@@ -43,12 +57,16 @@ class TrackerBox (gtk.VBox):
         self.vb = self.builder.get_object('vbox1')
         self.vb.unparent()
         self.pack_start(self.vb, expand = True, fill = True)
+
+        self.tracker_tree = None
+        self.tracker_model = None
+        self.tracker_actions = None
+
         self._setup_actions()
         self._setup_tree()
         self.show_all()
 
     def reset (self):
-
         for tree in self.tracker_model:
             if tree[0] > -1:
                 self.tracker_model.remove(tree.iter)
@@ -119,7 +137,7 @@ class TrackerBox (gtk.VBox):
             tracker_id = self.tinfo.create_tracker(keys['tracker_id'])
         else:
             tracker_id = self.tinfo.create_tracker()
-        pixbuf = self._pixbuf_transform_color(
+        pixbuf = pixbuf_transform_color(
             STOCK_PIXBUFS['tracks'],
             self.tinfo.get_color(tracker_id)
             )
@@ -132,20 +150,6 @@ class TrackerBox (gtk.VBox):
             )
         self.tinfo.set_tracker(tracker_id)
 
-    def _pixbuf_transform_color (self, pixbuf, color):
-        """Return new pixbuf with color changed to color"""
-        pixbuf_str = pixbuf.get_pixels()
-        pixbuf_str_new = ""
-
-        for alpha in pixbuf_str[3::4]:
-            pixbuf_str_new += chr(int(color[0]*255))
-            pixbuf_str_new += chr(int(color[1]*255))
-            pixbuf_str_new += chr(int(color[2]*255))
-            pixbuf_str_new += alpha
-
-        return gtk.gdk.pixbuf_new_from_data(pixbuf_str_new, gtk.gdk.COLORSPACE_RGB, True, 8, 
-                                            pixbuf.get_width(), pixbuf.get_height(), pixbuf.get_rowstride())
-
     def find_tracker (self, tracker_id):
         for row in self.tracker_model:
             if row[0] == tracker_id:



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