[gnome-maps] application: Wait for view realized before open



commit f9e114918bc1077e91ac0289d3f07165ff1eb048
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Thu Nov 5 23:00:37 2015 +0800

    application: Wait for view realized before open

 src/application.js |   18 ++++++++++++++----
 src/mapView.js     |   14 +-------------
 2 files changed, 15 insertions(+), 17 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 292c46c..348a777 100644
--- a/src/application.js
+++ b/src/application.js
@@ -253,15 +253,25 @@ const Application = new Lang.Class({
         this._mainWindow.present();
     },
 
-    vfunc_open: function(files) {
-        this.activate();
-        let content_type = Gio.content_type_guess(files[0].get_uri(), null)[0];
+    _openInternal: function(file) {
+        let content_type = Gio.content_type_guess(file.get_uri(), null)[0];
         if (content_type === 'application/vnd.geo+json' ||
             content_type === 'application/json') {
-            this._mainWindow.mapView.openGeoJSON(files[0]);
+            this._mainWindow.mapView.openGeoJSON(file);
         }
     },
 
+    vfunc_open: function(files) {
+        this.activate();
+
+        let mapView = this._mainWindow.mapView;
+        if (mapView.view.realized)
+            this._openInternal(files[0]);
+        else
+            mapView.view.connect('notify::realized',
+                                 this._openInternal.bind(this, files[0]));
+    },
+
     _onWindowDestroy: function(window) {
         this._mainWindow = null;
     }
diff --git a/src/mapView.js b/src/mapView.js
index 1c63527..bf93654 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -184,10 +184,7 @@ const MapView = new Lang.Class({
         }
     },
 
-    _openGeoJSONInternal: function(file) {
-        if (!this.view.realized)
-            return;
-
+    openGeoJSON: function(file) {
         try {
             this._annotationMarkerLayer.remove_all();
             let geoJSONSource = new GeoJSONSource.GeoJSONSource({
@@ -211,15 +208,6 @@ const MapView = new Lang.Class({
         }
     },
 
-    openGeoJSON: function(file) {
-        if (this.view.realized) {
-            this._openGeoJSONInternal(file);
-        } else {
-            this.view.connect('notify::realized',
-                              this._openGeoJSONInternal.bind(this, file));
-        }
-    },
-
     gotoUserLocation: function(animate) {
         if (!this._userLocation)
             return;


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