[gnome-maps/wip/jonasdn/service-gnome-3-14: 2/3] Use GtkClutter for attribution logo



commit e3bc98c9457cb9addbb3e53c7ac4146501abf8d7
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 |    3 ---
 src/mapSource.js  |   36 ++++++++++++++++++++++++++++--------
 src/mapView.js    |    5 +++++
 3 files changed, 33 insertions(+), 11 deletions(-)
---
diff --git a/src/mainWindow.js b/src/mainWindow.js
index 4e0f67b..4863ab9 100644
--- a/src/mainWindow.js
+++ b/src/mainWindow.js
@@ -31,7 +31,6 @@ const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 
 const Application = imports.application;
-const MapSource = imports.mapSource;
 const MapView = imports.mapView;
 const LayersPopover = imports.layersPopover;
 const ContextMenu = imports.contextMenu;
@@ -64,8 +63,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 = new Sidebar.Sidebar(this.mapView);
diff --git a/src/mapSource.js b/src/mapSource.js
index dca701b..b82b232 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;
 
@@ -38,16 +39,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({ halign: Gtk.Align.END,
-                      valign: Gtk.Align.END,
-                      margin_bottom: 6,
-                      margin_end: 6 });
-        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);
+
     }
 });
 
diff --git a/src/mapView.js b/src/mapView.js
index cd9aa30..803185c 100644
--- a/src/mapView.js
+++ b/src/mapView.js
@@ -152,6 +152,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) {


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