annotate src/cagou/core/profile_manager.py @ 62:1922506846be

design fixes: - adjust sizes using sp/dp so it adapts on different screen resolutions - use a shorter sentence for profile manager label, so it appears better on small screens - various design adjustment to appear correclty on different screen size
author Goffi <goffi@goffi.org>
date Sun, 04 Dec 2016 21:34:30 +0100
parents 817a45e6d7e3
children af4f986d86f0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
1 #!/usr/bin/python
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
3
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
4 # Cagou: desktop/mobile frontend for Salut à Toi XMPP client
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
5 # Copyright (C) 2016 Jérôme Poisson (goffi@goffi.org)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
6
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
7 # This program is free software: you can redistribute it and/or modify
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
10 # (at your option) any later version.
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
11
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
12 # This program is distributed in the hope that it will be useful,
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
15 # GNU Affero General Public License for more details.
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
16
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
19
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
20
2
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
21 from sat.core import log as logging
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
22 log = logging.getLogger(__name__)
56
817a45e6d7e3 core (profile_manager): fixed bad import
Goffi <goffi@goffi.org>
parents: 16
diff changeset
23 from .constants import Const as C
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
24 from sat_frontends.quick_frontend.quick_profile_manager import QuickProfileManager
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from kivy.uix.boxlayout import BoxLayout
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from kivy.uix import listview
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
27 from kivy.uix.button import Button
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
28 from kivy.uix.screenmanager import ScreenManager, Screen
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from kivy.adapters import listadapter
62
1922506846be design fixes:
Goffi <goffi@goffi.org>
parents: 56
diff changeset
30 from kivy.metrics import sp
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
31 from kivy import properties
16
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
32 from cagou import G
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
33
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
34
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
35 class ProfileItem(listview.ListItemButton):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
36 pass
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
37
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
38
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
39 class ProfileListAdapter(listadapter.ListAdapter):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
40
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
41 def __init__(self, pm, *args, **kwargs):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
42 super(ProfileListAdapter, self).__init__(*args, **kwargs)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
43 self.pm = pm
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
44
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
45 def closeUI(self, xmlui):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
46 self.pm.screen_manager.transition.direction = 'right'
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
47 self.pm.screen_manager.current = 'profiles'
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
48
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
49 def showUI(self, xmlui):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
50 xmlui.setCloseCb(self.closeUI)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
51 if xmlui.type == 'popup':
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
52 xmlui.bind(on_touch_up=lambda obj, value: self.closeUI(xmlui))
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
53 self.pm.xmlui_screen.clear_widgets()
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
54 self.pm.xmlui_screen.add_widget(xmlui)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
55 self.pm.screen_manager.transition.direction = 'left'
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
56 self.pm.screen_manager.current = 'xmlui'
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
57
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
58 def select_item_view(self, view):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
59 def authenticate_cb(data, cb_id, profile):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
60 if C.bool(data.pop('validated', C.BOOL_FALSE)):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
61 super(ProfileListAdapter, self).select_item_view(view)
16
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
62 G.host.actionManager(data, callback=authenticate_cb, ui_show_cb=self.showUI, profile=profile)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
63
16
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
64 G.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=view.text)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
65
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
66
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
67 class ConnectButton(Button):
4
440a743b58ee Profile manager: Connect button is disabled when no profile is selected
Goffi <goffi@goffi.org>
parents: 2
diff changeset
68
5
33b619506832 profile manger: launch plug process when "Connect" button is pressed (full plugging is not working yet)
Goffi <goffi@goffi.org>
parents: 4
diff changeset
69 def __init__(self, profile_screen):
33b619506832 profile manger: launch plug process when "Connect" button is pressed (full plugging is not working yet)
Goffi <goffi@goffi.org>
parents: 4
diff changeset
70 self.profile_screen = profile_screen
33b619506832 profile manger: launch plug process when "Connect" button is pressed (full plugging is not working yet)
Goffi <goffi@goffi.org>
parents: 4
diff changeset
71 self.pm = profile_screen.pm
4
440a743b58ee Profile manager: Connect button is disabled when no profile is selected
Goffi <goffi@goffi.org>
parents: 2
diff changeset
72 super(ConnectButton, self).__init__()
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
73
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
74
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
75 class NewProfileScreen(Screen):
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
76 profile_name = properties.ObjectProperty(None)
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
77 jid = properties.ObjectProperty(None)
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
78 password = properties.ObjectProperty(None)
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
79 error_msg = properties.StringProperty('')
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
80
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
81 def __init__(self, pm):
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
82 super(NewProfileScreen, self).__init__(name=u'new_profile')
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
83 self.pm = pm
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
84
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
85 def onCreationFailure(self, failure):
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
86 msg = [l for l in unicode(failure).split('\n') if l][-1]
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
87 self.error_msg = unicode(msg)
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
88
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
89 def onCreationSuccess(self, profile):
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
90 self.pm.profiles_screen.reload()
16
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
91 G.host.bridge.profileStartSession(self.password.text, profile, callback=lambda dummy: self._sessionStarted(profile), errback=self.onCreationFailure)
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
92
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
93 def _sessionStarted(self, profile):
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
94 jid = self.jid.text.strip()
16
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
95 G.host.bridge.setParam("JabberID", jid, "Connection", -1, profile)
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
96 G.host.bridge.setParam("Password", self.password.text, "Connection", -1, profile)
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
97 self.pm.screen_manager.transition.direction = 'right'
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
98 self.pm.screen_manager.current = 'profiles'
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
99
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
100 def doCreate(self):
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
101 name = self.profile_name.text.strip()
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
102 # XXX: we use XMPP password for profile password to simplify
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
103 # if user want to change profile password, he can do it in preferences
16
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
104 G.host.bridge.asyncCreateProfile(name, self.password.text, callback=lambda: self.onCreationSuccess(name), errback=self.onCreationFailure)
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
105
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
106
2
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
107 class DeleteProfilesScreen(Screen):
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
108
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
109 def __init__(self, pm):
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
110 self.pm = pm
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
111 super(DeleteProfilesScreen, self).__init__(name=u'delete_profiles')
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
112
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
113 def doDelete(self):
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
114 """This method will delete *ALL* selected profiles"""
5
33b619506832 profile manger: launch plug process when "Connect" button is pressed (full plugging is not working yet)
Goffi <goffi@goffi.org>
parents: 4
diff changeset
115 to_delete = self.pm.getProfiles()
2
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
116 deleted = [0]
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
117
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
118 def deleteInc():
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
119 deleted[0] += 1
5
33b619506832 profile manger: launch plug process when "Connect" button is pressed (full plugging is not working yet)
Goffi <goffi@goffi.org>
parents: 4
diff changeset
120 if deleted[0] == len(to_delete):
2
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
121 self.pm.profiles_screen.reload()
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
122 self.pm.screen_manager.transition.direction = 'right'
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
123 self.pm.screen_manager.current = 'profiles'
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
124
5
33b619506832 profile manger: launch plug process when "Connect" button is pressed (full plugging is not working yet)
Goffi <goffi@goffi.org>
parents: 4
diff changeset
125 for profile in to_delete:
2
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
126 log.info(u"Deleteing profile [{}]".format(profile))
16
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
127 G.host.bridge.asyncDeleteProfile(profile, callback=deleteInc, errback=deleteInc)
2
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
128
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
129
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
130 class ProfilesScreen(Screen):
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
131 layout = properties.ObjectProperty(None)
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
132
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
133 def __init__(self, pm):
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
134 self.pm = pm
16
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
135 profiles = G.host.bridge.getProfilesList()
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
136 profiles.sort()
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
137 self.list_adapter = ProfileListAdapter(pm,
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
138 data=profiles,
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
139 cls=ProfileItem,
62
1922506846be design fixes:
Goffi <goffi@goffi.org>
parents: 56
diff changeset
140 args_converter=self.converter,
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
141 selection_mode='multiple',
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
142 allow_empty_selection=True,
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
143 )
2
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
144 super(ProfilesScreen, self).__init__(name=u'profiles')
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
145 self.layout.add_widget(listview.ListView(adapter=self.list_adapter))
4
440a743b58ee Profile manager: Connect button is disabled when no profile is selected
Goffi <goffi@goffi.org>
parents: 2
diff changeset
146 connect_btn = ConnectButton(self)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
147 self.layout.add_widget(connect_btn)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
148
62
1922506846be design fixes:
Goffi <goffi@goffi.org>
parents: 56
diff changeset
149 def converter(self, row_idx, obj):
1922506846be design fixes:
Goffi <goffi@goffi.org>
parents: 56
diff changeset
150 return {'text': obj,
1922506846be design fixes:
Goffi <goffi@goffi.org>
parents: 56
diff changeset
151 'size_hint_y': None,
1922506846be design fixes:
Goffi <goffi@goffi.org>
parents: 56
diff changeset
152 'height': sp(40)}
1922506846be design fixes:
Goffi <goffi@goffi.org>
parents: 56
diff changeset
153
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
154 def reload(self):
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
155 """Reload profiles list"""
16
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
156 profiles = G.host.bridge.getProfilesList()
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
157 profiles.sort()
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
158 self.list_adapter.data = profiles
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
159
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
160
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
161 class ProfileManager(QuickProfileManager, BoxLayout):
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
162
16
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
163 def __init__(self, autoconnect=None):
ba14b596b90e host can now be get as a global value:
Goffi <goffi@goffi.org>
parents: 15
diff changeset
164 QuickProfileManager.__init__(self, G.host, autoconnect)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
165 BoxLayout.__init__(self, orientation="vertical")
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
166 self.screen_manager = ScreenManager()
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
167 self.profiles_screen = ProfilesScreen(self)
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
168 self.new_profile_screen = NewProfileScreen(self)
2
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
169 self.delete_profiles_screen = DeleteProfilesScreen(self)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
170 self.xmlui_screen = Screen(name=u'xmlui')
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
171 self.screen_manager.add_widget(self.profiles_screen)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
172 self.screen_manager.add_widget(self.xmlui_screen)
1
189b76859110 Profile manager: new profile creation is handled
Goffi <goffi@goffi.org>
parents: 0
diff changeset
173 self.screen_manager.add_widget(self.new_profile_screen)
2
8f9ed634a5eb Profile manager: profile(s) deletion is handled
Goffi <goffi@goffi.org>
parents: 1
diff changeset
174 self.screen_manager.add_widget(self.delete_profiles_screen)
0
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
175 self.add_widget(self.screen_manager)
160cc95ad7ea initial commit:
Goffi <goffi@goffi.org>
parents:
diff changeset
176
5
33b619506832 profile manger: launch plug process when "Connect" button is pressed (full plugging is not working yet)
Goffi <goffi@goffi.org>
parents: 4
diff changeset
177 def getProfiles(self):
33b619506832 profile manger: launch plug process when "Connect" button is pressed (full plugging is not working yet)
Goffi <goffi@goffi.org>
parents: 4
diff changeset
178 return [pi.text for pi in self.profiles_screen.list_adapter.selection]