Merge lp:~stephen-j-boddy/terminator/feature-easier-grouping into lp:terminator/trunk

Proposed by Stephen Boddy
Status: Merged
Merge reported by: Chris Jones
Merged at revision: not available
Proposed branch: lp:~stephen-j-boddy/terminator/feature-easier-grouping
Merge into: lp:terminator/trunk
Diff against target: 153 lines (+62/-11)
3 files modified
terminatorlib/terminal.py (+36/-1)
terminatorlib/terminator.py (+13/-8)
terminatorlib/titlebar.py (+13/-2)
To merge this branch: bzr merge lp:~stephen-j-boddy/terminator/feature-easier-grouping
Reviewer Review Type Date Requested Status
Terminator Pending
Review via email: mp+111748@code.launchpad.net

Description of the change

There are two group improvements here.
1) When editing a group the edit widget is filled with the current group, and the label is hidden.
2) Power grouping features:

Ctrl-Button1 on group button of non-focused terminal will join focused group. Second click will clear group of non-focused terminal

Shift-Button1 on group button of any terminal will edit that terminals group

In both cases adding the additional Super key modifier will include the group siblings of the clicked terminal.

To post a comment you must log in.
1314. By Stephen Boddy

Merge updates from trunk

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'terminatorlib/terminal.py'
2--- terminatorlib/terminal.py 2012-07-10 19:27:34 +0000
3+++ terminatorlib/terminal.py 2012-07-23 13:32:19 +0000
4@@ -107,6 +107,7 @@
5 composite_support = None
6
7 cnxids = None
8+ targets_for_new_group = None
9
10 def __init__(self):
11 """Class initialiser"""
12@@ -119,6 +120,7 @@
13 # FIXME: Surely these should happen in Terminator::register_terminal()?
14 self.connect('enumerate', self.terminator.do_enumerate)
15 self.connect('focus-in', self.terminator.focus_changed)
16+ self.connect('focus-out', self.terminator.focus_left)
17
18 self.matches = {}
19 self.cnxids = Signalman()
20@@ -770,7 +772,40 @@
21 def on_group_button_press(self, widget, event):
22 """Handler for the group button"""
23 if event.button == 1:
24- self.create_popup_group_menu(widget, event)
25+ if event.type == gtk.gdk._2BUTTON_PRESS or \
26+ event.type == gtk.gdk._3BUTTON_PRESS:
27+ # Ignore these, or they make the interaction bad
28+ return False
29+ # Super key applies interaction to all terms in group
30+ include_siblings=event.state & gtk.gdk.MOD4_MASK == gtk.gdk.MOD4_MASK
31+ if include_siblings:
32+ targets=self.terminator.get_sibling_terms(self)
33+ else:
34+ targets=[self]
35+ if event.state & gtk.gdk.CONTROL_MASK == gtk.gdk.CONTROL_MASK:
36+ dbg('on_group_button_press: toggle terminal to focused terminals group')
37+ focused=self.get_toplevel().get_focussed_terminal()
38+ if focused in targets: targets.remove(focused)
39+ if self != focused:
40+ if self.group==focused.group:
41+ new_group=None
42+ else:
43+ new_group=focused.group
44+ [term.set_group(None, new_group) for term in targets]
45+ [term.titlebar.update(focused) for term in targets]
46+ return True
47+ elif event.state & gtk.gdk.SHIFT_MASK == gtk.gdk.SHIFT_MASK:
48+ dbg('on_group_button_press: rename of terminals group')
49+ self.targets_for_new_group = targets
50+ self.titlebar.create_group()
51+ return True
52+ elif event.type == gtk.gdk.BUTTON_PRESS:
53+ # Single Click gives popup
54+ dbg('on_group_button_press: group menu popup')
55+ self.create_popup_group_menu(widget, event)
56+ return True
57+ else:
58+ dbg('on_group_button_press: unknown group button interaction')
59 return(False)
60
61 def on_keypress(self, widget, event):
62
63=== modified file 'terminatorlib/terminator.py'
64--- terminatorlib/terminator.py 2012-01-14 20:11:46 +0000
65+++ terminatorlib/terminator.py 2012-07-23 13:32:19 +0000
66@@ -349,19 +349,21 @@
67 idx = terminals.index(term)
68 term.feed(numstr % (idx + 1))
69
70+ def get_sibling_terms(self, widget):
71+ termset = []
72+ for term in self.terminals:
73+ if term.group == widget.group:
74+ termset.append(term)
75+ return(termset)
76+
77 def get_target_terms(self, widget):
78 """Get the terminals we should currently be broadcasting to"""
79 if self.groupsend == self.groupsend_type['all']:
80 return(self.terminals)
81 elif self.groupsend == self.groupsend_type['group']:
82- termset = []
83- for term in self.terminals:
84- if term == widget or (term.group != None and term.group ==
85- widget.group):
86- termset.append(term)
87- return(termset)
88- else:
89- return([widget])
90+ if widget.group != None:
91+ return(self.get_sibling_terms(widget))
92+ return([widget])
93
94 def get_focussed_terminal(self):
95 """iterate over all the terminals to find which, if any, has focus"""
96@@ -376,6 +378,9 @@
97 terminal.titlebar.update(widget)
98 return
99
100+ def focus_left(self, widget):
101+ self.last_focused_term=widget
102+
103 def describe_layout(self):
104 """Describe our current layout"""
105 layout = {}
106
107=== modified file 'terminatorlib/titlebar.py'
108--- terminatorlib/titlebar.py 2011-08-21 00:07:11 +0000
109+++ terminatorlib/titlebar.py 2012-07-23 13:32:19 +0000
110@@ -93,7 +93,7 @@
111
112 def connect_icon(self, func):
113 """Connect the supplied function to clicking on the group icon"""
114- self.ebox.connect('button-release-event', func)
115+ self.ebox.connect('button-press-event', func)
116
117 def update(self, other=None):
118 """Update our contents"""
119@@ -233,7 +233,10 @@
120
121 def create_group(self):
122 """Create a new group"""
123+ if self.terminal.group:
124+ self.groupentry.set_text(self.terminal.group)
125 self.groupentry.show()
126+ self.grouplabel.hide()
127 self.groupentry.grab_focus()
128 self.update_visibility()
129
130@@ -241,6 +244,7 @@
131 """Hide the group name entry"""
132 self.groupentry.set_text('')
133 self.groupentry.hide()
134+ self.grouplabel.show()
135 self.get_parent().grab_focus()
136
137 def groupentry_activate(self, widget):
138@@ -248,7 +252,14 @@
139 groupname = self.groupentry.get_text()
140 dbg('Titlebar::groupentry_activate: creating group: %s' % groupname)
141 self.groupentry_cancel(None, None)
142- self.emit('create-group', groupname)
143+ last_focused_term=self.terminator.last_focused_term
144+ if self.terminal.targets_for_new_group:
145+ [term.titlebar.emit('create-group', groupname) for term in self.terminal.targets_for_new_group]
146+ self.terminal.targets_for_new_group = None
147+ else:
148+ self.emit('create-group', groupname)
149+ last_focused_term.grab_focus()
150+ self.terminator.focus_changed(last_focused_term)
151
152 def groupentry_keypress(self, widget, event):
153 """Handle keypresses on the entry widget"""