diff cagou/core/xmlui.py @ 243:50f7c000b4ae

xmlui: implemented MessageDialog
author Goffi <goffi@goffi.org>
date Thu, 03 Jan 2019 20:37:55 +0100
parents 661b9cf7b4e4
children 1f579baf787a
line wrap: on
line diff
--- a/cagou/core/xmlui.py	Thu Jan 03 10:52:57 2019 +0100
+++ b/cagou/core/xmlui.py	Thu Jan 03 20:37:55 2019 +0100
@@ -411,6 +411,29 @@
         G.host.addNote(self.title, self.message, self.level)
 
 
+class MessageDialog(xmlui.MessageDialog, dialog.MessageDialog):
+
+    def __init__(self, _xmlui_parent, title, message, level):
+        dialog.MessageDialog.__init__(self,
+                                      title=title,
+                                      message=message,
+                                      level=level,
+                                      close_cb = self.close_cb)
+        xmlui.MessageDialog.__init__(self, _xmlui_parent)
+
+    def close_cb(self):
+        self._xmluiClose()
+
+    def _xmluiShow(self):
+        G.host.addNotifUI(self)
+
+    def _xmluiClose(self):
+        G.host.closeUI()
+
+    def show(self, *args, **kwargs):
+        G.host.showUI(self)
+
+
 class ConfirmDialog(xmlui.ConfirmDialog, dialog.ConfirmDialog):
 
     def __init__(self, _xmlui_parent, title, message, level, buttons_set):
@@ -501,7 +524,8 @@
 class XMLUIPanel(xmlui.XMLUIPanel, BoxLayout):
     widget_factory = WidgetFactory()
 
-    def __init__(self, host, parsed_xml, title=None, flags=None, callback=None, ignore=None, whitelist=None, profile=C.PROF_KEY_NONE):
+    def __init__(self, host, parsed_xml, title=None, flags=None, callback=None,
+                 ignore=None, whitelist=None, profile=C.PROF_KEY_NONE):
         BoxLayout.__init__(self)
         self.close_cb = None
         self._post_treats = []  # list of callback to call after UI is constructed