Enhancing the way we handle refocus when a terminal is closed

* Fixes LP#234905 : Refocus on term close
  * Added new conf parameter: focus_on_close
  * Default to auto, possible values: auto, next, prev
  * When auto, if the term parent is a gtk.Paned, the focus is 
     given to the sibling rather than the previous term which could 
     be in another tab
  * Added entry to doc/terminatorrc.5
This commit is contained in:
Emmanuel Bretelle 2008-06-06 19:13:54 +01:00
parent 47e51e7855
commit 4a74f74897
3 changed files with 20 additions and 13 deletions

View File

@ -82,6 +82,13 @@ Default value: \fB100\fR
Sets what type of mouse events should determine terminal focus. Can be "sloppy" or "click". "mouse" is also interpreted as "sloppy". Sets what type of mouse events should determine terminal focus. Can be "sloppy" or "click". "mouse" is also interpreted as "sloppy".
Default value: \fBsloppy\fR Default value: \fBsloppy\fR
.TP .TP
.B focus_on_close
Sets which terminal should get the focus when another terminal is closed.
Values can be "prev", "next" or "auto".
Using "auto", if the closed terminal is within a splitted window, the focus will be on the sibling terminal
rather than another tab.
Default value: \fBauto\fR
.TP
.B exit_action .B exit_action
Possible values are "close" to close the terminal, and "restart" to restart the command. Possible values are "close" to close the terminal, and "restart" to restart the command.
Default value: \fBclose\fR Default value: \fBclose\fR

View File

@ -1302,7 +1302,7 @@ class Terminator:
Returns True on success, False on failure""" Returns True on success, False on failure"""
parent = widget.get_parent () parent = widget.get_parent ()
sibling = None sibling = None
focus_on_close = 'prev'
if isinstance (parent, gtk.Window): if isinstance (parent, gtk.Window):
# We are the only term # We are the only term
if not self.on_delete_event (parent, gtk.gdk.Event (gtk.gdk.DELETE)): if not self.on_delete_event (parent, gtk.gdk.Event (gtk.gdk.DELETE)):
@ -1316,6 +1316,7 @@ class Terminator:
# Discover sibling while all objects exist # Discover sibling while all objects exist
if widget == parent.get_child1 (): if widget == parent.get_child1 ():
sibling = parent.get_child2 () sibling = parent.get_child2 ()
focus_on_close = 'next'
if widget == parent.get_child2 (): if widget == parent.get_child2 ():
sibling = parent.get_child1 () sibling = parent.get_child1 ()
@ -1350,14 +1351,6 @@ class Terminator:
self.term_list.remove (widget) self.term_list.remove (widget)
if not isinstance (sibling, gtk.Paned):
for term in self.term_list:
if term == sibling:
term._vte.grab_focus ()
break
else:
if index == 0: index = 1
self.term_list[index - 1]._vte.grab_focus ()
elif isinstance (parent, gtk.Notebook): elif isinstance (parent, gtk.Notebook):
parent.remove(widget) parent.remove(widget)
nbpages = parent.get_n_pages() nbpages = parent.get_n_pages()
@ -1380,9 +1373,15 @@ class Terminator:
if isinstance(sibling, TerminatorTerm) and sibling.conf.titlebars and sibling.conf.extreme_tabs: if isinstance(sibling, TerminatorTerm) and sibling.conf.titlebars and sibling.conf.extreme_tabs:
sibling._titlebox.show() sibling._titlebox.show()
parent.destroy() parent.destroy()
if index == 0: index = 1 if self.conf.focus_on_close == 'prev' or ( self.conf.focus_on_close == 'auto' and focus_on_close == 'prev'):
self.term_list[index - 1]._vte.grab_focus () if index == 0: index = 1
self._set_current_notebook_page_recursive(self.term_list[index - 1]) self.term_list[index - 1]._vte.grab_focus ()
self._set_current_notebook_page_recursive(self.term_list[index - 1])
elif self.conf.focus_on_close == 'next' or ( self.conf.focus_on_close == 'auto' and focus_on_close == 'next'):
if index == len(self.term_list): index = index - 1
self.term_list[index]._vte.grab_focus ()
self._set_current_notebook_page_recursive(self.term_list[index])
if len(self.term_list) == 1: if len(self.term_list) == 1:
self.term_list[0]._titlebox.hide() self.term_list[0]._titlebox.hide()

View File

@ -119,6 +119,7 @@ class TerminatorConfValuestore:
'borderless' : False, 'borderless' : False,
'maximise' : False, 'maximise' : False,
'handle_size' : -1, 'handle_size' : -1,
'focus_on_close' : 'auto',
} }
def __getattr__ (self, keyname): def __getattr__ (self, keyname):