[gnome-maps] Make PlaceStore globally accessible



commit 819c8ea1e0cecbdd0550d3b61a2d182747c86e78
Author: rishirajsinghjhelumi <rishiakhnoor gmail com>
Date:   Wed Mar 19 05:22:09 2014 +0530

    Make PlaceStore globally accessible
    
    PlaceStore is used from many different sub modules and is best
    treated as an application service same as settings.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=722871

 src/application.js |   13 +++++++++++++
 src/mainWindow.js  |   12 +-----------
 2 files changed, 14 insertions(+), 11 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index de4cdfc..ced3bd3 100644
--- a/src/application.js
+++ b/src/application.js
@@ -38,10 +38,12 @@ const MainWindow = imports.mainWindow;
 const Utils = imports.utils;
 const Path = imports.path;
 const Settings = imports.settings;
+const PlaceStore = imports.placeStore;
 
 // used globally
 let application = null;
 let settings = null;
+let placeStore = null;
 
 const Application = new Lang.Class({
     Name: 'Application',
@@ -61,6 +63,16 @@ const Application = new Lang.Class({
         this._mainWindow.window.destroy();
     },
 
+    _initPlaceStore: function() {
+        placeStore = new PlaceStore.PlaceStore();
+        try {
+            placeStore.load();
+        } catch (e) {
+            log('Failed to parse Maps places file, ' +
+                'subsequent writes will overwrite the file!');
+        }
+    },
+
     _initAppMenu: function() {
         let builder = new Gtk.Builder();
         builder.add_from_resource('/org/gnome/maps/app-menu.ui');
@@ -85,6 +97,7 @@ const Application = new Lang.Class({
             signalHandlers: { activate: this._onQuitActivate }
         }], this);
 
+        this._initPlaceStore();
         this._initAppMenu();
     },
 
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 35fbfd1..a157195 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -60,6 +60,7 @@ const MainWindow = new Lang.Class({
         this.window = ui.appWindow;
         this.window.application = app;
         this._windowContent = ui.windowContent;
+        this._placeStore = Application.placeStore;
 
         this.mapView = new MapView.MapView();
         ui.windowContent.add(this.mapView);
@@ -70,7 +71,6 @@ const MainWindow = new Lang.Class({
 
         ui.layersButton.popover = new LayersPopover.LayersPopover();
 
-        this._initPlaces();
         this._initSearchWidgets();
         this._initActions();
         this._initSignals();
@@ -81,16 +81,6 @@ const MainWindow = new Lang.Class({
         this._windowContent.show_all();
     },
 
-    _initPlaces: function() {
-        this._placeStore = new PlaceStore.PlaceStore();
-        try {
-            this._placeStore.load();
-        } catch (e) {
-            log('Failed to parse Maps places file, ' +
-                'subsequent writes will overwrite the file!');
-        }
-    },
-
     _initSearchWidgets: function() {
         this._searchPopup = new SearchPopup.SearchPopup(this._searchEntry, 10);
 


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