diff --git a/terminatorlib/config.py b/terminatorlib/config.py index a4c08a2f..d8a00833 100644 --- a/terminatorlib/config.py +++ b/terminatorlib/config.py @@ -187,6 +187,9 @@ DEFAULTS = { 'group_all' : 'g', 'group_all_toggle' : '', 'ungroup_all' : 'g', + 'group_win' : '', + 'group_win_toggle' : '', + 'ungroup_win' : 'w', 'group_tab' : 't', 'group_tab_toggle' : '', 'ungroup_tab' : 't', diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index e7345a52..69d8216e 100644 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -264,6 +264,9 @@ class Notebook(Container, Gtk.Notebook): 'group-all': top_window.group_all, 'group-all-toggle': top_window.group_all_toggle, '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-toggle': top_window.group_tab_toggle, 'ungroup-tab': top_window.ungroup_tab, diff --git a/terminatorlib/paned.py b/terminatorlib/paned.py index 3f6d7f1d..0eea6d61 100644 --- a/terminatorlib/paned.py +++ b/terminatorlib/paned.py @@ -103,6 +103,9 @@ class Paned(Container): 'group-all': top_window.group_all, 'group-all-toggle': top_window.group_all_toggle, '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-toggle': top_window.group_tab_toggle, 'ungroup-tab': top_window.ungroup_tab, diff --git a/terminatorlib/prefseditor.py b/terminatorlib/prefseditor.py index ad36213d..4512c32a 100755 --- a/terminatorlib/prefseditor.py +++ b/terminatorlib/prefseditor.py @@ -161,6 +161,9 @@ class PrefsEditor: 'group_all' : _('Group all terminals'), 'group_all_toggle' : _('Group/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_toggle' : _('Group/Ungroup terminals in tab'), 'ungroup_tab' : _('Ungroup terminals in tab'), diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 36ba2586..0226cc1b 100644 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -69,6 +69,9 @@ class Terminal(Gtk.VBox): 'group-all-toggle': (GObject.SignalFlags.RUN_LAST, None, ()), 'move-tab': (GObject.SignalFlags.RUN_LAST, None, (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 @@ -510,6 +513,16 @@ class Terminal(Gtk.VBox): item.connect('activate', self.ungroup, self.group) 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): item = Gtk.MenuItem.new_with_mnemonic(_('G_roup all in tab')) item.connect('activate', lambda x: self.emit('group_tab')) @@ -583,7 +596,7 @@ class Terminal(Gtk.VBox): if self.group == name: # already in this group, no action needed return - dbg('Terminal::set_group: Setting group to %s' % name) + dbg('Setting group to %s' % name) self.group = name self.titlebar.set_group_label(name) self.terminator.group_hoover() @@ -1918,6 +1931,16 @@ class Terminal(Gtk.VBox): def key_ungroup_all(self): 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): self.emit('group-tab') diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 6cbf4d68..729c7513 100644 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -589,7 +589,7 @@ class Terminator(Borg): for term in self.get_target_terms(widget): idx = terminals.index(term) - term.feed(numstr % (idx + 1)) + term.feed(numstr.encode() % (idx + 1)) def get_sibling_terms(self, widget): termset = [] diff --git a/terminatorlib/window.py b/terminatorlib/window.py index ee02ffb2..0b77b40d 100644 --- a/terminatorlib/window.py +++ b/terminatorlib/window.py @@ -421,6 +421,9 @@ class Window(Container, Gtk.Window): 'group-all': self.group_all, 'group-all-toggle': self.group_all_toggle, '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-toggle': self.group_tab_toggle, 'ungroup-tab': self.ungroup_tab, @@ -574,6 +577,9 @@ class Window(Container, Gtk.Window): self.set_pos_by_ratio = False + def get_terminals(self): + return(util.enumerate_descendants(self)[1]) + def get_visible_terminals(self): """Walk down the widget tree to find all of the visible terminals. Mostly using Container::get_visible_terminals()""" @@ -733,6 +739,25 @@ class Window(Container, Gtk.Window): """Ungroup all 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): """Group all terminals in the current tab""" maker = Factory()