Make the move-tab keyboard shortcuts work
This commit is contained in:
parent
9f348c349a
commit
ab02add397
|
@ -118,7 +118,8 @@ class Notebook(Container, gtk.Notebook):
|
||||||
'group-all': top_window.group_all,
|
'group-all': top_window.group_all,
|
||||||
'ungroup-all': top_window.ungroup_all,
|
'ungroup-all': top_window.ungroup_all,
|
||||||
'group-tab': top_window.group_tab,
|
'group-tab': top_window.group_tab,
|
||||||
'ungroup-tab': top_window.ungroup_tab}
|
'ungroup-tab': top_window.ungroup_tab,
|
||||||
|
'move-tab': top_window.move_tab}
|
||||||
|
|
||||||
if maker.isinstance(widget, 'Terminal'):
|
if maker.isinstance(widget, 'Terminal'):
|
||||||
for signal in signals:
|
for signal in signals:
|
||||||
|
|
|
@ -90,6 +90,7 @@ class Paned(Container):
|
||||||
'ungroup-all': top_window.ungroup_all,
|
'ungroup-all': top_window.ungroup_all,
|
||||||
'group-tab': top_window.group_tab,
|
'group-tab': top_window.group_tab,
|
||||||
'ungroup-tab': top_window.ungroup_tab,
|
'ungroup-tab': top_window.ungroup_tab,
|
||||||
|
'move-tab': top_window.move_tab,
|
||||||
'maximise': [top_window.zoom, False]}
|
'maximise': [top_window.zoom, False]}
|
||||||
|
|
||||||
for signal in signals:
|
for signal in signals:
|
||||||
|
|
|
@ -1223,11 +1223,9 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
|
||||||
def key_resize_right(self):
|
def key_resize_right(self):
|
||||||
self.emit('resize-term', 'right')
|
self.emit('resize-term', 'right')
|
||||||
|
|
||||||
# FIXME: Nothing currently handles this signal. Make it so something does.
|
|
||||||
def key_move_tab_right(self):
|
def key_move_tab_right(self):
|
||||||
self.emit('move-tab', 'right')
|
self.emit('move-tab', 'right')
|
||||||
|
|
||||||
# FIXME: Nothing currently handles this signal. Make it so something does.
|
|
||||||
def key_move_tab_left(self):
|
def key_move_tab_left(self):
|
||||||
self.emit('move-tab', 'left')
|
self.emit('move-tab', 'left')
|
||||||
|
|
||||||
|
|
|
@ -258,7 +258,8 @@ class Window(Container, gtk.Window):
|
||||||
'group-all': self.group_all,
|
'group-all': self.group_all,
|
||||||
'ungroup-all': self.ungroup_all,
|
'ungroup-all': self.ungroup_all,
|
||||||
'group-tab': self.group_tab,
|
'group-tab': self.group_tab,
|
||||||
'ungroup-tab': self.ungroup_tab}
|
'ungroup-tab': self.ungroup_tab,
|
||||||
|
'move-tab': self.move_tab}
|
||||||
|
|
||||||
for signal in signals:
|
for signal in signals:
|
||||||
self.connect_child(widget, signal, signals[signal])
|
self.connect_child(widget, signal, signals[signal])
|
||||||
|
@ -405,6 +406,8 @@ class Window(Container, gtk.Window):
|
||||||
pages = child.get_n_pages()
|
pages = child.get_n_pages()
|
||||||
if cur == pages - 1:
|
if cur == pages - 1:
|
||||||
num = 0
|
num = 0
|
||||||
|
else:
|
||||||
|
num = cur + 1
|
||||||
elif num == -2:
|
elif num == -2:
|
||||||
# Go to the previous tab
|
# Go to the previous tab
|
||||||
cur = child.get_current_page()
|
cur = child.get_current_page()
|
||||||
|
@ -463,6 +466,36 @@ class Window(Container, gtk.Window):
|
||||||
for terminal in self.get_visible_terminals():
|
for terminal in self.get_visible_terminals():
|
||||||
terminal.set_group(None, None)
|
terminal.set_group(None, None)
|
||||||
|
|
||||||
|
def move_tab(self, widget, direction):
|
||||||
|
"""Handle a keyboard shortcut for moving tab positions"""
|
||||||
|
maker = Factory()
|
||||||
|
notebook = self.get_child()
|
||||||
|
|
||||||
|
if not maker.isinstance(notebook, 'Notebook'):
|
||||||
|
dbg('not in a notebook, refusing to move tab %s' % direction)
|
||||||
|
return
|
||||||
|
|
||||||
|
dbg('moving tab %s' % direction)
|
||||||
|
numpages = notebook.get_n_pages()
|
||||||
|
page = notebook.get_current_page()
|
||||||
|
child = notebook.get_nth_page(page)
|
||||||
|
|
||||||
|
if direction == 'left':
|
||||||
|
if page == 0:
|
||||||
|
page = numpages
|
||||||
|
else:
|
||||||
|
page = page - 1
|
||||||
|
elif direction == 'right':
|
||||||
|
if page == numpages - 1:
|
||||||
|
page = 0
|
||||||
|
else:
|
||||||
|
page = page + 1
|
||||||
|
else:
|
||||||
|
err('unknown direction: %s' % direction)
|
||||||
|
return
|
||||||
|
|
||||||
|
notebook.reorder_child(child, page)
|
||||||
|
|
||||||
class WindowTitle(object):
|
class WindowTitle(object):
|
||||||
"""Class to handle the setting of the window title"""
|
"""Class to handle the setting of the window title"""
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue