diff --git a/src/dataforms_widget.py b/src/dataforms_widget.py index e654e226f..f3ce6c6e4 100644 --- a/src/dataforms_widget.py +++ b/src/dataforms_widget.py @@ -25,10 +25,13 @@ single means these with one record of data (without element), multiple - these which may contain more data (with element).""" import gtk +import gobject import gtkgui_helpers +import dialogs import common.dataforms as dataforms +from common import helpers import itertools @@ -374,7 +377,8 @@ class SingleForm(gtk.Table, object): elif field.type == 'jid-multi': commonwidget = False - xml = gtkgui_helpers.get_glade('data_form_window.glade', 'item_list_table') + xml = gtkgui_helpers.get_glade('data_form_window.glade', + 'item_list_table') widget = xml.get_widget('item_list_table') treeview = xml.get_widget('item_treeview') @@ -388,7 +392,8 @@ class SingleForm(gtk.Table, object): renderer = gtk.CellRendererText() renderer.set_property('editable', True) renderer.connect('edited', - self.on_jid_multi_cellrenderertext_edited, listmodel, field) + self.on_jid_multi_cellrenderertext_edited, treeview, listmodel, + field) treeview.append_column(gtk.TreeViewColumn(None, renderer, text=0)) @@ -509,8 +514,22 @@ class SingleForm(gtk.Table, object): widget.get_start_iter(), widget.get_end_iter()) - def on_jid_multi_cellrenderertext_edited(self, cell, path, newtext, model, field): - old=model[path][0] + def on_jid_multi_cellrenderertext_edited(self, cell, path, newtext, treeview, + model, field): + old = model[path][0] + if old == newtext: + return + try: + newtext = helpers.parse_jid(newtext) + except helpers.InvalidFormat, s: + dialogs.ErrorDialog(_('Invalid Jabber ID'), str(s)) + return + if newtext in field.values: + dialogs.ErrorDialog( + _('Jabber ID already in list'), + _('The Jabber ID you entered is already in the list. Choose another one.')) + gobject.idle_add(treeview.set_cursor, path) + return model[path][0]=newtext values = field.values