Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 365 #480

Merged
merged 1 commit into from
Aug 6, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions terminatorlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@
'group_all' : '<Super>g',
'group_all_toggle' : '',
'ungroup_all' : '<Shift><Super>g',
'group_win' : '',
'group_win_toggle' : '',
'ungroup_win' : '<Shift><Super>w',
'group_tab' : '<Super>t',
'group_tab_toggle' : '',
'ungroup_tab' : '<Shift><Super>t',
Expand Down
3 changes: 3 additions & 0 deletions terminatorlib/notebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ def newtab(self, debugtab=False, widget=None, cwd=None, metadata=None, profile=N
'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,
Expand Down
3 changes: 3 additions & 0 deletions terminatorlib/paned.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ def add(self, widget, metadata=None):
'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,
Expand Down
3 changes: 3 additions & 0 deletions terminatorlib/prefseditor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
Expand Down
25 changes: 24 additions & 1 deletion terminatorlib/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -510,6 +513,16 @@ def populate_group_menu(self):
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'))
Expand Down Expand Up @@ -583,7 +596,7 @@ def set_group(self, _item, name):
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()
Expand Down Expand Up @@ -1918,6 +1931,16 @@ def key_group_all_toggle(self):
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')

Expand Down
2 changes: 1 addition & 1 deletion terminatorlib/terminator.py
Original file line number Diff line number Diff line change
Expand Up @@ -589,7 +589,7 @@ def do_enumerate(self, widget, pad):

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 = []
Expand Down
25 changes: 25 additions & 0 deletions terminatorlib/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ def add(self, widget, metadata=None):
'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,
Expand Down Expand Up @@ -574,6 +577,9 @@ def rotate(self, widget, clockwise):

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()"""
Expand Down Expand Up @@ -733,6 +739,25 @@ def ungroup_all(self, widget):
"""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()
Expand Down