diff --git a/set_location/config_dialog.ui b/set_location/config_dialog.ui index 386b5a0..aedf343 100644 --- a/set_location/config_dialog.ui +++ b/set_location/config_dialog.ui @@ -1,139 +1,54 @@ + - + False - + + + + True False + 18 + vertical + 6 - + True False - - - True + warning + True + + False + 6 + end - + True False - 0 - Preset: + You need to install gir1.2-gtkchamplain and gir1.2-gtkclutter-1.0 for the map to work. False - False - 7 - 0 - - - - - True - False - - - - True True 1 + + + False + True + 0 + + + + + False - - False - True - False - True - False - 0 - - - - True - False - - - True - False - gtk-save - - - True - True - 0 - - - - - True - False - 0 - Save preset - - - True - True - 1 - - - - - - - False - False - 7 - 2 - - - - - False - True - False - False - True - False - - - - True - False - - - True - False - gtk-delete - - - True - True - 0 - - - - - True - False - Delete preset - - - True - True - 1 - - - - - - - False - False - 3 - + @@ -142,479 +57,651 @@ 0 + + + True + True + 0 + + + + + True + False + 12 - + True False - 6 - 16 - 2 - 7 - 5 + 6 + 12 - + True False - 0 - alt: - - - GTK_FILL - GTK_FILL - - - - - True - False - 0 - area: - - - 1 - 2 - GTK_FILL - GTK_FILL - - - - - True - False - 0 - building: - - - 2 - 3 - GTK_FILL - GTK_FILL - - - - - True - False - 0 - country: - - - 3 - 4 - - - - - True - False - 0 - countrycode: - - - 4 - 5 - - - - - True - False - 0 - description: - - - 5 - 6 - - - - - True - False - 0 - floor: - - - 6 - 7 - - - - - True - False - 0 - locality: - - - 7 - 8 - - - - - True - False - 0 - lat: - - - 8 - 9 - - - - - True - False - 0 - lon: - - - 9 - 10 - - - - - True - False - 0 - postalcode: - - - 10 - 11 - - - - - True - False - 0 - region: - - - 11 - 12 - - - - - True - False - 0 - room: - - - 12 - 13 - - - - - True - False - 0 - street: - - - 13 - 14 - - - - - True - False - 0 - text: - - - 14 - 15 - - - - - True - False - 0 - uri: - - - 15 - 16 - - - - - True - True - True - Altitude in meters above or below sea level - + vertical + 6 + + + 200 + True + False + + + + True + True + 0 + + + + + True + False + 6 + start + + + gtk-save + True + False + True + Save Preset + True + + + + False + True + 0 + + + + + gtk-remove + True + False + False + True + Remove Preset + True + + + + False + True + 1 + + + + + False + True + 1 + + 1 - 2 + 0 - + True - True - True - A named area such as a campus or neighborhood - + False + end + Preset + - 1 - 2 - 1 - 2 - - - - - True - True - True - A specific building on a street or in an area - - - - 1 - 2 - 2 - 3 - - - - - True - True - True - The nation where the user is located - - - - 1 - 2 - 3 - 4 - - - - - True - True - True - The ISO 3166 two-letter country code - - - - 1 - 2 - 4 - 5 - - - - - True - True - True - A natural-language name for or description of the location - - - - 1 - 2 - 5 - 6 - - - - - True - True - True - A particular floor in a building - - - - 1 - 2 - 6 - 7 - - - - - True - True - True - A locality within the administrative region, such as a town or city - - - - 1 - 2 - 7 - 8 + 0 + 0 + 250 True True - True Latitude in decimal degrees North - + * 1 - 2 - 8 - 9 + 1 + + + + + True + False + end + L_atitude + True + + + + 0 + 1 True True - True Longitude in decimal degrees East - + * 1 - 2 - 9 - 10 + 2 - + + True + False + end + L_ongitude + True + lon + + + + 0 + 2 + + + + True True - True - A code used for postal delivery - + Altitude in meters above sea level + * 1 - 2 - 10 - 11 + 3 + + + + + True + False + end + A_ltitude + True + alt + + + + 0 + 3 + + + + + True + True + Nation we are located in + * + + + 1 + 4 + + + + + True + False + end + _Country + True + country + + + + 0 + 4 + + + + + True + True + Two-letter country code (ISO 3166) + * + + + 1 + 5 + + + + + True + False + end + Cou_ntry code + True + countrycode + + + + 0 + 5 True True - True - An administrative region of the nation, such as a state or province - + Administrative region of the nation, such as a state or province + * 1 - 2 - 11 - 12 + 6 - + + True + False + end + Re_gion + True + region + + + + 0 + 6 + + + + True True - True - A particular room in a building - + Locality within the administrative region, such as a town or city + * 1 - 2 - 12 - 13 + 7 + + + + + True + False + end + Localit_y + True + locality + + + + 0 + 7 + + + + + True + True + Code used for postal delivery + * + + + 1 + 8 + + + + + True + False + end + _Postal code + True + postalcode + + + + 0 + 8 + + + + + True + True + A named area such as a campus or neighborhood + * + + + 1 + 9 + + + + + True + False + end + A_rea + True + area + + + + 0 + 9 True True - True - A thoroughfare within the locality, or a crossing of two thoroughfares - + A street within the locality, or a crossing of two streets + * 1 - 2 - 13 - 14 + 10 - + + True + False + end + _Street + True + street + + + + 0 + 10 + + + + True True - True - A catch-all element that captures any other information about the location - + A specific building on a street or in an area + * + + + 1 + 11 + + + + + True + False + end + _Building + True + building + + + + 0 + 11 + + + + + True + True + A particular floor in a building + * + + + 1 + 12 + + + + + True + False + end + _Floor + True + floor + + + + 0 + 12 + + + + + True + True + A particular room in a building + * + + + 1 + 13 + + + + + True + False + end + Roo_m + True + room + + + + 0 + 13 + + + + + True + True + A description of the location + * 1 - 2 14 - 15 + + + + + True + False + end + Descrip_tion + True + description + + + + 0 + 14 True True - True - A URI or URL pointing to information about the location - + An URI or URL pointing to information about the location + * 1 - 2 15 - 16 + + + + + True + False + end + UR_I + True + uri + + + + 0 + 15 + + + + + True + True + Any other information about the location + * + + + 1 + 16 + + + + + True + False + end + Te_xt + True + text + + + + 0 + 16 False - False + True + 0 + + + + + True + False + vertical + 6 + + + True + False + vertical + 6 + + + + + + True + True + 0 + + + + + 400 + False + start + Map + True + + + + True + True + 1 + + + + + True + False + start + end + Use right mouse button to set your location. +Middle mouse button shows/hides your contacts on the map. + + + + False + True + 2 + + + + + False + True 1 False - False - 0 - - - - - True - False - immediate - - - - - - - - - True True - 6 1 diff --git a/set_location/set_location.py b/set_location/set_location.py index fe8cb20..6c77da4 100644 --- a/set_location/set_location.py +++ b/set_location/set_location.py @@ -35,7 +35,7 @@ try: GtkClutter.init([]) # Must be initialized before importing those: from gi.repository import Champlain, GtkChamplain except: - log.debug('Champlain library not available') + log.exception('Champlain library not available') CHAMPLAIN_AVAILABLE = False @@ -43,9 +43,9 @@ class SetLocationPlugin(GajimPlugin): @log_calls('SetLocationPlugin') def init(self): self.description = _('Set information about your current geographical ' - 'or physical location. \n' - 'To be able to set your location on the built-in map, ' - 'you must install gir1.2-gtkchamplain') + 'or physical location. \nTo be able to set your location on the ' + 'built-in map, you need to have gir1.2-gtkchamplain and ' + 'gir1.2-gtkclutter-1.0 installed') self.config_dialog = SetLocationPluginConfigDialog(self) self.config_default_values = { 'alt': (1609, ''), @@ -93,7 +93,7 @@ class SetLocationPlugin(GajimPlugin): self._data[name] = self.config[name] if not acct: - #set geo for all accounts + # Set geo for all accounts for acct in app.connections: if app.config.get_per('accounts', acct, 'publish_location'): app.connections[acct].get_module('UserLocation').send( @@ -108,10 +108,10 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): 'config_dialog.ui') self.xml = Gtk.Builder() self.xml.set_translation_domain('gajim_plugins') - self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, - ['hbox1']) - hbox = self.xml.get_object('hbox1') - self.get_child().pack_start(hbox, True, True, 0) + self.xml.add_objects_from_file(self.GTK_BUILDER_FILE_PATH, + ['config_box']) + config_box = self.xml.get_object('config_box') + self.get_child().pack_start(config_box, True, True, 0) self.xml.connect_signals(self) self.connect('hide', self.on_hide) self.connect('show', self.on_show) @@ -125,6 +125,7 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): self.preset_combo.add_attribute(cellrenderer, 'text', 0) #self.plugin.config['presets'] = {'default': {}} + @log_calls('SetLocationPlugin.SetLocationPluginConfigDialog') def on_run(self): if not self.is_active: @@ -138,9 +139,17 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): widget = self.xml.get_object(name) widget.set_text(str(self.plugin.config[name])) + map_placeholder = self.xml.get_object('map_placeholder') + dependency_bar = self.xml.get_object('dependency_warning') + dependency_bar.connect("close", lambda b: b.hide()) + dependency_bar.connect("response", lambda b,i: b.hide()) + if CHAMPLAIN_AVAILABLE and not self.is_active: - vbox = self.xml.get_object('vbox1') - vbox.set_size_request(400, -1) + map_placeholder.set_no_show_all(True) + map_placeholder.hide() + dependency_bar.set_revealed(False) + map_box = self.xml.get_object('map_box') + map_box.set_size_request(400, -1) embed = GtkChamplain.Embed() @@ -165,11 +174,8 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): self.path_to_image = os.path.abspath(gtkgui_helpers.get_icon_path( 'org.gajim.Gajim', 16)) - vbox.pack_start(embed, expand=True, fill=True, padding=6) - label = Gtk.Label(_( - 'Click right mouse button to set your location, \n'\ - 'middle mouse button to show / hide your contacts on the map')) - vbox.pack_start(label, expand=False, fill=False, padding=6) + map_box.pack_start(embed, expand=True, fill=True, padding=0) + self.is_active = True self.layer = Champlain.MarkerLayer() texture = Clutter.Texture() @@ -198,6 +204,7 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): continue widget = self.xml.get_object(name) self.plugin.config[name] = widget.get_text() + lat = self.xml.get_object('lat').get_text() lon = self.xml.get_object('lon').get_text() if self.is_valid_coord(lat, lon): @@ -208,7 +215,7 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): else: self.plugin.config['lat'] = '0.0' self.plugin.config['lon'] = '0.0' - error_text = 'lat or lon field contains wrong value.' + error_text = _('Latitude or Longitude field contains an invalid value') WarningDialog(_('Wrong coordinates'), error_text, self) def map_clicked(self, actor, event, view):