comparison src/cagou/core/profile_manager.py @ 63:af4f986d86f0

core: pb bridge implementation: - media_dir is now gotten directly from config - replaced sync bridge calls by async ones - pb is now the bridge used in sat.conf for Android
author Goffi <goffi@goffi.org>
date Tue, 13 Dec 2016 23:10:41 +0100
parents 1922506846be
children 7f7f3b8eb154
comparison
equal deleted inserted replaced
62:1922506846be 63:af4f986d86f0
130 class ProfilesScreen(Screen): 130 class ProfilesScreen(Screen):
131 layout = properties.ObjectProperty(None) 131 layout = properties.ObjectProperty(None)
132 132
133 def __init__(self, pm): 133 def __init__(self, pm):
134 self.pm = pm 134 self.pm = pm
135 profiles = G.host.bridge.getProfilesList()
136 profiles.sort()
137 self.list_adapter = ProfileListAdapter(pm, 135 self.list_adapter = ProfileListAdapter(pm,
138 data=profiles, 136 data=[],
139 cls=ProfileItem, 137 cls=ProfileItem,
140 args_converter=self.converter, 138 args_converter=self.converter,
141 selection_mode='multiple', 139 selection_mode='multiple',
142 allow_empty_selection=True, 140 allow_empty_selection=True,
143 ) 141 )
144 super(ProfilesScreen, self).__init__(name=u'profiles') 142 super(ProfilesScreen, self).__init__(name=u'profiles')
145 self.layout.add_widget(listview.ListView(adapter=self.list_adapter)) 143 self.layout.add_widget(listview.ListView(adapter=self.list_adapter))
146 connect_btn = ConnectButton(self) 144 connect_btn = ConnectButton(self)
147 self.layout.add_widget(connect_btn) 145 self.layout.add_widget(connect_btn)
146 self.reload()
147
148 def _getProfilesListCb(self, profiles):
149 profiles.sort()
150 self.list_adapter.data = profiles
148 151
149 def converter(self, row_idx, obj): 152 def converter(self, row_idx, obj):
150 return {'text': obj, 153 return {'text': obj,
151 'size_hint_y': None, 154 'size_hint_y': None,
152 'height': sp(40)} 155 'height': sp(40)}
153 156
154 def reload(self): 157 def reload(self):
155 """Reload profiles list""" 158 """Reload profiles list"""
156 profiles = G.host.bridge.getProfilesList() 159 G.host.bridge.getProfilesList(callback=self._getProfilesListCb)
157 profiles.sort()
158 self.list_adapter.data = profiles
159 160
160 161
161 class ProfileManager(QuickProfileManager, BoxLayout): 162 class ProfileManager(QuickProfileManager, BoxLayout):
162 163
163 def __init__(self, autoconnect=None): 164 def __init__(self, autoconnect=None):