[gnome-maps/wip/jonasdn/service: 4/4] Use GtkClutter for attribution logo
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/jonasdn/service: 4/4] Use GtkClutter for attribution logo
- Date: Thu, 18 Aug 2016 18:47:55 +0000 (UTC)
commit a0929fccfda00b274d459d0372668136d2b2216d
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Wed Aug 17 12:57:05 2016 +0200
Use GtkClutter for attribution logo
https://bugzilla.gnome.org/show_bug.cgi?id=769352
src/mainWindow.js | 5 -----
src/mapSource.js | 37 +++++++++++++++++++++++++++++--------
src/mapView.js | 5 +++++
3 files changed, 34 insertions(+), 13 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 52d689e..dd28a8e 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -35,7 +35,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;
@@ -80,10 +79,6 @@ const MainWindow = new Lang.Class({
this._overlay.add(this._mapView);
- if (!this.application.local_tile_path) {
- this._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 f542025..2930ff4 100644
--- a/src/mapSource.js
+++ b/src/mapSource.js
@@ -18,10 +18,12 @@
*/
const Champlain = imports.gi.Champlain;
+const Clutter = imports.gi.Clutter;
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,16 +38,35 @@ 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();
+ this.contents = _attributionImage;
+
+ 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) {
diff --git a/src/mapView.js b/src/mapView.js
index 1c905b2..6b38cb1 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -212,6 +212,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);
+ }
} else {
let renderer = new Champlain.ImageRenderer();
let source = new Maps.FileTileSource({
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]