ability to validate dataform widget by pressing enter. Fixes #6032
This commit is contained in:
parent
98e89a5204
commit
8d7e587c5b
|
@ -43,6 +43,10 @@ class DataFormWidget(gtk.Alignment, object):
|
|||
Data Form widget. Use like any other widget
|
||||
"""
|
||||
|
||||
__gsignals__ = dict(
|
||||
validated = (gobject.SIGNAL_RUN_LAST | gobject.SIGNAL_ACTION, None, ())
|
||||
)
|
||||
|
||||
def __init__(self, dataformnode=None):
|
||||
''' Create a widget. '''
|
||||
gtk.Alignment.__init__(self, xscale=1.0, yscale=1.0)
|
||||
|
@ -68,6 +72,9 @@ class DataFormWidget(gtk.Alignment, object):
|
|||
selection.connect('changed', self.on_records_selection_changed)
|
||||
selection.set_mode(gtk.SELECTION_MULTIPLE)
|
||||
|
||||
def on_data_form_vbox_key_press_event(self, widget, event):
|
||||
print 'key pressed'
|
||||
|
||||
def set_data_form(self, dataform):
|
||||
"""
|
||||
Set the data form (xmpp.DataForm) displayed in widget
|
||||
|
@ -141,6 +148,9 @@ class DataFormWidget(gtk.Alignment, object):
|
|||
self.clean_data_form()
|
||||
|
||||
self.singleform = SingleForm(self._data_form)
|
||||
def _on_validated(widget):
|
||||
self.emit('validated')
|
||||
self.singleform.connect('validated', _on_validated)
|
||||
self.singleform.show()
|
||||
self.single_form_viewport.add(self.singleform)
|
||||
self.data_form_types_notebook.set_current_page(
|
||||
|
@ -299,6 +309,10 @@ class SingleForm(gtk.Table, object):
|
|||
forms, it is in another class
|
||||
"""
|
||||
|
||||
__gsignals__ = dict(
|
||||
validated = (gobject.SIGNAL_RUN_LAST | gobject.SIGNAL_ACTION, None, ())
|
||||
)
|
||||
|
||||
def __init__(self, dataform):
|
||||
assert isinstance(dataform, dataforms.SimpleDataForm)
|
||||
|
||||
|
@ -506,6 +520,11 @@ class SingleForm(gtk.Table, object):
|
|||
commonlabelcenter = True
|
||||
if readwrite:
|
||||
widget = gtk.Entry()
|
||||
def kpe(widget, event):
|
||||
if event.keyval == gtk.keysyms.Return or \
|
||||
event.keyval == gtk.keysyms.KP_Enter:
|
||||
self.emit('validated')
|
||||
widget.connect('key-press-event', kpe)
|
||||
widget.connect('changed', self.on_text_single_entry_changed,
|
||||
field)
|
||||
widget.set_sensitive(readwrite)
|
||||
|
|
|
@ -829,9 +829,6 @@ class GroupchatControl(ChatControlBase):
|
|||
self.btn_box.destroy()
|
||||
dataform = dataforms.ExtendForm(node=obj.captcha_form)
|
||||
self.form_widget = dataforms_widget.DataFormWidget(dataform)
|
||||
self.form_widget.show_all()
|
||||
vbox = self.xml.get_object('gc_textviews_vbox')
|
||||
vbox.pack_start(self.form_widget, expand=False, fill=False)
|
||||
|
||||
def on_send_dataform_clicked(widget):
|
||||
if not self.form_widget:
|
||||
|
@ -845,6 +842,11 @@ class GroupchatControl(ChatControlBase):
|
|||
self.form_widget = None
|
||||
del self.btn_box
|
||||
|
||||
self.form_widget.connect('validated', on_send_dataform_clicked)
|
||||
self.form_widget.show_all()
|
||||
vbox = self.xml.get_object('gc_textviews_vbox')
|
||||
vbox.pack_start(self.form_widget, expand=False, fill=False)
|
||||
|
||||
valid_button = gtk.Button(stock=gtk.STOCK_OK)
|
||||
valid_button.connect('clicked', on_send_dataform_clicked)
|
||||
self.btn_box = gtk.HButtonBox()
|
||||
|
|
Loading…
Reference in New Issue