diff --git a/terminatorlib/newterminator.py b/terminatorlib/newterminator.py index 3c8398b8..6829925d 100755 --- a/terminatorlib/newterminator.py +++ b/terminatorlib/newterminator.py @@ -103,6 +103,7 @@ class Terminator(Borg): def create_group(self, name): """Create a new group""" if name not in self.groups: + dbg('Terminator::create_group: registering group %s' % name) self.groups.append(name) def ungroup_all(self, widget): @@ -121,17 +122,20 @@ class Terminator(Borg): """Clean out unused groups""" if self.config['autoclean_groups']: + inuse = [] todestroy = [] + + for terminal in self.terminals: + if terminal.group: + if not terminal.group in inuse: + inuse.append(terminal.group) + for group in self.groups: - for terminal in self.terminals: - save = False - if terminal.group == group: - save = True - break - - if not save: - todestroy.append(group) + if not group in inuse: + todestroy.append(group) + dbg('Terminator::group_hoover: %d groups, hoovering %d' % + (len(self.groups), len(todestroy))) for group in todestroy: self.groups.remove(group) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 6d689649..da1ada97 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -285,7 +285,7 @@ class Terminal(gtk.VBox): item = gtk.MenuItem(_('New group...')) item.connect('activate', self.create_group) menu.append(item) - + if len(self.terminator.groups) > 0: groupitem = gtk.RadioMenuItem(groupitem, _('None')) groupitem.set_active(self.group == None) diff --git a/terminatorlib/titlebar.py b/terminatorlib/titlebar.py index f44c5571..852b2d11 100755 --- a/terminatorlib/titlebar.py +++ b/terminatorlib/titlebar.py @@ -136,7 +136,7 @@ class Titlebar(gtk.EventBox): def groupentry_activate(self, widget): """Actually cause a group to be created""" groupname = self.groupentry.get_text() - dbg('creating group: %s' % groupname) + dbg('Titlebar::groupentry_activate: creating group: %s' % groupname) self.groupentry_cancel(None, None) self.emit('create-group', groupname)