[gnome-documents/wip/ui-changes] searchbar: fix preview searchbar eating first key press events
- From: Cosimo Cecchi <cosimoc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-documents/wip/ui-changes] searchbar: fix preview searchbar eating first key press events
- Date: Tue, 4 Dec 2012 23:17:00 +0000 (UTC)
commit 80fda9b61f3b119e57c2e86fd4e7fbb0770c1344
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 | 19 ++++++++++++++-----
src/searchbar.js | 6 +++---
2 files changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/src/preview.js b/src/preview.js
index 0aa85d9..2419c49 100644
--- a/src/preview.js
+++ b/src/preview.js
@@ -415,6 +415,7 @@ const PreviewSearchbar = new Lang.Class({
_init: function(previewView) {
this.parent();
+ this._lastText = '';
this._previewView = previewView;
this._previewView.connect('search-changed', Lang.bind(this, this._onSearchChanged));
},
@@ -454,8 +455,10 @@ const PreviewSearchbar = new Lang.Class({
},
_onSearchChanged: function(view, hasResults) {
- this._prev.sensitive = hasResults;
- this._next.sensitive = hasResults;
+ let findPrev = Global.application.lookup_action('find-prev');
+ let findNext = Global.application.lookup_action('find-next');
+ findPrev.enabled = hasResults;
+ findNext.enabled = hasResults;
},
entryChanged: function() {
@@ -466,15 +469,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]