[gnome-maps/wip/jonasdn/geojson: 6/7] application: Handle open GeoJSON files



commit 3bc38509cb40e9a14bc52815b9f72879ddd28952
Author: Jonas Danielsson <jonas threetimestwo org>
Date:   Fri Oct 23 12:09:52 2015 +0200

    application: Handle open GeoJSON files

 src/application.js |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)
---
diff --git a/src/application.js b/src/application.js
index 2a6ca2c..292c46c 100644
--- a/src/application.js
+++ b/src/application.js
@@ -76,7 +76,8 @@ const Application = new Lang.Class({
         /* Translators: This is the program name. */
         GLib.set_application_name(_("Maps"));
 
-        this.parent({ application_id: 'org.gnome.Maps' });
+        this.parent({ application_id: 'org.gnome.Maps',
+                      flags: Gio.ApplicationFlags.HANDLES_OPEN });
         this._connected = false;
 
         this.add_main_option('local',
@@ -252,6 +253,15 @@ 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];
+        if (content_type === 'application/vnd.geo+json' ||
+            content_type === 'application/json') {
+            this._mainWindow.mapView.openGeoJSON(files[0]);
+        }
+    },
+
     _onWindowDestroy: function(window) {
         this._mainWindow = null;
     }


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