set_location. some fix
This commit is contained in:
@@ -417,17 +417,7 @@
|
|||||||
<placeholder/>
|
<placeholder/>
|
||||||
</child>
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkLabel" id="help_label">
|
<placeholder/>
|
||||||
<property name="visible">True</property>
|
|
||||||
<property name="label" translatable="yes">Click the right mouse button to specify the location</property>
|
|
||||||
</object>
|
|
||||||
<packing>
|
|
||||||
<property name="expand">False</property>
|
|
||||||
<property name="fill">False</property>
|
|
||||||
<property name="padding">6</property>
|
|
||||||
<property name="pack_type">end</property>
|
|
||||||
<property name="position">1</property>
|
|
||||||
</packing>
|
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
[info]
|
[info]
|
||||||
name: Set Location
|
name: Set Location
|
||||||
short_name: set_location
|
short_name: set_location
|
||||||
version: 0.2
|
version: 0.3
|
||||||
description: Set information about the current geographical or physical location.
|
description: Set information about the current geographical or physical location.
|
||||||
To be able to specify a location on the built-in card, you must install python-osmgpsmap
|
To be able to specify a location on the built-in card, you must install python-osmgpsmap > 0.5
|
||||||
authors: Denis Fomin <fominde@gmail.com>
|
authors: Denis Fomin <fominde@gmail.com>
|
||||||
homepage: http://trac-plugins.gajim.org/wiki/SetLocalitionPlugin
|
homepage: http://trac-plugins.gajim.org/wiki/SetLocalitionPlugin
|
||||||
|
|
||||||
|
|||||||
@@ -78,14 +78,22 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog):
|
|||||||
self.child.pack_start(hbox)
|
self.child.pack_start(hbox)
|
||||||
self.xml.connect_signals(self)
|
self.xml.connect_signals(self)
|
||||||
self.connect('hide', self.on_hide)
|
self.connect('hide', self.on_hide)
|
||||||
|
self.is_active = None
|
||||||
|
|
||||||
def on_run(self):
|
def on_run(self):
|
||||||
no_map = None
|
no_map = None
|
||||||
|
|
||||||
|
for name in self.plugin.config_default_values:
|
||||||
|
widget = self.xml.get_object(name)
|
||||||
|
widget.set_text(str(self.plugin.config[name]))
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import osmgpsmap
|
import osmgpsmap
|
||||||
|
if osmgpsmap.__version__ < '0.6':
|
||||||
|
no_map = True
|
||||||
except:
|
except:
|
||||||
no_map = True
|
no_map = True
|
||||||
if not no_map:
|
if not no_map and not self.is_active:
|
||||||
from layers import DummyLayer
|
from layers import DummyLayer
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
|
|
||||||
@@ -103,13 +111,15 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog):
|
|||||||
'gajim', 16))
|
'gajim', 16))
|
||||||
self.icon = gtk.gdk.pixbuf_new_from_file_at_size(
|
self.icon = gtk.gdk.pixbuf_new_from_file_at_size(
|
||||||
self.path_to_image, 16, 16)
|
self.path_to_image, 16, 16)
|
||||||
self.osm_image = self.osm.image_add(lat, lon, self.icon)
|
|
||||||
self.osm.connect('button_release_event', self.map_clicked)
|
self.osm.connect('button_release_event', self.map_clicked)
|
||||||
vbox.pack_start(self.osm)
|
vbox.pack_start(self.osm, expand=True, fill=True, padding=6)
|
||||||
|
label = gtk.Label(
|
||||||
for name in self.plugin.config_default_values:
|
'Click the right mouse button to specify the location')
|
||||||
widget = self.xml.get_object(name)
|
vbox.pack_start(label, expand=False, fill=False, padding=6)
|
||||||
widget.set_text(str(self.plugin.config[name]))
|
self.is_active = True
|
||||||
|
self.osm_image = self.osm.image_add(lat, lon, self.icon)
|
||||||
|
self.xml.get_object('lat').connect('changed', self.on_lon_changed)
|
||||||
|
self.xml.get_object('lon').connect('changed', self.on_lon_changed)
|
||||||
|
|
||||||
def on_hide(self, widget):
|
def on_hide(self, widget):
|
||||||
for name in self.plugin.config_default_values:
|
for name in self.plugin.config_default_values:
|
||||||
@@ -124,3 +134,15 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog):
|
|||||||
self.osm_image = self.osm.image_add(lat, lon, self.icon)
|
self.osm_image = self.osm.image_add(lat, lon, self.icon)
|
||||||
self.xml.get_object('lat').set_text(str(lat))
|
self.xml.get_object('lat').set_text(str(lat))
|
||||||
self.xml.get_object('lon').set_text(str(lon))
|
self.xml.get_object('lon').set_text(str(lon))
|
||||||
|
|
||||||
|
def on_lon_changed(self, widget):
|
||||||
|
try:
|
||||||
|
lat = float(self.xml.get_object('lat').get_text())
|
||||||
|
lon = float(self.xml.get_object('lon').get_text())
|
||||||
|
except ValueError,e:
|
||||||
|
return
|
||||||
|
if not -85 < lat < 85 or not -180 < lon < 180:
|
||||||
|
return
|
||||||
|
self.osm.image_remove(self.osm_image)
|
||||||
|
self.osm_image = self.osm.image_add(lat, lon, self.icon)
|
||||||
|
self.osm.set_center(lat, lon)
|
||||||
|
|||||||
Reference in New Issue
Block a user