[gnome-maps/wip/osm-edit: 18/47] osmEdit: wire up a rudimentary upload dialog to enter comment and source



commit ff49ef75c6d3e5346d7abb6815630cd42487a569
Author: Marcus Lundblad <ml update uu se>
Date:   Tue Feb 10 22:45:15 2015 +0100

    osmEdit: wire up a rudimentary upload dialog to enter comment and source

 data/ui/osm-edit-dialog.ui |   69 +++++++++++++++++++++++++++++++++++++++++++-
 src/osmEditDialog.js       |   18 +++++++++++-
 2 files changed, 85 insertions(+), 2 deletions(-)
---
diff --git a/data/ui/osm-edit-dialog.ui b/data/ui/osm-edit-dialog.ui
index c65624c..15170c3 100644
--- a/data/ui/osm-edit-dialog.ui
+++ b/data/ui/osm-edit-dialog.ui
@@ -76,6 +76,72 @@
                 <property name="name">editor</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkGrid" id="uploadGrid">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="margin_start">15</property>
+                <property name="margin_end">15</property>
+                <property name="margin_top">15</property>
+                <property name="margin_bottom">15</property>
+                <child>
+                  <object class="GtkLabel" id="commentLabel">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                   <property name="label" translatable="true">Comment:</property>
+                 </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+               <child>
+                  <object class="GtkEntry" id="commentEntry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                 </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="sourceLabel">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                   <property name="label" translatable="true">Source:</property>
+                 </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+               <child>
+                  <object class="GtkEntry" id="sourceEntry">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="hexpand">True</property>
+                    <property name="vexpand">True</property>
+                 </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">1</property>
+                  </packing>
+                </child>
+
+              </object>
+              <packing>
+                <property name="name">upload</property>
+              </packing>
+            </child>
+
+
          </object>
        </child>
       </object>
@@ -99,7 +165,8 @@
         <child>
           <object class="GtkButton" id="saveButton">
             <property name="label" translatable="yes">_Save</property>
-            <property name="visible">False</property>
+            <property name="visible">True</property>
+           <property name="sensitive">False</property>
             <property name="can_focus">True</property>
             <property name="use_underline">True</property>
             <style>
diff --git a/src/osmEditDialog.js b/src/osmEditDialog.js
index 556795b..d7fdc68 100644
--- a/src/osmEditDialog.js
+++ b/src/osmEditDialog.js
@@ -43,7 +43,7 @@ const OSMEditDialog = new Lang.Class({
     _init: function(params) {
        this._place = params.place;
        delete params.place;
-       
+
        // This is a construct-only property and cannot be set by GtkBuilder
         params.use_header_bar = true;
 
@@ -58,11 +58,25 @@ const OSMEditDialog = new Lang.Class({
             this._cancellable.cancel();
         }).bind(this));
 
+       this._isEditing = false;
+       this._saveButton.connect('clicked', this._onSaveClicked.bind(this));
+       
        Application.osmEditManager.fetchObject(this._place,
                                               this._fetchOSMObjectCB.bind(this),
                                               this._cancellable);
     },
 
+    _onSaveClicked: function() {
+       if (this._isEditing) {
+           // switch to the upload view
+           this._stack.set_visible_child_name('upload');
+           this._saveButton.label = _("Upload");
+           this._isEditing = false;
+       } else {
+           // upload data to OSM
+       }
+    },
+    
     _fetchOSMObjectCB: function(success, status, data) {
        if (success) {
            this._loadOSMData(data);
@@ -73,6 +87,7 @@ const OSMEditDialog = new Lang.Class({
 
     _loadOSMData: function(data) {
        this._osmObject = data;
+       this._isEditing = true;
        this._initEditWidgets();
        this._stack.set_visible_child_name('editor');
     },
@@ -90,6 +105,7 @@ const OSMEditDialog = new Lang.Class({
 
        this._nameEntry.connect('changed', (function() {
            this._osmObject.setTag('name', this._nameEntry.text);
+           this._saveButton.sensitive = true;
        }).bind(this));
     }
 });


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