changeset 450:ff5516adc1f5

profile manager: don't activate `Connect` button until we get authentication result from backend
author Goffi <goffi@goffi.org>
date Sat, 28 Mar 2020 19:11:35 +0100
parents 6c21a5a44b54
children 8607c218807d
files cagou/core/profile_manager.py cagou/kv/profile_manager.kv
diffstat 2 files changed, 7 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/core/profile_manager.py	Mon Mar 23 16:52:08 2020 +0100
+++ b/cagou/core/profile_manager.py	Sat Mar 28 19:11:35 2020 +0100
@@ -140,7 +140,6 @@
         self.screen_manager.add_widget(self.new_profile_screen)
         self.screen_manager.add_widget(self.delete_profiles_screen)
         self.add_widget(self.screen_manager)
-        self.bind(selected=self.onProfileSelect)
 
     def closeUI(self, xmlui, reason=None):
         self.screen_manager.transition.direction = 'right'
@@ -155,23 +154,23 @@
         self.screen_manager.transition.direction = 'left'
         self.screen_manager.current = 'xmlui'
 
-    def onProfileSelect(self, __, selected):
-        if not selected:
+    def selectProfile(self, profile_item):
+        if not profile_item.selected:
             return
         def authenticate_cb(data, cb_id, profile):
             if not C.bool(data.pop('validated', C.BOOL_FALSE)):
                 # profile didn't validate, we unselect it
-                selected.state = 'normal'
+                profile_item.state = 'normal'
                 self.selected = ''
             else:
                 # state may have been modified so we need to be sure it's down
-                selected.state = 'down'
-                self.selected = selected
+                profile_item.state = 'down'
+                self.selected = profile_item
             G.host.actionManager(data, callback=authenticate_cb, ui_show_cb=self.showUI,
                                  profile=profile)
 
         G.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb,
-                            profile=selected.text)
+                            profile=profile_item.text)
 
     def getProfiles(self):
         # for now we restrict to a single profile in Cagou
--- a/cagou/kv/profile_manager.kv	Mon Mar 23 16:52:08 2020 +0100
+++ b/cagou/kv/profile_manager.kv	Sat Mar 28 19:11:35 2020 +0100
@@ -193,5 +193,5 @@
     selected: self.state == 'down'
     color: 0,0,0,1
     background_color: self.selected_color if self.selected else self.deselected_color
-    on_press: self.ps.pm.selected = self if self.selected else ''
+    on_press: self.ps.pm.selectProfile(self)
     height: dp(30)