Add context menu functionality for grouping/ungrouping all terminals in a tab. Closes LP#378603
This commit is contained in:
parent
18d4df6af8
commit
e77a3e6c07
|
@ -1317,10 +1317,23 @@ text/plain
|
||||||
item.connect ("activate", self.group_all)
|
item.connect ("activate", self.group_all)
|
||||||
widget.append (item)
|
widget.append (item)
|
||||||
|
|
||||||
|
if self.terminator.get_first_parent_widget (self, gtk.Notebook) is not None and \
|
||||||
|
not isinstance (self.get_parent(), gtk.Notebook):
|
||||||
|
item = gtk.MenuItem (_("G_roup all in tab"))
|
||||||
|
item.connect ("activate", self.group_tab)
|
||||||
|
widget.append (item)
|
||||||
|
|
||||||
if len (self.terminator.groupings) > 0:
|
if len (self.terminator.groupings) > 0:
|
||||||
item = gtk.MenuItem (_("_Ungroup all"))
|
item = gtk.MenuItem (_("_Ungroup all"))
|
||||||
item.connect ("activate", self.ungroup_all)
|
item.connect ("activate", self.ungroup_all)
|
||||||
widget.append (item)
|
widget.append (item)
|
||||||
|
|
||||||
|
if self.terminator.get_first_parent_widget(self, gtk.Notebook) is not None and \
|
||||||
|
not isinstance(self.get_parent(), gtk.Notebook) and \
|
||||||
|
len(self.terminator.groupings) > 0:
|
||||||
|
item = gtk.MenuItem(_("Ungr_oup all in tab"))
|
||||||
|
item.connect("activate", self.ungroup_tab)
|
||||||
|
widget.append(item)
|
||||||
|
|
||||||
def create_group (self, item):
|
def create_group (self, item):
|
||||||
win = gtk.Window ()
|
win = gtk.Window ()
|
||||||
|
@ -1348,11 +1361,15 @@ text/plain
|
||||||
|
|
||||||
def do_create_group (self, widget, window, entry):
|
def do_create_group (self, widget, window, entry):
|
||||||
name = entry.get_text ()
|
name = entry.get_text ()
|
||||||
self.terminator.groupings.append (name)
|
self.add_group(name)
|
||||||
self.set_group (None, name)
|
self.set_group (None, name)
|
||||||
|
|
||||||
window.destroy ()
|
window.destroy ()
|
||||||
|
|
||||||
|
def add_group (self, groupname):
|
||||||
|
if not groupname in self.terminator.groupings:
|
||||||
|
self.terminator.groupings.append(groupname)
|
||||||
|
|
||||||
def set_group (self, item, data):
|
def set_group (self, item, data):
|
||||||
if self._group == data:
|
if self._group == data:
|
||||||
# No action needed
|
# No action needed
|
||||||
|
@ -1367,8 +1384,7 @@ text/plain
|
||||||
|
|
||||||
def group_all (self, widget):
|
def group_all (self, widget):
|
||||||
allname = _("All")
|
allname = _("All")
|
||||||
if not allname in self.terminator.groupings:
|
self.add_group(allname)
|
||||||
self.terminator.groupings.append (allname)
|
|
||||||
for term in self.terminator.term_list:
|
for term in self.terminator.term_list:
|
||||||
term.set_group (None, allname)
|
term.set_group (None, allname)
|
||||||
self.terminator.group_hoover ()
|
self.terminator.group_hoover ()
|
||||||
|
@ -1378,6 +1394,49 @@ text/plain
|
||||||
term.set_group (None, None)
|
term.set_group (None, None)
|
||||||
self.terminator.group_hoover ()
|
self.terminator.group_hoover ()
|
||||||
|
|
||||||
|
def find_all_terms_in_tab (self, notebook, pagenum=-1):
|
||||||
|
if pagenum == -1:
|
||||||
|
pagenum = notebook.get_current_page()
|
||||||
|
notebookchild = notebook.get_nth_page(pagenum)
|
||||||
|
|
||||||
|
terms = []
|
||||||
|
|
||||||
|
for term in self.terminator.term_list:
|
||||||
|
termparent = term.get_parent()
|
||||||
|
while not isinstance(termparent, gtk.Window):
|
||||||
|
if termparent == notebookchild:
|
||||||
|
terms.append(term)
|
||||||
|
termparent = termparent.get_parent()
|
||||||
|
|
||||||
|
return terms
|
||||||
|
|
||||||
|
def group_tab (self, widget):
|
||||||
|
groupname = ""
|
||||||
|
notebook = self.terminator.get_first_parent_widget(self, gtk.Notebook)
|
||||||
|
pagenum = notebook.get_current_page()
|
||||||
|
notebookchild = notebook.get_nth_page(pagenum)
|
||||||
|
terms = self.find_all_terms_in_tab(notebook)
|
||||||
|
|
||||||
|
notebooktablabel = notebook.get_tab_label(notebookchild)
|
||||||
|
if notebooktablabel.custom is True:
|
||||||
|
groupname = notebooktablabel.get_title()
|
||||||
|
|
||||||
|
if groupname == "":
|
||||||
|
groupname = "Tab %d" % pagenum
|
||||||
|
|
||||||
|
self.add_group(groupname)
|
||||||
|
for term in terms:
|
||||||
|
term.set_group(None, groupname)
|
||||||
|
self.terminator.group_hoover()
|
||||||
|
|
||||||
|
def ungroup_tab (self, widget):
|
||||||
|
notebook = self.terminator.get_first_parent_widget(self, gtk.Notebook)
|
||||||
|
terms = self.find_all_terms_in_tab (notebook)
|
||||||
|
|
||||||
|
for term in terms:
|
||||||
|
term.set_group (None, None)
|
||||||
|
self.terminator.group_hoover()
|
||||||
|
|
||||||
def on_encoding_change (self, widget, encoding):
|
def on_encoding_change (self, widget, encoding):
|
||||||
current = self._vte.get_encoding ()
|
current = self._vte.get_encoding ()
|
||||||
if current != encoding:
|
if current != encoding:
|
||||||
|
|
Loading…
Reference in New Issue