diff cagou/core/xmlui.py @ 305:b2727877bad4

remote: fixed workflow and size for XMLUI panel used with Ad-Hoc commands: the XMLUI panel was added to the StackLayout used for discovery, resulting in a bad sizing. This patch fixes this by moving discovery panel to a new widget, and adding a main BoxLayout where the XMLUI panel are added. The XMLUI close callback is now handled properly. fix 325
author Goffi <goffi@goffi.org>
date Fri, 19 Jul 2019 17:13:05 +0200
parents 4772ba26623f
children 772c170b47a9
line wrap: on
line diff
--- a/cagou/core/xmlui.py	Wed Jul 10 08:38:39 2019 +0200
+++ b/cagou/core/xmlui.py	Fri Jul 19 17:13:05 2019 +0200
@@ -20,7 +20,6 @@
 from sat.core.i18n import _
 from .constants import Const as C
 from sat.core.log import getLogger
-log = getLogger(__name__)
 from sat_frontends.tools import xmlui
 from kivy.uix.scrollview import ScrollView
 from kivy.uix.boxlayout import BoxLayout
@@ -37,6 +36,7 @@
 from cagou.core import dialog
 from functools import partial
 
+log = getLogger(__name__)
 
 ## Widgets ##
 
@@ -405,7 +405,7 @@
     def _xmluiShow(self):
         G.host.addNotifUI(self)
 
-    def _xmluiClose(self):
+    def _xmluiClose(self, reason=None):
         G.host.closeUI()
 
     def show(self, *args, **kwargs):
@@ -433,7 +433,7 @@
     def _xmluiShow(self):
         G.host.addNotifUI(self)
 
-    def _xmluiClose(self):
+    def _xmluiClose(self, reason=None):
         G.host.closeUI()
 
     def show(self, *args, **kwargs):
@@ -454,7 +454,7 @@
     def _xmluiShow(self):
         G.host.addNotifUI(self)
 
-    def _xmluiClose(self):
+    def _xmluiClose(self, reason=None):
         # FIXME: notif UI is not removed if dialog is not shown yet
         G.host.closeUI()
 
@@ -554,9 +554,9 @@
     def setCloseCb(self, close_cb):
         self.close_cb = close_cb
 
-    def _xmluiClose(self, *__):
+    def _xmluiClose(self, __=None, reason=None):
         if self.close_cb is not None:
-            self.close_cb(self)
+            self.close_cb(self, reason)
         else:
             G.host.closeUI()
 
@@ -598,12 +598,12 @@
             self.layout.add_widget(self.save_btn)
         elif self.type == 'window':
             cancel_btn = CancelButton(text=_(u"Cancel"))
-            cancel_btn.bind(on_press=self._xmluiClose)
+            cancel_btn.bind(
+                on_press=partial(self._xmluiClose, reason=C.XMLUI_DATA_CANCELLED))
             self.layout.add_widget(cancel_btn)
 
     def onHeight(self, __, height):
         if isinstance(self.main_cont, TabsContainer):
-            # when the main
             other_children_height = sum([c.height for c in self.layout.children
                                          if c is not self.main_cont])
             self.main_cont.height = height - other_children_height