Mercurial > libervia-desktop-kivy
comparison src/cagou.py @ 9:7b0a53d2afd3
contact list: first draft
author | Goffi <goffi@goffi.org> |
---|---|
date | Fri, 08 Jul 2016 18:30:30 +0200 |
parents | 85649eca9f9b |
children | 49d30fc15884 |
comparison
equal
deleted
inserted
replaced
8:d9095d1dd7ae | 9:7b0a53d2afd3 |
---|---|
31 import kivy.support | 31 import kivy.support |
32 kivy.support.install_gobject_iteration() | 32 kivy.support.install_gobject_iteration() |
33 from kivy.app import App | 33 from kivy.app import App |
34 import xmlui | 34 import xmlui |
35 from profile_manager import ProfileManager | 35 from profile_manager import ProfileManager |
36 from contact_list import ContactList | |
37 from kivy.uix.boxlayout import BoxLayout | |
38 import os.path | |
39 | |
40 | |
41 class CagouRootWidget(BoxLayout): | |
42 | |
43 def __init__(self, widgets): | |
44 super(CagouRootWidget, self).__init__(orientation=("vertical")) | |
45 for wid in widgets: | |
46 self.add_widget(wid) | |
47 | |
48 def change_widgets(self, widgets): | |
49 self.clear_widgets() | |
50 for wid in widgets: | |
51 self.add_widget(wid) | |
36 | 52 |
37 | 53 |
38 class CagouApp(App): | 54 class CagouApp(App): |
39 """Kivy App for Cagou""" | 55 """Kivy App for Cagou""" |
40 | 56 |
41 def build(self): | 57 def build(self): |
42 return ProfileManager(self.host) | 58 return CagouRootWidget([ProfileManager(self.host)]) |
43 | 59 |
44 | 60 |
45 class Cagou(QuickApp): | 61 class Cagou(QuickApp): |
46 MB_HANDLE = False | 62 MB_HANDLE = False |
47 | 63 |
48 def __init__(self): | 64 def __init__(self): |
49 super(Cagou, self).__init__(create_bridge=DBusBridgeFrontend, xmlui=xmlui) | 65 super(Cagou, self).__init__(create_bridge=DBusBridgeFrontend, xmlui=xmlui) |
50 self.app = CagouApp() | 66 self.app = CagouApp() |
51 self.app.host = self | 67 self.app.host = self |
68 media_dir = self.app.media_dir = self.bridge.getConfig("", "media_dir") | |
69 self.app.default_avatar = os.path.join(media_dir, "misc/default_avatar.png") | |
52 | 70 |
53 def run(self): | 71 def run(self): |
54 self.app.run() | 72 self.app.run() |
55 | 73 |
74 def plugging_profiles(self): | |
75 contact_list = self.widgets.getOrCreateWidget(ContactList, None, on_new_widget=None) | |
76 self.app.root.change_widgets([contact_list]) | |
77 | |
78 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): | |
79 log.info(u"Profile presence status set to {show}/{status}".format(show=show, status=status)) | |
80 | |
56 | 81 |
57 if __name__ == '__main__': | 82 if __name__ == '__main__': |
58 Cagou().run() | 83 Cagou().run() |