From d66fba1aecb398d0fc44c3225058cb9eb4163713 Mon Sep 17 00:00:00 2001 From: Denis Fomin Date: Thu, 30 Sep 2010 11:22:45 +0400 Subject: set_location.fix #1 --- set_location/config_dialog.ui | 858 +++++++++++++++++++++++------------------- set_location/set_location.py | 49 ++- 2 files changed, 517 insertions(+), 390 deletions(-) (limited to 'set_location') diff --git a/set_location/config_dialog.ui b/set_location/config_dialog.ui index 6c7b659..3570ebc 100644 --- a/set_location/config_dialog.ui +++ b/set_location/config_dialog.ui @@ -7,397 +7,477 @@ True - + 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 - - + vertical - - True - True - - - - 1 - 2 - 15 - 16 + + True + + + True + 0 + Preset: + + + False + False + 7 + 0 + + + + + True + + + + 1 + + + + + True + False + True + 0 + + + + True + + + True + gtk-save + + + 0 + + + + + True + 0 + Save preset + + + 1 + + + + + + + False + False + 7 + 2 + + + + + 0 + + + + + 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 + 1 diff --git a/set_location/set_location.py b/set_location/set_location.py index ba0abf8..f8cc974 100644 --- a/set_location/set_location.py +++ b/set_location/set_location.py @@ -13,6 +13,7 @@ from plugins import GajimPlugin from plugins.helpers import log_calls, log from common import gajim import gtkgui_helpers +from dialogs import InputDialog locale_path = os.path.dirname(__file__) + '/locales' locale.bindtextdomain('setlocation', locale_path) @@ -42,7 +43,8 @@ class SetLocationPlugin(GajimPlugin): 'room' : ('Observatory', ''), 'street' : ('34th and Broadway', ''), 'text' : ('Northwest corner of the lobby', ''), - 'uri' : ('http://beta.plazes.com/plazes/1940:jabber_inc', ''),} + 'uri' : ('http://beta.plazes.com/plazes/1940:jabber_inc', ''), + 'presets': ({'default': {}}, ''),} @log_calls('SetLocationPlugin') def activate(self): @@ -81,10 +83,23 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): self.connect('hide', self.on_hide) self.is_active = None + self.preset_combo = self.xml.get_object('preset_combobox') + self.preset_liststore = gtk.ListStore(str) + self.preset_combo.set_model(self.preset_liststore) + cellrenderer = gtk.CellRendererText() + self.preset_combo.pack_start(cellrenderer, True) + self.preset_combo.add_attribute(cellrenderer, 'text', 0) + #self.plugin.config['presets'] = {'default': {}} + pres_keys = sorted(self.plugin.config['presets'].keys()) + for key in pres_keys: + self.preset_liststore.append((key,)) + def on_run(self): no_map = None for name in self.plugin.config_default_values: + if name == 'presets': + continue widget = self.xml.get_object(name) widget.set_text(str(self.plugin.config[name])) @@ -125,6 +140,8 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): def on_hide(self, widget): for name in self.plugin.config_default_values: + if name == 'presets': + continue widget = self.xml.get_object(name) self.plugin.config[name] = widget.get_text() self.plugin.activate() @@ -178,3 +195,33 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog): for image in self.images: self.osm.image_remove(image) self.images = [] + + def on_preset_button_clicked(self, widget): + def on_ok(preset_name): + if preset_name == '': + return + preset = {} + for name in self.plugin.config_default_values: + if name == 'presets': + continue + widget = self.xml.get_object(name) + preset[name] = widget.get_text() + preset = {preset_name: preset} + presets = dict(self.plugin.config['presets'].items() + \ + preset.items()) + self.plugin.config['presets'] = presets + iter_ = self.preset_liststore.append((preset_name,)) + self.preset_combo.set_active_iter(iter_) + self.set_modal(False) + InputDialog(_('Save as Preset'), _('Please type a name for this preset'), + is_modal=True, ok_handler=on_ok) + + def on_preset_combobox_changed(self, widget): + model = widget.get_model() + active = widget.get_active() + if active < 0: + return + pres_name = model[active][0].decode('utf-8') + for name in self.plugin.config['presets'][pres_name].keys(): + widget = self.xml.get_object(name) + widget.set_text(str(self.plugin.config['presets'][pres_name][name])) -- cgit v1.2.3