From 68da0b24b36e6da06ec18b4d4b3f138fba4de5c8 Mon Sep 17 00:00:00 2001 From: Chris Jones Date: Fri, 9 Apr 2010 12:58:46 +0100 Subject: [PATCH] Tidy up some focus grabbing on new Terminal creation. Closes LP #558376 --- terminatorlib/notebook.py | 5 ++++- terminatorlib/terminal.py | 3 ++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/terminatorlib/notebook.py b/terminatorlib/notebook.py index 1cbdc6f1..80340ea2 100755 --- a/terminatorlib/notebook.py +++ b/terminatorlib/notebook.py @@ -125,6 +125,7 @@ class Notebook(Container, gtk.Notebook): self.set_current_page(page_num) self.show_all() + terminal.grab_focus() def add(self, widget): """Add a widget to the container""" @@ -196,7 +197,9 @@ class Notebook(Container, gtk.Notebook): gtk.PACK_START) self.set_current_page(-1) - widget.grab_focus() + self.show_all() + if maker.isinstance(widget, 'Terminal'): + widget.grab_focus() def wrapcloseterm(self, widget): """A child terminal has closed""" diff --git a/terminatorlib/terminal.py b/terminatorlib/terminal.py index bfd7e9dd..7acd9ec2 100755 --- a/terminatorlib/terminal.py +++ b/terminatorlib/terminal.py @@ -925,7 +925,8 @@ for %s (%s)' % (name, urlplugin.__class__.__name__)) def grab_focus(self): """Steal focus for this terminal""" - self.vte.grab_focus() + if not self.vte.has_focus(): + self.vte.grab_focus() def on_vte_focus(self, _widget): """Update our UI when we get focus"""