[gnome-maps/wip/accuracy-circle: 4/5] userLocation: Display description & accuracy on selection
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/accuracy-circle: 4/5] userLocation: Display description & accuracy on selection
- Date: Sun, 14 Apr 2013 15:59:30 +0000 (UTC)
commit 552e96715dd9a625ee6c6f217d2f2c6de7396c40
Author: Zeeshan Ali (Khattak) <zeeshanak gnome org>
Date: Sat Apr 13 19:38:16 2013 +0300
userLocation: Display description & accuracy on selection
Known issues:
* For some reason the default font Cantarell doesn't render nicely.
* There is no way to unselect the location pin currently.
data/icons/Makefile.am | 1 +
data/icons/bubble.svg | 78 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/userLocation.js | 35 ++++++++++++++++++++--
3 files changed, 111 insertions(+), 3 deletions(-)
---
diff --git a/data/icons/Makefile.am b/data/icons/Makefile.am
index 1fbb2fd..9f24530 100644
--- a/data/icons/Makefile.am
+++ b/data/icons/Makefile.am
@@ -15,6 +15,7 @@ public_icons = \
imagesdir = $(datadir)/gnome-maps/pixmaps
images_DATA = \
+ bubble.svg \
pin.svg \
$(NULL)
diff --git a/data/icons/bubble.svg b/data/icons/bubble.svg
new file mode 100644
index 0000000..699446a
--- /dev/null
+++ b/data/icons/bubble.svg
@@ -0,0 +1,78 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+ xmlns:dc="http://purl.org/dc/elements/1.1/"
+ xmlns:cc="http://creativecommons.org/ns#"
+ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+ xmlns:svg="http://www.w3.org/2000/svg"
+ xmlns="http://www.w3.org/2000/svg"
+ xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+ xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+ width="161"
+ height="115.5625"
+ id="svg7688"
+ version="1.1"
+ inkscape:version="0.48.4 r9939"
+ sodipodi:docname="New document 3">
+ <defs
+ id="defs7690" />
+ <sodipodi:namedview
+ inkscape:document-units="mm"
+ pagecolor="#ffffff"
+ bordercolor="#666666"
+ borderopacity="1.0"
+ inkscape:pageopacity="0.0"
+ inkscape:pageshadow="2"
+ inkscape:zoom="1.2279853"
+ inkscape:cx="251.09627"
+ inkscape:cy="70.10915"
+ inkscape:current-layer="layer1"
+ id="namedview7692"
+ showgrid="false"
+ inkscape:snap-nodes="false"
+ inkscape:snap-bbox="true"
+ units="mm"
+ fit-margin-top="0"
+ fit-margin-left="0"
+ fit-margin-right="0"
+ fit-margin-bottom="0"
+ inkscape:window-width="1600"
+ inkscape:window-height="841"
+ inkscape:window-x="0"
+ inkscape:window-y="27"
+ inkscape:window-maximized="1">
+ <inkscape:grid
+ type="xygrid"
+ id="grid7704"
+ empspacing="5"
+ visible="true"
+ enabled="true"
+ snapvisiblegridlinesonly="true"
+ originx="-100px"
+ originy="-524.4375px" />
+ </sodipodi:namedview>
+ <metadata
+ id="metadata7694">
+ <rdf:RDF>
+ <cc:Work
+ rdf:about="">
+ <dc:format>image/svg+xml</dc:format>
+ <dc:type
+ rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
+ <dc:title></dc:title>
+ </cc:Work>
+ </rdf:RDF>
+ </metadata>
+ <g
+ inkscape:label="Layer 1"
+ inkscape:groupmode="layer"
+ id="layer1"
+ transform="translate(-100,-104.09448)">
+ <path
+ style="fill:#000000;fill-opacity:0.9;stroke:none;display:inline"
+ d="m 106,104.09448 c -3.324,0 -6,2.676 -6,6 l 0,87.5 c 0,3.324 2.676,6 6,6 l 58.4375,0
16.0625,16.0625 16.0625,-16.0625 58.4375,0 c 3.324,0 6,-2.676 6,-6 l 0,-87.5 c 0,-3.324 -2.676,-6 -6,-6 l
-149,0 z"
+ id="rect6900"
+ inkscape:connector-curvature="0" />
+ </g>
+</svg>
diff --git a/src/userLocation.js b/src/userLocation.js
index 902ca10..5be0b7e 100644
--- a/src/userLocation.js
+++ b/src/userLocation.js
@@ -21,6 +21,7 @@
const Clutter = imports.gi.Clutter;
const Champlain = imports.gi.Champlain;
const Geocode = imports.gi.GeocodeGlib;
+const GObject = imports.gi.GObject;
const Lang = imports.lang;
const Mainloop = imports.mainloop;
@@ -47,10 +48,38 @@ const UserLocation = new Lang.Class({
// FIXME: Using deprecated function here cause I failed to get the same result
// with locationMarker.set_pivot_point(0.5, 0).
locationMarker.set_anchor_point_from_gravity(Clutter.Gravity.SOUTH);
- let actor = Utils.CreateActorFromImageFile(Path.ICONS_DIR + "/pin.svg");
- if (actor == null)
+ let pin_actor = Utils.CreateActorFromImageFile(Path.ICONS_DIR + "/pin.svg");
+ if (pin_actor == null)
return;
- locationMarker.add_actor(actor);
+ let bubbleActor = Utils.CreateActorFromImageFile(Path.ICONS_DIR + "/bubble.svg");
+ if (bubbleActor == null)
+ return;
+ bubbleActor.set_x_expand(true);
+ bubbleActor.set_y_expand(true);
+ let text = _("%s\nPosition Accuracy: %s").format (this.description,
+ Utils.getDescriptionForAccuracy(this.accuracy));
+ let textActor = new Clutter.Text({ text: text });
+ textActor.set_margin_left(6);
+ textActor.set_margin_right(6);
+ textActor.set_color(new Clutter.Color({ red: 255,
+ blue: 255,
+ green: 255,
+ alpha: 255 }));
+ let layout = new Clutter.BinLayout();
+ let descriptionActor = new Clutter.Actor({ layout_manager: layout });
+ descriptionActor.add_child(bubbleActor);
+ descriptionActor.add_child(textActor);
+
+ let layout = new Clutter.BoxLayout({ vertical: true });
+ let locationActor = new Clutter.Actor({ layout_manager: layout });
+ locationActor.add_child(descriptionActor);
+ locationActor.add_child(pin_actor);
+
+ locationMarker.add_actor(locationActor);
+
+ locationMarker.bind_property("selected",
+ descriptionActor, "visible",
+ GObject.BindingFlags.SYNC_CREATE);
if (this.accuracy == 0) {
layer.add_marker(locationMarker);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]