[gnome-maps] Remove necessity of importing application



commit f432e8f8fec399467bbe6a53843444d1e6459449
Author: Alaf Azam <alafazam gmail com>
Date:   Sun Jan 10 14:27:43 2016 +0530

    Remove necessity of importing application
    
    placeStore, storedRoute classes both imports 'application'. This makes
    them unusable if application is not available in imports.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=744032

 src/application.js |    5 ++++-
 src/geoclue.js     |    1 -
 src/placeStore.js  |   13 +++++++------
 src/sidebar.js     |    3 ++-
 src/storedRoute.js |   11 +++++++++--
 5 files changed, 22 insertions(+), 11 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 05185aa..7764bb0 100644
--- a/src/application.js
+++ b/src/application.js
@@ -170,7 +170,10 @@ const Application = new Lang.Class({
     },
 
     _initPlaceStore: function() {
-        placeStore = new PlaceStore.PlaceStore();
+        placeStore = new PlaceStore.PlaceStore({
+            recentPlacesLimit: settings.get('recent-places-limit'),
+            recentRoutesLimit: settings.get('recent-routes-limit')
+        });
         try {
             placeStore.load();
         } catch (e) {
diff --git a/src/geoclue.js b/src/geoclue.js
index 485bb5b..1069aeb 100644
--- a/src/geoclue.js
+++ b/src/geoclue.js
@@ -24,7 +24,6 @@ const GClue = imports.gi.Geoclue;
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
-const Application = imports.application;
 const Place = imports.place;
 const Location = imports.location;
 const Settings = imports.settings;
diff --git a/src/placeStore.js b/src/placeStore.js
index 6d5237c..a472a69 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -24,7 +24,6 @@ const Geocode = imports.gi.GeocodeGlib;
 const Gtk = imports.gi.Gtk;
 const Lang = imports.lang;
 
-const Application = imports.application;
 const ContactPlace = imports.contactPlace;
 const Place = imports.place;
 const StoredRoute = imports.storedRoute;
@@ -55,9 +54,13 @@ const PlaceStore = new Lang.Class({
     Name: 'PlaceStore',
     Extends: Gtk.ListStore,
 
-    _init: function() {
-        this._recentPlacesLimit = Application.settings.get('recent-places-limit');
-        this._recentRoutesLimit = Application.settings.get('recent-routes-limit');
+    _init: function(params) {
+        this._recentPlacesLimit = params.recentPlacesLimit;
+        delete params.recentPlacesLimit;
+
+        this._recentRoutesLimit = params.recentRoutesLimit;
+        delete params.recentRoutesLimit;
+
         this._numRecentPlaces = 0;
         this._numRecentRoutes = 0;
         this.filename = GLib.build_filenamev([GLib.get_user_data_dir(),
@@ -163,7 +166,6 @@ const PlaceStore = new Lang.Class({
         let buffer = Utils.readFile(this.filename);
         if (buffer === null)
             return;
-
         try {
             let jsonArray = JSON.parse(buffer);
             jsonArray.forEach((function({ place, type, added }) {
@@ -236,7 +238,6 @@ const PlaceStore = new Lang.Class({
 
             if (!place || !place.store)
                 return;
-
             jsonArray.push({
                 place: place.toJSON(),
                 type: type,
diff --git a/src/sidebar.js b/src/sidebar.js
index 79fb75f..4026344 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -210,7 +210,8 @@ const Sidebar = new Lang.Class({
                 let storedRoute = new StoredRoute.StoredRoute({
                     transportation: query.transportation,
                     route: route,
-                    places: places
+                    places: places,
+                    geoclue: Application.geoclue
                 });
 
                 if (!storedRoute.containsNull) {
diff --git a/src/storedRoute.js b/src/storedRoute.js
index 05e56de..c44932d 100644
--- a/src/storedRoute.js
+++ b/src/storedRoute.js
@@ -24,7 +24,6 @@ const Champlain = imports.gi.Champlain;
 const Gio = imports.gi.Gio;
 const Lang = imports.lang;
 
-const Application = imports.application;
 const Place = imports.place;
 const Route = imports.route;
 const RouteQuery = imports.routeQuery;
@@ -51,10 +50,18 @@ const StoredRoute = new Lang.Class({
         delete params.places;
         params.name = places[0].name + ' → ' + places[places.length -1].name;
 
+        let geoclue = params.geoclue;
+        delete params.geoclue;
+
         this.places = [];
         this._containsCurrentLocation = false;
+
+        let currentLocation = null;
+        if (geoclue)
+            currentLocation = geoclue.place;
+
         places.forEach((function(place) {
-            if (place === Application.geoclue.place)
+            if (currentLocation && place === currentLocation)
                 this._containsCurrentLocation = true;
 
             this.places.push(new Place.Place({ place: place }));


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]