changeset 5:33b619506832

profile manger: launch plug process when "Connect" button is pressed (full plugging is not working yet)
author Goffi <goffi@goffi.org>
date Thu, 07 Jul 2016 09:39:21 +0200
parents 440a743b58ee
children 85649eca9f9b
files src/profile_manager.kv src/profile_manager.py
diffstat 2 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/profile_manager.kv	Thu Jul 07 09:39:21 2016 +0200
+++ b/src/profile_manager.kv	Thu Jul 07 09:39:21 2016 +0200
@@ -154,7 +154,8 @@
 <ConnectButton>:
     text: "Connect"
     size_hint: 1, 0.1
-    disabled: not self.ps.list_adapter.selection
+    disabled: not self.profile_screen.list_adapter.selection
+    on_press: self.pm._onConnectProfiles()
 
 
 <ProfileItem>:
--- a/src/profile_manager.py	Thu Jul 07 09:39:21 2016 +0200
+++ b/src/profile_manager.py	Thu Jul 07 09:39:21 2016 +0200
@@ -65,8 +65,9 @@
 
 class ConnectButton(Button):
 
-    def __init__(self, ps):
-        self.ps = ps
+    def __init__(self, profile_screen):
+        self.profile_screen = profile_screen
+        self.pm = profile_screen.pm
         super(ConnectButton, self).__init__()
 
 
@@ -112,18 +113,17 @@
 
     def doDelete(self):
         """This method will delete *ALL* selected profiles"""
-        to_delete = len(self.pm.profiles_screen.list_adapter.selection)
+        to_delete = self.pm.getProfiles()
         deleted = [0]
 
         def deleteInc():
             deleted[0] += 1
-            if deleted[0] == to_delete:
+            if deleted[0] == len(to_delete):
                 self.pm.profiles_screen.reload()
                 self.pm.screen_manager.transition.direction = 'right'
                 self.pm.screen_manager.current = 'profiles'
 
-        for profile_item in self.pm.profiles_screen.list_adapter.selection:
-            profile = profile_item.text
+        for profile in to_delete:
             log.info(u"Deleteing profile [{}]".format(profile))
             self.host.bridge.asyncDeleteProfile(profile, callback=deleteInc, errback=deleteInc)
 
@@ -169,3 +169,5 @@
         self.screen_manager.add_widget(self.delete_profiles_screen)
         self.add_widget(self.screen_manager)
 
+    def getProfiles(self):
+        return [pi.text for pi in self.profiles_screen.list_adapter.selection]