[gnome-maps] transitLegRow: Collaps instructions when clicking on header



commit c90482499cdbe1fab369e53cd9ee39b3fb8a4f40
Author: Marcus Lundblad <ml update uu se>
Date:   Wed May 31 23:19:38 2017 +0200

    transitLegRow: Collaps instructions when clicking on header
    
    Collaps the instruction list revealed contents when clicking a second
    time on the top header with basic information about a transit leg.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=778171

 data/ui/transit-leg-row.ui |  368 ++++++++++++++++++++++---------------------
 src/transitLegRow.js       |   20 ++-
 2 files changed, 199 insertions(+), 189 deletions(-)
---
diff --git a/data/ui/transit-leg-row.ui b/data/ui/transit-leg-row.ui
index f1d824b..a35919b 100644
--- a/data/ui/transit-leg-row.ui
+++ b/data/ui/transit-leg-row.ui
@@ -5,217 +5,211 @@
     <property name="visible">True</property>
     <property name="can-focus">False</property>
     <child>
-      <object class="GtkEventBox" id="eventBox">
+      <object class="GtkGrid">
         <property name="visible">True</property>
-        <property name="can-focus">False</property>
         <child>
-          <object class="GtkGrid" id="grid">
+          <object class="GtkEventBox" id="eventBox">
             <property name="visible">True</property>
-            <property name="margin-top">0</property>
-            <property name="margin-bottom">0</property>
-            <property name="row-spacing">3</property>
+            <property name="can-focus">False</property>
             <child>
-              <object class="GtkImage" id="modeImage">
+              <object class="GtkGrid" id="grid">
                 <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <property name="margin-start">12</property>
-                <property name="margin-end">12</property>
-                <property name="halign">GTK_ALIGN_START</property>
-              </object>
-              <packing>
-                <property name="left-attach">0</property>
-                <property name="top-attach">0</property>
-                <property name="height">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkLabel" id="fromLabel">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <property name="halign">GTK_ALIGN_START</property>
-                <property name="max-width-chars">25</property>
-                <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
-              </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">0</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkGrid" id="routeGrid">
-                <property name="visible">True</property>
-                <property name="can-focus">False</property>
-                <property name="halign">GTK_ALIGN_START</property>
-                <property name="hexpand">True</property>
+                <property name="margin-top">0</property>
+                <property name="margin-bottom">0</property>
+                <property name="row-spacing">3</property>
+                <child>
+                  <object class="GtkImage" id="modeImage">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="margin-start">12</property>
+                    <property name="margin-end">12</property>
+                    <property name="halign">GTK_ALIGN_START</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">0</property>
+                    <property name="top-attach">0</property>
+                    <property name="height">2</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="fromLabel">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="halign">GTK_ALIGN_START</property>
+                    <property name="max-width-chars">25</property>
+                    <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">1</property>
+                    <property name="top-attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkGrid" id="routeGrid">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="halign">GTK_ALIGN_START</property>
+                    <property name="hexpand">True</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">1</property>
+                    <property name="top-attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="timeLabel">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="margin-start">6</property>
+                    <property name="margin-end">18</property>
+                    <property name="hexpand">False</property>
+                    <property name="halign">GTK_ALIGN_END</property>
+                  </object>
+                  <packing>
+                    <property name="left-attach">2</property>
+                    <property name="top-attach">0</property>
+                    <property name="height">2</property>
+                  </packing>
+                </child>
               </object>
-              <packing>
-                <property name="left-attach">1</property>
-                <property name="top-attach">1</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="left-attach">0</property>
+            <property name="top-attach">0</property>
+          </packing>
+        </child>
+
+        <child>
+          <object class="GtkRevealer" id="detailsRevealer">
+            <property name="visible">True</property>
             <child>
-              <object class="GtkLabel" id="timeLabel">
+              <object class="GtkGrid">
                 <property name="visible">True</property>
                 <property name="can-focus">False</property>
-                <property name="margin-start">6</property>
-                <property name="margin-end">18</property>
-                <property name="hexpand">False</property>
-                <property name="halign">GTK_ALIGN_END</property>
-              </object>
-              <packing>
-                <property name="left-attach">2</property>
-                <property name="top-attach">0</property>
-                <property name="height">2</property>
-              </packing>
-            </child>
-            <child>
-              <object class="GtkRevealer" id="detailsRevealer">
-                <property name="visible">True</property>
+                <property name="margin-left">15</property>
+                <property name="margin-right">15</property>
+                <property name="row-spacing">1</property>
+                <child>
+                  <object class="GtkLabel" id="agencyLabel">
+                    <property name="visible">False</property>
+                    <property name="use-markup">True</property>
+                    <property name="halign">GTK_ALIGN_START</property>
+                    <property name="max_width_chars">30</property>
+                    <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
+                  </object>
+                  <packing>
+                    <property name="top-attach">0</property>
+                    <property name="left-attach">0</property>
+                    <property name="width">3</property>
+                  </packing>
+                </child>
                 <child>
