primitivus: partly reverted commit 641cfd2faefe :
- showDialog is actually still used and useful
- updated the code to use the widget argument in removePopup
This commit is contained in:
parent
455a7e00f7
commit
2a3b5ad8e3
1 changed files with 24 additions and 6 deletions
|
|
@ -583,17 +583,35 @@ class PrimitivusApp(QuickApp, InputHistory):
|
|||
self.menu_roller.addMenu(_('Chat menu'), chat_widget.getMenu(), C.MENU_ID_WIDGET)
|
||||
|
||||
def _dialogOkCb(self, widget, data):
|
||||
self.removePopUp()
|
||||
answer_cb = data[0]
|
||||
answer_data = [data[1]] if data[1] else []
|
||||
popup, answer_cb, answer_data = data
|
||||
self.removePopUp(popup)
|
||||
answer_cb(True, *answer_data)
|
||||
|
||||
def _dialogCancelCb(self, widget, data):
|
||||
self.removePopUp()
|
||||
answer_cb = data[0]
|
||||
answer_data = [data[1]] if data[1] else []
|
||||
popup, answer_cb, answer_data = data
|
||||
self.removePopUp(popup)
|
||||
answer_cb(False, *answer_data)
|
||||
|
||||
def showDialog(self, message, title="", type_="info", answer_cb = None, answer_data = None):
|
||||
if type_ == 'info':
|
||||
popup = sat_widgets.Alert(title, message, ok_cb=answer_cb)
|
||||
if answer_cb is None:
|
||||
popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
|
||||
elif type_ == 'error':
|
||||
popup = sat_widgets.Alert(title, message, ok_cb=answer_cb)
|
||||
if answer_cb is None:
|
||||
popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
|
||||
elif type_ == 'yes/no':
|
||||
popup = sat_widgets.ConfirmDialog(message,
|
||||
yes_cb=self._dialogOkCb, yes_value = (popup, answer_cb, answer_data),
|
||||
no_cb=self._dialogCancelCb, no_value = (popup, answer_cb, answer_data))
|
||||
else:
|
||||
popup = sat_widgets.Alert(title, message, ok_cb=answer_cb)
|
||||
if answer_cb is None:
|
||||
popup.setCallback('ok', lambda dummy: self.removePopUp(popup))
|
||||
log.error(u'unmanaged dialog type: {}'.format(type_))
|
||||
self.showPopUp(popup)
|
||||
|
||||
def dialogFailure(self, failure):
|
||||
"""Show a failure that has been returned by an asynchronous bridge method.
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue