[gnome-maps/wip/jonasdn/printmarkers: 1/2] mapMarker: Make actorFromIconName static
- From: Jonas Danielsson <jonasdn src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/jonasdn/printmarkers: 1/2] mapMarker: Make actorFromIconName static
- Date: Tue, 23 Feb 2016 20:04:13 +0000 (UTC)
commit 98dee3c31589b0c1d456402bfcb4a5b2ee0b2422
Author: Jonas Danielsson <jonas threetimestwo org>
Date: Tue Feb 23 21:03:22 2016 +0100
mapMarker: Make actorFromIconName static
src/mapMarker.js | 78 ++++++++++++++++++++++----------------------
src/placeMarker.js | 2 +-
src/turnPointMarker.js | 8 ++--
src/userLocationMarker.js | 4 +-
4 files changed, 46 insertions(+), 46 deletions(-)
---
diff --git a/src/mapMarker.js b/src/mapMarker.js
index ce70716..529610b 100644
--- a/src/mapMarker.js
+++ b/src/mapMarker.js
@@ -31,6 +31,45 @@ const Mainloop = imports.mainloop;
const MapWalker = imports.mapWalker;
const Utils = imports.utils;
+function actorFromIconName(name, size, color) {
+ try {
+ let theme = Gtk.IconTheme.get_default();
+ let pixbuf;
+
+ if (color) {
+ let info = theme.lookup_icon(name, size, 0);
+ pixbuf = info.load_symbolic(color, null, null, null,
+ null, null)[0];
+ } else {
+ pixbuf = theme.load_icon(name, size, 0);
+ }
+
+ let canvas = new Clutter.Canvas({ width: pixbuf.get_width(),
+ height: pixbuf.get_height() });
+
+ canvas.connect('draw', (function(canvas, cr) {
+ cr.setOperator(Cairo.Operator.CLEAR);
+ cr.paint();
+ cr.setOperator(Cairo.Operator.OVER);
+
+ Gdk.cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
+ cr.paint();
+
+ this._surface = cr.getTarget();
+ }).bind(this));
+
+ let actor = new Clutter.Actor();
+ actor.set_content(canvas);
+ actor.set_size(pixbuf.get_width(), pixbuf.get_height());
+ canvas.invalidate();
+
+ return actor;
+ } catch (e) {
+ Utils.debug('Failed to load image: %s'.format(e.message));
+ return null;
+ }
+}
+
const MapMarker = new Lang.Class({
Name: 'MapMarker',
Extends: Champlain.Marker,
@@ -90,45 +129,6 @@ const MapMarker = new Lang.Class({
this._surface = surface;
},
- _actorFromIconName: function(name, size, color) {
- try {
- let theme = Gtk.IconTheme.get_default();
- let pixbuf;
-
- if (color) {
- let info = theme.lookup_icon(name, size, 0);
- pixbuf = info.load_symbolic(color, null, null, null,
- null, null)[0];
- } else {
- pixbuf = theme.load_icon(name, size, 0);
- }
-
- let canvas = new Clutter.Canvas({ width: pixbuf.get_width(),
- height: pixbuf.get_height() });
-
- canvas.connect('draw', (function(canvas, cr) {
- cr.setOperator(Cairo.Operator.CLEAR);
- cr.paint();
- cr.setOperator(Cairo.Operator.OVER);
-
- Gdk.cairo_set_source_pixbuf(cr, pixbuf, 0, 0);
- cr.paint();
-
- this._surface = cr.getTarget();
- }).bind(this));
-
- let actor = new Clutter.Actor();
- actor.set_content(canvas);
- actor.set_size(pixbuf.get_width(), pixbuf.get_height());
- canvas.invalidate();
-
- return actor;
- } catch (e) {
- Utils.debug('Failed to load image: %s'.format(e.message));
- return null;
- }
- },
-
_onButtonPress: function(marker, event) {
// Zoom in on marker on double-click
if (event.get_click_count() > 1) {
diff --git a/src/placeMarker.js b/src/placeMarker.js
index 3083b53..6ae2ef1 100644
--- a/src/placeMarker.js
+++ b/src/placeMarker.js
@@ -31,7 +31,7 @@ const PlaceMarker = new Lang.Class({
_init: function(params) {
this.parent(params);
- this.add_actor(this._actorFromIconName('mark-location', 32));
+ this.add_actor(MapMarker.actorFromIconName('mark-location', 32));
},
get anchor() {
diff --git a/src/turnPointMarker.js b/src/turnPointMarker.js
index 3774083..cc6e394 100644
--- a/src/turnPointMarker.js
+++ b/src/turnPointMarker.js
@@ -55,16 +55,16 @@ const TurnPointMarker = new Lang.Class({
this.connect('drag-finish', (function() {
this._onMarkerDrag();
}).bind(this));
- actor = this._actorFromIconName(this._turnPoint.iconName, 0);
+ actor = MapMarker.actorFromIconName(this._turnPoint.iconName, 0);
} else {
// A GNOMEish blue color
let color = new Gdk.RGBA({ red: 33 / 255,
green: 93 / 255,
blue: 156 / 255,
alpha: 255 });
- actor = this._actorFromIconName('maps-point-end-symbolic',
- 0,
- color);
+ actor = MapMarker.actorFromIconName('maps-point-end-symbolic',
+ 0,
+ color);
}
this.add_actor(actor);
},
diff --git a/src/userLocationMarker.js b/src/userLocationMarker.js
index 0db4906..a9bc165 100644
--- a/src/userLocationMarker.js
+++ b/src/userLocationMarker.js
@@ -70,12 +70,12 @@ const UserLocationMarker = new Lang.Class({
this.parent(params);
if (this.place.location.heading > -1) {
- let actor = this._actorFromIconName('user-location-compass', 0);
+ let actor = MapMarker.actorFromIconName('user-location-compass', 0);
actor.set_pivot_point(0.5, 0.5);
actor.set_rotation_angle(Clutter.RotateAxis.Z_AXIS, this.place.location.heading);
this.add_actor(actor);
} else {
- this.add_actor(this._actorFromIconName('user-location', 0));
+ this.add_actor(MapMarker.actorFromIconName('user-location', 0));
}
if (this.place.location.accuracy > 0) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]