[gnome-maps/wip/mlundblad/remove-attribution-logo] mapSource: Remove attribution logo handling
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/remove-attribution-logo] mapSource: Remove attribution logo handling
- Date: Sat, 30 Apr 2022 20:58:37 +0000 (UTC)
commit f2215b606f487e79fb3ccf975a85725b24111700
Author: Marcus Lundblad <ml dfupdate se>
Date: Fri Apr 29 22:30:07 2022 +0200
mapSource: Remove attribution logo handling
src/mapSource.js | 81 --------------------------------------------------------
1 file changed, 81 deletions(-)
---
diff --git a/src/mapSource.js b/src/mapSource.js
index 5feb6298..dd25a6ce 100644
--- a/src/mapSource.js
+++ b/src/mapSource.js
@@ -18,93 +18,13 @@
*/
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 GObject = imports.gi.GObject;
-const Gtk = imports.gi.Gtk;
-const GtkClutter = imports.gi.GtkClutter;
-const System = imports.system;
const Service = imports.service;
const Utils = imports.utils;
-let _attributionImages = [];
-
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;
-// extra padding below logo in RTL, where scale will be on the right side
-const _LOGO_PADDING_Y_RTL = 35;
-
-var AttributionLogo = GObject.registerClass({},
-class AttributionLogo extends GtkClutter.Actor {
-
- _init(view) {
- super._init();
-
- this._view = view;
- this._rtl = Gtk.get_locale_direction() === Gtk.TextDirection.RTL;
- view.connect('notify::width', () => this._updatePosition());
- view.connect('notify::height', () => this._updatePosition());
-
- this._updatePosition(view);
- }
-
- setSource(source) {
- this._id = source.get_id();
-
- let bin = this.get_widget();
-
- if (bin.get_child())
- bin.remove(bin.get_child());
-
- if (_attributionImages[source.get_id()]) {
- bin.add(_attributionImages[source.get_id()]);
- bin.visible = true;
- } else {
- bin.visible = false;
- }
-
- this._updatePosition();
- }
-
- _updatePosition() {
- let image = _attributionImages[this._id];
-
- if (image) {
- let width = image.pixbuf.width;
- let height = image.pixbuf.height;
- let x = this._view.width - width - _LOGO_PADDING_X;
- /* TODO: ideally the attribution logo should be aligned to the left
- * side in RTL locales, but I couldn't get that working with Clutter
- * actor positioning, so adjust the padding to fit above the scale
- * for now
- */
- let y = this._view.height - height -
- (this._rtl ? _LOGO_PADDING_Y_RTL : _LOGO_PADDING_Y);
-
- this.set_position(x, y);
- }
- }
-});
-
-function _updateAttributionImage(source) {
- if (!source.attribution_logo || source.attribution_logo === "")
- return;
-
- if (!_attributionImages[source.id])
- _attributionImages[source.id] = new Gtk.Image({ visible: true });
-
- let data = GLib.base64_decode(source.attribution_logo);
- let stream = Gio.MemoryInputStream.new_from_bytes(GLib.Bytes.new(data));
- _attributionImages[source.id].pixbuf =
- GdkPixbuf.Pixbuf.new_from_stream(stream, null);
-}
-
function _createTileSource(source) {
let tileSource = new Champlain.NetworkTileSource({
id: source.id,
@@ -123,7 +43,6 @@ function _createTileSource(source) {
function _createCachedSource(source) {
let tileSource = _createTileSource(source);
- _updateAttributionImage(source);
let fileCache = new Champlain.FileCache({
size_limit: _FILE_CACHE_SIZE_LIMIT,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]