changeset 1612:48f324352c52

primitivus: fixed showDialog and XMLUI message dialog
author Goffi <goffi@goffi.org>
date Tue, 17 Nov 2015 12:28:45 +0100
parents f4a0b12d2442
children 1c5761cb1bdc
files frontends/src/primitivus/primitivus frontends/src/primitivus/xmlui.py
diffstat 2 files changed, 8 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/frontends/src/primitivus/primitivus	Mon Nov 16 11:58:11 2015 +0100
+++ b/frontends/src/primitivus/primitivus	Tue Nov 17 12:28:45 2015 +0100
@@ -585,12 +585,14 @@
     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 @@
             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:
--- a/frontends/src/primitivus/xmlui.py	Mon Nov 16 11:58:11 2015 +0100
+++ b/frontends/src/primitivus/xmlui.py	Tue Nov 17 12:28:45 2015 +0100
@@ -336,7 +336,7 @@
     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):