[gnome-maps/wip/routing2: 7/8] MapLocation: Add route search button



commit b9efc733e32a0d606ffe31e796520478c10c34e9
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Fri May 2 21:11:28 2014 +0200

    MapLocation: Add route search button
    
    Make it possible to make simple route searches via location bubbles.
    More advanced searches will have to be made via the sidebar.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=728695

 data/gnome-maps.css               |    3 ++
 src/gnome-maps.data.gresource.xml |    1 +
 src/map-location.ui               |   50 +++++++++++++++++++++++++++++++++++++
 src/mapLocation.js                |   38 +++++++++++++++++++++++++--
 4 files changed, 89 insertions(+), 3 deletions(-)
---
diff --git a/data/gnome-maps.css b/data/gnome-maps.css
index 48bdc5c..23e2923 100644
--- a/data/gnome-maps.css
+++ b/data/gnome-maps.css
@@ -1,6 +1,9 @@
 .maps-sidebar {
     border-width: 0 0 0 1px;
 }
+.map-location > GtkLabel {
+    color: #D0D0D0;
+}
 
 .maps-sidebar:dir(rtl) {
     border-width: 0 1px 0 0;
diff --git a/src/gnome-maps.data.gresource.xml b/src/gnome-maps.data.gresource.xml
index d9265a9..7ee7af1 100644
--- a/src/gnome-maps.data.gresource.xml
+++ b/src/gnome-maps.data.gresource.xml
@@ -3,6 +3,7 @@
   <gresource prefix="/org/gnome/maps">
     <file preprocess="xml-stripblanks">app-menu.ui</file>
     <file preprocess="xml-stripblanks">main-window.ui</file>
+    <file preprocess="xml-stripblanks">map-location.ui</file>
     <file preprocess="xml-stripblanks">zoom-control.ui</file>
     <file preprocess="xml-stripblanks">search-popup.ui</file>
     <file preprocess="xml-stripblanks">context-menu.ui</file>
diff --git a/src/map-location.ui b/src/map-location.ui
new file mode 100644
index 0000000..5813ab7
--- /dev/null
+++ b/src/map-location.ui
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.15.2 on Sun Sep 15 18:56:41 2013 -->
+<interface>
+  <!-- interface-requires gtk+ 3.10 -->
+  <object class="GtkGrid" id="map-location">
+    <property name="width_request">151</property>
+    <property name="height_request">90</property>
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="column_homogeneous">True</property>
+    <style>
+      <class name="map-location"/>
+      <class name="osd"/>
+    </style>
+    <child>
+      <object class="GtkButton" id="to-here-button">
+        <property name="label" translatable="yes">Get to here</property>
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <property name="receives_default">True</property>
+        <property name="valign">end</property>
+        <property name="vexpand">True</property>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">1</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkLabel" id="name">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="justify">center</property>
+        <property name="wrap">True</property>
+        <property name="wrap_mode">word-char</property>
+        <property name="ellipsize">end</property>
+        <property name="max_width_chars">17</property>
+        <property name="lines">2</property>
+      </object>
+      <packing>
+        <property name="left_attach">0</property>
+        <property name="top_attach">0</property>
+        <property name="width">1</property>
+        <property name="height">1</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/src/mapLocation.js b/src/mapLocation.js
index 508e93c..615d0b7 100644
--- a/src/mapLocation.js
+++ b/src/mapLocation.js
@@ -23,13 +23,16 @@
 const Clutter = imports.gi.Clutter;
 const Champlain = imports.gi.Champlain;
 const Geocode = imports.gi.GeocodeGlib;
+const GtkClutter = imports.gi.GtkClutter;
 
 const Lang = imports.lang;
 const Mainloop = imports.mainloop;
 const Signals = imports.signals;
 
+const Application = imports.application;
 const Utils = imports.utils;
 const Path = imports.path;
+const Route = imports.route;
 const _ = imports.gettext.gettext;
 
 const _MAX_DISTANCE = 19850; // half of Earth's curcumference (km)
@@ -106,12 +109,41 @@ const MapLocation = new Lang.Class({
     },
 
     show: function(layer) {
-        let marker = new Champlain.Label({ text: this.description });
-        marker.set_location(this.latitude, this.longitude);
-        layer.add_marker(marker);
+        let image = Utils.CreateActorFromImageFile(Path.ICONS_DIR + "/bubble.svg");
+        let bubble = new Champlain.CustomMarker();
+        bubble.add_child(image);
+        bubble.set_location(this.latitude, this.longitude);
+        bubble.connect('notify::width',
+                       bubble.set_translation.bind(bubble,
+                                                   -(Math.floor(bubble.get_width() / 2)),
+                                                   -bubble.get_height(),
+                                                   0));
+
+        let ui = Utils.getUIObject('map-location', [ 'map-location',
+                                                     'name',
+                                                     'to-here-button' ]);
+        ui.name.label = this.description;
+        ui.toHereButton.connect("clicked",
+                                this._onHereButtonClicked.bind(this));
+        let gtkActor = new GtkClutter.Actor({ contents:    ui.mapLocation,
+                                              margin_top:  5,
+                                              margin_left: 5 });
+        Utils.clearGtkClutterActorBg(gtkActor);
+        bubble.add_child(gtkActor);
+
+        layer.add_marker(bubble);
         Utils.debug("Added marker at " + this.latitude + ", " + this.longitude);
     },
 
+    _onHereButtonClicked: function() {
+        let to = new Geocode.Location({ latitude: this.latitude,
+                                        longitude: this.longitude
+                                      });
+        Application.routeService.query.setMany({ from: Application.geoclue.location,
+                                                 to:   to
+                                               });
+    },
+
     showNGoTo: function(animate, layer) {
         this.show(layer);
         this.goTo(animate);


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