[gnome-maps/wip/mlundblad/osm-edit-negative-integers: 4/4] osmEditDialog: Add support for signed integer fields
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps/wip/mlundblad/osm-edit-negative-integers: 4/4] osmEditDialog: Add support for signed integer fields
- Date: Tue, 25 Aug 2020 20:22:06 +0000 (UTC)
commit 1225dbc91479ddec7a0ea22f079ec4226338cce6
Author: Marcus Lundblad <ml update uu se>
Date: Mon Aug 24 22:56:03 2020 +0200
osmEditDialog: Add support for signed integer fields
src/osmEditDialog.js | 28 ++++++++++++++++------------
1 file changed, 16 insertions(+), 12 deletions(-)
---
diff --git a/src/osmEditDialog.js b/src/osmEditDialog.js
index c4929e2d..4504c7b5 100644
--- a/src/osmEditDialog.js
+++ b/src/osmEditDialog.js
@@ -50,10 +50,11 @@ var Response = {
* field types
*/
const EditFieldType = {
- TEXT: 0,
- INTEGER: 1,
- COMBO: 2,
- ADDRESS: 3
+ TEXT: 0,
+ INTEGER: 1,
+ UNSIGNED_INTEGER: 2,
+ COMBO: 3,
+ ADDRESS: 4
};
const _WIKI_BASE = 'https://wiki.openstreetmap.org/wiki/Key:';
@@ -151,7 +152,7 @@ const OSM_FIELDS = [
{
name: _("Population"),
tag: 'population',
- type: EditFieldType.INTEGER
+ type: EditFieldType.UNSIGNED_INTEGER
},
{
name: _("Altitude"),
@@ -652,10 +653,10 @@ var OSMEditDialog = GObject.registerClass({
this._currentRow++;
}
- _addOSMEditIntegerEntry(fieldSpec, value) {
+ _addOSMEditIntegerEntry(fieldSpec, value, min, max) {
this._addOSMEditLabel(fieldSpec);
- let spinbutton = Gtk.SpinButton.new_with_range(0, 1e9, 1);
+ let spinbutton = Gtk.SpinButton.new_with_range(min, max, 1);
spinbutton.value = value;
spinbutton.numeric = true;
spinbutton.hexpand = true;
@@ -763,7 +764,7 @@ var OSMEditDialog = GObject.registerClass({
button.connect('clicked', () => {
this._addFieldButton.active = false;
- this._addOSMField(fieldSpec, '');
+ this._addOSMField(fieldSpec);
/* add a "placeholder" empty OSM tag to keep the add field
* menu updated, these tags will be filtered out if nothing
* is entered */
@@ -788,16 +789,19 @@ var OSMEditDialog = GObject.registerClass({
_addOSMField(fieldSpec, value) {
switch (fieldSpec.type) {
case EditFieldType.TEXT:
- this._addOSMEditTextEntry(fieldSpec, value);
+ this._addOSMEditTextEntry(fieldSpec, value || '');
break;
case EditFieldType.INTEGER:
- this._addOSMEditIntegerEntry(fieldSpec, value);
+ this._addOSMEditIntegerEntry(fieldSpec, value || 0, -1e9, 1e9);
+ break;
+ case EditFieldType.UNSIGNED_INTEGER:
+ this._addOSMEditIntegerEntry(fieldSpec, value || 0, 0, 1e9);
break;
case EditFieldType.COMBO:
- this._addOSMEditComboEntry(fieldSpec, value);
+ this._addOSMEditComboEntry(fieldSpec, value || '');
break;
case EditFieldType.ADDRESS:
- this._addOSMEditAddressEntry(fieldSpec, value);
+ this._addOSMEditAddressEntry(fieldSpec, value || '');
break;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]