search: Port all search providers over to the async API
https://bugzilla.gnome.org/show_bug.cgi?id=675328
This commit is contained in:
parent
f2d883dab2
commit
58f77a19ed
@ -313,10 +313,11 @@ const AppSearchProvider = new Lang.Class({
|
|||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent(_("APPLICATIONS"));
|
this.parent(_("APPLICATIONS"));
|
||||||
|
|
||||||
|
this.async = true;
|
||||||
this._appSys = Shell.AppSystem.get_default();
|
this._appSys = Shell.AppSystem.get_default();
|
||||||
},
|
},
|
||||||
|
|
||||||
getResultMetas: function(apps) {
|
getResultMetasAsync: function(apps, callback) {
|
||||||
let metas = [];
|
let metas = [];
|
||||||
for (let i = 0; i < apps.length; i++) {
|
for (let i = 0; i < apps.length; i++) {
|
||||||
let app = apps[i];
|
let app = apps[i];
|
||||||
@ -327,15 +328,15 @@ const AppSearchProvider = new Lang.Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return metas;
|
callback(metas);
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialResultSet: function(terms) {
|
getInitialResultSetAsync: function(terms) {
|
||||||
return this._appSys.initial_search(terms);
|
this.searchSystem.pushResults(this, this._appSys.initial_search(terms));
|
||||||
},
|
},
|
||||||
|
|
||||||
getSubsearchResultSet: function(previousResults, terms) {
|
getSubsearchResultSetAsync: function(previousResults, terms) {
|
||||||
return this._appSys.subsearch(previousResults, terms);
|
this.searchSystem.pushResults(this, this._appSys.subsearch(previousResults, terms));
|
||||||
},
|
},
|
||||||
|
|
||||||
activateResult: function(app, params) {
|
activateResult: function(app, params) {
|
||||||
@ -374,11 +375,12 @@ const SettingsSearchProvider = new Lang.Class({
|
|||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent(_("SETTINGS"));
|
this.parent(_("SETTINGS"));
|
||||||
|
|
||||||
|
this.async = true;
|
||||||
this._appSys = Shell.AppSystem.get_default();
|
this._appSys = Shell.AppSystem.get_default();
|
||||||
this._gnomecc = this._appSys.lookup_app('gnome-control-center.desktop');
|
this._gnomecc = this._appSys.lookup_app('gnome-control-center.desktop');
|
||||||
},
|
},
|
||||||
|
|
||||||
getResultMetas: function(prefs) {
|
getResultMetasAsync: function(prefs, callback) {
|
||||||
let metas = [];
|
let metas = [];
|
||||||
for (let i = 0; i < prefs.length; i++) {
|
for (let i = 0; i < prefs.length; i++) {
|
||||||
let pref = prefs[i];
|
let pref = prefs[i];
|
||||||
@ -389,15 +391,15 @@ const SettingsSearchProvider = new Lang.Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return metas;
|
callback(metas);
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialResultSet: function(terms) {
|
getInitialResultSetAsync: function(terms) {
|
||||||
return this._appSys.search_settings(terms);
|
this.searchSystem.pushResults(this, this._appSys.search_settings(terms));
|
||||||
},
|
},
|
||||||
|
|
||||||
getSubsearchResultSet: function(previousResults, terms) {
|
getSubsearchResultSetAsync: function(previousResults, terms) {
|
||||||
return this._appSys.search_settings(terms);
|
this.searchSystem.pushResults(this, this._appSys.search_settings(terms));
|
||||||
},
|
},
|
||||||
|
|
||||||
activateResult: function(pref, params) {
|
activateResult: function(pref, params) {
|
||||||
|
@ -151,10 +151,11 @@ const ContactSearchProvider = new Lang.Class({
|
|||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent(_("CONTACTS"));
|
this.parent(_("CONTACTS"));
|
||||||
|
this.async = true;
|
||||||
this._contactSys = Shell.ContactSystem.get_default();
|
this._contactSys = Shell.ContactSystem.get_default();
|
||||||
},
|
},
|
||||||
|
|
||||||
getResultMetas: function(ids) {
|
getResultMetasAsync: function(ids, callback) {
|
||||||
let metas = [];
|
let metas = [];
|
||||||
for (let i = 0; i < ids.length; i++) {
|
for (let i = 0; i < ids.length; i++) {
|
||||||
let contact = new Contact(ids[i]);
|
let contact = new Contact(ids[i]);
|
||||||
@ -165,15 +166,15 @@ const ContactSearchProvider = new Lang.Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return metas;
|
callback(metas);
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialResultSet: function(terms) {
|
getInitialResultSetAsync: function(terms) {
|
||||||
return this._contactSys.initial_search(terms);
|
this.searchSystem.pushResults(this, this._contactSys.initial_search(terms));
|
||||||
},
|
},
|
||||||
|
|
||||||
getSubsearchResultSet: function(previousResults, terms) {
|
getSubsearchResultSetAsync: function(previousResults, terms) {
|
||||||
return this._contactSys.subsearch(previousResults, terms);
|
this.searchSystem.pushResults(this, this._contactSys.subsearch(previousResults, terms));
|
||||||
},
|
},
|
||||||
|
|
||||||
createResultActor: function(resultMeta, terms) {
|
createResultActor: function(resultMeta, terms) {
|
||||||
|
@ -365,10 +365,11 @@ const PlaceSearchProvider = new Lang.Class({
|
|||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent(_("PLACES & DEVICES"));
|
this.parent(_("PLACES & DEVICES"));
|
||||||
|
this.async = true;
|
||||||
this.placesManager = new PlacesManager();
|
this.placesManager = new PlacesManager();
|
||||||
},
|
},
|
||||||
|
|
||||||
getResultMetas: function(resultIds) {
|
getResultMetasAsync: function(resultIds, callback) {
|
||||||
let metas = [];
|
let metas = [];
|
||||||
for (let i = 0; i < resultIds.length; i++) {
|
for (let i = 0; i < resultIds.length; i++) {
|
||||||
let placeInfo = this.placesManager.lookupPlaceById(resultIds[i]);
|
let placeInfo = this.placesManager.lookupPlaceById(resultIds[i]);
|
||||||
@ -382,7 +383,7 @@ const PlaceSearchProvider = new Lang.Class({
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return metas;
|
callback(metas);
|
||||||
},
|
},
|
||||||
|
|
||||||
activateResult: function(id, params) {
|
activateResult: function(id, params) {
|
||||||
@ -413,18 +414,18 @@ const PlaceSearchProvider = new Lang.Class({
|
|||||||
prefixResults.sort(Lang.bind(this, this._compareResultMeta));
|
prefixResults.sort(Lang.bind(this, this._compareResultMeta));
|
||||||
substringResults.sort(Lang.bind(this, this._compareResultMeta));
|
substringResults.sort(Lang.bind(this, this._compareResultMeta));
|
||||||
|
|
||||||
return prefixResults.concat(substringResults);
|
this.searchSystem.pushResults(this, prefixResults.concat(substringResults));
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialResultSet: function(terms) {
|
getInitialResultSetAsync: function(terms) {
|
||||||
let places = this.placesManager.getAllPlaces();
|
let places = this.placesManager.getAllPlaces();
|
||||||
return this._searchPlaces(places, terms);
|
this._searchPlaces(places, terms);
|
||||||
},
|
},
|
||||||
|
|
||||||
getSubsearchResultSet: function(previousResults, terms) {
|
getSubsearchResultSetAsync: function(previousResults, terms) {
|
||||||
let places = previousResults.map(Lang.bind(this, function(id) {
|
let places = previousResults.map(Lang.bind(this, function(id) {
|
||||||
return this.placesManager.lookupPlaceById(id);
|
return this.placesManager.lookupPlaceById(id);
|
||||||
}));
|
}));
|
||||||
return this._searchPlaces(places, terms);
|
this._searchPlaces(places, terms);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -166,10 +166,11 @@ const WandaSearchProvider = new Lang.Class({
|
|||||||
|
|
||||||
_init: function() {
|
_init: function() {
|
||||||
this.parent(_("Your favorite Easter Egg"));
|
this.parent(_("Your favorite Easter Egg"));
|
||||||
|
this.async = true;
|
||||||
},
|
},
|
||||||
|
|
||||||
getResultMetas: function(fish) {
|
getResultMetasAsync: function(fish, callback) {
|
||||||
return [{ 'id': fish[0], // there may be many fish in the sea, but
|
callback([{ 'id': fish[0], // there may be many fish in the sea, but
|
||||||
// only one which speaks the truth!
|
// only one which speaks the truth!
|
||||||
'name': capitalize(fish[0]),
|
'name': capitalize(fish[0]),
|
||||||
'createIcon': function(iconSize) {
|
'createIcon': function(iconSize) {
|
||||||
@ -184,18 +185,19 @@ const WandaSearchProvider = new Lang.Class({
|
|||||||
St.IconType.FULLCOLOR,
|
St.IconType.FULLCOLOR,
|
||||||
iconSize);
|
iconSize);
|
||||||
}
|
}
|
||||||
}];
|
}]);
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialResultSet: function(terms) {
|
getInitialResultSetAsync: function(terms) {
|
||||||
if (terms.join(' ') == MAGIC_FISH_KEY) {
|
if (terms.join(' ') == MAGIC_FISH_KEY) {
|
||||||
return [ FISH_NAME ];
|
this.searchSystem.pushResults(this, [ FISH_NAME ]);
|
||||||
|
} else {
|
||||||
|
this.searchSystem.pushResults(this, []);
|
||||||
}
|
}
|
||||||
return [];
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getSubsearchResultSet: function(previousResults, terms) {
|
getSubsearchResultSetAsync: function(previousResults, terms) {
|
||||||
return this.getInitialResultSet(terms);
|
this.getInitialResultSetAsync(terms);
|
||||||
},
|
},
|
||||||
|
|
||||||
activateResult: function(fish, params) {
|
activateResult: function(fish, params) {
|
||||||
|
Loading…
Reference in New Issue
Block a user