-                  <object class="GtkGrid">
+                  <object class="GtkSeparator">
                     <property name="visible">True</property>
                     <property name="can-focus">False</property>
-                    <property name="margin-left">15</property>
-                    <property name="margin-right">15</property>
-                    <property name="row-spacing">1</property>
-                    <child>
-                      <object class="GtkLabel" id="agencyLabel">
-                        <property name="visible">False</property>
-                        <property name="use-markup">True</property>
-                        <property name="halign">GTK_ALIGN_START</property>
-                        <property name="max_width_chars">30</property>
-                        <property name="ellipsize">PANGO_ELLIPSIZE_END</property>
-                      </object>
-                      <packing>
-                        <property name="top-attach">0</property>
-                        <property name="left-attach">0</property>
-                        <property name="width">3</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkSeparator">
-                        <property name="visible">True</property>
-                        <property name="can-focus">False</property>
-                        <property name="hexpand">True</property>
-                        <property name="valign">GTK_ALIGN_CENTER</property>
-                      </object>
-                      <packing>
-                        <property name="top-attach">1</property>
-                        <property name="left-attach">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="collapsButton">
-                        <property name="visible">True</property>
-                        <property name="can-focus">True</property>
-                        <property name="tooltip-text" translatable="yes">Hide intermediate stops and 
information</property>
-                        <style>
-                          <class name="small-circular"/>
-                        </style>
-                        <child>
-                          <object class="GtkImage">
-                            <property name="visible">True</property>
-                            <property name="can-focus">False</property>
-                            <property name="icon-name">go-up-symbolic</property>
-                            <property name="pixel-size">8</property>
-                          </object>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="top-attach">1</property>
-                        <property name="left-attach">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkSeparator">
-                        <property name="visible">True</property>
-                        <property name="can-focus">False</property>
-                        <property name="hexpand">True</property>
-                        <property name="valign">GTK_ALIGN_CENTER</property>
-                      </object>
-                      <packing>
-                        <property name="top-attach">1</property>
-                        <property name="left-attach">2</property>
-                      </packing>
-                    </child>
+                    <property name="hexpand">True</property>
+                    <property name="valign">GTK_ALIGN_CENTER</property>
+                  </object>
+                  <packing>
+                    <property name="top-attach">1</property>
+                    <property name="left-attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="collapsButton">
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="tooltip-text" translatable="yes">Hide intermediate stops and 
information</property>
+                    <style>
+                      <class name="small-circular"/>
+                    </style>
                     <child>
-                      <object class="GtkListBox" id="instructionList">
+                      <object class="GtkImage">
                         <property name="visible">True</property>
                         <property name="can-focus">False</property>
+                        <property name="icon-name">go-up-symbolic</property>
+                        <property name="pixel-size">8</property>
                       </object>
-                      <packing>
-                        <property name="top-attach">2</property>
-                        <property name="left-attach">0</property>
-                        <property name="width">3</property>
-                      </packing>
                     </child>
-
                   </object>
+                  <packing>
+                    <property name="top-attach">1</property>
+                    <property name="left-attach">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkSeparator">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="valign">GTK_ALIGN_CENTER</property>
+                  </object>
+                  <packing>
+                    <property name="top-attach">1</property>
+                    <property name="left-attach">2</property>
+                  </packing>
                 </child>
+                <child>
+                  <object class="GtkListBox" id="instructionList">
+                    <property name="visible">True</property>
+                    <property name="can-focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="top-attach">2</property>
+                    <property name="left-attach">0</property>
+                    <property name="width">3</property>
+                  </packing>
+                </child>
+
               </object>
-              <packing>
-                <property name="top-attach">3</property>
-                <property name="left-attach">0</property>
-                <property name="width">3</property>
-              </packing>
             </child>
+          </object>
+          <packing>
+            <property name="top-attach">1</property>
+            <property name="left-attach">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkStack" id="footerStack">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
             <child>
-              <object class="GtkStack" id="footerStack">
+              <object class="GtkGrid">
                 <property name="visible">True</property>
                 <property name="can-focus">False</property>
                 <child>
-                  <object class="GtkGrid">
+                  <object class="GtkSeparator">
                     <property name="visible">True</property>
                     <property name="can-focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="valign">GTK_ALIGN_CENTER</property>
