[gnome-documents] searchbar: fix preview searchbar eating first key press events



commit 37f116ed8c7492ca3fb268e9733c6946cdf23f96
Author: Cosimo Cecchi <cosimoc gnome org>
Date:   Tue Dec 4 18:10:11 2012 -0500

    searchbar: fix preview searchbar eating first key press events

 src/preview.js   |   13 ++++++++++---
 src/searchbar.js |    6 +++---
 2 files changed, 13 insertions(+), 6 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index 2720fe8..1a57371 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -445,6 +445,7 @@ const PreviewSearchbar = new Lang.Class({
     _init: function(previewView) {
         this.parent();
 
+        this._lastText = '';
         this._previewView = previewView;
     },
 
@@ -488,15 +489,21 @@ const PreviewSearchbar = new Lang.Class({
     show: function() {
         this.parent();
 
-        this._searchEntry.select_region(0, -1);
+        if (!this._searchEntry.get_text()) {
+            this._searchEntry.set_text(this._lastText);
+            this._searchEntry.select_region(0, -1);
+        }
+
+        this._lastText = '';
         this._previewView.view.find_set_highlight_search(true);
         this._previewView.startSearch(this._searchEntry.get_text());
     },
 
     hide: function() {
-        this.parent();
-
         this._previewView.view.find_set_highlight_search(false);
+        this._lastText = this._searchEntry.get_text();
+
+        this.parent();
     }
 });
 
diff --git a/src/searchbar.js b/src/searchbar.js
index 621fde9..476c091 100644
--- a/src/searchbar.js
+++ b/src/searchbar.js
@@ -446,6 +446,9 @@ const Searchbar = new Lang.Class({
                                        onComplete: function() {
                                            this._searchEntry.hide();
                                            this._in = false;
+
+                                           // clear all the search properties when hiding the entry
+                                           this._searchEntry.set_text('');
                                        },
                                        onCompleteScope: this });
     }
@@ -646,9 +649,6 @@ const OverviewSearchbar = new Lang.Class({
     hide: function() {
         this._dropdownButton.set_active(false);
 
-        // clear all the search properties when hiding the entry
-        this._searchEntry.set_text('');
-
         Global.searchTypeManager.setActiveItemById('all');
         Global.searchMatchManager.setActiveItemById('all');
         Global.sourceManager.setActiveItemById('all');



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]