[gnome-maps/gnome-3-14] Add MAPS_SERVICE environment override
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/gnome-3-14] Add MAPS_SERVICE environment override
- Date: Mon, 22 Aug 2016 18:37:03 +0000 (UTC)
commit 8363ddd8fe6fad6f32c709c96b360bf8fc7f44f4
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Sat Aug 20 20:36:31 2016 +0200
Add MAPS_SERVICE environment override
src/mapSource.js | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/src/mapSource.js b/src/mapSource.js
index 39323b3..3a0b982 100644
--- a/src/mapSource.js
+++ b/src/mapSource.js
@@ -25,6 +25,7 @@ const Gtk = imports.gi.Gtk;
const GtkClutter = imports.gi.GtkClutter;
const Lang = imports.lang;
const Soup = imports.gi.Soup;
+const System = imports.system;
const Config = imports.config;
const Path = imports.path;
@@ -87,17 +88,30 @@ function _updateAttributionImage(source) {
_attributionImage.pixbuf = GdkPixbuf.Pixbuf.new_from_stream(stream, null);
}
+function _getServiceFromFile(filename) {
+ let data = Utils.readFile(filename);
+ if (!data) {
+ log('Failed to open service file: ' + filename);
+ System.exit(1);
+ }
+ _tileService = JSON.parse(data).tiles;
+ return _tileService;
+}
+
function _createDefaultService() {
let filename = GLib.build_filenamev([Path.RESOURCE_DIR,
_DEFAULT_SERVICE_FILE]);
- let data = Utils.readFile(filename);
- return JSON.parse(data);
+ return _getServiceFromFile(filename);
}
function _getTileService() {
if (_tileService)
return _tileService;
+ let serviceOverride = GLib.getenv('MAPS_SERVICE');
+ if (serviceOverride)
+ return _getServiceFromFile(serviceOverride);
+
let user_agent = 'gnome-maps/' + Config.PACKAGE_VERSION;
let session = new Soup.Session({ user_agent : user_agent });
let msg = Soup.Message.new('GET', _TILE_SERVICE_URL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]