add group all terminals in window

This commit is contained in:
Matt Rose 2021-08-06 18:38:27 -04:00
parent 550ccf7abf
commit b80d133ccf
7 changed files with 62 additions and 2 deletions

View File

@ -187,6 +187,9 @@ DEFAULTS = {
'group_all' : '<Super>g', 'group_all' : '<Super>g',
'group_all_toggle' : '', 'group_all_toggle' : '',
'ungroup_all' : '<Shift><Super>g', 'ungroup_all' : '<Shift><Super>g',
'group_win' : '',
'group_win_toggle' : '',
'ungroup_win' : '<Shift><Super>w',
'group_tab' : '<Super>t', 'group_tab' : '<Super>t',
'group_tab_toggle' : '', 'group_tab_toggle' : '',
'ungroup_tab' : '<Shift><Super>t', 'ungroup_tab' : '<Shift><Super>t',

View File

@ -264,6 +264,9 @@ class Notebook(Container, Gtk.Notebook):
'group-all': top_window.group_all, 'group-all': top_window.group_all,
'group-all-toggle': top_window.group_all_toggle, 'group-all-toggle': top_window.group_all_toggle,
'ungroup-all': top_window.ungroup_all, 'ungroup-all': top_window.ungroup_all,
'group-win': top_window.group_win,
'group-win-toggle': top_window.group_win_toggle,
'ungroup-win': top_window.ungroup_win,
'group-tab': top_window.group_tab, 'group-tab': top_window.group_tab,
'group-tab-toggle': top_window.group_tab_toggle, 'group-tab-toggle': top_window.group_tab_toggle,
'ungroup-tab': top_window.ungroup_tab, 'ungroup-tab': top_window.ungroup_tab,

View File

@ -103,6 +103,9 @@ class Paned(Container):
'group-all': top_window.group_all, 'group-all': top_window.group_all,
'group-all-toggle': top_window.group_all_toggle, 'group-all-toggle': top_window.group_all_toggle,
'ungroup-all': top_window.ungroup_all, 'ungroup-all': top_window.ungroup_all,
'group-win': top_window.group_win,
'group-win-toggle': top_window.group_win_toggle,
'ungroup-win': top_window.ungroup_win,
'group-tab': top_window.group_tab, 'group-tab': top_window.group_tab,
'group-tab-toggle': top_window.group_tab_toggle, 'group-tab-toggle': top_window.group_tab_toggle,
'ungroup-tab': top_window.ungroup_tab, 'ungroup-tab': top_window.ungroup_tab,

View File

@ -161,6 +161,9 @@ class PrefsEditor:
'group_all' : _('Group all terminals'), 'group_all' : _('Group all terminals'),
'group_all_toggle' : _('Group/Ungroup all terminals'), 'group_all_toggle' : _('Group/Ungroup all terminals'),
'ungroup_all' : _('Ungroup all terminals'), 'ungroup_all' : _('Ungroup all terminals'),
'group_win' : _('Group terminals in window'),
'group_win_toggle' : _('Group/Ungroup terminals in window'),
'ungroup_win' : _('Ungroup terminals in window'),
'group_tab' : _('Group terminals in tab'), 'group_tab' : _('Group terminals in tab'),
'group_tab_toggle' : _('Group/Ungroup terminals in tab'), 'group_tab_toggle' : _('Group/Ungroup terminals in tab'),
'ungroup_tab' : _('Ungroup terminals in tab'), 'ungroup_tab' : _('Ungroup terminals in tab'),

View File

@ -69,6 +69,9 @@ class Terminal(Gtk.VBox):
'group-all-toggle': (GObject.SignalFlags.RUN_LAST, None, ()), 'group-all-toggle': (GObject.SignalFlags.RUN_LAST, None, ()),
'move-tab': (GObject.SignalFlags.RUN_LAST, None, 'move-tab': (GObject.SignalFlags.RUN_LAST, None,
(GObject.TYPE_STRING,)), (GObject.TYPE_STRING,)),
'group-win': (GObject.SignalFlags.RUN_LAST, None, ()),
'group-win-toggle': (GObject.SignalFlags.RUN_LAST, None, ()),
'ungroup-win': (GObject.SignalFlags.RUN_LAST, None, ()),
} }
TARGET_TYPE_VTE = 8 TARGET_TYPE_VTE = 8
@ -510,6 +513,16 @@ class Terminal(Gtk.VBox):
item.connect('activate', self.ungroup, self.group) item.connect('activate', self.ungroup, self.group)
menu.append(item) menu.append(item)
if util.has_ancestor(self, Gtk.Window):
item = Gtk.MenuItem.new_with_mnemonic(_('G_roup all in window'))
item.connect('activate', lambda x: self.emit('group_win'))
menu.append(item)
if len(self.terminator.groups) > 0:
item = Gtk.MenuItem.new_with_mnemonic(_('Ungro_up all in window'))
item.connect('activate', lambda x: self.emit('ungroup_win'))
menu.append(item)
if util.has_ancestor(self, Gtk.Notebook): if util.has_ancestor(self, Gtk.Notebook):
item = Gtk.MenuItem.new_with_mnemonic(_('G_roup all in tab')) item = Gtk.MenuItem.new_with_mnemonic(_('G_roup all in tab'))
item.connect('activate', lambda x: self.emit('group_tab')) item.connect('activate', lambda x: self.emit('group_tab'))
@ -583,7 +596,7 @@ class Terminal(Gtk.VBox):
if self.group == name: if self.group == name:
# already in this group, no action needed # already in this group, no action needed
return return
dbg('Terminal::set_group: Setting group to %s' % name) dbg('Setting group to %s' % name)
self.group = name self.group = name
self.titlebar.set_group_label(name) self.titlebar.set_group_label(name)
self.terminator.group_hoover() self.terminator.group_hoover()
@ -1918,6 +1931,16 @@ class Terminal(Gtk.VBox):
def key_ungroup_all(self): def key_ungroup_all(self):
self.emit('ungroup-all') self.emit('ungroup-all')
def key_group_win(self):
dbg("Group Win")
self.emit('group-win')
def key_group_win_toggle(self):
self.emit('group-win-toggle')
def key_ungroup_win(self):
self.emit('ungroup-win')
def key_group_tab(self): def key_group_tab(self):
self.emit('group-tab') self.emit('group-tab')

