Implement (un)group_all and (un)group_tab

This commit is contained in:
Chris Jones 2010-01-21 12:55:57 +00:00
parent 9c72b6287d
commit 14f98c1b89
4 changed files with 64 additions and 10 deletions

View File

@ -41,7 +41,12 @@ class Notebook(Container, gtk.Notebook):
def configure(self): def configure(self):
"""Apply widget-wide settings""" """Apply widget-wide settings"""
# FIXME: Should all of our widgets have this? # FIXME: Should all of our widgets have a ::configure()?
# FIXME: The old reordered handler updated Terminator.terminals with
# the new order of terminals. We probably need to preserve this for
# navigation to next/prev terminals.
#self.connect('page-reordered', self.on_page_reordered) #self.connect('page-reordered', self.on_page_reordered)
self.set_property('homogeneous', not self.config['scroll_tabbar']) self.set_property('homogeneous', not self.config['scroll_tabbar'])
self.set_scrollable(self.config['scroll_tabbar']) self.set_scrollable(self.config['scroll_tabbar'])

View File

@ -79,7 +79,6 @@ class Paned(Container):
if maker.isinstance(widget, 'Terminal'): if maker.isinstance(widget, 'Terminal'):
top_window = get_top_window(self) top_window = get_top_window(self)
signals = {'close-term': self.wrapcloseterm, signals = {'close-term': self.wrapcloseterm,
'split-horiz': self.split_horiz, 'split-horiz': self.split_horiz,
'split-vert': self.split_vert, 'split-vert': self.split_vert,
@ -90,8 +89,14 @@ class Paned(Container):
for signal in signals: for signal in signals:
self.connect_child(widget, signal, signals[signal]) self.connect_child(widget, signal, signals[signal])
# FIXME: We shouldn't be doing this exact same thing in each
# Container
self.connect_child(widget, 'maximise', top_window.zoom, False) self.connect_child(widget, 'maximise', top_window.zoom, False)
self.connect_child(widget, 'tab-change', top_window.tab_change) self.connect_child(widget, 'tab-change', top_window.tab_change)
self.connect_child(widget, 'group-all', top_window.group_all)
self.connect_child(widget, 'ungroup-all', top_window.ungroup_all)
self.connect_child(widget, 'group-tab', top_window.group_tab)
self.connect_child(widget, 'ungroup-tab', top_window.ungroup_tab)
widget.grab_focus() widget.grab_focus()

View File

@ -58,6 +58,10 @@ class Terminal(gtk.VBox):
(gobject.TYPE_STRING,)), (gobject.TYPE_STRING,)),
'tab-change': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, 'tab-change': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE,
(gobject.TYPE_INT,)), (gobject.TYPE_INT,)),
'group-all': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'ungroup-all': (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ()),
'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
@ -1241,20 +1245,16 @@ for %s (%s)' % (name, urlplugin.__class__.__name__))
self.vte.reset (True, True) self.vte.reset (True, True)
def key_group_all(self): def key_group_all(self):
# FIXME: Implement this self.emit('group-all')
self.group_all(self)
def key_ungroup_all(self): def key_ungroup_all(self):
# FIXME: Implement this self.emit('ungroup-all')
self.ungroup_all(self)
def key_group_tab(self): def key_group_tab(self):
# FIXME: Implement this self.emit('group-tab')
self.group_tab(self)
def key_ungroup_tab(self): def key_ungroup_tab(self):
# FIXME: IMplement this self.emit('ungroup-tab')
self.ungroup_tab(self)
def key_new_window(self): def key_new_window(self):
cmd = sys.argv[0] cmd = sys.argv[0]

View File

@ -405,6 +405,50 @@ class Window(Container, gtk.Window):
# change # change
child.set_current_page(child.get_current_page()) child.set_current_page(child.get_current_page())
# FIXME: All of these (un)group_(all|tab) methods need refactoring work
def group_all(self, widget):
"""Group all terminals"""
# FIXME: Why isn't this being done by Terminator() ?
group = _('All')
self.terminator.create_group(group)
for terminal in self.terminator.terminals:
terminal.set_group(None, group)
def ungroup_all(self, widget):
"""Ungroup all terminals"""
for terminal in self.terminator.terminals:
terminal.set_group(None, None)
def group_tab(self, widget):
"""Group all terminals in the current tab"""
maker = Factory()
notebook = self.get_child()
if not maker.isinstance(notebook, 'Notebook'):
dbg('not in a notebook, refusing to group tab')
return
pagenum = notebook.get_current_page()
while True:
group = _('Tab %d') % pagenum
if group not in self.terminator.groups:
break
pagenum += 1
for terminal in self.get_visible_terminals():
terminal.set_group(None, group)
def ungroup_tab(self, widget):
"""Ungroup all terminals in the current tab"""
maker = Factory()
notebook = self.get_child()
if not maker.isinstance(notebook, 'Notebook'):
dbg('note in a notebook, refusing to ungroup tab')
return
for terminal in self.get_visible_terminals():
terminal.set_group(None, None)
class WindowTitle(object): class WindowTitle(object):
"""Class to handle the setting of the window title""" """Class to handle the setting of the window title"""