Added buttons for navigating the move history

This commit is contained in:
2012-04-26 00:31:26 -04:00
parent 3625cb3804
commit f11055f04e
2 changed files with 74 additions and 12 deletions

View File

@ -83,6 +83,25 @@ class GoGame(gtk.HBox):
self.pack_start(self.board_area, expand=False)
self.pack_end(info_box, expand=False)
nav_row = gtk.HBox()
fwd_button = gtk.Button(stock=gtk.STOCK_GO_FORWARD)
back_button = gtk.Button(stock=gtk.STOCK_GO_BACK)
first_button = gtk.Button(stock=gtk.STOCK_GOTO_FIRST)
last_button = gtk.Button(stock=gtk.STOCK_GOTO_LAST)
nav_row.pack_start(first_button)
nav_row.pack_start(back_button)
nav_row.pack_start(fwd_button)
nav_row.pack_start(last_button)
first_button.connect('clicked', self.do_first_move)
back_button.connect('clicked', self.do_back_move)
fwd_button.connect('clicked', self.do_forward_move)
last_button.connect('clicked', self.do_last_move)
info_box.pack_start(nav_row, expand=False)
self.update_info()
@ -122,6 +141,26 @@ class GoGame(gtk.HBox):
self.update(changed)
def do_back_move(self, widget):
self.goban.play_to_move_n(self.goban.move - 1)
self.update()
def do_forward_move(self, widget):
self.goban.play_to_move_n(self.goban.move + 1)
self.update()
def do_first_move(self, widget):
self.goban.soft_reset()
self.update()
def do_last_move(self, widget):
self.goban.play_to_move_n()
self.update()
def do_board_configure(self, widget, event):
gc = widget.get_style().fg_gc[gtk.STATE_NORMAL]
x,y,width,height = widget.get_allocation()