work on grouping/ungrouping of all terminals in a tab

This commit is contained in:
Chris Jones 2009-09-05 00:34:09 +01:00
parent bb073887fc
commit 5e54d42eca
3 changed files with 31 additions and 3 deletions

View File

@ -93,4 +93,11 @@ class Terminator(Borg):
else: else:
return([widget]) return([widget])
def group_tab(self, widget):
"""Group all the terminals in a tab"""
pass
def ungroup_tab(self, widget):
"""Ungroup all the terminals in a tab"""
pass
# vim: set expandtab ts=4 sw=4: # vim: set expandtab ts=4 sw=4:

View File

@ -11,7 +11,7 @@ pygtk.require('2.0')
import gtk import gtk
import gobject import gobject
from util import dbg, err, gerr from util import dbg, err, gerr, has_ancestor
from config import Config from config import Config
from cwd import get_default_cwd from cwd import get_default_cwd
from newterminator import Terminator from newterminator import Terminator
@ -35,6 +35,8 @@ class Terminal(gtk.VBox):
(gobject.TYPE_STRING,)), (gobject.TYPE_STRING,)),
'enumerate': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, 'enumerate': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_INT,)), (gobject.TYPE_INT,)),
'group-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'ungroup-tab': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
} }
TARGET_TYPE_VTE = 8 TARGET_TYPE_VTE = 8
@ -63,6 +65,8 @@ class Terminal(gtk.VBox):
self.terminator = Terminator() self.terminator = Terminator()
self.connect('enumerate', self.terminator.do_enumerate) self.connect('enumerate', self.terminator.do_enumerate)
self.connect('group-tab', self.terminator.group_tab)
self.connect('ungroup-tab', self.terminator.ungroup_tab)
self.matches = {} self.matches = {}
@ -277,7 +281,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)
# FIXME: Functions to group/ungroup all terms in current tab if has_ancestor(self, gtk.Notebook):
item = gtk.MenuItem(_('G_roup all in tab'))
item.connect('activate', lambda menu_item: self.emit('group_tab'))
menu.append(item)
if len(self.terminator.groups) > 0:
item = gtk.MenuItem(_('Ungr_oup all in tab'))
item.connect('activate', lambda menu_item:
self.emit('ungroup_tab'))
menu.append(item)
if len(self.terminator.groups) > 0: if len(self.terminator.groups) > 0:
item = gtk.MenuItem(_('Remove all groups')) item = gtk.MenuItem(_('Remove all groups'))

View File

@ -17,6 +17,7 @@
"""Terminator.util - misc utility functions""" """Terminator.util - misc utility functions"""
import sys import sys
import gtk
# set this to true to enable debugging output # set this to true to enable debugging output
DEBUG = True DEBUG = True
@ -34,8 +35,15 @@ def gerr(message = None):
"""Display a graphical error. This should only be used for serious """Display a graphical error. This should only be used for serious
errors as it will halt execution""" errors as it will halt execution"""
import gtk
dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL, dialog = gtk.MessageDialog(None, gtk.DIALOG_MODAL,
gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, message) gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, message)
dialog.run() dialog.run()
def has_ancestor(widget, type):
"""Walk up the family tree of widget to see if any ancestors are of type"""
while widget:
widget = widget.get_parent()
if isinstance(widget, type):
return(True)
return(False)