Mercurial > libervia-desktop-kivy
comparison cagou/core/profile_manager.py @ 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 | 1da3c379205b |
children | 3c9ba4a694ef |
comparison
equal
deleted
inserted
replaced
449:6c21a5a44b54 | 450:ff5516adc1f5 |
---|---|
138 self.screen_manager.add_widget(self.profiles_screen) | 138 self.screen_manager.add_widget(self.profiles_screen) |
139 self.screen_manager.add_widget(self.xmlui_screen) | 139 self.screen_manager.add_widget(self.xmlui_screen) |
140 self.screen_manager.add_widget(self.new_profile_screen) | 140 self.screen_manager.add_widget(self.new_profile_screen) |
141 self.screen_manager.add_widget(self.delete_profiles_screen) | 141 self.screen_manager.add_widget(self.delete_profiles_screen) |
142 self.add_widget(self.screen_manager) | 142 self.add_widget(self.screen_manager) |
143 self.bind(selected=self.onProfileSelect) | |
144 | 143 |
145 def closeUI(self, xmlui, reason=None): | 144 def closeUI(self, xmlui, reason=None): |
146 self.screen_manager.transition.direction = 'right' | 145 self.screen_manager.transition.direction = 'right' |
147 self.screen_manager.current = 'profiles' | 146 self.screen_manager.current = 'profiles' |
148 | 147 |
153 self.xmlui_screen.clear_widgets() | 152 self.xmlui_screen.clear_widgets() |
154 self.xmlui_screen.add_widget(xmlui) | 153 self.xmlui_screen.add_widget(xmlui) |
155 self.screen_manager.transition.direction = 'left' | 154 self.screen_manager.transition.direction = 'left' |
156 self.screen_manager.current = 'xmlui' | 155 self.screen_manager.current = 'xmlui' |
157 | 156 |
158 def onProfileSelect(self, __, selected): | 157 def selectProfile(self, profile_item): |
159 if not selected: | 158 if not profile_item.selected: |
160 return | 159 return |
161 def authenticate_cb(data, cb_id, profile): | 160 def authenticate_cb(data, cb_id, profile): |
162 if not C.bool(data.pop('validated', C.BOOL_FALSE)): | 161 if not C.bool(data.pop('validated', C.BOOL_FALSE)): |
163 # profile didn't validate, we unselect it | 162 # profile didn't validate, we unselect it |
164 selected.state = 'normal' | 163 profile_item.state = 'normal' |
165 self.selected = '' | 164 self.selected = '' |
166 else: | 165 else: |
167 # state may have been modified so we need to be sure it's down | 166 # state may have been modified so we need to be sure it's down |
168 selected.state = 'down' | 167 profile_item.state = 'down' |
169 self.selected = selected | 168 self.selected = profile_item |
170 G.host.actionManager(data, callback=authenticate_cb, ui_show_cb=self.showUI, | 169 G.host.actionManager(data, callback=authenticate_cb, ui_show_cb=self.showUI, |
171 profile=profile) | 170 profile=profile) |
172 | 171 |
173 G.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, | 172 G.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, |
174 profile=selected.text) | 173 profile=profile_item.text) |
175 | 174 |
176 def getProfiles(self): | 175 def getProfiles(self): |
177 # for now we restrict to a single profile in Cagou | 176 # for now we restrict to a single profile in Cagou |
178 # TODO: handle multi-profiles | 177 # TODO: handle multi-profiles |
179 return [self.selected.text] if self.selected else [] | 178 return [self.selected.text] if self.selected else [] |