do some tests when adding a new JID to jid-multi field in dataforms
This commit is contained in:
parent
fa7ea0783a
commit
227c811b82
|
@ -25,10 +25,13 @@ single means these with one record of data (without <reported/> element),
|
||||||
multiple - these which may contain more data (with <reported/> element)."""
|
multiple - these which may contain more data (with <reported/> element)."""
|
||||||
|
|
||||||
import gtk
|
import gtk
|
||||||
|
import gobject
|
||||||
|
|
||||||
import gtkgui_helpers
|
import gtkgui_helpers
|
||||||
|
import dialogs
|
||||||
|
|
||||||
import common.dataforms as dataforms
|
import common.dataforms as dataforms
|
||||||
|
from common import helpers
|
||||||
|
|
||||||
import itertools
|
import itertools
|
||||||
|
|
||||||
|
@ -374,7 +377,8 @@ class SingleForm(gtk.Table, object):
|
||||||
elif field.type == 'jid-multi':
|
elif field.type == 'jid-multi':
|
||||||
commonwidget = False
|
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')
|
widget = xml.get_widget('item_list_table')
|
||||||
treeview = xml.get_widget('item_treeview')
|
treeview = xml.get_widget('item_treeview')
|
||||||
|
|
||||||
|
@ -388,7 +392,8 @@ class SingleForm(gtk.Table, object):
|
||||||
renderer = gtk.CellRendererText()
|
renderer = gtk.CellRendererText()
|
||||||
renderer.set_property('editable', True)
|
renderer.set_property('editable', True)
|
||||||
renderer.connect('edited',
|
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,
|
treeview.append_column(gtk.TreeViewColumn(None, renderer,
|
||||||
text=0))
|
text=0))
|
||||||
|
@ -509,8 +514,22 @@ class SingleForm(gtk.Table, object):
|
||||||
widget.get_start_iter(),
|
widget.get_start_iter(),
|
||||||
widget.get_end_iter())
|
widget.get_end_iter())
|
||||||
|
|
||||||
def on_jid_multi_cellrenderertext_edited(self, cell, path, newtext, model, field):
|
def on_jid_multi_cellrenderertext_edited(self, cell, path, newtext, treeview,
|
||||||
old=model[path][0]
|
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
|
model[path][0]=newtext
|
||||||
|
|
||||||
values = field.values
|
values = field.values
|
||||||
|
|
Loading…
Reference in New Issue