[gnome-maps/wip/osm-edit: 43/47] osmEdit: Somewhat working in-bubble editing.
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/osm-edit: 43/47] osmEdit: Somewhat working in-bubble editing.
- Date: Thu, 30 Apr 2015 13:00:59 +0000 (UTC)
commit 694b61ecd8b4aa1e37bd2b6dd964b8cb866f8e82
Author: Marcus Lundblad <ml update uu se>
Date: Sat Mar 14 17:39:21 2015 +0100
osmEdit: Somewhat working in-bubble editing.
data/ui/map-bubble.ui | 40 ++++++++++++++++++++++++++++++++--------
src/mapBubble.js | 33 ++++++++++++++++++++++++++++++---
2 files changed, 62 insertions(+), 11 deletions(-)
---
diff --git a/data/ui/map-bubble.ui b/data/ui/map-bubble.ui
index faa1397..f481bc0 100644
--- a/data/ui/map-bubble.ui
+++ b/data/ui/map-bubble.ui
@@ -171,7 +171,7 @@
<child>
<object class="GtkEntry" id="bubble-edit-name-entry">
<property name="visible">True</property>
- <property name="can_focus">False</property>
+ <property name="can_focus">True</property>
</object>
<packing>
<property name="left_attach">1</property>
@@ -193,14 +193,38 @@
<property name="margin-top">10</property>
<property name="margin-start">15</property>
<child>
-
+ <object class="GtkBox" id="bubble-edit-button-box">
+ <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-cancel-button">
+ <property name="name">bubble-cancel-button"</property>
+ <property name="label" translatable="yes">Cancel</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ </object>
+ </child>
+ <child>
+ <object class="GtkButton" id="bubble-save-button">
+ <property name="name">bubble-save-button"</property>
+ <property name="label" translatable="yes">Save</property>
+ <property name="visible">True</property>
+ <property name="sensitive">False</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">True</property>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="left_attach">0</property>
+ <property name="top_attach">1</property>
+ </packing>
</child>
- </object>
- <packing>
- <property name="left_attach">0</property>
- <property name="top_attach">1</property>
- </packing>
- </child>
+ </object>
+ </child>
</object>
<packing>
<property name="name">edit</property>
diff --git a/src/mapBubble.js b/src/mapBubble.js
index 42f1b86..c80c87e 100644
--- a/src/mapBubble.js
+++ b/src/mapBubble.js
@@ -80,13 +80,15 @@ const MapBubble = new Lang.Class({
'bubble-favorite-button',
'bubble-check-in-button',
'bubble-edit-button',
- 'bubble-edit-name-entry']);
+ 'bubble-edit-name-entry',
+ 'bubble-save-button']);
this._viewOrEditStack = ui.stack;
this._mainGrid = ui.bubbleMainGrid;
this._editGrid = ui.bubbleEditGrid;
this._image = ui.bubbleImage;
this._content = ui.bubbleContentArea;
this._nameEntry = ui.bubbleEditNameEntry;
+ this._saveButton = ui.bubbleSaveButton;
if (!buttonFlags)
ui.bubbleButtonArea.visible = false;
@@ -99,9 +101,11 @@ const MapBubble = new Lang.Class({
this._initFavoriteButton(ui.bubbleFavoriteButton);
if (buttonFlags & Button.CHECK_IN)
this._initCheckInButton(ui.bubbleCheckInButton, checkInMatchPlace);
- if (buttonFlags & Button.EDIT)
+ if (buttonFlags & Button.EDIT) {
this._initEditButton(ui.bubbleEditButton);
- }
+ this._initOSMEditor();
+ }
+ }
this.add(ui.stack);
@@ -203,9 +207,20 @@ const MapBubble = new Lang.Class({
this._cancellable);
},
+ _initOSMEditor: function() {
+ this._nameEntry.connect('changed', (function() {
+ this._osmObject.setTag('name', this._nameEntry.text);
+ this._saveButton.sensitive = true;
+ }).bind(this));
+
+ this._saveButton.connect('clicked', this._onSaveClicked.bind(this));
+ },
+
_onObjectFetched: function(success, status, data) {
if (success) {
this._editGrid.sensitive = true;
+ // keep the save button insensitive until the user has done a change
+ this._saveButton.sensitive = false;
this._loadOSMData(data);
} else
this._showError(status);
@@ -218,5 +233,17 @@ const MapBubble = new Lang.Class({
_showError: function(status) {
+ },
+
+ _onSaveClicked: function() {
+ Application.osmEditManager.uploadObject(this._osmObject,
+ null, // TODO: add comment editing
+ null,
+ this._uploadObjectCB.bind(this));
+ },
+
+ _uploadObjectCB: function(success, status) {
+ // TODO: show error
+ this._viewOrEditStack.visible_child_name = 'view';
}
});
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]