diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index dd58fd9a..47e55838 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -107,6 +107,7 @@ class Terminal(gtk.VBox): composite_support = None cnxids = None + targets_for_new_group = None def __init__(self): """Class initialiser""" @@ -119,6 +120,7 @@ class Terminal(gtk.VBox): # FIXME: Surely these should happen in Terminator::register_terminal()? self.connect('enumerate', self.terminator.do_enumerate) self.connect('focus-in', self.terminator.focus_changed) + self.connect('focus-out', self.terminator.focus_left) self.matches = {} self.cnxids = Signalman() diff --git a/terminatorlib/terminator.py b/terminatorlib/terminator.py index 54226838..5bea899a 100755 --- a/terminatorlib/terminator.py +++ b/terminatorlib/terminator.py @@ -349,19 +349,21 @@ class Terminator(Borg): idx = terminals.index(term) term.feed(numstr % (idx + 1)) + def get_sibling_terms(self, widget): + termset = [] + for term in self.terminals: + if term.group == widget.group: + termset.append(term) + return(termset) + def get_target_terms(self, widget): """Get the terminals we should currently be broadcasting to""" if self.groupsend == self.groupsend_type['all']: return(self.terminals) elif self.groupsend == self.groupsend_type['group']: - termset = [] - for term in self.terminals: - if term == widget or (term.group != None and term.group == - widget.group): - termset.append(term) - return(termset) - else: - return([widget]) + if widget.group != None: + return(self.get_sibling_terms(widget)) + return([widget]) def get_focussed_terminal(self): """iterate over all the terminals to find which, if any, has focus""" @@ -376,6 +378,9 @@ class Terminator(Borg): terminal.titlebar.update(widget) return + def focus_left(self, widget): + self.last_focused_term=widget + def describe_layout(self): """Describe our current layout""" layout = {} diff --git a/terminatorlib/titlebar.py b/terminatorlib/titlebar.py index 18aada45..e9ee73fb 100755 --- a/terminatorlib/titlebar.py +++ b/terminatorlib/titlebar.py @@ -93,7 +93,7 @@ class Titlebar(gtk.EventBox): def connect_icon(self, func): """Connect the supplied function to clicking on the group icon""" - self.ebox.connect('button-release-event', func) + self.ebox.connect('button-press-event', func) def update(self, other=None): """Update our contents""" @@ -252,7 +252,14 @@ class Titlebar(gtk.EventBox): groupname = self.groupentry.get_text() dbg('Titlebar::groupentry_activate: creating group: %s' % groupname) self.groupentry_cancel(None, None) - self.emit('create-group', groupname) + last_focused_term=self.terminator.last_focused_term + if self.terminal.targets_for_new_group: + [term.titlebar.emit('create-group', groupname) for term in self.terminal.targets_for_new_group] + self.terminal.targets_for_new_group = None + else: + self.emit('create-group', groupname) + last_focused_term.grab_focus() + self.terminator.focus_changed(last_focused_term) def groupentry_keypress(self, widget, event): """Handle keypresses on the entry widget"""