[gnome-maps] mapBubble: Add route button



commit 88b0a73c54af9daf33b96de3bdbeeedc343a3b82
Author: Jonas Danielsson <jonas danielsson threetimestwo org>
Date:   Thu Oct 16 01:03:02 2014 -0400

    mapBubble: Add route button
    
    https://bugzilla.gnome.org/show_bug.cgi?id=737775

 src/map-bubble.ui         |   16 ++++++++++++++++
 src/mapBubble.js          |   37 +++++++++++++++++++++++++++++++++++--
 src/searchResultBubble.js |    5 +++--
 src/userLocationBubble.js |    6 ++++--
 4 files changed, 58 insertions(+), 6 deletions(-)
---
diff --git a/src/map-bubble.ui b/src/map-bubble.ui
index b809aa0..5d4331a 100644
--- a/src/map-bubble.ui
+++ b/src/map-bubble.ui
@@ -48,6 +48,22 @@
             <style>
               <class name="linked" />
             </style>
+            <child>
+              <object class="GtkButton" id="bubble-route-button">
+                <property name="name">bubble-route-button</property>
+                <property name="visible">False</property>
+                <property name="can_focus">True</property>
+                <property name="receives_default">False</property>
+                <child>
+                  <object class="GtkImage" id="bubble-route-button-image">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="icon-name">route-button-symbolic</property>
+                    <property name="icon_size">1</property>
+                  </object>
+                </child>
+              </object>
+            </child>
           </object>
           <packing>
             <property name="left_attach">0</property>
diff --git a/src/mapBubble.js b/src/mapBubble.js
index 49fd676..d08f532 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -22,12 +22,14 @@
 
 const Gtk = imports.gi.Gtk;
 const Lang = imports.lang;
+const Mainloop = imports.mainloop;
 
 const Application = imports.application;
 const Utils = imports.utils;
 
 const Button = {
-    NONE: 0
+    NONE: 0,
+    ROUTE: 2
 };
 
 const MapBubble = new Lang.Class({
@@ -46,18 +48,26 @@ const MapBubble = new Lang.Class({
         let buttonFlags = params.buttons || Button.NONE;
         delete params.buttons;
 
+        let routeFrom = params.routeFrom;
+        delete params.routeFrom;
+
         params.modal = false;
 
         this.parent(params);
         let ui = Utils.getUIObject('map-bubble', [ 'bubble-main-grid',
                                                    'bubble-image',
                                                    'bubble-content-area',
-                                                   'bubble-button-area']);
+                                                   'bubble-button-area',
+                                                   'bubble-route-button']);
         this._image = ui.bubbleImage;
         this._content = ui.bubbleContentArea;
 
         if (!buttonFlags)
             ui.bubbleButtonArea.visible = false;
+        else {
+            if (buttonFlags & Button.ROUTE)
+                this._initRouteButton(ui.bubbleRouteButton, routeFrom);
+        }
 
         this.add(ui.bubbleMainGrid);
     },
@@ -72,5 +82,28 @@ const MapBubble = new Lang.Class({
 
     get content() {
         return this._content;
+    },
+
+    _initRouteButton: function(button, routeFrom) {
+        let query = Application.routeService.query;
+        let route = Application.routeService.route;
+        let from = query.points[0];
+        let to = query.points[query.points.length - 1];
+
+        button.visible = true;
+
+        button.connect('clicked', (function() {
+            query.freeze_notify();
+            query.reset();
+            route.reset();
+            if (routeFrom) {
+                from.place = this._place;
+            } else {
+                from.place = Application.geoclue.place;
+                to.place = this._place;
+            }
+            this.destroy();
+            query.thaw_notify();
+        }).bind(this));
     }
 });
diff --git a/src/searchResultBubble.js b/src/searchResultBubble.js
index 08b057a..e099d38 100644
--- a/src/searchResultBubble.js
+++ b/src/searchResultBubble.js
@@ -33,10 +33,11 @@ const SearchResultBubble = new Lang.Class({
     Extends: MapBubble.MapBubble,
 
     _init: function(params) {
-        this.parent(params);
-
         let ui = Utils.getUIObject('search-result-bubble', [ 'box-content',
                                                              'label-title']);
+        params.buttons = MapBubble.Button.ROUTE;
+        this.parent(params);
+
         let place = this.place;
 
         Utils.load_icon(this.place.icon, 48, (function(pixbuf) {
diff --git a/src/userLocationBubble.js b/src/userLocationBubble.js
index 0c08233..fe4c4f7 100644
--- a/src/userLocationBubble.js
+++ b/src/userLocationBubble.js
@@ -30,11 +30,13 @@ const UserLocationBubble = new Lang.Class({
     Extends: MapBubble.MapBubble,
 
     _init: function(params) {
-        this.parent(params);
-
         let ui = Utils.getUIObject('user-location-bubble', [ 'grid-content',
                                                              'label-accuracy',
                                                              'label-coordinates' ]);
+        params.buttons = MapBubble.Button.ROUTE;
+        params.routeFrom = true;
+
+        this.parent(params);
 
         this.image.icon_name = 'find-location-symbolic';
         this.image.pixel_size = 48;


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