From ec6e0e704d71ac7d5442298f705170377944525c Mon Sep 17 00:00:00 2001 From: Denis Fomin Date: Tue, 28 Sep 2010 19:29:50 +0400 Subject: set_location. some fix --- set_location/config_dialog.ui | 12 +----------- set_location/manifest.ini | 4 ++-- set_location/set_location.py | 36 +++++++++++++++++++++++++++++------- 3 files changed, 32 insertions(+), 20 deletions(-) (limited to 'set_location') diff --git a/set_location/config_dialog.ui b/set_location/config_dialog.ui index 8976fdc..6c7b659 100644 --- a/set_location/config_dialog.ui +++ b/set_location/config_dialog.ui @@ -417,17 +417,7 @@ - - True - Click the right mouse button to specify the location - - - False - False - 6 - end - 1 - + diff --git a/set_location/manifest.ini b/set_location/manifest.ini index 29fce84..a840ecf 100644 --- a/set_location/manifest.ini +++ b/set_location/manifest.ini @@ -1,9 +1,9 @@ [info] name: Set Location short_name: set_location -version: 0.2 +version: 0.3 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 homepage: http://trac-plugins.gajim.org/wiki/SetLocalitionPlugin diff --git a/set_location/set_location.py b/set_location/set_location.py index b01c9ae..d593f79 100644 --- a/set_location/set_location.py +++ b/set_location/set_location.py @@ -78,14 +78,22 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): self.child.pack_start(hbox) self.xml.connect_signals(self) self.connect('hide', self.on_hide) + self.is_active = None def on_run(self): 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: import osmgpsmap + if osmgpsmap.__version__ < '0.6': + no_map = True except: no_map = True - if not no_map: + if not no_map and not self.is_active: from layers import DummyLayer import gtkgui_helpers @@ -103,13 +111,15 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): 'gajim', 16)) self.icon = gtk.gdk.pixbuf_new_from_file_at_size( 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) - vbox.pack_start(self.osm) - - for name in self.plugin.config_default_values: - widget = self.xml.get_object(name) - widget.set_text(str(self.plugin.config[name])) + vbox.pack_start(self.osm, expand=True, fill=True, padding=6) + label = gtk.Label( + 'Click the right mouse button to specify the location') + vbox.pack_start(label, expand=False, fill=False, padding=6) + 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): 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.xml.get_object('lat').set_text(str(lat)) 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) -- cgit v1.2.3