Merge pull request #255 from SNoiraud/FR9373

9373: Ability to be able to enter comma separated latitude/longitude …
This commit is contained in:
Sam Manzi 2017-02-12 15:30:55 +11:00 committed by GitHub
commit 61c678417a
5 changed files with 195 additions and 24 deletions

View File

@ -174,6 +174,26 @@ class EditPlace(EditPrimary):
#force validation now with initial entry
self.top.get_object("lat_entry").validate(force=True)
self.latlon = MonitoredEntry(
self.top.get_object("latlon_entry"),
self.set_latlongitude, self.get_latlongitude,
self.db.readonly)
def set_latlongitude(self, value):
try:
coma = value.index(',')
self.longitude.set_text(value[coma+1:])
self.latitude.set_text(value[:coma])
self.top.get_object("lat_entry").validate(force=True)
self.top.get_object("lon_entry").validate(force=True)
self.obj.set_latitude(self.latitude.get_value())
self.obj.set_longitude(self.longitude.get_value())
except:
pass
def get_latlongitude(self):
return ""
def _validate_coordinate(self, widget, text, typedeg):
if (typedeg == 'lat') and not conv_lat_lon(text, "0", "ISO-D"):
return ValidationError(_("Invalid latitude (syntax: 18\u00b09'") +
@ -279,7 +299,6 @@ class EditPlace(EditPrimary):
def save(self, *obj):
self.ok_button.set_sensitive(False)
if self.obj.get_name().get_value().strip() == '':
msg1 = _("Cannot save place. Name not entered.")
msg2 = _("You must enter a name before saving.")

View File

@ -167,6 +167,26 @@ class EditPlaceRef(EditReference):
#force validation now with initial entry
self.top.get_object("lat_entry").validate(force=True)
self.latlon = MonitoredEntry(
self.top.get_object("latlon_entry"),
self.set_latlongitude, self.get_latlongitude,
self.db.readonly)
def set_latlongitude(self, value):
try:
coma = value.index(',')
self.longitude.set_text(value[coma+1:])
self.latitude.set_text(value[:coma])
self.top.get_object("lat_entry").validate(force=True)
self.top.get_object("lon_entry").validate(force=True)
self.obj.set_latitude(self.latitude.get_value())
self.obj.set_longitude(self.longitude.get_value())
except:
pass
def get_latlongitude(self):
return ""
def _validate_coordinate(self, widget, text, typedeg):
if (typedeg == 'lat') and not conv_lat_lon(text, "0", "ISO-D"):
return ValidationError(_("Invalid latitude (syntax: 18\u00b09'") +

View File

@ -97,11 +97,25 @@
<property name="top_attach">1</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="comment1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Either use the two fields below to enter coordinates(latitude and longitude),</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label249">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="halign">center</property>
<property name="label" translatable="yes">L_atitude:</property>
<property name="use_underline">True</property>
<property name="justify">center</property>
@ -109,7 +123,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
@ -124,7 +138,7 @@
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
@ -152,7 +166,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
@ -167,7 +181,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
@ -182,7 +196,59 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkBox" id="copypaste">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="comment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">or use copy/paste from your favorite map provider (format : latitude,longitude) in the following field:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">4</property>
</packing>
</child>
<child>
<object class="GtkBox" id="paste_field">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="ValidatableMaskedEntry" id="latlon_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Field used to paste info from a web page like google, openstreetmap, ... </property>
<property name="hexpand">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="width">4</property>
</packing>
</child>
<child>
@ -236,7 +302,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
@ -266,7 +332,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">3</property>
<property name="top_attach">2</property>
</packing>
</child>
<child>
@ -277,7 +343,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">4</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
@ -332,7 +398,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">4</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
@ -344,7 +410,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">4</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>

View File

@ -220,6 +220,20 @@
<property name="top_attach">2</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="comment1">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="halign">start</property>
<property name="label" translatable="yes">Either use the two fields below to enter coordinates(latitude and longitude),</property>
<property name="hexpand">True</property>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="width">5</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label504">
<property name="visible">True</property>
@ -233,7 +247,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">4</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
@ -246,7 +260,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
@ -291,7 +305,7 @@
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="top_attach">8</property>
<property name="width">5</property>
</packing>
</child>
@ -320,7 +334,59 @@
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
<object class="GtkBox" id="copypaste">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="comment2">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="label" translatable="yes">or use copy/paste from your favorite map provider (format : latitude,longitude) in the following field:</property>
<property name="use_underline">True</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">5</property>
<property name="width">4</property>
</packing>
</child>
<child>
<object class="GtkBox" id="paste_field">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="spacing">6</property>
<child>
<object class="ValidatableMaskedEntry" id="latlon_entry">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="tooltip_text" translatable="yes">Field used to paste info from a web page like google, openstreetmap, ... </property>
<property name="hexpand">True</property>
<property name="invisible_char">●</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="left_attach">0</property>
<property name="top_attach">6</property>
<property name="width">4</property>
</packing>
</child>
<child>
@ -369,7 +435,7 @@
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
@ -398,7 +464,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
@ -413,7 +479,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">3</property>
<property name="top_attach">4</property>
</packing>
</child>
<child>
@ -467,7 +533,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">1</property>
<property name="top_attach">4</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
@ -479,7 +545,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">2</property>
<property name="top_attach">4</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
@ -491,7 +557,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">3</property>
<property name="top_attach">4</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>
@ -502,7 +568,7 @@ You can set these values via the Geography View by searching the place, or via a
</object>
<packing>
<property name="left_attach">4</property>
<property name="top_attach">4</property>
<property name="top_attach">7</property>
</packing>
</child>
<child>

View File

@ -144,7 +144,7 @@ class MonitoredEntry:
def force_value(self, value):
self.obj.set_text(value)
def get_value(self, value):
def get_value(self):
return str(self.obj.get_text())
def enable(self, value):