Add method to generate map links
This commit is contained in:
parent
dd7496d7a7
commit
423cfb9fdc
|
@ -44,6 +44,7 @@ from gajim.common import i18n
|
|||
from gajim.common.i18n import _
|
||||
from gajim.common.helpers import AdditionalDataDict
|
||||
from gajim.common.helpers import open_uri
|
||||
from gajim.common.helpers import geo_provider_from_location
|
||||
from gajim.common.contacts import GC_Contact
|
||||
from gajim.common.const import AvatarSize
|
||||
from gajim.common.const import KindConstant
|
||||
|
@ -648,10 +649,9 @@ class ChatControl(ChatControlBase):
|
|||
def on_location_eventbox_button_release_event(self, widget, event):
|
||||
if 'geoloc' in self.contact.pep:
|
||||
location = self.contact.pep['geoloc'].data
|
||||
if ('lat' in location) and ('lon' in location):
|
||||
uri = 'https://www.openstreetmap.org/?' + \
|
||||
'mlat=%(lat)s&mlon=%(lon)s&zoom=16' % {'lat': location['lat'],
|
||||
'lon': location['lon']}
|
||||
if 'lat' in location and 'lon' in location:
|
||||
uri = geo_provider_from_location(location['lat'],
|
||||
location['lon'])
|
||||
open_uri(uri)
|
||||
|
||||
def on_location_eventbox_leave_notify_event(self, widget, event):
|
||||
|
|
|
@ -1506,8 +1506,7 @@ def parse_uri(uri):
|
|||
if not lon:
|
||||
return URI(type=URIType.UNKNOWN, data=uri)
|
||||
|
||||
uri = ('https://www.openstreetmap.org/?'
|
||||
'mlat=%s&mlon=%s&zoom=16') % (lat, lon)
|
||||
uri = geo_provider_from_location(lat, lon)
|
||||
return URI(type=URIType.GEO, data=uri)
|
||||
|
||||
if uri.startswith('file://'):
|
||||
|
@ -1565,3 +1564,8 @@ def open_uri_with_custom(config_app, uri):
|
|||
exec_command(command)
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
|
||||
def geo_provider_from_location(lat, lon):
|
||||
return ('https://www.openstreetmap.org/?'
|
||||
'mlat=%s&mlon=%s&zoom=16') % (lat, lon)
|
||||
|
|
Loading…
Reference in New Issue