All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Gavrilov <angavrilov@gmail.com>
To: git@vger.kernel.org
Cc: "Shawn O. Pearce" <spearce@spearce.org>
Subject: [PATCH (GIT-GUI)] git-gui: Fix focus transition in the blame viewer.
Date: Sun, 9 Nov 2008 18:36:50 +0300	[thread overview]
Message-ID: <200811091836.50832.angavrilov@gmail.com> (raw)

Now that the blame viewer has a search panel, it should be
taken into account by the focus transition code. Otherwise
showing a commit tip (by accidentally moving the mouse to
the text frame) causes the focus to transfer away from the
search field.

Signed-off-by: Alexander Gavrilov <angavrilov@gmail.com>
---
 lib/blame.tcl  |   16 ++++++++++++----
 lib/search.tcl |   14 +++++++++++---
 2 files changed, 23 insertions(+), 7 deletions(-)

diff --git a/lib/blame.tcl b/lib/blame.tcl
index 765d08c..642f5ca 100644
--- a/lib/blame.tcl
+++ b/lib/blame.tcl
@@ -321,7 +321,7 @@ constructor new {i_commit i_path i_jump} {
 			tk_popup $w.ctxm %X %Y
 		"
 		bind $i <Shift-Tab> "[list focus $w_cviewer];break"
-		bind $i <Tab>       "[list focus $w_cviewer];break"
+		bind $i <Tab>       "[cb _focus_search $w_cviewer];break"
 	}
 
 	foreach i [concat $w_columns $w_cviewer] {
@@ -337,10 +337,10 @@ constructor new {i_commit i_path i_jump} {
 		bind $i <Control-Key-f> {catch {%W yview scroll  1 pages};break}
 	}
 
-	bind $w_cviewer <Shift-Tab> "[list focus $w_file];break"
+	bind $w_cviewer <Shift-Tab> "[cb _focus_search $w_file];break"
 	bind $w_cviewer <Tab>       "[list focus $w_file];break"
-	bind $w_cviewer <Button-1> [list focus $w_cviewer]
-	bind $w_file    <Visibility> [list focus $w_file]
+	bind $w_cviewer <Button-1>   [list focus $w_cviewer]
+	bind $w_file    <Visibility> [cb _focus_search $w_file]
 	bind $top       <F7>         [list searchbar::show $finder]
 	bind $top       <Escape>     [list searchbar::hide $finder]
 	bind $top       <F3>         [list searchbar::find_next $finder]
@@ -382,6 +382,14 @@ constructor new {i_commit i_path i_jump} {
 	_load $this $i_jump
 }
 
+method _focus_search {win} {
+	if {[searchbar::visible $finder]} {
+		focus [searchbar::editor $finder]
+	} else {
+		focus $win
+	}
+}
+
 method _handle_destroy {win} {
 	if {$win eq $w} {
 		_kill $this
diff --git a/lib/search.tcl b/lib/search.tcl
index d292f20..32c8656 100644
--- a/lib/search.tcl
+++ b/lib/search.tcl
@@ -19,11 +19,11 @@ constructor new {i_w i_text args} {
 
 	frame  $w
 	label  $w.l       -text [mc Find:]
+	entry  $w.ent -textvariable ${__this}::searchstring -background lightgreen
 	button $w.bn      -text [mc Next] -command [cb find_next]
 	button $w.bp      -text [mc Prev] -command [cb find_prev]
 	checkbutton $w.cs -text [mc Case-Sensitive] \
 		-variable ${__this}::casesensitive -command [cb _incrsearch]
-	entry  $w.ent -textvariable ${__this}::searchstring -background lightgreen
 	pack   $w.l   -side left
 	pack   $w.cs  -side right
 	pack   $w.bp  -side right
@@ -40,19 +40,27 @@ constructor new {i_w i_text args} {
 }
 
 method show {} {
-	if {![winfo ismapped $w]} {
+	if {![visible $this]} {
 		grid $w
 	}
 	focus -force $w.ent
 }
 
 method hide {} {
-	if {[winfo ismapped $w]} {
+	if {[visible $this]} {
 		focus $ctext
 		grid remove $w
 	}
 }
 
+method visible {} {
+	return [winfo ismapped $w]
+}
+
+method editor {} {
+	return $w.ent
+}
+
 method _get_new_anchor {} {
 	# use start of selection if it is visible,
 	# or the bounds of the visible area
-- 
1.6.0.3.15.gb8d36

                 reply	other threads:[~2008-11-09 15:40 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200811091836.50832.angavrilov@gmail.com \
    --to=angavrilov@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=spearce@spearce.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.