[gnome-games/applygsoc2009: 20/76] Mark methods as private with underscore



commit 74ef8df1cae63d6b259408871044efe433d08cc9
Author: Pablo Castellano <pablog src gnome org>
Date:   Sun Aug 1 18:59:47 2010 +0200

    Mark methods as private with underscore
    
    The previous commmit log has a typo; should be 'prepend'.
    
    Also:
    ***********
    Remove simple_debug
    
    it's not very helpful

 gnome-sudoku/src/lib/Makefile.am      |    1 -
 gnome-sudoku/src/lib/game_selector.py |   11 -----
 gnome-sudoku/src/lib/gsudoku.py       |   16 -------
 gnome-sudoku/src/lib/main.py          |   74 ++++++++++++---------------------
 gnome-sudoku/src/lib/simple_debug.py  |   45 --------------------
 5 files changed, 27 insertions(+), 120 deletions(-)
---
diff --git a/gnome-sudoku/src/lib/Makefile.am b/gnome-sudoku/src/lib/Makefile.am
index ef7bbf4..9b9380c 100644
--- a/gnome-sudoku/src/lib/Makefile.am
+++ b/gnome-sudoku/src/lib/Makefile.am
@@ -19,7 +19,6 @@ gnomesudoku_PYTHON = \
 	pausable.py	\
 	printing.py	\
 	saver.py	\
-	simple_debug.py	\
 	sudoku_maker.py	\
 	sudoku_thumber.py \
 	sudoku.py	\
diff --git a/gnome-sudoku/src/lib/game_selector.py b/gnome-sudoku/src/lib/game_selector.py
index 0e1e1b6..4f2eabc 100644
--- a/gnome-sudoku/src/lib/game_selector.py
+++ b/gnome-sudoku/src/lib/game_selector.py
@@ -6,7 +6,6 @@ import sudoku_thumber
 from gettext import gettext as _
 from timer import format_time, format_friendly_date
 import defaults
-from simple_debug import simple_debug
 from colors import color_hex_to_float
 
 def color_from_difficulty (diff):
@@ -51,7 +50,6 @@ class NewOrSavedGameSelector:
 
     ui_file = os.path.join(defaults.UI_DIR, 'select_game.ui')
 
-    @simple_debug
     def __init__ (self):
         self.sudoku_maker = sudoku_maker.SudokuMaker()
         self.dialog = None
@@ -109,7 +107,6 @@ class NewOrSavedGameSelector:
         new_game_view.connect('item-activated', self.new_item_activated_cb)
         new_game_view.connect('button-release-event', self.item_clicked_cb)
 
-    @simple_debug
     def make_new_game_model (self):
         # Description, Pixbuf, Puzzle (str)
         self.new_game_model = gtk.ListStore(str, gtk.gdk.Pixbuf, str)
@@ -145,7 +142,6 @@ class NewOrSavedGameSelector:
                                         puzzle
                                         ))
 
-    @simple_debug
     def make_saved_game_model (self):
         # Description, Image, Last-Access time (for sorting), Puzzle (jar)
         self.saved_game_model = gtk.ListStore(str, gtk.gdk.Pixbuf, int, gobject.TYPE_PYOBJECT)
@@ -173,15 +169,12 @@ class NewOrSavedGameSelector:
                 g
                 ))
 
-    @simple_debug
     def new_item_activated_cb (self, iconview, path):
         self.play_game(iconview.get_model()[path][2])
 
-    @simple_debug
     def saved_item_activated_cb (self, iconview, path):
         self.resume_game(iconview.get_model()[path][3])
 
