set_location. delete preset button added

This commit is contained in:
Denis Fomin
2010-09-30 15:34:04 +04:00
parent 0e010f9b7d
commit 884bc28407
2 changed files with 52 additions and 3 deletions

View File

@@ -74,6 +74,43 @@
<property name="position">2</property>
</packing>
</child>
<child>
<object class="GtkButton" id="del_preset">
<property name="visible">True</property>
<property name="sensitive">False</property>
<property name="can_focus">False</property>
<property name="receives_default">True</property>
<signal name="clicked" handler="on_del_preset_clicked"/>
<child>
<object class="GtkHBox" id="hbox4">
<property name="visible">True</property>
<child>
<object class="GtkImage" id="image2">
<property name="visible">True</property>
<property name="stock">gtk-delete</property>
</object>
<packing>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="label18">
<property name="visible">True</property>
<property name="label" translatable="yes">Delete 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="position">3</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>

View File

@@ -207,12 +207,12 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog):
continue
widget = self.xml.get_object(name)
preset[name] = widget.get_text()
if preset_name not in self.plugin.config['presets'].keys():
iter_ = self.preset_liststore.append((preset_name,))
self.preset_combo.set_active_iter(iter_)
preset = {preset_name: preset}
presets = dict(self.plugin.config['presets'].items() + \
preset.items())
if preset_name not in self.plugin.config['presets'].keys():
iter_ = self.preset_liststore.append((preset_name,))
#self.preset_combo.set_active_iter(iter_)
self.plugin.config['presets'] = presets
self.set_modal(False)
InputDialog(_('Save as Preset'), _('Please type a name for this preset'),
@@ -222,8 +222,20 @@ class SetLocationPluginConfigDialog(GajimPluginConfigDialog):
model = widget.get_model()
active = widget.get_active()
if active < 0:
self.xml.get_object('del_preset').set_sensitive(False)
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]))
self.xml.get_object('del_preset').set_sensitive(True)
def on_del_preset_clicked(self, widget):
active = self.preset_combo.get_active()
active_iter = self.preset_combo.get_active_iter()
name = self.preset_liststore[active][0].decode('utf-8')
presets = self.plugin.config['presets']
del presets[name]
self.plugin.config['presets'] = presets
self.preset_liststore.remove(active_iter)