+                  </object>
+                  <packing>
+                    <property name="top-attach">0</property>
+                    <property name="left-attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkButton" id="expandButton">
+                    <property name="visible">True</property>
+                    <property name="can-focus">True</property>
+                    <property name="tooltip-text" translatable="yes">Show intermediate stops and 
information</property>
+                    <style>
+                      <class name="small-circular"/>
+                    </style>
                     <child>
-                      <object class="GtkSeparator">
-                        <property name="visible">True</property>
-                        <property name="can-focus">False</property>
-                        <property name="hexpand">True</property>
-                        <property name="valign">GTK_ALIGN_CENTER</property>
-                      </object>
-                      <packing>
-                        <property name="top-attach">0</property>
-                        <property name="left-attach">0</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkButton" id="expandButton">
-                        <property name="visible">True</property>
-                        <property name="can-focus">True</property>
-                        <property name="tooltip-text" translatable="yes">Show intermediate stops and 
information</property>
-                        <style>
-                          <class name="small-circular"/>
-                        </style>
-                        <child>
-                          <object class="GtkImage">
-                            <property name="visible">True</property>
-                            <property name="can-focus">False</property>
-                            <property name="icon-name">go-down-symbolic</property>
-                            <property name="pixel-size">8</property>
-                          </object>
-                        </child>
-                      </object>
-                      <packing>
-                        <property name="top-attach">0</property>
-                        <property name="left-attach">1</property>
-                      </packing>
-                    </child>
-                    <child>
-                      <object class="GtkSeparator">
+                      <object class="GtkImage">
                         <property name="visible">True</property>
                         <property name="can-focus">False</property>
-                        <property name="hexpand">True</property>
-                        <property name="valign">GTK_ALIGN_CENTER</property>
+                        <property name="icon-name">go-down-symbolic</property>
+                        <property name="pixel-size">8</property>
                       </object>
-                      <packing>
-                        <property name="top-attach">0</property>
-                        <property name="left-attach">2</property>
-                      </packing>
                     </child>
                   </object>
                   <packing>
-                    <property name="name">expander</property>
+                    <property name="top-attach">0</property>
+                    <property name="left-attach">1</property>
                   </packing>
                 </child>
                 <child>
@@ -226,17 +220,31 @@
                     <property name="valign">GTK_ALIGN_CENTER</property>
                   </object>
                   <packing>
-                    <property name="name">separator</property>
+                    <property name="top-attach">0</property>
+                    <property name="left-attach">2</property>
                   </packing>
                 </child>
               </object>
               <packing>
-                <property name="top-attach">4</property>
-                <property name="left-attach">0</property>
-                <property name="width">3</property>
+                <property name="name">expander</property>
+              </packing>
+            </child>
+            <child>
+              <object class="GtkSeparator">
+                <property name="visible">True</property>
+                <property name="can-focus">False</property>
+                <property name="hexpand">True</property>
+                <property name="valign">GTK_ALIGN_CENTER</property>
+              </object>
+              <packing>
+                <property name="name">separator</property>
               </packing>
             </child>
           </object>
+          <packing>
+            <property name="top-attach">2</property>
+            <property name="left-attach">0</property>
+          </packing>
         </child>
       </object>
     </child>
diff --git a/src/transitLegRow.js b/src/transitLegRow.js
index 31be422..a3cf8b5 100644
--- a/src/transitLegRow.js
+++ b/src/transitLegRow.js
@@ -37,8 +37,7 @@ const TransitLegRow = new Lang.Class({
     Name: 'TransitLegRow',
     Extends: Gtk.ListBoxRow,
     Template: 'resource:///org/gnome/Maps/ui/transit-leg-row.ui',
-    InternalChildren: ['grid',
-                       'modeImage',
+    InternalChildren: ['modeImage',
                        'fromLabel',
                        'routeGrid',
                        'timeLabel',
@@ -179,13 +178,16 @@ const TransitLegRow = new Lang.Class({
         let [isButton, button] = event.get_button();
         let type = event.get_event_type();
 
-        if (isButton && button === 1 && !this._isExpanded &&
-            type === Gdk.EventType.BUTTON_PRESS) {
-            this._mapView.view.zoom_level = 16;
-            this._mapView.view.center_on(this._leg.fromCoordinate[0],
-                                         this._leg.fromCoordinate[1]);
-            if (this._hasIntructions())
-                this._expand();
+        if (isButton && button === 1 && type === Gdk.EventType.BUTTON_PRESS) {
+            if (this._isExpanded) {
+                this._collaps();
+            } else {
+                this._mapView.view.zoom_level = 16;
+                this._mapView.view.center_on(this._leg.fromCoordinate[0],
+                                             this._leg.fromCoordinate[1]);
+                if (this._hasIntructions())
+                    this._expand();
+            }
         }
     },
 


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