summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Danielsson <jonas@threetimestwo.org>2016-08-17 12:57:05 +0200
committerJonas Danielsson <jonas@threetimestwo.org>2016-08-19 20:14:18 +0200
commit25a0800a9f12d033bfc0f8c2c354583ad1763556 (patch)
tree1c5bfdfff8c853ac92035d46ec9ddc0e164634cb
parente6ac45eff18676d7f21d5b928de7881b55dd8919 (diff)
downloadgnome-maps-25a0800a9f12d033bfc0f8c2c354583ad1763556.tar.gz
Use GtkClutter for attribution logo
https://bugzilla.gnome.org/show_bug.cgi?id=769352
-rw-r--r--src/mainWindow.js3
-rw-r--r--src/mapSource.js47
-rw-r--r--src/mapView.js5
3 files changed, 39 insertions, 16 deletions
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 44341b67..98a500e2 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -34,7 +34,6 @@ const FavoritesPopover = imports.favoritesPopover;
const Geoclue = imports.geoclue;
const LayersPopover = imports.layersPopover;
const LocationServiceNotification = imports.locationServiceNotification;
-const MapSource = imports.mapSource;
const MapView = imports.mapView;
const PlaceEntry = imports.placeEntry;
const PlaceStore = imports.placeStore;
@@ -67,8 +66,6 @@ const MainWindow = new Lang.Class({
this.mapView = new MapView.MapView();
overlay.add(this.mapView);
- overlay.add_overlay(new MapSource.AttributionLogo());
-
this.mapView.gotoUserLocation(false);
this._sidebar = this._createSidebar();
diff --git a/src/mapSource.js b/src/mapSource.js
index e5b4d373..16fa99f9 100644
--- a/src/mapSource.js
+++ b/src/mapSource.js
@@ -22,6 +22,7 @@ const GdkPixbuf = imports.gi.GdkPixbuf;
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Gtk = imports.gi.Gtk;
+const GtkClutter = imports.gi.GtkClutter;
const Lang = imports.lang;
const Soup = imports.gi.Soup;
@@ -36,28 +37,48 @@ const _DEFAULT_SERVICE_FILE = 'maps-service.json';
const _FILE_CACHE_SIZE_LIMIT = (10 * 1024 * 1024); /* 10Mb */
const _MEMORY_CACHE_SIZE_LIMIT = 100; /* number of tiles */
+const _LOGO_PADDING_X = 10;
+const _LOGO_PADDING_Y = 25;
+
const AttributionLogo = new Lang.Class({
Name: 'AttributionLogo',
- Extends: Gtk.Bin,
-
- _init: function() {
- this.parent({ margin_end: 6,
- margin_bottom: 25,
- halign: Gtk.Align.END,
- valign: Gtk.Align.END });
- this.add(_attributionImage);
+ Extends: GtkClutter.Actor,
+
+ _init: function(view) {
+ this.parent();
+
+ if (_attributionImage)
+ this.contents = _attributionImage;
+ else
+ return;
+
+ view.connect('notify::width', (function() {
+ this._updatePosition(view);
+ }).bind(this));
+
+ view.connect('notify::height', (function() {
+ this._updatePosition(view);
+ }).bind(this));
+
+ this._updatePosition(view);
+ },
+
+ _updatePosition: function(view) {
+ let width = _attributionImage.pixbuf.width;
+ let height = _attributionImage.pixbuf.height;
+
+ this.set_position(view.width - width - _LOGO_PADDING_X,
+ view.height - height - _LOGO_PADDING_Y);
}
});
function _updateAttributionImage(source) {
+ if (!source.attribution_logo || source.attribution_logo === "")
+ return;
+
if (!_attributionImage)
_attributionImage = new Gtk.Image();
- if (!source.attribution_logo || source.attribution_logo === "") {
- _attributionImage.visible = false;
- return;
- }
-
let data = GLib.base64_decode(source.attribution_logo);
let stream = Gio.MemoryInputStream.new_from_bytes(GLib.Bytes.new(data));
_attributionImage.pixbuf = GdkPixbuf.Pixbuf.new_from_stream(stream, null);
diff --git a/src/mapView.js b/src/mapView.js
index a4f3045e..15a88c1d 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -150,6 +150,11 @@ const MapView = new Lang.Class({
this.view.map_source = MapSource.createAerialSource();
else
this.view.map_source = MapSource.createStreetSource();
+
+ if (!this._attribution) {
+ this._attribution = new MapSource.AttributionLogo(this.view);
+ this.view.add_child(this._attribution);
+ }
},
gotoUserLocation: function(animate) {