-    @simple_debug
     def item_clicked_cb (self, wdgt, evt):
         '''Single click event handler
 
@@ -200,21 +193,17 @@ class NewOrSavedGameSelector:
         wdgt.get_parent_window().process_updates(False)
         wdgt.item_activated(position)
 
-    @simple_debug
     def resume_game (self, jar):
         self.puzzle = (self.SAVED_GAME, jar)
         self.dialog.emit('response', gtk.RESPONSE_OK)
 
-    @simple_debug
     def play_game (self, puzzle):
         self.puzzle = (self.NEW_GAME, puzzle)
         self.dialog.emit('response', gtk.RESPONSE_OK)
 
-    @simple_debug
     def close (self, *args):
         self.dialog.emit('response', gtk.RESPONSE_CLOSE)
 
-    @simple_debug
     def handle_response (self, response):
         if response == gtk.RESPONSE_OK:
             return self.puzzle
diff --git a/gnome-sudoku/src/lib/gsudoku.py b/gnome-sudoku/src/lib/gsudoku.py
index 3d940c9..0a2ad68 100644
--- a/gnome-sudoku/src/lib/gsudoku.py
+++ b/gnome-sudoku/src/lib/gsudoku.py
@@ -3,7 +3,6 @@ import gtk, gobject
 import colors
 import math
 import random
-from simple_debug import simple_debug
 import sudoku
 import number_box
 import tracker_info
@@ -74,7 +73,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
 
     do_highlight_cells = False
 
-    @simple_debug
     def __init__ (self, grid = None, group_size = 9,
                   show_impossible_implications = False):
         group_size = int(group_size)
@@ -120,7 +118,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
             return None
         return dest
 
-    @simple_debug
     def focus_callback (self, e, event):
         self.focused = e
         self.emit('focus-changed')
@@ -211,7 +208,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
             self.animate_hint()
             self.hint_timer = gobject.timeout_add(150, self.animate_hint)
 
-    @simple_debug
     def show_hint (self):
         min_options = 10;
         squares = []
@@ -249,7 +245,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         else:
             set_method(bottom_text = "", for_hint = True)
 
-    @simple_debug
     def reset_grid (self):
         '''Remove all untracked values from the grid
 
@@ -354,7 +349,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         # Redraw the notes
         self.update_all_notes()
 
-    @simple_debug
     def _blank_grid (self):
         '''Wipe out everything on the grid.
 
@@ -374,14 +368,12 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         self.clear_notes('All')
         self.tinfo.reset()
 
-    @simple_debug
     def change_grid (self, grid, group_size):
         self.hints = 0
         self.impossible_hints = 0
         self._blank_grid()
         self._setup_grid(grid, group_size)
 
-    @simple_debug
     def load_game (self, game):
         """Load a game.
 
@@ -404,7 +396,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
                     if values[index] and not self.grid._get_(col, row):
                         self.add_value(col, row, values[index])
 
-    @simple_debug
     def _setup_grid (self, grid, group_size):
         self.doing_initial_setup = True
         if isinstance(grid, sudoku.SudokuGrid):
@@ -418,7 +409,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
                     self.add_value(x, y, val)
         self.doing_initial_setup = False
 
-    @simple_debug
     def _entry_callback (self, widget, *args):
         if not widget.get_text():
             self.remove(widget.x, widget.y, *args)
@@ -449,7 +439,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
             for y in range(self.group_size):
                 self.__entries__[(x, y)].show_note_text()
 
-    @simple_debug
     def _entry_validate (self, widget, *args):
         val = widget.get_value()
         if (args and args[0] == 'undo-change'):
@@ -485,7 +474,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         '''
         self.__entries__[(x, y)].set_text_interactive(str(val))
 
-    @simple_debug
     def add_value (self, x, y, val, tracker = None):
         """Add value val at position x, y.
 
@@ -529,7 +517,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         if not self.doing_initial_setup:
             self._mark_impossible_implications(x, y)
 
-    @simple_debug
     def remove (self, x, y, *args):
         """Remove x, y from our visible grid.
 
@@ -566,7 +553,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
             linked_entry = self.__entries__[coord]
             linked_entry.set_error_highlight(False)
 
-    @simple_debug
     def auto_fill (self):
         changed = self.grid.auto_fill()
         retval = []
@@ -577,7 +563,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
             self.emit('puzzle-finished')
         return retval
 
-    @simple_debug
     def auto_fill_current_entry (self):
         e = self.focused
         if not e:
@@ -619,7 +604,6 @@ class SudokuGameDisplay (SudokuNumberGrid, gobject.GObject):
         if self.always_show_hints:
             self.update_all_hints()
 
