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() {
|
||||
this.parent(_("APPLICATIONS"));
|
||||
|
||||
this.async = true;
|
||||
this._appSys = Shell.AppSystem.get_default();
|
||||
},
|
||||
|
||||
getResultMetas: function(apps) {
|
||||
getResultMetasAsync: function(apps, callback) {
|
||||
let metas = [];
|
||||
for (let i = 0; i < apps.length; i++) {
|
||||
let app = apps[i];
|
||||
@ -327,15 +328,15 @@ const AppSearchProvider = new Lang.Class({
|
||||
}
|
||||
});
|
||||
}
|
||||
return metas;
|
||||
callback(metas);
|
||||
},
|
||||
|
||||
getInitialResultSet: function(terms) {
|
||||
return this._appSys.initial_search(terms);
|
||||
getInitialResultSetAsync: function(terms) {
|
||||
this.searchSystem.pushResults(this, this._appSys.initial_search(terms));
|
||||
},
|
||||
|
||||
getSubsearchResultSet: function(previousResults, terms) {
|
||||
return this._appSys.subsearch(previousResults, terms);
|
||||
getSubsearchResultSetAsync: function(previousResults, terms) {
|
||||
this.searchSystem.pushResults(this, this._appSys.subsearch(previousResults, terms));
|
||||
},
|
||||
|
||||
activateResult: function(app, params) {
|
||||
@ -374,11 +375,12 @@ const SettingsSearchProvider = new Lang.Class({
|
||||
_init: function() {
|
||||
this.parent(_("SETTINGS"));
|
||||
|
||||
this.async = true;
|
||||
this._appSys = Shell.AppSystem.get_default();
|
||||
this._gnomecc = this._appSys.lookup_app('gnome-control-center.desktop');
|
||||
},
|
||||
|
||||
getResultMetas: function(prefs) {
|
||||
getResultMetasAsync: function(prefs, callback) {
|
||||
let metas = [];
|
||||
for (let i = 0; i < prefs.length; i++) {
|
||||
let pref = prefs[i];
|
||||
@ -389,15 +391,15 @@ const SettingsSearchProvider = new Lang.Class({
|
||||
}
|
||||
});
|
||||
}
|
||||
return metas;
|
||||
callback(metas);
|
||||
},
|
||||
|
||||
getInitialResultSet: function(terms) {
|
||||
return this._appSys.search_settings(terms);
|
||||
getInitialResultSetAsync: function(terms) {
|
||||
this.searchSystem.pushResults(this, this._appSys.search_settings(terms));
|
||||
},
|
||||
|
||||
getSubsearchResultSet: function(previousResults, terms) {
|
||||
return this._appSys.search_settings(terms);
|
||||
getSubsearchResultSetAsync: function(previousResults, terms) {
|
||||
this.searchSystem.pushResults(this, this._appSys.search_settings(terms));
|
||||
},
|
||||
|
||||
activateResult: function(pref, params) {
|
||||
|
@ -151,10 +151,11 @@ const ContactSearchProvider = new Lang.Class({
|
||||
|
||||
_init: function() {
|
||||
this.parent(_("CONTACTS"));
|
||||
this.async = true;
|
||||
this._contactSys = Shell.ContactSystem.get_default();
|
||||
},
|
||||
|
||||
getResultMetas: function(ids) {
|
||||
getResultMetasAsync: function(ids, callback) {
|
||||
let metas = [];
|
||||
for (let i = 0; i < ids.length; i++) {
|
||||
let contact = new Contact(ids[i]);
|
||||
@ -165,15 +166,15 @@ const ContactSearchProvider = new Lang.Class({
|
||||
}
|
||||
});
|
||||
}
|
||||
return metas;
|
||||
callback(metas);
|
||||
},
|
||||
|
||||
getInitialResultSet: function(terms) {
|
||||
return this._contactSys.initial_search(terms);
|
||||
getInitialResultSetAsync: function(terms) {
|
||||
this.searchSystem.pushResults(this, this._contactSys.initial_search(terms));
|
||||
},
|
||||
|
||||
getSubsearchResultSet: function(previousResults, terms) {
|
||||
return this._contactSys.subsearch(previousResults, terms);
|
||||
getSubsearchResultSetAsync: function(previousResults, terms) {
|
||||
this.searchSystem.pushResults(this, this._contactSys.subsearch(previousResults, terms));
|
||||
},
|
||||
|
||||
createResultActor: function(resultMeta, terms) {
|
||||
|
@ -365,10 +365,11 @@ const PlaceSearchProvider = new Lang.Class({
|
||||
|
||||
_init: function() {
|
||||
this.parent(_("PLACES & DEVICES"));
|
||||
this.async = true;
|
||||
this.placesManager = new PlacesManager();
|
||||
},
|
||||
|
||||
getResultMetas: function(resultIds) {
|
||||
getResultMetasAsync: function(resultIds, callback) {
|
||||
let metas = [];
|
||||
for (let i = 0; i < resultIds.length; 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) {
|
||||
@ -413,18 +414,18 @@ const PlaceSearchProvider = new Lang.Class({
|
||||
prefixResults.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();
|
||||
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) {
|
||||
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() {
|
||||
this.parent(_("Your favorite Easter Egg"));
|
||||
this.async = true;
|
||||
},
|
||||
|
||||
getResultMetas: function(fish) {
|
||||
return [{ 'id': fish[0], // there may be many fish in the sea, but
|
||||
getResultMetasAsync: function(fish, callback) {
|
||||
callback([{ 'id': fish[0], // there may be many fish in the sea, but
|
||||
// only one which speaks the truth!
|
||||
'name': capitalize(fish[0]),
|
||||
'createIcon': function(iconSize) {
|
||||
@ -184,18 +185,19 @@ const WandaSearchProvider = new Lang.Class({
|
||||
St.IconType.FULLCOLOR,
|
||||
iconSize);
|
||||
}
|
||||
}];
|
||||
}]);
|
||||
},
|
||||
|
||||
getInitialResultSet: function(terms) {
|
||||
getInitialResultSetAsync: function(terms) {
|
||||
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) {
|
||||
return this.getInitialResultSet(terms);
|
||||
getSubsearchResultSetAsync: function(previousResults, terms) {
|
||||
this.getInitialResultSetAsync(terms);
|
||||
},
|
||||
|
||||
activateResult: function(fish, params) {
|
||||
|
Loading…
Reference in New Issue
Block a user