[gnome-maps/wip/osm-edit: 39/47] osmEdit: Started experimenting with in-bubble editing.



commit 71eddc6eedf3a74bd02522b2558e7fe6f0add160
Author: Marcus Lundblad <ml update uu se>
Date:   Wed Mar 11 22:01:35 2015 +0100

    osmEdit: Started experimenting with in-bubble editing.

 data/ui/map-bubble.ui |  295 +++++++++++++++++++++++++++++++------------------
 src/mapBubble.js      |   44 ++++++--
 2 files changed, 222 insertions(+), 117 deletions(-)
---
diff --git a/data/ui/map-bubble.ui b/data/ui/map-bubble.ui
index 3ee9928..a7b795e 100644
--- a/data/ui/map-bubble.ui
+++ b/data/ui/map-bubble.ui
@@ -2,134 +2,211 @@
 <!-- Generated with glade 3.18.3 -->
 <interface>
   <requires lib="gtk+" version="3.12"/>
-  <object class="GtkGrid" id="bubble-main-grid">
+  <object class="GtkStack" id="stack">
     <property name="visible">True</property>
     <property name="can_focus">False</property>
-    <property name="margin_start">10</property>
-    <property name="margin_end">10</property>
-    <property name="margin_top">10</property>
-    <property name="margin_bottom">10</property>
-    <property name="orientation">vertical</property>
     <child>
-      <object class="GtkImage" id="bubble-image">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="valign">start</property>
-        <property name="pixel_size">0</property>
-        <property name="icon_size">16</property>
-      </object>
-      <packing>
-        <property name="left_attach">0</property>
-        <property name="top_attach">0</property>
-      </packing>
-    </child>
-    <child>
-      <object class="GtkGrid" id="bubble-content-area">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin-start">15</property>
+      <object class="GtkGrid" id="bubble-main-grid">
+       <property name="visible">True</property>
+       <property name="can_focus">False</property>
+       <property name="margin_start">10</property>
+       <property name="margin_end">10</property>
+       <property name="margin_top">10</property>
+       <property name="margin_bottom">10</property>
+       <property name="orientation">vertical</property>
+       <child>
+         <object class="GtkImage" id="bubble-image">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="valign">start</property>
+            <property name="pixel_size">0</property>
+            <property name="icon_size">16</property>
+         </object>
+         <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">0</property>
+         </packing>
+       </child>
+       <child>
+         <object class="GtkGrid" id="bubble-content-area">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin-start">15</property>
+         </object>
+         <packing>
+            <property name="left_attach">1</property>
+            <property name="top_attach">0</property>
+         </packing>
+       </child>
+       <child>
+         <object class="GtkGrid" id="bubble-button-area">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin-top">10</property>
+            <property name="margin-start">15</property>
+            <child>
+              <object class="GtkBox" id="bubble-standard-button-area">
+               <property name="visible">True</property>
+               <property name="can_focus">False</property>
+               <property name="orientation">horizontal</property>
+               <property name="spacing">5</property>
+               <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>
+                    <property name="tooltip-text" translatable="yes">Add to new route</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>
+               <child>
+                 <object class="GtkButton" id="bubble-send-to-button">
+                    <property name="name">bubble-send-to-button</property>
+                    <property name="visible">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip-text" translatable="yes">Open with another application</property>
+                    <child>
+                      <object class="GtkImage" id="bubble-send-to-button-image">
+                       <property name="visible">True</property>
+                       <property name="can_focus">False</property>
+                       <property name="icon-name">send-to-symbolic</property>
+                       <property name="pixel_size">16</property>
+                      </object>
+                    </child>
+                 </object>
+               </child>
+               <child>
+                 <object class="GtkToggleButton" id="bubble-favorite-button">
+                    <property name="name">bubble-favorite-button</property>
+                    <property name="visible">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="tooltip-text" translatable="yes">Mark as favorite</property>
+                    <child>
+                      <object class="GtkImage" id="bubble-favorite-button-image">
+                       <property name="name">bubble-favorite-button-image</property>
+                       <property name="visible">True</property>
+                       <property name="can_focus">False</property>
+                       <property name="icon-name">emblem-favorite-symbolic</property>
+                       <property name="pixel_size">16</property>
+                      </object>
+                    </child>
+                 </object>
+               </child>
+               <child>
+                 <object class="GtkButton" id="bubble-check-in-button">
+                    <property name="label" translatable="yes" comments="Translators: Check in is used as a 
verb">C_heck in</property>
+                    <property name="visible">False</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="tooltip-text" translatable="yes">Check in here</property>
+                 </object>
+               </child>
+               <child>
+                 <object class="GtkButton" id="bubble-edit-button">
+                   <property name="name">bubble-edit-button"</property>
+                   <property name="label" translatable="yes">Edit</property>
+                   <!-- TODO: this button should be invisible by default
+                        when we handle OSM accounts -->
+                   <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                 </object>
+               </child>
+              </object>
+              <packing>
+               <property name="left_attach">0</property>
+               <property name="top_attach">0</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">1</property>
-        <property name="top_attach">0</property>
+        <property name="name">view</property>
       </packing>
