set_location.fix #1
This commit is contained in:
@@ -6,6 +6,79 @@
|
|||||||
<child>
|
<child>
|
||||||
<object class="GtkHBox" id="hbox1">
|
<object class="GtkHBox" id="hbox1">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkVBox" id="vbox2">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="orientation">vertical</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkHBox" id="hbox2">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="preset">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">Preset:</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="padding">7</property>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkComboBox" id="preset_combobox">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<signal name="changed" handler="on_preset_combobox_changed"/>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkButton" id="preset_button">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="can_focus">False</property>
|
||||||
|
<property name="receives_default">True</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<signal name="clicked" handler="on_preset_button_clicked"/>
|
||||||
|
<child>
|
||||||
|
<object class="GtkHBox" id="hbox3">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkImage" id="image1">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="stock">gtk-save</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkLabel" id="label17">
|
||||||
|
<property name="visible">True</property>
|
||||||
|
<property name="xalign">0</property>
|
||||||
|
<property name="label" translatable="yes">Save preset</property>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="padding">7</property>
|
||||||
|
<property name="position">2</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="position">0</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
<child>
|
<child>
|
||||||
<object class="GtkTable" id="config_table">
|
<object class="GtkTable" id="config_table">
|
||||||
<property name="visible">True</property>
|
<property name="visible">True</property>
|
||||||
@@ -401,6 +474,13 @@
|
|||||||
</packing>
|
</packing>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
<packing>
|
||||||
|
<property name="expand">False</property>
|
||||||
|
<property name="fill">False</property>
|
||||||
|
<property name="position">1</property>
|
||||||
|
</packing>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
<packing>
|
<packing>
|
||||||
<property name="expand">False</property>
|
<property name="expand">False</property>
|
||||||
<property name="fill">False</property>
|
<property name="fill">False</property>
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ from plugins import GajimPlugin
|
|||||||
from plugins.helpers import log_calls, log
|
from plugins.helpers import log_calls, log
|
||||||
from common import gajim
|
from common import gajim
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
|
from dialogs import InputDialog
|
||||||
|
|
||||||
locale_path = os.path.dirname(__file__) + '/locales'
|
locale_path = os.path.dirname(__file__) + '/locales'
|
||||||
locale.bindtextdomain('setlocation', locale_path)
|
locale.bindtextdomain('setlocation', locale_path)
|
||||||
@@ -42,7 +43,8 @@ class SetLocationPlugin(GajimPlugin):
|
|||||||
'room' : ('Observatory', ''),
|
'room' : ('Observatory', ''),
|
||||||
'street' : ('34th and Broadway', ''),
|
'street' : ('34th and Broadway', ''),
|
||||||
'text' : ('Northwest corner of the lobby', ''),
|
'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')
|
@log_calls('SetLocationPlugin')
|
||||||
def activate(self):
|
def activate(self):
|
||||||
@@ -81,10 +83,23 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog):
|
|||||||
self.connect('hide', self.on_hide)
|
self.connect('hide', self.on_hide)
|
||||||
self.is_active = None
|
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):
|
def on_run(self):
|
||||||
no_map = None
|
no_map = None
|
||||||
|
|
||||||
for name in self.plugin.config_default_values:
|
for name in self.plugin.config_default_values:
|
||||||
|
if name == 'presets':
|
||||||
|
continue
|
||||||
widget = self.xml.get_object(name)
|
widget = self.xml.get_object(name)
|
||||||
widget.set_text(str(self.plugin.config[name]))
|
widget.set_text(str(self.plugin.config[name]))
|
||||||
|
|
||||||
@@ -125,6 +140,8 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog):
|
|||||||
|
|
||||||
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:
|
||||||
|
if name == 'presets':
|
||||||
|
continue
|
||||||
widget = self.xml.get_object(name)
|
widget = self.xml.get_object(name)
|
||||||
self.plugin.config[name] = widget.get_text()
|
self.plugin.config[name] = widget.get_text()
|
||||||
self.plugin.activate()
|
self.plugin.activate()
|
||||||
@@ -178,3 +195,33 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog):
|
|||||||
for image in self.images:
|
for image in self.images:
|
||||||
self.osm.image_remove(image)
|
self.osm.image_remove(image)
|
||||||
self.images = []
|
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]))
|
||||||
|
|||||||
Reference in New Issue
Block a user