From 3951acedf6a576e6938b574e1ee5032466abf438 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Sun, 24 Jun 2012 20:22:21 +0200 Subject: [PATCH 1/4] Hide the group label while editing the group --- terminatorlib/titlebar.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/terminatorlib/titlebar.py b/terminatorlib/titlebar.py index 7f2e23fb..91e4b2bc 100755 --- a/terminatorlib/titlebar.py +++ b/terminatorlib/titlebar.py @@ -234,6 +234,7 @@ class Titlebar(gtk.EventBox): def create_group(self): """Create a new group""" self.groupentry.show() + self.grouplabel.hide() self.groupentry.grab_focus() self.update_visibility() @@ -241,6 +242,7 @@ class Titlebar(gtk.EventBox): """Hide the group name entry""" self.groupentry.set_text('') self.groupentry.hide() + self.grouplabel.show() self.get_parent().grab_focus() def groupentry_activate(self, widget): From 11eb98f2e3fbb839fa9339d32f7e6623c1a7a0d8 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Sun, 24 Jun 2012 20:23:35 +0200 Subject: [PATCH 2/4] Set edit widget to current group when editing --- terminatorlib/titlebar.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/terminatorlib/titlebar.py b/terminatorlib/titlebar.py index 91e4b2bc..18aada45 100755 --- a/terminatorlib/titlebar.py +++ b/terminatorlib/titlebar.py @@ -233,6 +233,8 @@ class Titlebar(gtk.EventBox): def create_group(self): """Create a new group""" + if self.terminal.group: + self.groupentry.set_text(self.terminal.group) self.groupentry.show() self.grouplabel.hide() self.groupentry.grab_focus() From b85f7c402c00a0c91239b640f5c1ba6bf5c1afc0 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Sun, 24 Jun 2012 20:36:39 +0200 Subject: [PATCH 3/4] Collection of changes that don't add/remove anything, but needed for next checkin to work --- terminatorlib/terminal.py | 2 ++ terminatorlib/terminator.py | 21 +++++++++++++-------- terminatorlib/titlebar.py | 11 +++++++++-- 3 files changed, 24 insertions(+), 10 deletions(-) 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""" From 618e38d18bffaccca53cbb2d97934348ef9fcd92 Mon Sep 17 00:00:00 2001 From: Stephen Boddy Date: Sun, 24 Jun 2012 20:42:12 +0200 Subject: [PATCH 4/4] Clicking with modifier on the group button gives more powerful control. (Shift: Rename, Ctrl: Join current, Super: Include siblings) --- terminatorlib/terminal.py | 35 ++++++++++++++++++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index 47e55838..5add2820 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -772,7 +772,40 @@ class Terminal(gtk.VBox): def on_group_button_press(self, widget, event): """Handler for the group button""" if event.button == 1: - self.create_popup_group_menu(widget, event) + if event.type == gtk.gdk._2BUTTON_PRESS or \ + event.type == gtk.gdk._3BUTTON_PRESS: + # Ignore these, or they make the interaction bad + return False + # Super key applies interaction to all terms in group + include_siblings=event.state & gtk.gdk.MOD4_MASK == gtk.gdk.MOD4_MASK + if include_siblings: + targets=self.terminator.get_sibling_terms(self) + else: + targets=[self] + if event.state & gtk.gdk.CONTROL_MASK == gtk.gdk.CONTROL_MASK: + dbg('on_group_button_press: toggle terminal to focused terminals group') + focused=self.get_toplevel().get_focussed_terminal() + if focused in targets: targets.remove(focused) + if self != focused: + if self.group==focused.group: + new_group=None + else: + new_group=focused.group + [term.set_group(None, new_group) for term in targets] + [term.titlebar.update(focused) for term in targets] + return True + elif event.state & gtk.gdk.SHIFT_MASK == gtk.gdk.SHIFT_MASK: + dbg('on_group_button_press: rename of terminals group') + self.targets_for_new_group = targets + self.titlebar.create_group() + return True + elif event.type == gtk.gdk.BUTTON_PRESS: + # Single Click gives popup + dbg('on_group_button_press: group menu popup') + self.create_popup_group_menu(widget, event) + return True + else: + dbg('on_group_button_press: unknown group button interaction') return(False) def on_keypress(self, widget, event):