+
     </child>
     <child>
-      <object class="GtkGrid" id="bubble-button-area">
-        <property name="visible">True</property>
-        <property name="can_focus">False</property>
-        <property name="margin-top">10</property>
-        <property name="margin-start">15</property>
-        <child>
-          <object class="GtkBox" id="bubble-standard-button-area">
+      <object class="GtkGrid" id="bubble-edit-grid">
+       <property name="visible">True</property>
+       <property name="can_focus">False</property>
+       <property name="margin_start">10</property>
+       <property name="margin_end">10</property>
+       <property name="margin_top">10</property>
+       <property name="margin_bottom">10</property>
+       <property name="orientation">vertical</property>
+
+       <child>
+         <object class="GtkGrid" id="bubble-edit-content-area">
             <property name="visible">True</property>
             <property name="can_focus">False</property>
-            <property name="orientation">horizontal</property>
-            <property name="spacing">5</property>
-            <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>
-                <property name="tooltip-text" translatable="yes">Add to new route</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>
-            <child>
-              <object class="GtkButton" id="bubble-send-to-button">
-                <property name="name">bubble-send-to-button</property>
-                <property name="visible">False</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip-text" translatable="yes">Open with another application</property>
-                <child>
-                  <object class="GtkImage" id="bubble-send-to-button-image">
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="icon-name">send-to-symbolic</property>
-                    <property name="pixel_size">16</property>
-                  </object>
-                </child>
-              </object>
-            </child>
-            <child>
-              <object class="GtkToggleButton" id="bubble-favorite-button">
-                <property name="name">bubble-favorite-button</property>
-                <property name="visible">False</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="tooltip-text" translatable="yes">Mark as favorite</property>
-                <child>
-                  <object class="GtkImage" id="bubble-favorite-button-image">
-                    <property name="name">bubble-favorite-button-image</property>
-                    <property name="visible">True</property>
-                    <property name="can_focus">False</property>
-                    <property name="icon-name">emblem-favorite-symbolic</property>
-                    <property name="pixel_size">16</property>
-                  </object>
-                </child>
-              </object>
-            </child>
-            <child>
-              <object class="GtkButton" id="bubble-check-in-button">
-                <property name="label" translatable="yes" comments="Translators: Check in is used as a 
verb">C_heck in</property>
-                <property name="visible">False</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="use_underline">True</property>
-                <property name="tooltip-text" translatable="yes">Check in here</property>
-              </object>
-            </child>
+            <property name="margin-start">15</property>
            <child>
-             <object class="GtkButton" id="bubble-edit-button">
-               <property name="name">bubble-edit-button"</property>
-               <property name="label" translatable="yes">Edit</property>
-               <!-- TODO: this button should be invisible by default
-                    when we handle OSM accounts -->
+             <object class="GtkLabel" id="edit-name-label">
                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
