comparison frontends/src/tools/xmlui.py @ 975:b37b1d183ac3

reverted changeset 5c7707c958d8 (revision 969)
author souliane <souliane@mailoo.org>
date Thu, 03 Apr 2014 14:38:48 +0200
parents 5c7707c958d8
children d2e612a45e76
comparison
equal deleted inserted replaced
974:54cd05f68c7c 975:b37b1d183ac3
309 self.ctrl_list[name] = ({'type': type_, 'control': ctrl}) 309 self.ctrl_list[name] = ({'type': type_, 'control': ctrl})
310 elif type_=="button": 310 elif type_=="button":
311 callback_id = node.getAttribute("callback") 311 callback_id = node.getAttribute("callback")
312 ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress) 312 ctrl = self.widget_factory.createButtonWidget(parent, value, self.onButtonPress)
313 ctrl._xmlui_param_id = (callback_id, [field.getAttribute('name') for field in node.getElementsByTagName("field_back")]) 313 ctrl._xmlui_param_id = (callback_id, [field.getAttribute('name') for field in node.getElementsByTagName("field_back")])
314 elif type_ == "internal_button":
315 action = node.getAttribute("action")
316 ctrl = self.widget_factory.createButtonWidget(parent, value, self.onInternalButtonPress)
317 ctrl._xmlui_param_id = (action, [field.getAttribute('name') for field in node.getElementsByTagName("internal_field")])
318 else: 314 else:
319 print(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_) 315 print(_("FIXME FIXME FIXME: widget type [%s] is not implemented") % type_)
320 raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_) 316 raise NotImplementedError(_("FIXME FIXME FIXME: type [%s] is not implemented") % type_)
321 317
322 if self.type == 'param' and type_ != 'text': 318 if self.type == 'param' and type_ != 'text':
415 data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelectedValues()) 411 data[escaped] = u'\t'.join(ctrl['control']._xmluiGetSelectedValues())
416 else: 412 else:
417 data[escaped] = ctrl['control']._xmluiGetValue() 413 data[escaped] = ctrl['control']._xmluiGetValue()
418 self._xmluiLaunchAction(callback_id, data) 414 self._xmluiLaunchAction(callback_id, data)
419 415
420 def onInternalButtonPress(self, button):
421 """ Called when an internal XMLUI button is clicked
422 Do the processing associated to the button
423 @param button: the button clicked
424
425 """
426 action, fields = button._xmlui_param_id
427 if action not in ('copy', 'move'):
428 raise NotImplementedError(_("FIXME: XMLUI internal action [%s] is not implemented") % action)
429 source = None
430 for field in fields:
431 widget = self.ctrl_list[field]['control']
432 if not source:
433 source = widget
434 continue
435 if isinstance(widget, ListWidget):
436 if isinstance(source, ListWidget):
437 values = source._xmluiGetSelectedValues()
438 else:
439 values = [source._xmluiGetValue()]
440 if action == 'move':
441 source._xmluiSetValue('')
442 widget._xmluiAddValues(values, select=True)
443 else:
444 if isinstance(source, ListWidget):
445 value = u', '.join(source._xmluiGetSelectedValues())
446 else:
447 value = source._xmluiGetValue()
448 if action == 'move':
449 source._xmluiSetValue('')
450 widget._xmluiSetValue(value)
451 source = None
452
453 def onFormSubmitted(self, ignore=None): 416 def onFormSubmitted(self, ignore=None):
454 """ An XMLUI form has been submited 417 """ An XMLUI form has been submited
455 call the submit action associated with this form 418 call the submit action associated with this form
456 419
457 """ 420 """