Improve options for adding/removing terminals to/from groups
This commit is contained in:
commit
da3a14a55e
|
@ -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()
|
||||
|
@ -770,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):
|
||||
|
|
|
@ -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 = {}
|
||||
|
|
|
@ -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"""
|
||||
|
@ -233,7 +233,10 @@ 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()
|
||||
self.update_visibility()
|
||||
|
||||
|
@ -241,6 +244,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):
|
||||
|
@ -248,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"""
|
||||
|
|
Loading…
Reference in New Issue