View File

@ -589,7 +589,7 @@ class Terminator(Borg):
for term in self.get_target_terms(widget): for term in self.get_target_terms(widget):
idx = terminals.index(term) idx = terminals.index(term)
term.feed(numstr % (idx + 1)) term.feed(numstr.encode() % (idx + 1))
def get_sibling_terms(self, widget): def get_sibling_terms(self, widget):
termset = [] termset = []

View File

@ -421,6 +421,9 @@ class Window(Container, Gtk.Window):
'group-all': self.group_all, 'group-all': self.group_all,
'group-all-toggle': self.group_all_toggle, 'group-all-toggle': self.group_all_toggle,
'ungroup-all': self.ungroup_all, 'ungroup-all': self.ungroup_all,
'group-win': self.group_win,
'group-win-toggle': self.group_win_toggle,
'ungroup-win': self.ungroup_win,
'group-tab': self.group_tab, 'group-tab': self.group_tab,
'group-tab-toggle': self.group_tab_toggle, 'group-tab-toggle': self.group_tab_toggle,
'ungroup-tab': self.ungroup_tab, 'ungroup-tab': self.ungroup_tab,
@ -574,6 +577,9 @@ class Window(Container, Gtk.Window):
self.set_pos_by_ratio = False self.set_pos_by_ratio = False
def get_terminals(self):
return(util.enumerate_descendants(self)[1])
def get_visible_terminals(self): def get_visible_terminals(self):
"""Walk down the widget tree to find all of the visible terminals. """Walk down the widget tree to find all of the visible terminals.
Mostly using Container::get_visible_terminals()""" Mostly using Container::get_visible_terminals()"""
@ -733,6 +739,25 @@ class Window(Container, Gtk.Window):
"""Ungroup all terminals""" """Ungroup all terminals"""
self.set_groups(None, self.terminator.terminals) self.set_groups(None, self.terminator.terminals)
def group_win(self, widget):
"""Group all terminals in the current window"""
# FIXME: Why isn't this being done by Terminator() ?
dbg("Group Windows")
group = _('Window group %s' % (len(self.terminator.groups) + 1))
self.terminator.create_group(group)
self.set_groups(group, self.get_terminals())
def group_win_toggle(self, widget):
"""Toggle grouping to all windows in the current window"""
if widget.group == 'Window':
self.ungroup_win(widget)
else:
self.group_win(widget)
def ungroup_win(self, widget):
"""Ungroup all terminals in the current window"""
self.set_groups(None, self.get_terminals())
def group_tab(self, widget): def group_tab(self, widget):
"""Group all terminals in the current tab""" """Group all terminals in the current tab"""
maker = Factory() maker = Factory()