viewSelector: clean up active search state code
'active' isn't terribly clear about just what is active; also, make it private, remove an useless extra object state we were saving, and refactor some messy code. Based on a patch by Tanner Doshier. https://bugzilla.gnome.org/show_bug.cgi?id=692454
This commit is contained in:
parent
309ac65447
commit
4bd071bf3c
@ -47,8 +47,7 @@ const ViewSelector = new Lang.Class({
|
|||||||
|
|
||||||
this._activePage = null;
|
this._activePage = null;
|
||||||
|
|
||||||
this.active = false;
|
this._searchActive = false;
|
||||||
this._searchPending = false;
|
|
||||||
this._searchTimeoutId = 0;
|
this._searchTimeoutId = 0;
|
||||||
|
|
||||||
this._searchSystem = new Search.SearchSystem();
|
this._searchSystem = new Search.SearchSystem();
|
||||||
@ -224,7 +223,7 @@ const ViewSelector = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onShowAppsButtonToggled: function() {
|
_onShowAppsButtonToggled: function() {
|
||||||
if (this.active)
|
if (this._searchActive)
|
||||||
this.reset();
|
this.reset();
|
||||||
else
|
else
|
||||||
this._showPage(this._showAppsButton.checked ? this._appsPage
|
this._showPage(this._showAppsButton.checked ? this._appsPage
|
||||||
@ -245,7 +244,7 @@ const ViewSelector = new Lang.Class({
|
|||||||
let symbol = event.get_key_symbol();
|
let symbol = event.get_key_symbol();
|
||||||
|
|
||||||
if (symbol == Clutter.Escape) {
|
if (symbol == Clutter.Escape) {
|
||||||
if (this.active)
|
if (this._searchActive)
|
||||||
this.reset();
|
this.reset();
|
||||||
else if (this._showAppsButton.checked)
|
else if (this._showAppsButton.checked)
|
||||||
this._resetShowAppsButton();
|
this._resetShowAppsButton();
|
||||||
@ -253,9 +252,9 @@ const ViewSelector = new Lang.Class({
|
|||||||
Main.overview.hide();
|
Main.overview.hide();
|
||||||
return true;
|
return true;
|
||||||
} else if (Clutter.keysym_to_unicode(symbol) ||
|
} else if (Clutter.keysym_to_unicode(symbol) ||
|
||||||
(symbol == Clutter.BackSpace && this.active)) {
|
(symbol == Clutter.BackSpace && this._searchActive)) {
|
||||||
this.startSearch(event);
|
this.startSearch(event);
|
||||||
} else if (!this.active) {
|
} else if (!this._searchActive) {
|
||||||
if (symbol == Clutter.Tab || symbol == Clutter.Down) {
|
if (symbol == Clutter.Tab || symbol == Clutter.Down) {
|
||||||
this._activePage.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
|
this._activePage.navigate_focus(null, Gtk.DirectionType.TAB_FORWARD, false);
|
||||||
return true;
|
return true;
|
||||||
@ -329,39 +328,37 @@ const ViewSelector = new Lang.Class({
|
|||||||
},
|
},
|
||||||
|
|
||||||
_onTextChanged: function (se, prop) {
|
_onTextChanged: function (se, prop) {
|
||||||
let searchPreviouslyActive = this.active;
|
let searchPreviouslyActive = this._searchActive;
|
||||||
this.active = this._entry.get_text() != '';
|
this._searchActive = this._entry.get_text() != '';
|
||||||
this._searchPending = this.active && !searchPreviouslyActive;
|
|
||||||
if (this._searchPending) {
|
let startSearch = this._searchActive && !searchPreviouslyActive;
|
||||||
|
if (startSearch)
|
||||||
this._searchResults.startingSearch();
|
this._searchResults.startingSearch();
|
||||||
}
|
|
||||||
if (this.active) {
|
if (this._searchActive) {
|
||||||
this._entry.set_secondary_icon(this._activeIcon);
|
this._entry.set_secondary_icon(this._activeIcon);
|
||||||
|
|
||||||
if (this._iconClickedId == 0) {
|
if (this._iconClickedId == 0)
|
||||||
this._iconClickedId = this._entry.connect('secondary-icon-clicked',
|
this._iconClickedId = this._entry.connect('secondary-icon-clicked',
|
||||||
Lang.bind(this, function() {
|
Lang.bind(this, this.reset));
|
||||||
this.reset();
|
|
||||||
}));
|
if (this._searchTimeoutId == 0)
|
||||||
}
|
this._searchTimeoutId = Mainloop.timeout_add(150,
|
||||||
} else {
|
Lang.bind(this, this._doSearch));
|
||||||
if (this._iconClickedId > 0)
|
} else {
|
||||||
this._entry.disconnect(this._iconClickedId);
|
if (this._iconClickedId > 0) {
|
||||||
this._iconClickedId = 0;
|
this._entry.disconnect(this._iconClickedId);
|
||||||
|
this._iconClickedId = 0;
|
||||||
|
}
|
||||||
|
|
||||||
this._entry.set_secondary_icon(this._inactiveIcon);
|
|
||||||
this._searchCancelled();
|
|
||||||
}
|
|
||||||
if (!this.active) {
|
|
||||||
if (this._searchTimeoutId > 0) {
|
if (this._searchTimeoutId > 0) {
|
||||||
Mainloop.source_remove(this._searchTimeoutId);
|
Mainloop.source_remove(this._searchTimeoutId);
|
||||||
this._searchTimeoutId = 0;
|
this._searchTimeoutId = 0;
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
|
this._entry.set_secondary_icon(this._inactiveIcon);
|
||||||
|
this._searchCancelled();
|
||||||
}
|
}
|
||||||
if (this._searchTimeoutId > 0)
|
|
||||||
return;
|
|
||||||
this._searchTimeoutId = Mainloop.timeout_add(150, Lang.bind(this, this._doSearch));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
_onKeyPress: function(entry, event) {
|
_onKeyPress: function(entry, event) {
|
||||||
@ -380,7 +377,7 @@ const ViewSelector = new Lang.Class({
|
|||||||
}
|
}
|
||||||
this._searchResults.activateDefault();
|
this._searchResults.activateDefault();
|
||||||
return true;
|
return true;
|
||||||
} else if (this.active) {
|
} else if (this._searchActive) {
|
||||||
let arrowNext, nextDirection;
|
let arrowNext, nextDirection;
|
||||||
if (entry.get_text_direction() == Clutter.TextDirection.RTL) {
|
if (entry.get_text_direction() == Clutter.TextDirection.RTL) {
|
||||||
arrowNext = Clutter.Left;
|
arrowNext = Clutter.Left;
|
||||||
|
Loading…
Reference in New Issue
Block a user