Additional shortcuts/code to toggle All/Tab grouping

This commit is contained in:
Stephen Boddy 2014-01-24 23:29:07 +01:00
parent c78612215c
commit 106afb85df
7 changed files with 43 additions and 21 deletions

View File

@ -163,8 +163,10 @@ DEFAULTS = {
'reset_clear' : '<Shift><Control>g',
'hide_window' : '<Shift><Control><Alt>a',
'group_all' : '<Super>g',
'group_all_toggle' : '',
'ungroup_all' : '<Shift><Super>g',
'group_tab' : '<Super>t',
'group_tab_toggle' : '',
'ungroup_tab' : '<Shift><Super>t',
'new_window' : '<Shift><Control>i',
'new_terminator' : '<Super>i',

View File

@ -236,8 +236,10 @@ class Notebook(Container, gtk.Notebook):
'unzoom': self.unzoom,
'tab-change': top_window.tab_change,
'group-all': top_window.group_all,
'group-all-toggle': top_window.group_all_toggle,
'ungroup-all': top_window.ungroup_all,
'group-tab': top_window.group_tab,
'group-tab-toggle': top_window.group_tab_toggle,
'ungroup-tab': top_window.ungroup_tab,
'move-tab': top_window.move_tab,
'tab-new': [top_window.tab_new, widget],

View File

@ -98,8 +98,10 @@ class Paned(Container):
'zoom': top_window.zoom,
'tab-change': top_window.tab_change,
'group-all': top_window.group_all,
'group-all-toggle': top_window.group_all_toggle,
'ungroup-all': top_window.ungroup_all,
'group-tab': top_window.group_tab,
'group-tab-toggle': top_window.group_tab_toggle,
'ungroup-tab': top_window.ungroup_tab,
'move-tab': top_window.move_tab,
'maximise': [top_window.zoom, False],

View File

@ -134,8 +134,10 @@ class PrefsEditor:
'reset_clear' : 'Reset and clear the terminal',
'hide_window' : 'Toggle window visibility',
'group_all' : 'Group all terminals',
'group_all_toggle' : 'Group/Ungroup all terminals',
'ungroup_all' : 'Ungroup all terminals',
'group_tab' : 'Group terminals in tab',
'group_tab_toggle' : 'Group/Ungroup terminals in tab',
'ungroup_tab' : 'Ungroup terminals in tab',
'new_window' : 'Create a new window',
'new_terminator' : 'Spawn a new Terminator process',

View File

@ -46,6 +46,7 @@ class Terminal(gtk.VBox):
'enumerate': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_INT,)),
'group-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'group-tab-toggle': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'ungroup-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'ungroup-all': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'split-horiz': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
@ -69,6 +70,7 @@ class Terminal(gtk.VBox):
'tab-change': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_INT,)),
'group-all': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'group-all-toggle': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'move-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_STRING,)),
}
@ -1669,12 +1671,18 @@ class Terminal(gtk.VBox):
def key_group_all(self):
self.emit('group-all')
def key_group_all_toggle(self):
self.emit('group-all-toggle')
def key_ungroup_all(self):
self.emit('ungroup-all')
def key_group_tab(self):
self.emit('group-tab')
def key_group_tab_toggle(self):
self.emit('group-tab-toggle')
def key_ungroup_tab(self):
self.emit('ungroup-tab')

View File

@ -159,7 +159,6 @@ class Terminator(Borg):
dbg('Terminator::register_terminal: registering %s:%s' %
(id(terminal), type(terminal)))
self.terminals.append(terminal)
terminal.connect('ungroup-all', self.ungroup_all)
def deregister_terminal(self, terminal):
"""De-register a terminal widget"""
@ -328,12 +327,6 @@ class Terminator(Borg):
dbg('Terminator::create_group: registering group %s' % name)
self.groups.append(name)
def ungroup_all(self, widget):
"""Remove all groups"""
for terminal in self.terminals:
terminal.set_group(None, None)
self.groups = []
def closegroupedterms(self, group):
"""Close all terminals in a group"""
for terminal in self.terminals[:]:

View File

@ -407,8 +407,10 @@ class Window(Container, gtk.Window):
'unzoom': self.unzoom,
'tab-change': self.tab_change,
'group-all': self.group_all,
'group-all-toggle': self.group_all_toggle,
'ungroup-all': self.ungroup_all,
'group-tab': self.group_tab,
'group-tab-toggle': self.group_tab_toggle,
'ungroup-tab': self.ungroup_tab,
'move-tab': self.move_tab,
'tab-new': [self.tab_new, widget],
@ -683,21 +685,29 @@ class Window(Container, gtk.Window):
# change
child.set_current_page(child.get_current_page())
# FIXME: All of these (un)group_(all|tab) methods need refactoring work
def set_groups(self, new_group, term_list):
"""Set terminals in term_list to new_group"""
for terminal in term_list:
terminal.set_group(None, new_group)
self.terminator.focus_changed(self.terminator.last_focused_term)
def group_all(self, widget):
"""Group all terminals"""
# FIXME: Why isn't this being done by Terminator() ?
group = _('All')
self.terminator.create_group(group)
for terminal in self.terminator.terminals:
terminal.set_group(None, group)
self.terminator.focus_changed(self.terminator.last_focused_term)
self.set_groups(group, self.terminator.terminals)
def group_all_toggle(self, widget):
"""Toggle grouping to all"""
if widget.group == 'All':
self.ungroup_all(widget)
else:
self.group_all(widget)
def ungroup_all(self, widget):
"""Ungroup all terminals"""
for terminal in self.terminator.terminals:
terminal.set_group(None, None)
self.terminator.focus_changed(self.terminator.last_focused_term)
self.set_groups(None, self.terminator.terminals)
def group_tab(self, widget):
"""Group all terminals in the current tab"""
@ -714,9 +724,14 @@ class Window(Container, gtk.Window):
if group not in self.terminator.groups:
break
pagenum += 1
for terminal in self.get_visible_terminals():
terminal.set_group(None, group)
self.terminator.focus_changed(self.terminator.last_focused_term)
self.set_groups(group, self.get_visible_terminals())
def group_tab_toggle(self, widget):
"""Blah"""
if widget.group and widget.group[:4] == 'Tab ':
self.ungroup_tab(widget)
else:
self.group_tab(widget)
def ungroup_tab(self, widget):
"""Ungroup all terminals in the current tab"""
@ -727,9 +742,7 @@ class Window(Container, gtk.Window):
dbg('note in a notebook, refusing to ungroup tab')
return
for terminal in self.get_visible_terminals():
terminal.set_group(None, None)
self.terminator.focus_changed(self.terminator.last_focused_term)
self.set_groups(None, self.get_visible_terminals())
def move_tab(self, widget, direction):
"""Handle a keyboard shortcut for moving tab positions"""