[gnome-maps/wip/routing2] more sidebar work



commit 24a53f1b2fa14d0397ac3392f70e0f5711f99914
Author: Mattias Bengtsson <mattias jc bengtsson gmail com>
Date:   Tue Jun 10 05:36:44 2014 +0200

    more sidebar work

 data/gnome-maps.css |   12 ++++++------
 src/route.js        |   20 ++++++++++++++++++++
 src/sidebar.js      |   39 +++++++++------------------------------
 src/sidebar.ui      |    3 ++-
 4 files changed, 37 insertions(+), 37 deletions(-)
---
diff --git a/data/gnome-maps.css b/data/gnome-maps.css
index d8e6e57..ef4ddea 100644
--- a/data/gnome-maps.css
+++ b/data/gnome-maps.css
@@ -74,7 +74,7 @@
     background-image: url('zoom-out-insensitive.png');
 }
 
-#sidebar > * {
+.maps-sidebar > * {
     padding-bottom: 8px;
     padding-top: 8px;
 }
@@ -90,12 +90,12 @@
     padding-bottom: 4px;
 }
 
-#sidebar-instruction-list > GtkBox {
+#instruction-box {
     margin-left: 10px;
     margin-right: 10px;
-    padding-right: 10px;
-    padding-left: 10px;
+    border-bottom: 1px solid black;
 }
-#sidebar-instruction-list GtkImage {
-    margin-right: 5px;
+#instruction-box > GtkImage {
+    padding-right: 6px;
+    padding-left: 6px;
 }
diff --git a/src/route.js b/src/route.js
index ac18f0f..c5a190c 100644
--- a/src/route.js
+++ b/src/route.js
@@ -85,11 +85,31 @@ const TurnPoint = new Lang.Class({
         this._type = type;
         this.distance = distance;
         this.instruction = instruction;
+        this.iconResource = this._getIconResource();
     },
 
     isDestination: function() {
         return this._type === TurnPointType.START
             || this._type === TurnPointType.VIA
             || this._type === TurnPointType.STOP;
+    },
+
+    _getIconResource: function() {
+        switch(this._type) {
+        case TurnPointType.SHARP_LEFT:   return '/org/gnome/maps/direction-sharpleft';
+        case TurnPointType.LEFT:         return '/org/gnome/maps/direction-left';
+        case TurnPointType.SLIGHT_LEFT:  return '/org/gnome/maps/direction-slightleft';
+        case TurnPointType.CONTINUE:     return '/org/gnome/maps/direction-continue';
+        case TurnPointType.SLIGHT_RIGHT: return '/org/gnome/maps/direction-slightright';
+        case TurnPointType.RIGHT:        return '/org/gnome/maps/direction-right';
+        case TurnPointType.SHARP_RIGHT:  return '/org/gnome/maps/direction-sharpright';
+
+        // TODO: get icons for these
+        // case dir.END:          return '/org/gnome/maps/direction-end';
+        // case dir.VIA:          return '/org/gnome/maps/direction-via';
+        // case dir.START:        return '/org/gnome/maps/direction-start';
+        default:               return "";
+        }
     }
 });
+
diff --git a/src/sidebar.js b/src/sidebar.js
index ba27686..dc6b1ee 100644
--- a/src/sidebar.js
+++ b/src/sidebar.js
@@ -45,7 +45,9 @@ const Sidebar = new Lang.Class({
                       halign:              Gtk.Align.END,
                       valign:              Gtk.Align.FILL
                     });
-        let ui = Utils.getUIObject('sidebar', [ 'grid',
+        this.get_style_context().add_class('maps-sidebar');
+        
+        let ui = Utils.getUIObject('sidebar', [ 'sidebar-form',
                                                 'instruction-list-scrolled',
                                                 'instruction-list',
                                                 'from-completion',
@@ -60,11 +62,11 @@ const Sidebar = new Lang.Class({
                                         ui.modeBikeToggle,
                                         ui.modeCarToggle);
 
-        ui.grid.attach(this._createEntry("from", ui.fromCompletion),
-                       1, 0, 1, 1);
-        ui.grid.attach(this._createEntry("to",   ui.toCompletion),
-                       1, 1, 1, 1);
-        this.add(ui.grid);
+        ui.sidebarForm.attach(this._createEntry("from", ui.fromCompletion),
+                              1, 0, 1, 1);
+        ui.sidebarForm.attach(this._createEntry("to",   ui.toCompletion),
+                              1, 1, 1, 1);
+        this.add(ui.sidebarForm);
     },
 
     _initTransportationToggles: function(pedestrian, bike, car) {
@@ -100,10 +102,6 @@ const Sidebar = new Lang.Class({
     },
 
     _initInstructionList: function() {
-        this._instructionList.connect('row-activated', (function(list, row) {
-            this.emit('instruction-selected', row.instruction);
-        }).bind(this));
-
         let route = Application.routeService.route;
 
         route.connect('reset', this._clearInstructions.bind(this));
@@ -200,27 +198,8 @@ const InstructionRow = new Lang.Class({
                                                'direction-image',
                                                'instruction-label']);
         ui.instructionLabel.label  = this.turnPoint.instruction;
-        ui.directionImage.resource = directionToResource(this.turnPoint.direction);
+        ui.directionImage.resource = this.turnPoint.iconResource;
         
         this.add(ui.instructionBox);
     }
 });
-
-function directionToResource(direction) {
-    let dir = Route.TurnPointType;
-    switch(direction) {
-    case dir.SHARP_LEFT:   return '/org/gnome/maps/direction-sharpleft';
-    case dir.LEFT:         return '/org/gnome/maps/direction-left';
-    case dir.SLIGHT_LEFT:  return '/org/gnome/maps/direction-slightleft';
-    case dir.CONTINUE:     return '/org/gnome/maps/direction-continue';
-    case dir.SLIGHT_RIGHT: return '/org/gnome/maps/direction-slightright';
-    case dir.RIGHT:        return '/org/gnome/maps/direction-right';
-    case dir.SHARP_RIGHT:  return '/org/gnome/maps/direction-sharpright';
-
-    // TODO: get icons for these
-    // case dir.END:          return '/org/gnome/maps/direction-end';
-    // case dir.VIA:          return '/org/gnome/maps/direction-via';
-    // case dir.START:        return '/org/gnome/maps/direction-start';
-    default:               return "";
-    }
-}
diff --git a/src/sidebar.ui b/src/sidebar.ui
index ec37c5f..b2f4916 100644
--- a/src/sidebar.ui
+++ b/src/sidebar.ui
@@ -40,7 +40,7 @@
       </attributes>
     </child>
   </object>
-  <object class="GtkGrid" id="grid">
+  <object class="GtkGrid" id="sidebar-form">
     <property name="name">sidebar-form</property>
     <property name="visible">True</property>
     <property name="can_focus">False</property>
@@ -52,6 +52,7 @@
     <property name="valign">fill</property>
     <property name="orientation">vertical</property>
     <property name="row_spacing">10</property>
+    <property name="width_request">250</property>
     <child>
       <object class="GtkBox" id="mode-chooser">
         <property name="visible">True</property>


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