-    @simple_debug
     def _mark_impossible_implications (self, x, y, check_conflicts = True):
         '''Mark cells with X if they have no possible values
 
diff --git a/gnome-sudoku/src/lib/main.py b/gnome-sudoku/src/lib/main.py
index 07492c7..504c192 100644
--- a/gnome-sudoku/src/lib/main.py
+++ b/gnome-sudoku/src/lib/main.py
@@ -7,6 +7,7 @@ except ImportError, err:
 
 import os.path
 import threading
+import optparse
 
 import gobject
 import gtk
@@ -24,7 +25,6 @@ import tracker_info
 from defaults import (APPNAME, APPNAME_SHORT, AUTHORS, COPYRIGHT, DESCRIPTION, DOMAIN, 
         IMAGE_DIR, LICENSE, MIN_NEW_PUZZLES, UI_DIR, VERSION, WEBSITE, WEBSITE_LABEL)
 from gtk_goodies import gconf_wrapper, Undo, dialog_extras
-from simple_debug import simple_debug, options
 
 ICON_FACTORY = gtk.IconFactory()
 STOCK_PIXBUFS = {}
@@ -106,7 +106,6 @@ class UI (gconf_wrapper.GConfWrapper):
                      'auto_save_interval':60 # auto-save interval in seconds...
                      }
 
-    @simple_debug
     def __init__ (self, run_selector = True):
         """run_selector means that we start our regular game.
 
@@ -211,7 +210,7 @@ class UI (gconf_wrapper.GConfWrapper):
         self.gsd.set_parent_for(self.w)
         self.gsd.connect('puzzle-finished', self.you_win_callback)
         self.setup_color()
-        self.setup_actions()
+        self._setup_actions()
         self.setup_undo()
         self.setup_autosave()
         self.w.add_accel_group(self.uimanager.get_accel_group())
@@ -228,7 +227,7 @@ class UI (gconf_wrapper.GConfWrapper):
         self.w.connect('delete-event', self.quit_cb)
         self.uimanager = gtk.UIManager()
 
-    def setup_actions (self):
+    def _setup_actions (self):
         self.main_actions = gtk.ActionGroup('MainActions')
         self.main_actions.add_actions([
             ('Game', None, _('_Game')),
@@ -352,7 +351,6 @@ class UI (gconf_wrapper.GConfWrapper):
               self.main_actions.get_action('Tracker')),
              ])
 
-    @simple_debug
     def start_worker_thread (self, *args):
         n_new_puzzles = self.sudoku_maker.n_puzzles(new = True)
         try:
@@ -367,7 +365,6 @@ class UI (gconf_wrapper.GConfWrapper):
             pass # assume we have enough new puzzles
         return True
 
-    @simple_debug
     def stop_worker_thread (self, *args):
         if hasattr(self, 'worker'):
             self.sudoku_maker.stop()
@@ -384,7 +381,6 @@ class UI (gconf_wrapper.GConfWrapper):
         self.dancer = dancer.GridDancer(self.gsd)
         self.dancer.start_dancing()
 
-    @simple_debug
     def you_win_callback (self, grid):
         if hasattr(self, 'dancer'):
             return
@@ -412,7 +408,6 @@ class UI (gconf_wrapper.GConfWrapper):
                                    sublabel = sublabel
                                    )
 
-    @simple_debug
     def initialize_prefs (self):
         for k, v in self.initial_prefs.items():
             try:
@@ -420,14 +415,12 @@ class UI (gconf_wrapper.GConfWrapper):
             except:
                 self.gconf[k] = v
 
-    @simple_debug
     def new_cb (self, *args):
         if self._close_current_game():
             choice = self.select_game()
 			if choice:
 			    self._open_game(choice[0], choice[1])
 
-    @simple_debug
     def _close_current_game (self):
         """Close current running game
 
@@ -455,12 +448,10 @@ class UI (gconf_wrapper.GConfWrapper):
         self.won = False
         self.old_tracker_view = None
 
-    @simple_debug
     def resize_cb (self, widget, event):
         self.gconf['width'] = event.width
         self.gconf['height'] = event.height
 
-    @simple_debug
     def quit_cb (self, *args):
         self.w.hide()
         if (self.gsd.grid
@@ -478,7 +469,6 @@ class UI (gconf_wrapper.GConfWrapper):
         except RuntimeError:
             pass
 
-    @simple_debug
     def save_game (self, *args):
         self.sudoku_tracker.save_game(self)
 
@@ -490,7 +480,6 @@ class UI (gconf_wrapper.GConfWrapper):
             self.w.fullscreen()
             self.is_fullscreen = True
 
-    @simple_debug
     def game_reset_cb (self, *args):
         clearer = Undo.UndoableObject(
             self.do_game_reset, #action
@@ -567,11 +556,9 @@ class UI (gconf_wrapper.GConfWrapper):
         if self.gsd.grid.check_for_completeness():
             self.start_dancer()
 
-    @simple_debug
     def show_hint_cb (self, *args):
         self.gsd.show_hint()
 
-    @simple_debug
     def auto_hint_cb (self, action):
         if action.get_active():
             self.gsd.always_show_hints = True
@@ -580,14 +567,12 @@ class UI (gconf_wrapper.GConfWrapper):
             self.gsd.always_show_hints = False
             self.gsd.clear_notes('AutoHint')
 
-    @simple_debug
     def impossible_implication_cb (self, action):
         if action.get_active():
             self.gsd.display_impossible_implications()
         else:
             self.gsd.hide_impossible_implications()
 
-    @simple_debug
     def setup_tracker_interface (self):
         self.tracker_ui = TrackerBox(self)
         self.tracker_ui.show_all()
@@ -596,7 +581,6 @@ class UI (gconf_wrapper.GConfWrapper):
         self.old_tracker_view = None
         self.game_box.add(self.tracker_ui)
 
-    @simple_debug
     def tracker_toggle_cb (self, widg):
         if widg.get_active():
             if self.old_tracker_view:
@@ -609,7 +593,6 @@ class UI (gconf_wrapper.GConfWrapper):
             self.tracker_ui.hide_tracker_cb(None)
             self.tracker_ui.hide()
 
-    @simple_debug
     def toggle_toolbar_cb (self, widg):
         if widg.get_active():
             self.tb.show()
@@ -622,7 +605,6 @@ class UI (gconf_wrapper.GConfWrapper):
         else:
             self.gsd.toggle_highlight(False)
 
-    @simple_debug
     def show_info_cb (self, *args):
         if not self.gsd.grid:
             dialog_extras.show_message(parent = self.w,
@@ -649,7 +631,6 @@ class UI (gconf_wrapper.GConfWrapper):
                                    label = _("Puzzle Statistics"),
                                    sublabel = information)
 
-    @simple_debug
     def autosave (self):
         # this is called on a regular loop and will autosave if we
         # have reason to...
@@ -657,7 +638,6 @@ class UI (gconf_wrapper.GConfWrapper):
             self.sudoku_tracker.save_game(self)
         return True
 
-    @simple_debug
     def show_about (self, *args):
         about = gtk.AboutDialog()
         about.set_transient_for(self.w)
@@ -675,7 +655,6 @@ class UI (gconf_wrapper.GConfWrapper):
         about.connect("response", lambda d, r: d.destroy())
         about.show()
 
-    @simple_debug
     def show_help (self, *args):
         try:
             gtk.show_uri(self.w.get_screen(), "ghelp:gnome-sudoku", gtk.get_current_event_time())
@@ -683,18 +662,15 @@ class UI (gconf_wrapper.GConfWrapper):
             # FIXME: This should create a pop-up dialog
             print _('Unable to display help: %s') % str(error)
 
-    @simple_debug
     def print_game (self, *args):
         printing.print_sudokus([self.gsd], self.w)
 
-    @simple_debug
     def print_multiple_games (self, *args):
         gp = printing.GamePrinter(self.sudoku_maker, self.gconf)
         gp.run_dialog()
 
 class TrackerBox (gtk.VBox):
 
-    @simple_debug
     def __init__ (self, main_ui):
 
         gtk.VBox.__init__(self)
@@ -707,11 +683,10 @@ class TrackerBox (gtk.VBox):
         self.vb = self.builder.get_object('vbox1')
         self.vb.unparent()
         self.pack_start(self.vb, expand = True, fill = True)
-        self.setup_actions()
-        self.setup_tree()
+        self._setup_actions()
+        self._setup_tree()
         self.show_all()
 
-    @simple_debug
     def reset (self):
 
         for tree in self.tracker_model:
@@ -720,8 +695,7 @@ class TrackerBox (gtk.VBox):
         self.tinfo.reset()
         self.tracker_actions.set_sensitive(False)
 
-    @simple_debug
-    def setup_tree (self):
+    def _setup_tree (self):
         self.tracker_tree = self.builder.get_object('TrackerTreeView')
         self.tracker_model = gtk.ListStore(int, gtk.gdk.Pixbuf, str)
         self.tracker_model.set_sort_column_id(0, gtk.SORT_ASCENDING)
@@ -733,15 +707,14 @@ class TrackerBox (gtk.VBox):
         self.tracker_tree.append_column(col2)
         self.tracker_tree.append_column(col1)
         # Our initial row...
-        pixbuf = self.pixbuf_transform_color(
+        pixbuf = self._pixbuf_transform_color(
             STOCK_PIXBUFS['tracks'],
             (0, 0, 0)
             )
         self.tracker_model.append([-1, pixbuf, _('Untracked')])
-        self.tracker_tree.get_selection().connect('changed', self.selection_changed_cb)
+        self.tracker_tree.get_selection().connect('changed', self._selection_changed_cb)
 
-    @simple_debug
-    def setup_actions (self):
+    def _setup_actions (self):
         self.tracker_actions = gtk.ActionGroup('tracker_actions')
         self.tracker_actions.add_actions(
             [('Remove',
@@ -781,13 +754,12 @@ class TrackerBox (gtk.VBox):
         else:
             cell.set_property('weight', pango.WEIGHT_NORMAL)
 
-    @simple_debug
     def add_tracker (self, *args, **keys):
         if keys and keys.has_key('tracker_id'):
             tracker_id = self.tinfo.create_tracker(keys['tracker_id'])
         else:
             tracker_id = self.tinfo.create_tracker()
-        pixbuf = self.pixbuf_transform_color(
+        pixbuf = self._pixbuf_transform_color(
             STOCK_PIXBUFS['tracks'],
             self.tinfo.get_color(tracker_id)
             )
@@ -800,8 +772,7 @@ class TrackerBox (gtk.VBox):
             )
         self.tinfo.set_tracker(tracker_id)
 
-    @simple_debug
-    def pixbuf_transform_color (self, pixbuf, color):
+    def _pixbuf_transform_color (self, pixbuf, color):
         """Return new pixbuf with color changed to color"""
         pixbuf_str = pixbuf.get_pixels()
         pixbuf_str_new = ""
@@ -815,14 +786,12 @@ class TrackerBox (gtk.VBox):
         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())
 
-    @simple_debug
     def find_tracker (self, tracker_id):
         for row in self.tracker_model:
             if row[0] == tracker_id:
                 return row
         return None
 
-    @simple_debug
     def select_tracker (self, tracker_id):
         track_row = self.find_tracker(tracker_id)
         if track_row:
@@ -839,8 +808,7 @@ class TrackerBox (gtk.VBox):
         for action in self.tracker_actions.list_actions():
             action.set_sensitive(self.tinfo.showing_tracker != tracker_info.NO_TRACKER)
 
-    @simple_debug
-    def selection_changed_cb (self, selection):
+    def _selection_changed_cb (self, selection):
         mod, itr = selection.get_selected()
         if itr:
             selected_tracker_id = mod.get_value(itr, 0)
@@ -859,7 +827,6 @@ class TrackerBox (gtk.VBox):
         if self.main_ui.gconf['always_show_hints']:
             self.main_ui.gsd.update_all_hints()
 
-    @simple_debug
     def remove_tracker_cb (self, action):
         mod, itr = self.tracker_tree.get_selection().get_selected()
         # This should only be called if there is an itr, but we'll
@@ -872,7 +839,6 @@ class TrackerBox (gtk.VBox):
                 )
             clearer.perform()
 
-    @simple_debug
     def hide_tracker_cb (self, action):
         hiding_tracker = self.tinfo.showing_tracker
         self.select_tracker(tracker_info.NO_TRACKER)
@@ -882,7 +848,6 @@ class TrackerBox (gtk.VBox):
         self.redraw_row(hiding_tracker)
         self.redraw_row(tracker_info.NO_TRACKER)
 
-    @simple_debug
     def apply_tracker_cb (self, action):
         '''Apply Tracker button action
         '''
@@ -971,6 +936,21 @@ class TrackerBox (gtk.VBox):
         self.main_ui.gsd.apply_notelist(self.main_ui.cleared_notes.pop())
 
 def start_game ():
+parser = optparse.OptionParser(
+    version = VERSION,
+    option_list = [
+        optparse.make_option("-v", const=True, action="store_const",
+           dest="debug", help="Print debug information",
+           default=False),
+        optparse.make_option("-p", const=True, action="store_const",
+           dest="profile", help="Profile gnome-sudoku",
+           default=False),
+        optparse.make_option("-w", const=True, action="store_const",
+           dest="walk", help="Step through program",
+           default=False)])
+
+    options, args = parser.parse_args()
+
     if options.debug:
         print 'Starting GNOME Sudoku in debug mode'
 



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