primitivus: fixed showDialog and XMLUI message dialog

This commit is contained in:
Goffi 2015-11-17 12:28:45 +01:00
commit e847a9f001
2 changed files with 8 additions and 6 deletions

View file

@ -585,12 +585,14 @@ class PrimitivusApp(QuickApp, InputHistory):
def _dialogOkCb(self, widget, data):
popup, answer_cb, answer_data = data
self.removePopUp(popup)
answer_cb(True, *answer_data)
if answer_cb is not None:
answer_cb(True, answer_data)
def _dialogCancelCb(self, widget, data):
popup, answer_cb, answer_data = data
self.removePopUp(popup)
answer_cb(False, *answer_data)
if answer_cb is not None:
answer_cb(False, answer_data)
def showDialog(self, message, title="", type_="info", answer_cb = None, answer_data = None):
if type_ == 'info':
@ -602,9 +604,9 @@ class PrimitivusApp(QuickApp, InputHistory):
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))
popup = sat_widgets.ConfirmDialog(message)
popup.setCallback('yes', self._dialogOkCb, (popup, answer_cb, answer_data))
popup.setCallback('no', self._dialogCancelCb, (popup, answer_cb, answer_data))
else:
popup = sat_widgets.alert(title, message, ok_cb=answer_cb)
if answer_cb is None:

View file

@ -336,7 +336,7 @@ class PrimitivusMessageDialog(PrimitivusDialog, xmlui.MessageDialog, sat_widgets
def __init__(self, _xmlui_parent, title, message, level):
PrimitivusDialog.__init__(self, _xmlui_parent)
xmlui.MessageDialog.__init__(self, _xmlui_parent)
sat_widgets.Alert.__init__(self, title, message, ok_cb=lambda dummy: self._xmluiValidated())
sat_widgets.Alert.__init__(self, title, message, ok_cb=lambda dummy: self._xmluiClose())
class PrimitivusNoteDialog(xmlui.NoteDialog, PrimitivusMessageDialog):