Implemented reordering tabs and Ctrl+tab to cycle between them
This commit is contained in:
parent
794fb23d5f
commit
c8e8379308
40
pygo.py
40
pygo.py
|
@ -37,13 +37,30 @@ class Pygo():
|
|||
# gobject.timeout_add(1000, self.update)
|
||||
|
||||
|
||||
# fixme - ctrl+shift+tab just does a shift+tab, even with the return True...
|
||||
def on_key_pressed(self, widget, event):
|
||||
key = gtk.gdk.keyval_name(event.keyval)
|
||||
|
||||
if key == 'Tab' and event.state & gtk.gdk.CONTROL_MASK:
|
||||
if event.state & gtk.gdk.SHIFT_MASK:
|
||||
self.do_prev_page()
|
||||
else:
|
||||
self.do_next_page()
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def on_game_close(self, widget):
|
||||
if self.games.get_current_page() == -1:
|
||||
return
|
||||
|
||||
self.games.remove_page(self.games.get_current_page())
|
||||
|
||||
|
||||
def on_local_new(self, widget):
|
||||
game = gogame.GoGame(goban.Goban())
|
||||
self.games.append_page(game, gtk.Label('Local Game'))
|
||||
self.games.set_tab_reorderable(game, True)
|
||||
game.show_all()
|
||||
|
||||
|
||||
|
@ -55,6 +72,29 @@ class Pygo():
|
|||
sys.exit(0)
|
||||
|
||||
|
||||
def do_prev_page(self):
|
||||
'''Goes to the previous tab page, but looping if this is the first'''
|
||||
if self.games.get_current_page() == -1:
|
||||
return
|
||||
|
||||
new_page = self.games.get_current_page() - 1
|
||||
if new_page < 0:
|
||||
new_page = self.games.get_n_pages() - 1
|
||||
|
||||
self.games.set_current_page(new_page)
|
||||
|
||||
|
||||
def do_next_page(self):
|
||||
'''Goes to the next tab page, but looping if this is the last'''
|
||||
if self.games.get_current_page() == -1:
|
||||
return
|
||||
|
||||
new_page = self.games.get_current_page() + 1
|
||||
if new_page >= self.games.get_n_pages():
|
||||
new_page = 0
|
||||
|
||||
self.games.set_current_page(new_page)
|
||||
|
||||
|
||||
def main():
|
||||
# Read config file
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
<property name="gravity">GDK_GRAVITY_NORTH_WEST</property>
|
||||
<property name="focus_on_map">True</property>
|
||||
<property name="urgency_hint">False</property>
|
||||
<signal name="key_press_event" handler="on_key_pressed" last_modification_time="Thu, 19 Apr 2012 20:15:47 GMT"/>
|
||||
|
||||
<child>
|
||||
<widget class="GtkVBox" id="main_box">
|
||||
|
|
Loading…
Reference in New Issue
Block a user