gnome-games r8651 - in trunk: gnome-sudoku/glade gnome-sudoku/src/lib gnome-sudoku/src/lib/gtk_goodies po
- From: thomashpa svn gnome org
- To: svn-commits-list gnome org
- Subject: gnome-games r8651 - in trunk: gnome-sudoku/glade gnome-sudoku/src/lib gnome-sudoku/src/lib/gtk_goodies po
- Date: Tue, 3 Feb 2009 18:57:57 +0000 (UTC)
Author: thomashpa
Date: Tue Feb 3 18:57:57 2009
New Revision: 8651
URL: http://svn.gnome.org/viewvc/gnome-games?rev=8651&view=rev
Log:
Remove dead and commented out code
Removed:
trunk/gnome-sudoku/glade/high_scores.glade
trunk/gnome-sudoku/glade/high_scores.gladep
trunk/gnome-sudoku/glade/new_game.glade
trunk/gnome-sudoku/glade/new_game.gladep
trunk/gnome-sudoku/glade/open_game.glade
trunk/gnome-sudoku/glade/open_game.gladep
trunk/gnome-sudoku/src/lib/sudoku_labeller.py
Modified:
trunk/gnome-sudoku/src/lib/Makefile.am
trunk/gnome-sudoku/src/lib/game_selector.py
trunk/gnome-sudoku/src/lib/gsudoku.py
trunk/gnome-sudoku/src/lib/gtk_goodies/dialog_extras.py
trunk/gnome-sudoku/src/lib/main.py
trunk/gnome-sudoku/src/lib/printing.py
trunk/gnome-sudoku/src/lib/saver.py
trunk/gnome-sudoku/src/lib/sudoku.py
trunk/gnome-sudoku/src/lib/sudoku_thumber.py
trunk/po/POTFILES.in
trunk/po/POTFILES.skip
Modified: trunk/gnome-sudoku/src/lib/Makefile.am
==============================================================================
--- trunk/gnome-sudoku/src/lib/Makefile.am (original)
+++ trunk/gnome-sudoku/src/lib/Makefile.am Tue Feb 3 18:57:57 2009
@@ -20,7 +20,6 @@
saver.py \
simple_debug.py \
sudoku_generator_gui.py \
- sudoku_labeller.py \
sudoku_maker.py \
sudoku_thumber.py \
sudoku.py \
Modified: trunk/gnome-sudoku/src/lib/game_selector.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/game_selector.py (original)
+++ trunk/gnome-sudoku/src/lib/game_selector.py Tue Feb 3 18:57:57 2009
@@ -34,7 +34,6 @@
c='#cc0000'
else:
c='#a40000'
- #print 'diff=',diff,'color=',c
return color_hex_to_float(c)
class NewOrSavedGameSelector (gconf_wrapper.GConfWrapper):
@@ -99,8 +98,6 @@
]
for cat in DR.ordered_categories:
rng = DR.categories[cat]; label = DR.label_by_cat[cat]
- #puzzle,diff = self.sudoku_maker.get_new_puzzle(.01*random.randint(*[r*100 for r in rng]))
- #diff_val = diff.value
puzzles = self.sudoku_maker.get_puzzles(1,[cat],new=True,
exclude=saved_games_to_exclude
)
@@ -118,7 +115,6 @@
else:
print 'WARNING: No puzzle for difficulty',cat
continue
- #print 'Got new puzzle for ',cat,'difficulty:',diff
grid = sudoku.sudoku_grid_from_string(puzzle).grid
self.new_game_model.append(('<b><i>'+label+'</i></b>',
sudoku_thumber.make_pixbuf(grid,
@@ -145,7 +141,6 @@
lastPlayedText,
durationText,
)
- #print 'Adding to saved...',g
self.saved_game_model.append((
desc,
sudoku_thumber.make_pixbuf(grid.grid,
@@ -180,12 +175,9 @@
@simple_debug
def handle_response (self, response):
- #print 'handle_response',response
if response==gtk.RESPONSE_OK:
- #print 'Returning ',self.puzzle
return self.puzzle
else:
- #print 'handle_response returning',None
return None
def run_swallowed_dialog (self, swallower):
@@ -309,7 +301,6 @@
def print_dialog_response_cb (self, dialog, response):
if response == gnomeprint.ui.DIALOG_RESPONSE_CANCEL:
- #self.dialog.hide()
pass
elif response == gnomeprint.ui.DIALOG_RESPONSE_PREVIEW:
pass
@@ -328,26 +319,3 @@
#self.setup_dialog()
self.dialog.show()
-# if __name__ == '__main__':
-# try:
-# IMAGE_DIR='/usr/share/gnome-sudoku/'
-# import defaults
-# from gnome_sudoku import sudoku_maker
-# st = sudoku_maker.SudokuTracker(sudoku_maker.SudokuMaker(pickle_to='/tmp/foo'))
-# hs=HighScores(st)
-# hs.highlight_newest=True
-# hs.run_dialog()
-# st.save()
-# except:
-# import sys
-# print 'path was ',sys.path
-# raise
-#
-#if __name__ == '__main__':
-# gs = NewOrSavedGameSelector()
-# print 'DIALOG RETURNS:',gs.run_dialog()
-#
-# import saver; sudoku_maker = sudoku_maker.SudokuMaker()
-# gs = GamePrinter(sudoku_maker,gconf_wrapper.GConf('gnome-sudoku'))
-# gs.run_dialog()
-# gtk.main()
Modified: trunk/gnome-sudoku/src/lib/gsudoku.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/gsudoku.py (original)
+++ trunk/gnome-sudoku/src/lib/gsudoku.py Tue Feb 3 18:57:57 2009
@@ -302,8 +302,6 @@
self.set_text_interactive(str(newval))
def show_number_picker (self):
- #self.number_picker_mode = True
- #return
w = gtk.Window(type=gtk.WINDOW_POPUP)
ns = NumberSelector(upper=self.upper,default=self.get_value())
ns.connect('changed', self.number_changed_cb, w)
@@ -315,10 +313,6 @@
popupx,popupy = w.get_size()
overlapx = popupx-x
overlapy = popupy-y
- #print 'origin is ',my_origin
- #print 'widget size is',x,y
- #print 'popup size is',popupx,popupy
- #print 'overlaps are ',overlapx,overlapy
w.move(my_origin[0]-(overlapx/2),my_origin[1]-(overlapy/2))
w.show()
self.npicker = w
@@ -466,9 +460,6 @@
def draw_background_color (self, cr):
if self.read_only:
if self.custom_background_color:
- #h,s,v = colors.rgb_to_hsv(*self.custom_background_color)
- #s = s*0.5 # Halve our saturation
- #v = v*0.5 # Halve our brightness
r,g,b = self.custom_background_color
cr.set_source_rgb(
r*0.6,g*0.6,b*0.6
@@ -507,7 +498,6 @@
cr.stroke()
# And now draw a thinner line around the very outside...
cr.set_source_color(
- #self.style.dark[gtk.STATE_NORMAL]
self.style.dark[state]
)
cr.rectangle(
@@ -614,8 +604,6 @@
val = self.get_value()
cols = (BASE_SIZE-NORMAL_LINE_WIDTH*2) / self.small_digit_width
rows = (BASE_SIZE-NORMAL_LINE_WIDTH*2) / self.small_digit_height
- #if cols > 4: cols=4
- #if rows > 4: rows=4
cols = 3; rows=3
row_size = BASE_SIZE/rows
col_size = BASE_SIZE/cols
@@ -729,17 +717,12 @@
e.x = x
e.y = y
self.table.attach(e,x,x+1,y,y+1,
- #xpadding=2,
- #ypadding=2)
)
self.__entries__[(x,y)] = e
gtk.AspectFrame.__init__(self,obey_child=False)
self.set_shadow_type(gtk.SHADOW_NONE)
self.eb = gtk.EventBox()
- #self.alignment = gtk.Alignment()
- #self.alignment.add(self.eb)
self.eb.add(self.table)
- #self.add(self.alignment)
self.add(self.eb)
self.connect('size-allocate',self.allocate_cb)
self.show_all()
@@ -869,9 +852,6 @@
entry = self.__entries__.values()[0]
default_color = gtkcolor_to_rgb(entry.style.bg[gtk.STATE_SELECTED])
hsv = colors.rgb_to_hsv(*default_color)
- #print 'default rgb = ',default_color
- #print 'default hsv = ',hsv
- #print 'halve saturation'
box_s = hsv[1]
box_v = hsv[2]
if box_v < 0.5: box_v = box_v*2
@@ -880,8 +860,6 @@
else:
box_s = box_s*1.5
if box_s > 1: box_s = 1.0
- #if box_s < 0.25: box_s = box_s*2
- #else: box_s = box_s*0.5
self.box_color = colors.hsv_to_rgb(
hsv[0],box_s,box_v
)
@@ -889,9 +867,6 @@
self.row_color = colors.rotate_hue_rgb(*self.box_color,**{'rotate_by':0.33})
self.col_color = colors.rotate_hue_rgb(*self.box_color,**{'rotate_by':0.66})
self.box_and_col_color = colors.rotate_hue_rgb(*self.box_color,**{'rotate_by':1.0-(0.33/2)})
- #print 'Default color = ',default_color
- #for att in ['box_color','row_color','box_and_col_color','col_color','box_and_row_color']:
- # print att,'=',getattr(self,att)
def toggle_highlight (self, val):
self.do_highlight_cells = val
@@ -1177,8 +1152,6 @@
@simple_debug
def auto_fill (self):
changed=self.grid.auto_fill()
- #changed=self.grid.fill_must_fills
- #changed=self.grid.fill_deterministically()
retval = []
for coords,val in changed:
self.add_value(coords[0],coords[1],val)
@@ -1218,7 +1191,6 @@
if not identifier: identifier = 0
while self.trackers.has_key(identifier): identifier+=1
self.trackers[identifier]=[]
- #self.__trackers_tracking__[identifier]=True
return identifier
def trackers_for_point (self, x, y, val=None):
@@ -1294,12 +1266,10 @@
DANCE_COLORS = [colors.color_hex_to_float(hx) for hx in
[
-
'#cc0000', # red
'#ef2929',
'#f57900', # orange
'#fcaf3e',
- #'#edd400', # yellow
'#fce94f',
'#8ae234', # green
'#73d216',
@@ -1429,8 +1399,6 @@
t.__entries__[(3,1)].set_error_highlight(False)
t.__entries__[(3,1)].set_value(3)
t.__entries__[(3,1)].set_note_text('2,3,4','1,2')
- #t.__entries__[(4,4)].set_value(5)
- #t.__entries__[(4,4)].set_note_text('2,7,8')
w.show_all()
gtk.main()
@@ -1458,7 +1426,6 @@
vb.pack_start(swallower,padding=12)
w.add(vb)
w.show_all()
- #test_dance_grid(sgd)
from gtk_goodies.dialog_extras import MessageDialog
md = MessageDialog(title="Foo",label="Foo",sublabel="Bar "*12)
swallower.run_dialog(md)
@@ -1487,11 +1454,5 @@
w.show_all()
gtk.main()
- #test_number_selector()
- #test_sng()
test_sudoku_game()
- #reproduce_foobared_rendering()
-
-
-
Modified: trunk/gnome-sudoku/src/lib/gtk_goodies/dialog_extras.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/gtk_goodies/dialog_extras.py (original)
+++ trunk/gnome-sudoku/src/lib/gtk_goodies/dialog_extras.py Tue Feb 3 18:57:57 2009
@@ -153,9 +153,6 @@
self.label.set_use_markup(True)
def setup_sublabel (self, sublabel):
- #curtext = self.label.get_text()
- #curtext += "\n%s"%sublabel
- #self.label.set_text(xml.sax.saxutils.escape(curtext))
self.format_secondary_text(sublabel)
class NumberDialog (ModalDialog):
@@ -167,7 +164,6 @@
ModalDialog.__init__(self,default=default, parent=parent)
self.hbox=gtk.HBox()
self.vbox.add(self.hbox)
- #self.spinButton=gtk.SpinButton(climb_rate=climb_rate,digits=digits)
if not default:
val = 0
else:
@@ -633,8 +629,5 @@
if __name__ == '__main__':
- #show_message("You win!",label="You win",
- # icon='/home/tom/Projects/gnome-sudoku/images/winner2.png',
- # sublabel="You completed the puzzle in %s"%'1 hour 25 minutes')
print getFileSaveAs()
gtk.main()
Modified: trunk/gnome-sudoku/src/lib/main.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/main.py (original)
+++ trunk/gnome-sudoku/src/lib/main.py Tue Feb 3 18:57:57 2009
@@ -77,19 +77,13 @@
<menubar name="MenuBar">
<menu name="Game" action="Game">
<menuitem action="New"/>
- <!--<menuitem action="ByHand"/>-->
- <!--<menuitem action="Open"/>-->
- <!--<separator/>
- <menuitem action="Save"/>-->
<separator/>
<menuitem action="PuzzleInfo"/>
- <!--<menuitem action="HighScores"/>-->
<separator/>
<menuitem action="Print"/>
<menuitem action="PrintMany"/>
<separator/>
<menuitem action="Close"/>
- <!--<menuitem action="Quit"/>-->
</menu>
<menu action="Edit">
<menuitem action="Undo"/>
@@ -105,47 +99,37 @@
<menuitem action="ToggleHighlight"/>
</menu>
<menu action="Tools">
- <menuitem action="ShowPossible"/>
- <menuitem action="AutofillCurrentSquare"/>
- <menuitem action="Autofill"/>
- <separator/>
- <menuitem action="AlwaysShowPossible"/>
- <menuitem action="ShowImpossibleImplications"/>
-
+ <menuitem action="ShowPossible"/>
+ <menuitem action="AutofillCurrentSquare"/>
+ <menuitem action="Autofill"/>
+ <separator/>
+ <menuitem action="AlwaysShowPossible"/>
+ <menuitem action="ShowImpossibleImplications"/>
<separator/>
<menuitem action="Generator"/>
<menuitem action="BackgroundGenerator"/>
<separator/>
<menuitem action="Tracker"/>
</menu>
- <menu action="Help">
- <menuitem action="ShowHelp"/>
- <menuitem action="About"/>
- </menu>
- </menubar>
- <toolbar name="Toolbar">
- <!--<toolitem action="Quit"/>-->
+ <menu action="Help">
+ <menuitem action="ShowHelp"/>
+ <menuitem action="About"/>
+ </menu>
+ </menubar>
+ <toolbar name="Toolbar">
<toolitem action="New"/>
- <!--<toolitem action="Open"/>-->
<toolitem action="Print"/>
- <!--<toolitem action="Save"/>-->
- <!--<separator/>-->
- <!--<toolitem action="Clear"/> -->
- <!--<toolitem action="ClearNotes"/>-->
<separator/>
<toolitem action="Undo"/>
<toolitem action="Redo"/>
<separator/>
<toolitem action="ShowPossible"/>
- <!--<toolitem action="AlwaysShowPossible"/>-->
<toolitem action="AutofillCurrentSquare"/>
<separator/>
<toolitem action="ToggleHighlight"/>
- <!--<toolitem action="AlwaysShowPossible"/>-->
-
<toolitem action="Tracker"/>
- </toolbar>
- </ui>'''
+ </toolbar>
+ </ui>'''
initial_prefs = {'group_size':9,
'font_zoom':0,
@@ -161,7 +145,6 @@
'width': 700,
'height': 675,
'auto_save_interval':60 # auto-save interval in seconds...
- #'show_notes':0
}
@simple_debug
@@ -183,24 +166,12 @@
# setup sudoku maker...
self.sudoku_maker = sudoku_maker.SudokuMaker()
self.sudoku_tracker = saver.SudokuTracker()
- #if not self.sudoku_tracker.playing:
- # self.main_actions.get_action('Open').set_sensitive(False)
- #else:
- #self.main_actions.get_action('Open').set_sensitive(True)
- #if not self.sudoku_tracker.are_finished_games():
- # self.main_actions.get_action('HighScores').set_sensitive(False)
- # select an easy puzzle...
- #puz,d=self.sudoku_maker.get_new_puzzle(self.gconf['difficulty'])
- #print 'Default to ',puz
- #self.gsd.change_grid(puz, 9)
# generate puzzles while our use is working...
self.show()
- #print 'Select game!'
if run_selector:
self.do_stop()
if self.select_game():
# If this return True, the user closed...
- #print 'select game returned True - exit'
self.quit = True
else:
self.quit = False
@@ -213,10 +184,8 @@
def select_game (self):
self.tb.hide()
choice = game_selector.NewOrSavedGameSelector().run_swallowed_dialog(self.swallower)
- #print "The user's choice is ",choice
if not choice:
return True
- #print 'choice is ',choice
self.timer.start_timing()
if choice[0] == game_selector.NewOrSavedGameSelector.NEW_GAME:
self.gsd.change_grid(choice[1],9)
@@ -268,19 +237,8 @@
None,_('Print current game'),self.print_game),
('PrintMany',gtk.STOCK_PRINT,_('Print _Multiple Sudokus'),
None,_('Print more than one sudoku at a time.'),self.print_multiple_games),
- #('Quit',gtk.STOCK_QUIT,None,'<Control>q',
- # 'Quit Sudoku game',self.quit_cb),
('Close',gtk.STOCK_CLOSE,None,'<Control>w',
_('Close Sudoku'),self.quit_cb),
- #('Save',gtk.STOCK_SAVE,_('_Save'),
- # '<Control>s','Save game to play later.',
- # self.save_game_cb),
- #('ByHand',gtk.STOCK_EDIT,_('_Enter custom game'),
- # None,_('Enter new puzzle by hand (use this to copy a puzzle from another source).'),
- # self.enter_game_by_hand),
- #('Open',gtk.STOCK_OPEN,_('Open game'),
- # '<Control>o',_('Open a saved game from file.'),
- # self.open_game),
('Tools',None,_('_Tools')),
('View',None,_('_View')),
('ShowPossible',gtk.STOCK_DIALOG_INFO,_('_Hint'),
@@ -304,9 +262,6 @@
None,None,self.show_about),
('ShowHelp',gtk.STOCK_HELP, _('_Contents'),
'F1',None,self.show_help),
- #('HighScores',None,_('High _Scores'),
- # None,_('Show high scores or replay old games.'),
- # self.show_high_scores_cb),
])
self.main_actions.add_toggle_actions([
('AlwaysShowPossible',
@@ -447,15 +402,12 @@
def start_worker_thread (self, *args):
n_new_puzzles = self.sudoku_maker.n_puzzles(new=True)
if n_new_puzzles < self.gconf['minimum_number_of_new_puzzles']:
- #print 'Generate puzzles'
self.worker = threading.Thread(target=lambda *args: self.sudoku_maker.work(limit=5))
self.worker_connections = [
self.timer.connect('timing-started',self.sudoku_maker.resume),
self.timer.connect('timing-stopped',self.sudoku_maker.pause)
]
self.worker.start()
- #else:
- # print "Don't generate...",'We already have ',n_new_puzzles,'!'
@simple_debug
def stop_worker_thread (self, *args):
@@ -497,19 +449,8 @@
self.dancer = GridDancer(self.gsd)
self.dancer.start_dancing()
dialog_extras.show_message(_("You win!"),label=_("You win!"),
- #icon=os.path.join(IMAGE_DIR,'winner2.png'),
sublabel=sublabel
)
- # High scores is complicated and kind of unnecessary for now...
- # If we reimplement, we should use the proper gnome-games system.
- #hs = game_selector.HighScores(self.sudoku_tracker)
- #hs.highlight_newest=True
- #hs.run_swallowed_dialog(self.swallower)
- #print 'Run high scores dialog!'
- #hs.run_dialog()
- #self.main_actions.get_action('HighScores').set_sensitive(True)
- #self.gsd.blank_grid()
- #self.new_cb()
@simple_debug
def initialize_prefs (self):
@@ -566,15 +507,10 @@
@simple_debug
def quit_cb (self, *args):
- # Offer a save...
- #try:
if (self.gsd.grid
and self.gsd.grid.is_changed()
and (not self.won)):
- #and dialog_extras.getBoolean(label=_("Save game before closing?"))):
self.save_game(self) # autosave...
- #except dialog_extras.UserCancelledError:
- # return
if gtk.main_level() > 1:
# If we are in an embedded mainloop, that means that one
# of our "swallowed" dialogs is active, in which case we
@@ -588,15 +524,6 @@
# to quit the main
# mainloop
return
- #buttons = d.action_area.get_children()
- #for b in buttons:
- # if d.get_response_for_widget(b) in [gtk.RESPONSE_CLOSE,gtk.RESPONSE_CANCEL]:
- # print 'clicking button',b
- # b.emit('clicked')
- # while gtk.events_pending():
- # print 'Take care of iters...'
- # gtk.main_iteration()
- # break
self.w.hide()
# make sure we really go away before doing our saving --
# otherwise we appear sluggish.
@@ -634,12 +561,6 @@
def cancel_handmade_grid (self, *args):
for w in self.by_hand_widgets: w.hide()
- #def save_game_cb (self, *args):
- # try:
- # self.save_game(*args)
- # except dialog_extras.UserCancelledError:
- # pass
-
@simple_debug
def save_game (self, *args):
self.sudoku_tracker.save_game(self)
@@ -765,8 +686,6 @@
@simple_debug
def tracker_toggle_cb (self, widg):
if widg.get_active():
- #if len(self.tracker_ui.tracker_model)<=1:
- # self.tracker_ui.add_tracker()
self.tracker_ui.show_all()
else:
self.tracker_ui.hide()
@@ -870,8 +789,6 @@
saver.unpickle_game(self,filename)
self.history.clear()
- #def toggle_autosave ():
-
@simple_debug
def show_about (self, *args):
about = gtk.AboutDialog()
@@ -976,9 +893,7 @@
@simple_debug
def add_tracker (self,*args):
- #print 'Adding tracker!'
tracker_id = self.main_ui.gsd.create_tracker()
- #print 'tracker_id = ',tracker_id
pb=image_extras.pixbuf_transform_color(
STOCK_PIXBUFS['tracks'],
(0,0,0),#white
Modified: trunk/gnome-sudoku/src/lib/printing.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/printing.py (original)
+++ trunk/gnome-sudoku/src/lib/printing.py Tue Feb 3 18:57:57 2009
@@ -28,8 +28,6 @@
self.left_upper = start_at
self.right_lower = self.left_upper[0]+self.grid_side_size,self.left_upper[1]-self.grid_side_size
self.box_size = math.sqrt(grid_size)
- #print 'beginpage 1'
- #self.gpc.beginpage("1")
# get the right font size for our increment...
self.increment * 0.7
# start with our maximum font...
@@ -42,7 +40,6 @@
self.font = gnomeprint.font_find_closest('Helvetica',
max_size)
self.THICK_WIDTH = 1 + float(max_size) / 8
- #print 'FONT SIZE ',max_size, 'BORDER SIZE: ',self.THICK_WIDTH
self.gpc.setfont(
self.font
)
@@ -66,10 +63,8 @@
move_to = list(self.left_upper)
char_w=font.get_width_utf8(str(val))
char_h = font.get_ascender()
- #print 'Center by ',(self.increment - char_w)/2
move_to[self.X] += (self.increment * x + (self.increment - char_w)/2)
move_to[self.Y] = move_to[self.Y] - (((y+1) * self.increment) - (self.increment - char_h)/2)
- #print 'Printing ',x,y,val,' at ',move_to
self.gpc.moveto(*move_to)
self.gpc.show(str(val))
if color: self.gpc.setrgbcolor(*self.default_color) #unset color
@@ -105,8 +100,6 @@
else:
dest_pos[opposite]=dest_pos[opposite]-self.grid_side_size-length_adjustment*2
self.gpc.lineto(*dest_pos)
- #print 'Printing line ',direction,':',n
- #print dest_pos,':',start_pos
self.gpc.stroke()
# Reset our width to normal if need be...
if n % self.box_size == 0: self.gpc.setlinewidth(1)
@@ -193,7 +186,6 @@
sudokus = [sudokus] # assume they passed us one sudoku by
self.nsudokus = 1 # mistake and be nice
self.sudokus = sudokus
- #print 'Getting default config'
self.job = gnomeprint.Job(gnomeprint.config_default())
def run (self):
@@ -206,19 +198,16 @@
self.dialog.show()
def response_cb (self, dialog, response):
- #print 'Ran dialog.'
if response == gnomeprint.ui.DIALOG_RESPONSE_CANCEL:
dialog.hide()
elif response == gnomeprint.ui.DIALOG_RESPONSE_PREVIEW:
if not self.drawn: self.draw_sudokus()
w=gnomeprint.ui.JobPreview(self.job,_('Print Preview'))
w.set_transient_for(dialog)
- #w.present()
w.set_property('allow-grow',1)
w.set_property('allow-shrink',1)
w.show_all()
w.present()
- #self.dialog.emit_stop_by_name('response')
elif response == gnomeprint.ui.DIALOG_RESPONSE_PRINT:
if not self.drawn: self.draw_sudokus()
self.job.print_()
@@ -226,7 +215,6 @@
def draw_sudokus (self):
- #print 'getting context'
self.gpc = self.job.get_context()
width,height = gnomeprint.job_get_page_size_from_config(self.job.get_config())
self.margin = 50
@@ -242,7 +230,6 @@
dimensions, square_size = fit_squares_in_rectangle(width,height,self.sudokus_per_page,self.margin)
else:
dimensions,square_size = fit_squares_in_rectangle(width,height,self.sudokus_per_page,self.margin)
- #print 'SQUARE_SIZE=',square_size
count = 0
for sudoku in self.sudokus:
if type(sudoku)==tuple:
@@ -302,7 +289,6 @@
square_size = across_size
else:
square_size = down_size
- #print n_across,'x',n_down,'=>',square_size,'x',square_size,'squares.'
if square_size > best_square_size:
best_square_size = square_size
best_fit = n_across,n_down
@@ -313,16 +299,3 @@
sp = SudokuPrinter(*args,**kwargs)
sp.run()
-
-def my_print ():
- sud=sudoku.SudokuSolver(sudoku.easy_sudoku)
- sud.fill_deterministically()
- sud2 = sudoku.SudokuSolver(sudoku.fiendish_sudoku)
- sud2.fill_deterministically()
- sud3 = sudoku.SudokuSolver(sudoku.hard_open_sudoku)
- #print_sudokus([sud,sud2,sud3,sud,sud2,sud3,sud,sud2,sud3],
- # )
- sp = SudokuPrinter([sud,sud2,sud3,sud,sud2,sud3,sud,sud2,sud3])
- #sp.run()
- print 'and...\n...\nreturns',sp.run(),'!'
-
Modified: trunk/gnome-sudoku/src/lib/saver.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/saver.py (original)
+++ trunk/gnome-sudoku/src/lib/saver.py Tue Feb 3 18:57:57 2009
@@ -31,7 +31,6 @@
def jar_game (ui):
jar = {} # what we will pickle
- #jar['undo_history']=ui.history
ui.timer.finish_timing()
jar['game']=ui.gsd.grid.to_string()
jar['trackers']=ui.gsd.trackers
@@ -46,7 +45,6 @@
return jar
def open_game (ui, jar):
- #ui.history = jar['undo_history']
ui.gsd.load_game(jar['game'])
# this is a bit easily breakable... we take advantage of the fact
# that we create tracker IDs sequentially and that {}.items()
@@ -54,7 +52,6 @@
for tracker,tracked in jar.get('trackers',{}).items():
# add 1 tracker per existing tracker...
ui.tracker_ui.add_tracker()
- #ui.tracker_ui.show() # Leave this to the toggle setting
for x,y,val in tracked:
ui.gsd.add_tracker(x,y,tracker,val=val)
for tracker,tracking in jar.get('tracking',{}).items():
@@ -128,7 +125,6 @@
def save_game (self, ui):
game = self.game_from_ui(ui)
jar = jar_game(ui)
- #jar['saved_at'] = time.time()
filename = os.path.join(self.save_path,self.get_filename(jar['game']))
try:
outfi = file(filename,'w')
@@ -153,7 +149,7 @@
self.finish_jar(jar)
def finish_jar (self, jar):
- self.remove_from_saved_games(jar) #
+ self.remove_from_saved_games(jar)
try:
filename = os.path.join(self.finished_path,
self.get_filename(jar['game']))
Modified: trunk/gnome-sudoku/src/lib/sudoku.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/sudoku.py (original)
+++ trunk/gnome-sudoku/src/lib/sudoku.py Tue Feb 3 18:57:57 2009
@@ -1,12 +1,9 @@
# -*- coding: utf-8 -*-
-# NOTE: We could also play in hexidecimal for kicks...
import random
import math
import re
from gettext import gettext as _
-
-
GROUP_SIZE = 9
TYPE_ROW = 0
@@ -14,7 +11,6 @@
TYPE_BOX = 2
digit_set = range(1,GROUP_SIZE+1)
-#random.shuffle(digit_set)
sets = [digit_set] * 9
def is_set (row):
@@ -264,7 +260,6 @@
self.initialized=True
self.solved = False
self.trail = []
- #self.complete_crumbs = BreadcrumbTrail()
def auto_fill_for_xy (self, x, y):
"""Fill the square x,y if possible."""
@@ -385,17 +380,12 @@
# just work on the open squares
coord_set = filter(lambda coords: not self._get_(*coords),coord_set)
for xy,poss_set in [(c,self.possible_values(*c)) for c in coord_set]:
- #print 'Looking at ',coords
- #print 'Possible vals: ',poss_set
# our set of values we can fill is now greater...
values = values|poss_set
# track who can fill our needs...
for v in poss_set: needed_dic[v].append(xy)
# check if our set of fillable values is sufficient
- #print 'Needed dic: ',needed_dic
if values != self.gen_set:
- #if self.verbose: print 'PROBLEM in ',label,' ',n
- #print 'Initial puzzle was: ',self.virgin
raise UnsolvablePuzzle("Impossible to solve! We are missing %s in %s"%(self.gen_set-values,label))
# Check if there are any values for which only one cell will suffice
needed_filled_by = needed_dic.items()
@@ -414,7 +404,6 @@
"Impossible to solve! %s,%s must be two values at once!"%(coords)
)
if self.verbose: print 'fill_must_fills returning ',has_changed
- #print 'fill_must_fills returning ',has_changed
return has_changed
def scan_must_fills (self):
@@ -436,7 +425,6 @@
self.add(coords[0],coords[1],val)
retval.append([(coords[0],coords[1]),val])
if self.verbose: print 'deterministically returning ',retval
- #print 'deterministically filled ',retval
return retval
def solve (self):
@@ -451,7 +439,6 @@
self.solved=True
yield tuple([tuple(r) for r in self.grid[0:]])
while self.breadcrumbs:
- #print self.breadcrumbs
self.unwrap_guess(self.breadcrumbs[-1])
try:
while not self.guess_least_open_square(): 1
@@ -492,8 +479,6 @@
if not possible_values:
if self.breadcrumbs:
self.backtraces += 1
- #print self.breadcrumbs
- #raw_input('Hit return to back up...')
self.unwrap_guess(self.breadcrumbs[-1])
return self.guess_least_open_square()
else:
@@ -504,18 +489,10 @@
self.guesses.guesses_for_coord(*least[0]),
self.guesses))
guess = random.choice(list(possible_values))
- #print 'Our trail so far: ',self.breadcrumbs
- #print 'Guessing ',guess,' from ',possible_values,' for ',least[0]
- #raw_input('Continue...')
- # If we have a trail, we mark our parent
- #if self.breadcrumbs: parent=self.breadcrumbs[-1]
- #else: parent=None
# Create guess object
guess_obj = Guess(least[0][0],least[0][1],guess)
if self.breadcrumbs:
self.breadcrumbs[-1].children.append(guess_obj)
- #print 'Guessing ',guess_obj
- #print 'adding guess ',least[0],guess
self.current_guess = None #reset (we're tracked via guess.child)
self.add(least[0][0],least[0][1],guess)
self.current_guess = guess_obj # (All deterministic additions
@@ -526,49 +503,24 @@
self.breadcrumbs.append(guess_obj)
try:
filled = self.auto_fill()
- #print 'filled :',filled
- #print 'Done with guess.'
except NotImplementedError:
- #print 'Bad Guess!!!'
- #print self
self.trail.append('Problem filling coordinates after guess')
- #raw_input('Hit return to unwrap %s'%guess_obj)
self.unwrap_guess(guess_obj)
return self.guess_least_open_square()
- #print self
if set([]) in self.calculate_open_squares().values():
- #print 'BAD GUESS!!!'
- #print self
self.trail.append('Guess leaves us with impossible squares.')
- #raw_input('Hit return to unwrap %s'%guess_obj)
self.unwrap_guess(guess_obj)
return self.guess_least_open_square()
- #print self
def unwrap_guess (self, guess):
- #print 'Unwrapping guess ',guess
- #print self
- #raw_input('Unwrap...')
- #print 'Before:'
- #print self
self.trail.append(('-',guess))
if self._get_(guess.x,guess.y): self.remove(guess.x,guess.y)
for consequence in guess.consequences.keys():
if self._get_(*consequence): self.remove(*consequence)
- #for d in self.guesses.remove_children(guess):
for child in guess.children:
- #if self._get_(d.x,d.y):
- #print 'remove descendant ',child.x,child.y
self.unwrap_guess(child)
if child in self.guesses: self.guesses.remove(child)
- #print 'removing %s from breadcrumbs (%s)'%(guess,self.breadcrumbs)
if guess in self.breadcrumbs: self.breadcrumbs.remove(guess)
- #print 'Remaining crumbs: ',self.breadcrumbs
- #print 'Remaining guesses: ',self.guesses
- #print 'New unwrapped self:'
- #print self
- #print 'After:'
- #print self
def print_possibilities (self):
poss = self.calculate_open_squares()
@@ -594,19 +546,6 @@
if self.current_guess:
self.current_guess.add_consequence(x,y,val)
SudokuGrid.add(self,x,y,val,*args,**kwargs)
- # if self.initialized:
- # stack = traceback.extract_stack()
- # print ":".join(str(x) for x in stack[-5][1:-1]),
- # print ":".join(str(x) for x in stack[-4][1:-1]),
- # print ":".join(str(x) for x in stack[-3][1:-1]),
- # print ': adding ',x,y,val
- #
- # SudokuGrid.add(self,x,y,val,*args,**kwargs)
-
- #def remove (self, x, y):
- # #if self.initialized: self.complete_crumbs.remove_guesses_for_coord(x,y)
- # SudokuGrid.remove(self,x,y)
-
class InteractiveSudoku (SudokuSolver):
@@ -614,7 +553,6 @@
functions for helping along a human.who is in the midst of
solving."""
def __init__ (self, grid=False, verbose=False, group_size=9):
- #self.virgin_self = SudokuSolver(grid,verbose,group_size)
SudokuSolver.__init__(self,grid,verbose,group_size)
def to_string (self):
@@ -638,17 +576,10 @@
def check_for_completeness (self):
for r in self.rows:
if len(r)!=self.group_size:
- #print 'Row not complete: ',r
return False
for c in self.cols:
if len(c)!=self.group_size:
- #print 'Column not complete: ',c
return False
- # (This is redundant)
- #for b in self.boxes:
- # if len(b)!=self.group_size:
- # print 'Box not complete: ',b
- # return False
return True
def is_changed (self):
@@ -782,13 +713,10 @@
def add (self,*args,**kwargs):
if not self.fake_add:
if self.initialized and not self.guessing:
- #print 'Scanning fillables'
self.scan_fillables()
- #print 'Done scanning fillables'
for delayed_args in self.add_me_queue:
coords = (delayed_args[0],delayed_args[1])
if not self._get_(*coords):
- #print 'Adding scanned fillable:'
SudokuSolver.add(self,*delayed_args)
if not self._get_(args[0],args[1]):
SudokuSolver.add(self,*args)
@@ -820,7 +748,6 @@
self.fake_add = False
def guess_least_open_square (self):
- #print 'guessing'
self.guessing = True
return SudokuSolver.guess_least_open_square(self)
@@ -832,7 +759,6 @@
r),
self.virgin.grid)
self.numbers_added = self.group_size**2 - self.clues
- #self.auto_fill()
rating = DifficultyRating(self.fill_must_fillables,
self.elimination_fillables,
self.guesses,
@@ -852,12 +778,9 @@
def remove_children (self, guess):
removed = []
for g in guess.children:
- #print 'removing descendant of ',guess,':',g
if g in self:
removed.append(g)
self.remove(g)
- #print 'recursion from ',g,'->'
- #removed.extend(self.remove_descendants(g))
return removed
def remove_guesses_for_coord (self, x, y):
@@ -868,7 +791,6 @@
if g.x==x and g.y == y:
nuking=True
if nuking:
- #print 'nuking ',g
self.remove(g)
nuked += [g]
return nuked
@@ -890,7 +812,6 @@
self.consequences = {}
def add_consequence (self, x, y, val):
- #print 'Guess: adding consequence ',x,y,val
self.consequences[(x,y)]=val
def __repr__ (self):
@@ -908,132 +829,3 @@
sum += float(n) / diminish_by(i)
return sum
-
-daily_sudoku = [
- [7,0,0,0,9,0,5,2,0],
- [0,9,8,0,0,2,0,0,0],
- [0,0,3,0,0,4,8,0,0],
- [3,0,0,0,4,0,0,8,0],
- [0,8,4,0,0,0,9,5,0],
- [0,6,0,0,3,0,0,0,2],
- [0,0,9,2,0,0,3,0,0],
- [0,0,0,4,0,0,2,1,0],
- [0,4,1,0,0,0,0,0,7]
- ]
-
-easy_sudoku = [
- [8,0,4,6,7,1,2,5,3],
- [0,0,0,0,0,5,0,7,1],
- [0,0,0,0,0,0,0,0,0],
- [5,0,0,9,1,0,0,8,4],
- [3,7,0,0,0,0,0,9,6],
- [4,1,0,0,6,8,0,0,5],
- [0,0,0,0,0,0,0,0,0],
- [9,6,0,7,0,0,0,0,0],
- [1,8,3,4,9,2,5,0,7]
- ]
-
-sample_open_sudoku = [
- [0,4,0,5,9,0,0,0,0],
- [3,0,6,0,4,0,0,0,0],
- [0,5,9,0,0,0,0,0,6],
- [0,0,0,4,0,1,0,5,0],
- [6,1,0,0,7,0,0,9,0],
- [5,2,0,3,0,9,0,8,0],
- [0,0,8,0,5,2,4,0,0],
- [0,9,0,0,0,0,0,0,0],
- [1,0,0,0,0,0,0,0,0]]
-
-hard_open_sudoku = [
- [0,0,9,0,0,3,0,0,2],
- [0,0,0,4,0,1,0,0,8],
- [0,0,5,0,0,0,0,0,4],
- [0,3,0,0,4,0,0,7,0],
- [0,8,0,0,9,0,0,2,0],
- [0,1,0,0,6,0,0,5,0],
- [7,0,0,0,0,0,6,0,0],
- [4,0,0,8,0,7,0,0,0],
- [3,0,0,2,0,0,1,0,0]
- ]
-
-fiendish_sudoku = [
- [0,7,0,0,0,0,2,0,0],
- [0,1,0,0,0,0,8,3,0],
- [0,0,0,0,3,5,6,0,7],
- [8,0,0,0,0,0,0,0,0],
- [0,0,0,2,9,6,0,0,0],
- [0,0,0,0,0,0,0,0,4],
- [1,0,2,7,8,0,0,0,0],
- [0,3,5,0,0,0,0,1,0],
- [0,0,4,0,0,0,0,9,0],
- ]
-#while 1:
-# try:
-# g=RandomGridGenerator()
-# #print 'We did it!!!'
-# #print g
-# break
-# except IndexError:
-# n += 1
-# if n % 10 == 0:
-# print 'Failed: Try ',n
-
-sample_sudoku = [
- [6,9,2,7,3,8,5,4,1],
- [4,8,3,1,5,6,2,9,7],
- [1,7,5,2,9,4,6,8,3],
- [7,5,9,6,2,3,8,1,4],
- [2,3,4,8,1,5,9,7,6],
- [8,1,6,4,7,9,3,5,2],
- [5,6,8,3,4,7,1,2,9],
- [9,4,1,5,6,2,7,3,8],
- [3,2,7,9,8,1,4,6,5],
- ]
-#is_sudoku(sample_sudoku)
-
-hard_hex_sudoku=[
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10],
- [1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 14, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0],
- [9, 0, 5, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 8, 0, 0, 0, 10, 0, 0, 0, 0],
- [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0],
- [2, 11, 3, 0, 16, 0, 7, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 6, 0, 5, 0, 0, 0, 0, 11, 0],
- [0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [3, 0, 0, 0, 0, 0, 0, 0, 0, 15, 0, 0, 0, 0, 0, 0],
- [0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 3, 0],
- [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 0, 0, 4, 0, 0, 8, 0, 0, 0, 0, 0],
- [0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
- [0, 0, 9, 0, 0, 0, 0, 15, 2, 0, 0, 0, 0, 0, 0, 0],
- ]
-
-hard_hex_sudoku_solution = [
- [15, 10, 7, 14, 11, 3, 16, 1, 8, 6, 2, 4, 9, 13, 12, 5],
- [6, 9, 12, 3, 15, 7, 14, 2, 13, 1, 11, 5, 16, 4, 8, 10],
- [1, 13, 16, 5, 4, 8, 12, 9, 10, 3, 15, 14, 6, 7, 2, 11],
- [8, 4, 2, 11, 6, 5, 10, 13, 9, 16, 12, 7, 1, 3, 15, 14],
- [9, 7, 5, 13, 1, 15, 4, 10, 16, 12, 14, 11, 3, 8, 6, 2],
- [16, 12, 15, 6, 9, 2, 11, 8, 4, 7, 3, 10, 5, 14, 1, 13],
- [10, 14, 8, 4, 5, 6, 13, 3, 15, 9, 1, 2, 12, 11, 7, 16],
- [2, 11, 3, 1, 16, 14, 7, 12, 5, 8, 6, 13, 15, 10, 9, 4],
- [13, 2, 10, 16, 12, 4, 3, 6, 1, 5, 9, 8, 14, 15, 11, 7],
- [5, 1, 11, 8, 2, 9, 15, 7, 14, 13, 4, 3, 10, 12, 16, 6],
- [3, 6, 14, 7, 8, 13, 5, 11, 12, 15, 10, 16, 2, 9, 4, 1],
- [12, 15, 4, 9, 14, 10, 1, 16, 11, 2, 7, 6, 13, 5, 3, 8],
- [4, 16, 1, 12, 3, 11, 8, 5, 6, 10, 13, 15, 7, 2, 14, 9],
- [7, 5, 6, 2, 13, 12, 9, 4, 3, 14, 8, 1, 11, 16, 10, 15],
- [11, 3, 13, 15, 10, 1, 2, 14, 7, 4, 16, 9, 8, 6, 5, 12],
- [14, 8, 9, 10, 7, 16, 6, 15, 2, 11, 5, 12, 4, 1, 13, 3],
- ]
-
-if __name__ == '__main__':
- #sgs = {}
- #for n in range(20):
- # sg=SudokuGenerator()
- # sg.generate_puzzles(20)
- # sgs[sg]=sg.average_difficulty()
-
- pass
Modified: trunk/gnome-sudoku/src/lib/sudoku_thumber.py
==============================================================================
--- trunk/gnome-sudoku/src/lib/sudoku_thumber.py (original)
+++ trunk/gnome-sudoku/src/lib/sudoku_thumber.py Tue Feb 3 18:57:57 2009
@@ -37,14 +37,12 @@
(SIZE-(BORDER)),
(SIZE-(BORDER)),
)
- #print 'HIGHLIGHT: ',BORDER*0.5,'-',SIZE-BORDER
cr.set_source_rgb(1,1,1)
cr.fill_preserve()
cr.set_source_rgb(*highlight_color)
cr.stroke()
cr.set_source_rgb(*LINE_GREY)
cr.set_line_width(THICK)
- #cr.set_line_join(cairo.LINE_JOIN_MITER)
cr.rectangle(BORDER,
BORDER,
(SIZE-(BORDER+2*THICK)),
@@ -55,25 +53,17 @@
position = BORDER + THICK
pos = {}
pos[0] = position + (SQUARE_SIZE/2.0)
- #print 'Full size=',SIZE
- #print 'border =',BORDER
- #print 'thin lines=',THIN
- #print 'thick lines=',THICK
- #print 'square size=',SQUARE_SIZE
last_line = 0
for n in range(1,SUDOKU_SIZE):
if n % N_BOXES == 0:
cr.set_line_width(THICK)
position += SQUARE_SIZE + last_line/2.0 + THICK/2.0
last_line = THICK
- #print 'THICK',
else:
cr.set_line_width(THIN)
position += SQUARE_SIZE + last_line/2.0 + THIN/2.0
last_line = THIN
- #print 'THIN ',
pos[n] = position + ((last_line + SQUARE_SIZE)/2.0)
- #print 'draw at ',position
cr.move_to(BORDER,position)
cr.line_to(SIZE-BORDER,position)
cr.move_to(position,BORDER)
@@ -83,15 +73,12 @@
for x in range(SUDOKU_SIZE):
for y in range(SUDOKU_SIZE):
cr.move_to(pos[x],pos[y])
- #cr.arc(pos[x],pos[y],SQUARE_SIZE/3.0,0.1,0)
- #cr.stroke()
letter = None
if sudoku[y][x]:
letter = str(sudoku[y][x])
cr.select_font_face("",
cairo.FONT_SLANT_NORMAL,
cairo.FONT_WEIGHT_BOLD)
- #cairo.FONT_WEIGHT_NORMAL)
cr.set_source_rgb(0,0,0)
xbearing,ybearing,width,height,xadvance,yadvance = (
cr.text_extents(letter)
@@ -119,10 +106,3 @@
del surf
return pixbuf
-if __name__ == '__main__':
- make_image_surface(sudoku,played,
- (1.0,0.5,0.5)).write_to_png(
- '/home/tom/Desktop/test.png'
- )
-
-
Modified: trunk/po/POTFILES.in
==============================================================================
--- trunk/po/POTFILES.in (original)
+++ trunk/po/POTFILES.in Tue Feb 3 18:57:57 2009
@@ -243,7 +243,6 @@
gnome-sudoku/src/lib/printing.py
gnome-sudoku/src/lib/game_selector.py
gnome-sudoku/src/lib/sudoku_generator_gui.py
-gnome-sudoku/src/lib/sudoku_labeller.py
gnome-sudoku/src/lib/dialog_swallower.py
gnome-sudoku/src/lib/sudoku.py
gnome-sudoku/src/lib/gtk_goodies/dialog_extras.py
Modified: trunk/po/POTFILES.skip
==============================================================================
--- trunk/po/POTFILES.skip (original)
+++ trunk/po/POTFILES.skip Tue Feb 3 18:57:57 2009
@@ -8,9 +8,6 @@
gnibbles/gnibbles.desktop.in
gnobots2/gnobots2.desktop.in
gnome-sudoku/gnome-sudoku.desktop.in
-gnome-sudoku/glade/high_scores.glade
-gnome-sudoku/glade/open_game.glade
-gnome-sudoku/glade/new_game.glade
gnome-sudoku/src/lib/defaults.py
gnometris/gnometris.desktop.in
gnometris/field.cpp
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]