comparison src/profile_manager.py @ 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
comparison
equal deleted inserted replaced
4:440a743b58ee 5:33b619506832
63 self.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=view.text) 63 self.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=view.text)
64 64
65 65
66 class ConnectButton(Button): 66 class ConnectButton(Button):
67 67
68 def __init__(self, ps): 68 def __init__(self, profile_screen):
69 self.ps = ps 69 self.profile_screen = profile_screen
70 self.pm = profile_screen.pm
70 super(ConnectButton, self).__init__() 71 super(ConnectButton, self).__init__()
71 72
72 73
73 class NewProfileScreen(Screen): 74 class NewProfileScreen(Screen):
74 profile_name = properties.ObjectProperty(None) 75 profile_name = properties.ObjectProperty(None)
110 self.host = pm.host 111 self.host = pm.host
111 super(DeleteProfilesScreen, self).__init__(name=u'delete_profiles') 112 super(DeleteProfilesScreen, self).__init__(name=u'delete_profiles')
112 113
113 def doDelete(self): 114 def doDelete(self):
114 """This method will delete *ALL* selected profiles""" 115 """This method will delete *ALL* selected profiles"""
115 to_delete = len(self.pm.profiles_screen.list_adapter.selection) 116 to_delete = self.pm.getProfiles()
116 deleted = [0] 117 deleted = [0]
117 118
118 def deleteInc(): 119 def deleteInc():
119 deleted[0] += 1 120 deleted[0] += 1
120 if deleted[0] == to_delete: 121 if deleted[0] == len(to_delete):
121 self.pm.profiles_screen.reload() 122 self.pm.profiles_screen.reload()
122 self.pm.screen_manager.transition.direction = 'right' 123 self.pm.screen_manager.transition.direction = 'right'
123 self.pm.screen_manager.current = 'profiles' 124 self.pm.screen_manager.current = 'profiles'
124 125
125 for profile_item in self.pm.profiles_screen.list_adapter.selection: 126 for profile in to_delete:
126 profile = profile_item.text
127 log.info(u"Deleteing profile [{}]".format(profile)) 127 log.info(u"Deleteing profile [{}]".format(profile))
128 self.host.bridge.asyncDeleteProfile(profile, callback=deleteInc, errback=deleteInc) 128 self.host.bridge.asyncDeleteProfile(profile, callback=deleteInc, errback=deleteInc)
129 129
130 130
131 class ProfilesScreen(Screen): 131 class ProfilesScreen(Screen):
167 self.screen_manager.add_widget(self.xmlui_screen) 167 self.screen_manager.add_widget(self.xmlui_screen)
168 self.screen_manager.add_widget(self.new_profile_screen) 168 self.screen_manager.add_widget(self.new_profile_screen)
169 self.screen_manager.add_widget(self.delete_profiles_screen) 169 self.screen_manager.add_widget(self.delete_profiles_screen)
170 self.add_widget(self.screen_manager) 170 self.add_widget(self.screen_manager)
171 171
172 def getProfiles(self):
173 return [pi.text for pi in self.profiles_screen.list_adapter.selection]