changeset 71:8c9fe2c5aacc

settings: save button is now disabled when there is nothing to save
author Goffi <goffi@goffi.org>
date Sun, 18 Dec 2016 16:31:23 +0100
parents 46b5f3ecf6a1
children 1a324c682d8a
files src/cagou/core/xmlui.py
diffstat 1 files changed, 11 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/src/cagou/core/xmlui.py	Sun Dec 18 10:27:34 2016 +0100
+++ b/src/cagou/core/xmlui.py	Sun Dec 18 16:31:23 2016 +0100
@@ -466,6 +466,10 @@
         else:
             G.host.closeUI()
 
+    def onParamChange(self, ctrl):
+        super(XMLUIPanel, self).onParamChange(ctrl)
+        self.save_btn.disabled = False
+
     def addPostTreat(self, callback):
         self._post_treats.append(callback)
 
@@ -474,6 +478,10 @@
             cb()
         del self._post_treats
 
+    def _saveButtonCb(self, button):
+        button.disabled = True
+        self.onSaveParams(button)
+
     def constructUI(self, parsed_dom):
         xmlui.XMLUIPanel.constructUI(self, parsed_dom, self._postTreatCb)
         if self.xmlui_title:
@@ -488,9 +496,9 @@
                 cancel_btn.bind(on_press=self.onFormCancelled)
                 self.add_widget(cancel_btn)
         elif self.type == 'param':
-            save_btn = FormButton(text=_(u"Save"))
-            save_btn.bind(on_press=self.onSaveParams)
-            self.add_widget(save_btn)
+            self.save_btn = FormButton(text=_(u"Save"), disabled=True)
+            self.save_btn.bind(on_press=self._saveButtonCb)
+            self.add_widget(self.save_btn)
         self.add_widget(Widget())  # to have elements on the top
 
     def show(self, *args, **kwargs):