Mercurial > libervia-backend
changeset 1582:a41cc0849008
primitivus: partly reverted commit 641cfd2faefe :
- showDialog is actually still used and useful
- updated the code to use the widget argument in removePopup
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 13 Nov 2015 16:45:56 +0100 |
parents | 8cc7d83141a4 |
children | d46aae87c03a |
files | frontends/src/primitivus/primitivus |
diffstat | 1 files changed, 24 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus Wed Nov 11 22:28:48 2015 +0100 +++ b/frontends/src/primitivus/primitivus Fri Nov 13 16:45:56 2015 +0100 @@ -583,17 +583,35 @@ 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.