comparison src/cagou/core/cagou_main.py @ 16:ba14b596b90e

host can now be get as a global value: instead of always copying host from class to class, it can now be gotten from a global class with: from cagou import G then G.host will give host. This will probably be used on the long term on all SàT (backend + frontends). As host is currently needed in several places (most importantly in QuickFrontend), the argument is still present, and must be there even is unused on class inheriting from QuickSomething.
author Goffi <goffi@goffi.org>
date Sat, 09 Jul 2016 18:41:52 +0200
parents 56838ad5c84b
children c58b522607f4
comparison
equal deleted inserted replaced
15:56838ad5c84b 16:ba14b596b90e
59 59
60 class CagouApp(App): 60 class CagouApp(App):
61 """Kivy App for Cagou""" 61 """Kivy App for Cagou"""
62 62
63 def build(self): 63 def build(self):
64 return CagouRootWidget([ProfileManager(self.host)]) 64 return CagouRootWidget([ProfileManager()])
65 65
66 66
67 class Cagou(QuickApp): 67 class Cagou(QuickApp):
68 MB_HANDLE = False 68 MB_HANDLE = False
69 69
70 def __init__(self): 70 def __init__(self):
71 super(Cagou, self).__init__(create_bridge=DBusBridgeFrontend, xmlui=xmlui) 71 super(Cagou, self).__init__(create_bridge=DBusBridgeFrontend, xmlui=xmlui)
72 self._import_kv() 72 self._import_kv()
73 self.app = CagouApp() 73 self.app = CagouApp()
74 self.app.host = self
75 media_dir = self.app.media_dir = self.bridge.getConfig("", "media_dir") 74 media_dir = self.app.media_dir = self.bridge.getConfig("", "media_dir")
76 self.app.default_avatar = os.path.join(media_dir, "misc/default_avatar.png") 75 self.app.default_avatar = os.path.join(media_dir, "misc/default_avatar.png")
77 self._plg_wids = [] # widget plugins 76 self._plg_wids = [] # widget plugins
78 self._import_plugins() 77 self._import_plugins()
79 78
80 def run(self): 79 def run(self):
81 self.app.run() 80 self.app.run()
82 81
83 def _defaultFactory(self, host, plugin_info, target, profiles): 82 def _defaultFactory(self, plugin_info, target, profiles):
84 """factory used to create widget instance when PLUGIN_INFO["factory"] is not set""" 83 """factory used to create widget instance when PLUGIN_INFO["factory"] is not set"""
85 main_cls = plugin_info['main'] 84 main_cls = plugin_info['main']
86 return self.widgets.getOrCreateWidget(main_cls, target, on_new_widget=None, profiles=profiles) 85 return self.widgets.getOrCreateWidget(main_cls, target, on_new_widget=None, profiles=profiles)
87 86
88 def _import_kv(self): 87 def _import_kv(self):
162 lst.remove(plugin_info) 161 lst.remove(plugin_info)
163 break 162 break
164 return lst 163 return lst
165 164
166 def plugging_profiles(self): 165 def plugging_profiles(self):
167 self.app.root.change_widgets([WidgetsHandler(self)]) 166 self.app.root.change_widgets([WidgetsHandler()])
168 167
169 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): 168 def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE):
170 log.info(u"Profile presence status set to {show}/{status}".format(show=show, status=status)) 169 log.info(u"Profile presence status set to {show}/{status}".format(show=show, status=status))
171 170
172 def switchWidget(self, old, new): 171 def switchWidget(self, old, new):