comparison frontends/src/primitivus/primitivus @ 812:084b52afdceb

frontends: fixed /me usage + renamed a couple of "type" parameters to type_
author Goffi <goffi@goffi.org>
date Tue, 04 Feb 2014 18:51:16 +0100
parents 1fe00f0c9a91
children 30fd34309949
comparison
equal deleted inserted replaced
811:1fe00f0c9a91 812:084b52afdceb
404 answer_cb = data[0] 404 answer_cb = data[0]
405 answer_data = [data[1]] if data[1] else [] 405 answer_data = [data[1]] if data[1] else []
406 answer_cb(False, *answer_data) 406 answer_cb(False, *answer_data)
407 407
408 408
409 def showDialog(self, message, title="", type="info", answer_cb = None, answer_data = None): 409 def showDialog(self, message, title="", type_="info", answer_cb = None, answer_data = None):
410 if type == 'info': 410 if type_ == 'info':
411 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 411 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore
412 elif type == 'error': 412 elif type_ == 'error':
413 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 413 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore
414 elif type == 'yes/no': 414 elif type_ == 'yes/no':
415 popup = sat_widgets.ConfirmDialog(unicode(message), 415 popup = sat_widgets.ConfirmDialog(unicode(message),
416 yes_cb=self._dialogOkCb, yes_value = (answer_cb, answer_data), 416 yes_cb=self._dialogOkCb, yes_value = (answer_cb, answer_data),
417 no_cb=self._dialogCancelCb, no_value = (answer_cb, answer_data)) 417 no_cb=self._dialogCancelCb, no_value = (answer_cb, answer_data))
418 else: 418 else:
419 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 419 popup = sat_widgets.Alert(unicode(title), unicode(message), ok_cb=answer_cb or self.removePopUp) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore
420 error(_('unmanaged dialog type: %s'), type) 420 error(_('unmanaged dialog type: %s'), type_)
421 self.showPopUp(popup) 421 self.showPopUp(popup)
422 422
423 def onNotification(self, notBar): 423 def onNotification(self, notBar):
424 """Called when a new notification has been received""" 424 """Called when a new notification has been received"""
425 if not isinstance(self.main_widget, sat_widgets.FocusFrame): 425 if not isinstance(self.main_widget, sat_widgets.FocusFrame):
491 491
492 elif confirmation_type == "YES/NO": 492 elif confirmation_type == "YES/NO":
493 pop_up_widget = sat_widgets.ConfirmDialog(data["message"], no_cb=refuse_cb, yes_cb=accept_cb) 493 pop_up_widget = sat_widgets.ConfirmDialog(data["message"], no_cb=refuse_cb, yes_cb=accept_cb)
494 self.showPopUp(pop_up_widget) 494 self.showPopUp(pop_up_widget)
495 495
496 def actionResult(self, type, id, data, profile): 496 def actionResult(self, type_, id, data, profile):
497 # FIXME: to be removed 497 # FIXME: to be removed
498 if not self.check_profile(profile): 498 if not self.check_profile(profile):
499 return 499 return
500 500
501 if not id in self.current_action_ids: 501 if not id in self.current_action_ids:
502 debug (_('unknown id, ignoring')) 502 debug (_('unknown id, ignoring'))
503 return 503 return
504 if type == "SUPPRESS": 504 if type_ == "SUPPRESS":
505 self.current_action_ids.remove(id) 505 self.current_action_ids.remove(id)
506 elif type == "XMLUI": 506 elif type_ == "XMLUI":
507 self.current_action_ids.remove(id) 507 self.current_action_ids.remove(id)
508 debug (_("XML user interface received")) 508 debug (_("XML user interface received"))
509 misc = {} 509 misc = {}
510 #FIXME FIXME FIXME: must clean all this crap ! 510 #FIXME FIXME FIXME: must clean all this crap !
511 title = _('Form') 511 title = _('Form')
516 ui = XMLUI(self, title=title, xml_data = data['xml'], misc = misc) 516 ui = XMLUI(self, title=title, xml_data = data['xml'], misc = misc)
517 if data['type'] == 'registration': 517 if data['type'] == 'registration':
518 ui.show('popup') 518 ui.show('popup')
519 else: 519 else:
520 ui.show('window') 520 ui.show('window')
521 elif type == "ERROR": 521 elif type_ == "ERROR":
522 self.current_action_ids.remove(id) 522 self.current_action_ids.remove(id)
523 self.showPopUp(sat_widgets.Alert(_("Error"), unicode(data["message"]), ok_cb=self.removePopUp)) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore 523 self.showPopUp(sat_widgets.Alert(_("Error"), unicode(data["message"]), ok_cb=self.removePopUp)) #FIXME: remove unicode here when DBus Bridge will no return dbus.String anymore
524 elif type == "RESULT": 524 elif type_ == "RESULT":
525 self.current_action_ids.remove(id) 525 self.current_action_ids.remove(id)
526 if self.current_action_ids_cb.has_key(id): 526 if self.current_action_ids_cb.has_key(id):
527 callback = self.current_action_ids_cb[id] 527 callback = self.current_action_ids_cb[id]
528 del self.current_action_ids_cb[id] 528 del self.current_action_ids_cb[id]
529 callback(data) 529 callback(data)
530 elif type == "DICT_DICT": 530 elif type_ == "DICT_DICT":
531 self.current_action_ids.remove(id) 531 self.current_action_ids.remove(id)
532 if self.current_action_ids_cb.has_key(id): 532 if self.current_action_ids_cb.has_key(id):
533 callback = self.current_action_ids_cb[id] 533 callback = self.current_action_ids_cb[id]
534 del self.current_action_ids_cb[id] 534 del self.current_action_ids_cb[id]
535 callback(data) 535 callback(data)
536 else: 536 else:
537 error (_("FIXME FIXME FIXME: type [%s] not implemented") % type) 537 error (_("FIXME FIXME FIXME: type [%s] not implemented") % type_)
538 raise NotImplementedError 538 raise NotImplementedError
539 539
540 ##DIALOGS CALLBACKS## 540 ##DIALOGS CALLBACKS##
541 def onJoinRoom(self, button, edit): 541 def onJoinRoom(self, button, edit):
542 self.removePopUp() 542 self.removePopUp()