placeDisplay: Create our own PlacesManager

Since we don't have a section showing off the available places somewhere,
we don't need a global PlacesManager.

https://bugzilla.gnome.org/show_bug.cgi?id=675328
This commit is contained in:
Jasper St. Pierre 2012-05-02 15:40:31 -04:00
parent 7ba8c7c2b5
commit f2d883dab2
2 changed files with 11 additions and 10 deletions

View File

@ -46,7 +46,6 @@ let automountManager = null;
let autorunManager = null; let autorunManager = null;
let panel = null; let panel = null;
let hotCorners = []; let hotCorners = [];
let placesManager = null;
let overview = null; let overview = null;
let runDialog = null; let runDialog = null;
let lookingGlass = null; let lookingGlass = null;
@ -80,7 +79,6 @@ function _createUserSession() {
// not loading any events until the user presses the clock // not loading any events until the user presses the clock
global.launch_calendar_server(); global.launch_calendar_server();
placesManager = new PlaceDisplay.PlacesManager();
telepathyClient = new TelepathyClient.Client(); telepathyClient = new TelepathyClient.Client();
automountManager = new AutomountManager.AutomountManager(); automountManager = new AutomountManager.AutomountManager();
autorunManager = new AutorunManager.AutorunManager(); autorunManager = new AutorunManager.AutorunManager();

View File

@ -365,12 +365,13 @@ const PlaceSearchProvider = new Lang.Class({
_init: function() { _init: function() {
this.parent(_("PLACES & DEVICES")); this.parent(_("PLACES & DEVICES"));
this.placesManager = new PlacesManager();
}, },
getResultMetas: function(resultIds) { getResultMetas: function(resultIds) {
let metas = []; let metas = [];
for (let i = 0; i < resultIds.length; i++) { for (let i = 0; i < resultIds.length; i++) {
let placeInfo = Main.placesManager.lookupPlaceById(resultIds[i]); let placeInfo = this.placesManager.lookupPlaceById(resultIds[i]);
if (!placeInfo) if (!placeInfo)
metas.push(null); metas.push(null);
else else
@ -385,13 +386,13 @@ const PlaceSearchProvider = new Lang.Class({
}, },
activateResult: function(id, params) { activateResult: function(id, params) {
let placeInfo = Main.placesManager.lookupPlaceById(id); let placeInfo = this.placesManager.lookupPlaceById(id);
placeInfo.launch(params); placeInfo.launch(params);
}, },
_compareResultMeta: function (idA, idB) { _compareResultMeta: function (idA, idB) {
let infoA = Main.placesManager.lookupPlaceById(idA); let infoA = this.placesManager.lookupPlaceById(idA);
let infoB = Main.placesManager.lookupPlaceById(idB); let infoB = this.placesManager.lookupPlaceById(idB);
return infoA.name.localeCompare(infoB.name); return infoA.name.localeCompare(infoB.name);
}, },
@ -409,19 +410,21 @@ const PlaceSearchProvider = new Lang.Class({
else if (mtype == Search.MatchType.SUBSTRING) else if (mtype == Search.MatchType.SUBSTRING)
substringResults.push(place.id); substringResults.push(place.id);
} }
prefixResults.sort(this._compareResultMeta); prefixResults.sort(Lang.bind(this, this._compareResultMeta));
substringResults.sort(this._compareResultMeta); substringResults.sort(Lang.bind(this, this._compareResultMeta));
return prefixResults.concat(substringResults); return prefixResults.concat(substringResults);
}, },
getInitialResultSet: function(terms) { getInitialResultSet: function(terms) {
let places = Main.placesManager.getAllPlaces(); let places = this.placesManager.getAllPlaces();
return this._searchPlaces(places, terms); return this._searchPlaces(places, terms);
}, },
getSubsearchResultSet: function(previousResults, terms) { getSubsearchResultSet: function(previousResults, terms) {
let places = previousResults.map(function (id) { return Main.placesManager.lookupPlaceById(id); }); let places = previousResults.map(Lang.bind(this, function(id) {
return this.placesManager.lookupPlaceById(id);
}));
return this._searchPlaces(places, terms); return this._searchPlaces(places, terms);
} }
}); });