+               <property name="can_focus">False</property>
+               <property name="label" translatable="yes">Name</property>
              </object>
+             <packing>
+               <property name="left_attach">0</property>
+               <property name="top_attach">0</property>
+             </packing>
            </child>
-          </object>
-          <packing>
+
+           <child>
+             <object class="GtkEntry" id="edit-name-entry">
+               <property name="visible">True</property>
+               <property name="can_focus">False</property>
+             </object>
+             <packing>
+               <property name="left_attach">1</property>
+               <property name="top_attach">0</property>
+             </packing>
+           </child>
+
+         </object>
+         <packing>
             <property name="left_attach">0</property>
             <property name="top_attach">0</property>
-          </packing>
-        </child>
+         </packing>
+       </child>
+
+       <child>
+         <object class="GtkGrid" id="bubble-edit-button-area">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="margin-top">10</property>
+            <property name="margin-start">15</property>
+            <child>
+             
+           </child>
+         </object>
+         <packing>
+            <property name="left_attach">0</property>
+            <property name="top_attach">1</property>
+         </packing>
+       </child>
       </object>
       <packing>
-        <property name="left_attach">1</property>
-        <property name="top_attach">1</property>
+        <property name="name">edit</property>
       </packing>
+
     </child>
   </object>
+
 </interface>
diff --git a/src/mapBubble.js b/src/mapBubble.js
index f5c20d8..e794a9f 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -69,7 +69,9 @@ const MapBubble = new Lang.Class({
         params.modal = false;
 
         this.parent(params);
-        let ui = Utils.getUIObject('map-bubble', [ 'bubble-main-grid',
+        let ui = Utils.getUIObject('map-bubble', [ 'stack',
+                                                  'bubble-main-grid',
+                                                  'bubble-edit-grid',
                                                    'bubble-image',
                                                    'bubble-content-area',
                                                    'bubble-button-area',
@@ -78,6 +80,9 @@ const MapBubble = new Lang.Class({
                                                    'bubble-favorite-button',
                                                    'bubble-check-in-button',
                                                   'bubble-edit-button']);
+       this._viewOrEditStack = ui.stack;
+       this._mainGrid = ui.bubbleMainGrid;
+       this._editGrid = ui.bubbleEditGrid;
         this._image = ui.bubbleImage;
         this._content = ui.bubbleContentArea;
 
@@ -96,7 +101,12 @@ const MapBubble = new Lang.Class({
                this._initEditButton(ui.bubbleEditButton);
         }
 
-        this.add(ui.bubbleMainGrid);
+        this.add(ui.stack);
+
+       this._cancellable = new Gio.Cancellable();
+        this.connect('delete-event', (function() {
+            this._cancellable.cancel();
+        }).bind(this));
     },
 
     get image() {
@@ -178,12 +188,30 @@ const MapBubble = new Lang.Class({
     },
 
     _initEditButton: function(button) {
-       button.connect('clicked', (function() {
-           print ('about to edit place: type: ' + this._place.osm_type + ' id: ' +
-                  this._place.osm_id);
+       button.connect('clicked', this._onEditClicked.bind(this));
+    },
+
+    _onEditClicked: function() {
+       print ('about to edit place: type: ' + this._place.osm_type + ' id: ' +
+              this._place.osm_id);
+       this._viewOrEditStack.visible_child_name = 'edit';
+       Application.osmEditManager.fetchObject(this._place,
+                                              this._onObjectFetched.bind(this),
+                                              this._cancellable);
+    },
+
+    _onObjectFetched: function(success, status, data) {
+       if (success)
+           this._loadOSMData(data);
+       else
+           this._showError(status);
+    },
+
+    _loadOSMData: function(data) {
+
+    },
+
+    _showError: function(status) {
 
-           Application.osmEditManager.showEditDialog(this.get_toplevel(),
-                                                     this.place);
-       }).bind(this));
     }
 });


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