From 560afe70af6b984b388505a16f322365e3862427 Mon Sep 17 00:00:00 2001 From: Denis Fomin Date: Tue, 28 Sep 2010 17:23:56 +0400 Subject: set_location. ability to specify a location on the built-in card --- set_location/config_dialog.ui | 832 ++++++++++++++++++++++-------------------- set_location/layers.py | 23 ++ set_location/manifest.ini | 3 +- set_location/set_location.py | 40 +- 4 files changed, 490 insertions(+), 408 deletions(-) create mode 100644 set_location/layers.py (limited to 'set_location') diff --git a/set_location/config_dialog.ui b/set_location/config_dialog.ui index 06b22e0..8976fdc 100644 --- a/set_location/config_dialog.ui +++ b/set_location/config_dialog.ui @@ -4,413 +4,435 @@ - + True - 6 - 16 - 2 - 7 - 5 - - True - 0 - alt: - - - GTK_FILL - GTK_FILL - - - - - True - 0 - area: - - - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - 0 - building: - - - 2 - 3 - GTK_FILL - GTK_FILL - - - - - True - 0 - country: - - - 3 - 4 - - - - - True - 0 - countrycode: - - - 4 - 5 - - - - - True - 0 - description: - - - 5 - 6 - - - - - True - 0 - floor: - - - 6 - 7 - - - - - True - 0 - locality: - - - 7 - 8 - - - - - True - 0 - lat: - - - 8 - 9 - - - - - True - 0 - lon: - - - 9 - 10 - - - - - True - 0 - postalcode: - - - 10 - 11 - - - - - True - 0 - region: - - - 11 - 12 - - - - - True - 0 - room: - - - 12 - 13 - - - - - True - 0 - street: - - - 13 - 14 - - - - - True - 0 - text: - - - 14 - 15 - - - - - True - 0 - uri: - - - 15 - 16 - - - - - True - True - Altitude in meters above or below sea level - - - - 1 - 2 - - - - - True - True - A named area such as a campus or neighborhood - - - - 1 - 2 - 1 - 2 - - - - - True - True - A specific building on a street or in an area - - - - 1 - 2 - 2 - 3 - - - - - True - True - The nation where the user is located - - - - 1 - 2 - 3 - 4 - - - - - True - True - The ISO 3166 two-letter country code - - - - 1 - 2 - 4 - 5 - - - - - True - True - A natural-language name for or description of the location - - - - 1 - 2 - 5 - 6 - - - - - True - True - A particular floor in a building - - - - 1 - 2 - 6 - 7 - - - - - True - True - A locality within the administrative region, such as a town or city - - - - 1 - 2 - 7 - 8 - - - - - True - True - Latitude in decimal degrees North - - - - 1 - 2 - 8 - 9 - - - - - True - True - Longitude in decimal degrees East - - - - 1 - 2 - 9 - 10 - - - - - True - True - A code used for postal delivery - - - - 1 - 2 - 10 - 11 - - - - - True - True - An administrative region of the nation, such as a state or province - - - - 1 - 2 - 11 - 12 - - - - - True - True - A particular room in a building - - - - 1 - 2 - 12 - 13 - - - - - True - True - A thoroughfare within the locality, or a crossing of two thoroughfares - - - - 1 - 2 - 13 - 14 - - - - - True - True - A catch-all element that captures any other information about the location - - - - 1 - 2 - 14 - 15 - - - - - True - True - A URI or URL pointing to information about the location - - - - 1 - 2 - 15 - 16 + + True + 6 + 16 + 2 + 7 + 5 + + + True + 0 + alt: + + + GTK_FILL + GTK_FILL + + + + + True + 0 + area: + + + 1 + 2 + GTK_FILL + GTK_FILL + + + + + True + 0 + building: + + + 2 + 3 + GTK_FILL + GTK_FILL + + + + + True + 0 + country: + + + 3 + 4 + + + + + True + 0 + countrycode: + + + 4 + 5 + + + + + True + 0 + description: + + + 5 + 6 + + + + + True + 0 + floor: + + + 6 + 7 + + + + + True + 0 + locality: + + + 7 + 8 + + + + + True + 0 + lat: + + + 8 + 9 + + + + + True + 0 + lon: + + + 9 + 10 + + + + + True + 0 + postalcode: + + + 10 + 11 + + + + + True + 0 + region: + + + 11 + 12 + + + + + True + 0 + room: + + + 12 + 13 + + + + + True + 0 + street: + + + 13 + 14 + + + + + True + 0 + text: + + + 14 + 15 + + + + + True + 0 + uri: + + + 15 + 16 + + + + + True + True + + + + 1 + 2 + + + + + True + True + + + + 1 + 2 + 1 + 2 + + + + + True + True + + + + 1 + 2 + 2 + 3 + + + + + True + True + + + + 1 + 2 + 3 + 4 + + + + + True + True + + + + 1 + 2 + 4 + 5 + + + + + True + True + + + + 1 + 2 + 5 + 6 + + + + + True + True + + + + 1 + 2 + 6 + 7 + + + + + True + True + + + + 1 + 2 + 7 + 8 + + + + + True + True + + + + 1 + 2 + 8 + 9 + + + + + True + True + + + + 1 + 2 + 9 + 10 + + + + + True + True + + + + 1 + 2 + 10 + 11 + + + + + True + True + + + + 1 + 2 + 11 + 12 + + + + + True + True + + + + 1 + 2 + 12 + 13 + + + + + True + True + + + + 1 + 2 + 13 + 14 + + + + + True + True + + + + 1 + 2 + 14 + 15 + + + + + True + True + + + + 1 + 2 + 15 + 16 + + + + + False + False + 0 + + + + + True + all + immediate + vertical + + + + + + True + Click the right mouse button to specify the location + + + False + False + 6 + end + 1 + + + + + 6 + 1 diff --git a/set_location/layers.py b/set_location/layers.py new file mode 100644 index 0000000..876a3d1 --- /dev/null +++ b/set_location/layers.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +## +import osmgpsmap +import gobject + + +class DummyLayer(gobject.GObject, osmgpsmap.GpsMapLayer): + def __init__(self): + gobject.GObject.__init__(self) + + def do_draw(self, gpsmap, gdkdrawable): + pass + + def do_render(self, gpsmap): + pass + + def do_busy(self): + return False + + def do_button_press(self, gpsmap, gdkeventbutton): + return False + +gobject.type_register(DummyLayer) diff --git a/set_location/manifest.ini b/set_location/manifest.ini index 1bc1b09..29fce84 100644 --- a/set_location/manifest.ini +++ b/set_location/manifest.ini @@ -1,8 +1,9 @@ [info] name: Set Location short_name: set_location -version: 0.1 +version: 0.2 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 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 32fb0df..b01c9ae 100644 --- a/set_location/set_location.py +++ b/set_location/set_location.py @@ -72,13 +72,41 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): self.xml = gtk.Builder() self.xml.set_translation_domain('setlocation') self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, - ['config_table']) + ['hbox1']) config_table = self.xml.get_object('config_table') - self.child.pack_start(config_table) + hbox = self.xml.get_object('hbox1') + self.child.pack_start(hbox) self.xml.connect_signals(self) self.connect('hide', self.on_hide) def on_run(self): + no_map = None + try: + import osmgpsmap + except: + no_map = True + if not no_map: + from layers import DummyLayer + import gtkgui_helpers + + vbox = self.xml.get_object('vbox1') + vbox.set_size_request(400, -1) + + self.osm = osmgpsmap.GpsMap() + self.osm.layer_add(osmgpsmap.GpsMapOsd(show_dpad=True, + show_zoom=True)) + self.osm.layer_add(DummyLayer()) + lat = float(self.plugin.config['lat']) + lon = float(self.plugin.config['lon']) + self.osm.set_center_and_zoom(lat, lon, 12) + self.path_to_image = os.path.abspath(gtkgui_helpers.get_icon_path( + '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])) @@ -88,3 +116,11 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): widget = self.xml.get_object(name) self.plugin.config[name] = widget.get_text() self.plugin.activate() + + def map_clicked(self, osm, event): + lat, lon = self.osm.get_event_location(event).get_degrees() + if event.button == 3: + self.osm.image_remove(self.osm_image) + 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)) -- cgit v1.2.3