[gnome-games/sudoku-tube] Simple refactoring
- From: Zhang Sen <zhangsen src gnome org>
- To: svn-commits-list gnome org
- Subject: [gnome-games/sudoku-tube] Simple refactoring
- Date: Sun, 12 Jul 2009 14:14:59 +0000 (UTC)
commit db40ebf44a426f165e9b4b7ddfeb6efe98b23789
Author: Zhang Sen <zh jesse gmail com>
Date: Sun Jul 12 22:12:29 2009 +0800
Simple refactoring
* Change a method to function
* Useless import (for now)
* Define attributes in __init__
gnome-sudoku/src/lib/tracker_box.py | 47 ++++++++++++++++++----------------
1 files changed, 25 insertions(+), 22 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/tracker_box.py b/gnome-sudoku/src/lib/tracker_box.py
index acc2d0b..7334dde 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,24 +27,43 @@ 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):
def __init__ (self, main_ui):
-
gtk.VBox.__init__(self)
self.builder = gtk.Builder()
- self.builder.add_from_file(os.path.join(defaults.UI_DIR,
- 'tracker.ui'))
+ self.builder.add_from_file(os.path.join(defaults.UI_DIR, 'tracker.ui'))
self._view_controller = ViewController(main_ui)
vbox = self.builder.get_object('vbox1')
vbox.unparent()
self.pack_start(vbox, 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)
@@ -90,10 +108,9 @@ class TrackerBox (gtk.VBox):
def add_tracker (self):
tracker_id = self._view_controller.create_tracker()
- pixbuf = self._pixbuf_transform_color(
+ pixbuf = _pixbuf_transform_color(
STOCK_PIXBUFS['tracks'],
- self._view_controller.get_tracker_color(tracker_id),
- )
+ self._view_controller.get_tracker_color(tracker_id))
# select our new tracker
self.tracker_tree.get_selection().select_iter(
self.tracker_model.append([tracker_id,
@@ -102,20 +119,6 @@ class TrackerBox (gtk.VBox):
)
)
- 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 select_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]