Added a way to close the currently open game, to ease transition to multiple games running at once

This commit is contained in:
Anna Rose 2012-04-17 01:46:55 -04:00
parent cb0fdcf017
commit 00b65a65df
3 changed files with 30 additions and 16 deletions

12
pygo.py
View File

@ -24,7 +24,7 @@ class Pygo():
self.our_color = None self.our_color = None
self.init_user_interface('./ui/default.glade') self.init_user_interface('./ui/default.glade')
self._init_widgets() self.init_widgets()
def init_user_interface(self, path_to_skin): def init_user_interface(self, path_to_skin):
@ -34,18 +34,22 @@ class Pygo():
self.contents = self.tree.get_widget('main_box') self.contents = self.tree.get_widget('main_box')
def _init_widgets(self): def init_widgets(self):
self.window.resize(1000,800) self.window.resize(1000,800)
self.gogame = None self.gogame = None
# gobject.timeout_add(1000, self.update) # gobject.timeout_add(1000, self.update)
def on_game_close(self, widget):
print 'Pygo.on_game_close(): stub'
def on_local_new(self, widget): def on_local_new(self, widget):
if self.gogame: if self.gogame:
self.contents.remove(self.gogame) self.contents.remove(self.gogame)
del self.gogame self.gogame = None
if self.goban: if self.goban:
del self.goban self.goban = None
self.goban = goban.Goban() self.goban = goban.Goban()
self.network_mode = False self.network_mode = False

View File

@ -40,6 +40,16 @@
<child> <child>
<widget class="GtkMenu" id="game1_menu"> <widget class="GtkMenu" id="game1_menu">
<child>
<widget class="GtkMenuItem" id="close1">
<property name="visible">True</property>
<property name="label" translatable="yes">_Close</property>
<property name="use_underline">True</property>
<signal name="activate" handler="on_game_close" last_modification_time="Tue, 17 Apr 2012 05:44:12 GMT"/>
<accelerator key="W" modifiers="GDK_CONTROL_MASK" signal="activate"/>
</widget>
</child>
<child> <child>
<widget class="GtkImageMenuItem" id="quit"> <widget class="GtkImageMenuItem" id="quit">
<property name="visible">True</property> <property name="visible">True</property>

View File

@ -13,19 +13,19 @@ class GoGame(gtk.HBox):
It also handles moves and other operations on the goban. It also handles moves and other operations on the goban.
""" """
_img_res = None img_res = None
def __init__(self, goban): def __init__(self, goban):
super(GoGame, self).__init__() super(GoGame, self).__init__()
self.goban = goban self.goban = goban
if GoGame._img_res is None: if GoGame.img_res is None:
GoGame._img_res = _build_img_res() GoGame.img_res = _build_img_res()
self._init_widgets() self.init_widgets()
def _init_widgets(self): def init_widgets(self):
self.board_area = gtk.DrawingArea() self.board_area = gtk.DrawingArea()
# All of this is to create the info box along the right side of the board # 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.pass_button = gtk.Button('Pass')
self.resign_button = gtk.Button('Resign') self.resign_button = gtk.Button('Resign')
self.pass_button.connect('clicked', self._on_pass) self.pass_button.connect('clicked', self.on_pass)
self.resign_button.connect('clicked', self._on_resign) self.resign_button.connect('clicked', self.on_resign)
info_box.pack_start(self.pass_button, expand=False, padding=10) info_box.pack_start(self.pass_button, expand=False, padding=10)
info_box.pack_start(self.resign_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) 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] 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) # gtk.gdk.gdk_pixbuf_scale_simple(img, new_width, new_height, GDK_INTERP_BILINEAR)
def _on_pass(self, widget): def on_pass(self, widget):
print 'GoGame._on_pass(): stub' print 'GoGame.on_pass(): stub'
def _on_resign(self, widget): def on_resign(self, widget):
print 'GoGame._on_resign(): stub' print 'GoGame.on_resign(): stub'