Partially prevent focus grabbing by terminals leaving a Paned where they had no focus to begin with. This is useful where terminals are exiting for reasons other than direct user intervention. LP#943311
This commit is contained in:
parent
11887770e1
commit
eda8d3fc22
|
@ -111,7 +111,10 @@ class Paned(Container):
|
||||||
handler = handler[0]
|
handler = handler[0]
|
||||||
self.connect_child(widget, signal, handler, *args)
|
self.connect_child(widget, signal, handler, *args)
|
||||||
|
|
||||||
widget.grab_focus()
|
if metadata and \
|
||||||
|
metadata.has_key('had_focus') and \
|
||||||
|
metadata['had_focus'] == True:
|
||||||
|
widget.grab_focus()
|
||||||
|
|
||||||
elif isinstance(widget, gtk.Paned):
|
elif isinstance(widget, gtk.Paned):
|
||||||
try:
|
try:
|
||||||
|
@ -220,9 +223,15 @@ class Paned(Container):
|
||||||
children.append(self.get_child2())
|
children.append(self.get_child2())
|
||||||
return(children)
|
return(children)
|
||||||
|
|
||||||
|
def get_child_metadata(self, widget):
|
||||||
|
"""Return metadata about a child"""
|
||||||
|
metadata = {}
|
||||||
|
metadata['had_focus'] = widget.has_focus()
|
||||||
|
|
||||||
def wrapcloseterm(self, widget):
|
def wrapcloseterm(self, widget):
|
||||||
"""A child terminal has closed, so this container must die"""
|
"""A child terminal has closed, so this container must die"""
|
||||||
dbg('Paned::wrapcloseterm: Called on %s' % widget)
|
dbg('Paned::wrapcloseterm: Called on %s' % widget)
|
||||||
|
|
||||||
if self.closeterm(widget):
|
if self.closeterm(widget):
|
||||||
# At this point we only have one child, which is the surviving term
|
# At this point we only have one child, which is the surviving term
|
||||||
sibling = self.children[0]
|
sibling = self.children[0]
|
||||||
|
@ -235,7 +244,6 @@ class Paned(Container):
|
||||||
parent.remove(self)
|
parent.remove(self)
|
||||||
self.cnxids.remove_all()
|
self.cnxids.remove_all()
|
||||||
parent.add(sibling, metadata)
|
parent.add(sibling, metadata)
|
||||||
sibling.grab_focus()
|
|
||||||
del(self)
|
del(self)
|
||||||
else:
|
else:
|
||||||
dbg("Paned::wrapcloseterm: self.closeterm failed")
|
dbg("Paned::wrapcloseterm: self.closeterm failed")
|
||||||
|
|
Loading…
Reference in New Issue