forbid to have twice the same jid in jid-multi field in dataforms

This commit is contained in:
Yann Leboulanger 2007-11-12 20:00:16 +00:00
parent 5536262a74
commit fa7ea0783a
1 changed files with 8 additions and 2 deletions

View File

@ -518,9 +518,15 @@ class SingleForm(gtk.Table, object):
field.values = values field.values = values
def on_jid_multi_add_button_clicked(self, widget, treeview, model, field): def on_jid_multi_add_button_clicked(self, widget, treeview, model, field):
iter = model.insert(999999, ("new@jabber.id",)) jid = 'new@jabber.id'
if jid in field.values:
i = 1
while 'new%d@jabber.id' % i in field.values:
i += 1
jid = 'new%d@jabber.id' % i
iter = model.insert(999999, (jid,))
treeview.set_cursor(model.get_path(iter), treeview.get_column(0), True) treeview.set_cursor(model.get_path(iter), treeview.get_column(0), True)
field.values = field.values + ["new@jabber.id"] field.values = field.values + [jid]
def on_jid_multi_edit_button_clicked(self, widget, treeview): def on_jid_multi_edit_button_clicked(self, widget, treeview):
model, iter = treeview.get_selection().get_selected() model, iter = treeview.get_selection().get_selected()