(trunk-1634/1637) Fix the tab switching if a terminal on another tab exits

This commit is contained in:
Stephen Boddy 2015-11-30 21:39:15 +01:00
parent 4435be2350
commit 042dbfb454
3 changed files with 32 additions and 4 deletions

View File

@ -42,6 +42,8 @@ terminator GTK3:
Koblinger, LP#1518596) Koblinger, LP#1518596)
* Fix right-click for mouse aware apps ((Egmont Koblinger, * Fix right-click for mouse aware apps ((Egmont Koblinger,
LP#1518700) LP#1518700)
* Fix the tab switching if a terminal on another tab exits (Steve
Boddy, LP#943311)
terminator 0.97: terminator 0.97:

View File

@ -40,9 +40,10 @@ class Notebook(Container, Gtk.Notebook):
child = window.get_child() child = window.get_child()
window.remove(child) window.remove(child)
window.add(self) window.add(self)
window_last_active_term = window.last_active_term
self.newtab(widget=child) self.newtab(widget=child)
if window.last_active_term: if window_last_active_term:
self.set_last_active_term(window.last_active_term) self.set_last_active_term(window_last_active_term)
window.last_active_term = None window.last_active_term = None
self.show_all() self.show_all()

View File

@ -7,7 +7,7 @@ variants"""
import time import time
from gi.repository import GObject, Gtk, Gdk from gi.repository import GObject, Gtk, Gdk
from util import dbg, err from util import dbg, err, enumerate_descendants
from terminator import Terminator from terminator import Terminator
from factory import Factory from factory import Factory
from container import Container from container import Container
@ -259,6 +259,26 @@ class Paned(Container):
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]
first_term_sibling = sibling
cur_tabnum = None
focus_sibling = True
if self.get_toplevel().is_child_notebook():
notebook = self.get_toplevel().get_children()[0]
cur_tabnum = notebook.get_current_page()
tabnum = notebook.page_num_descendant(self)
nth_page = notebook.get_nth_page(tabnum)
exiting_term_was_last_active = (notebook.last_active_term[nth_page] == widget.uuid)
if exiting_term_was_last_active:
first_term_sibling = enumerate_descendants(self)[1][0]
notebook.set_last_active_term(first_term_sibling.uuid)
notebook.clean_last_active_term()
self.get_toplevel().last_active_term = None
if cur_tabnum != tabnum:
focus_sibling = False
elif self.get_toplevel().last_active_term != widget.uuid:
focus_sibling = False
self.remove(sibling) self.remove(sibling)
metadata = None metadata = None
@ -268,7 +288,12 @@ 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() if cur_tabnum:
notebook.set_current_page(cur_tabnum)
if focus_sibling:
first_term_sibling.grab_focus()
elif not sibling.get_toplevel().is_child_notebook():
Terminator().find_terminal_by_uuid(sibling.get_toplevel().last_active_term.urn).grab_focus()
else: else:
dbg("Paned::wrapcloseterm: self.closeterm failed") dbg("Paned::wrapcloseterm: self.closeterm failed")