From 00b65a65df850a917cfe3a417730c17d7880a1ef Mon Sep 17 00:00:00 2001 From: Anna Wiggins Date: Tue, 17 Apr 2012 01:46:55 -0400 Subject: [PATCH] Added a way to close the currently open game, to ease transition to multiple games running at once --- pygo.py | 12 ++++++++---- ui/default.glade | 10 ++++++++++ widgets/gogame.py | 24 ++++++++++++------------ 3 files changed, 30 insertions(+), 16 deletions(-) diff --git a/pygo.py b/pygo.py index c9a7294..857139f 100755 --- a/pygo.py +++ b/pygo.py @@ -24,7 +24,7 @@ class Pygo(): self.our_color = None self.init_user_interface('./ui/default.glade') - self._init_widgets() + self.init_widgets() def init_user_interface(self, path_to_skin): @@ -34,18 +34,22 @@ class Pygo(): self.contents = self.tree.get_widget('main_box') - def _init_widgets(self): + def init_widgets(self): self.window.resize(1000,800) self.gogame = None # gobject.timeout_add(1000, self.update) + def on_game_close(self, widget): + print 'Pygo.on_game_close(): stub' + + def on_local_new(self, widget): if self.gogame: self.contents.remove(self.gogame) - del self.gogame + self.gogame = None if self.goban: - del self.goban + self.goban = None self.goban = goban.Goban() self.network_mode = False diff --git a/ui/default.glade b/ui/default.glade index 88d53f7..a5b1a40 100644 --- a/ui/default.glade +++ b/ui/default.glade @@ -40,6 +40,16 @@ + + + True + _Close + True + + + + + True diff --git a/widgets/gogame.py b/widgets/gogame.py index 03fec02..2027fb8 100644 --- a/widgets/gogame.py +++ b/widgets/gogame.py @@ -13,19 +13,19 @@ class GoGame(gtk.HBox): It also handles moves and other operations on the goban. """ - _img_res = None + img_res = None def __init__(self, goban): super(GoGame, self).__init__() self.goban = goban - if GoGame._img_res is None: - GoGame._img_res = _build_img_res() - self._init_widgets() + if GoGame.img_res is None: + GoGame.img_res = _build_img_res() + self.init_widgets() - def _init_widgets(self): + def init_widgets(self): self.board_area = gtk.DrawingArea() # All of this is to create the info box along the right side of the board @@ -54,8 +54,8 @@ class GoGame(gtk.HBox): self.pass_button = gtk.Button('Pass') self.resign_button = gtk.Button('Resign') - self.pass_button.connect('clicked', self._on_pass) - self.resign_button.connect('clicked', self._on_resign) + self.pass_button.connect('clicked', self.on_pass) + self.resign_button.connect('clicked', self.on_resign) info_box.pack_start(self.pass_button, expand=False, padding=10) info_box.pack_start(self.resign_button, expand=False, padding=10) @@ -64,18 +64,18 @@ class GoGame(gtk.HBox): self.pack_end(info_box, expand=False) - def _draw_board(self): + def draw_board(self): gc = self.board_area.get_style().fg_gc[gtk.STATE_NORMAL] # gtk.gdk.gdk_pixbuf_scale_simple(img, new_width, new_height, GDK_INTERP_BILINEAR) - def _on_pass(self, widget): - print 'GoGame._on_pass(): stub' + def on_pass(self, widget): + print 'GoGame.on_pass(): stub' - def _on_resign(self, widget): - print 'GoGame._on_resign(): stub' + def on_resign(self, widget): + print 'GoGame.on_resign(): stub'