Mercurial > libervia-desktop-kivy
diff src/cagou/core/cagou_main.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 | 0b7f10de416e |
children | 8e16abcadbb8 |
line wrap: on
line diff
--- a/src/cagou/core/cagou_main.py Sun Dec 04 21:34:30 2016 +0100 +++ b/src/cagou/core/cagou_main.py Tue Dec 13 23:10:41 2016 +0100 @@ -34,12 +34,13 @@ import kivy kivy.require('1.9.1') import kivy.support -bridge_name = config.getConfig(config.parseMainConf(), '', 'bridge', 'dbus') +main_config = config.parseMainConf() +bridge_name = config.getConfig(main_config, '', 'bridge', 'dbus') # FIXME: event loop is choosen according to bridge_name, a better way should be used -if bridge_name == 'embedded': +if 'dbus' in bridge_name: + kivy.support.install_gobject_iteration() +elif bridge_name in ('pb', 'embedded'): kivy.support.install_twisted_reactor() -else: - kivy.support.install_gobject_iteration() from kivy.app import App from kivy.lang import Builder from kivy import properties @@ -60,7 +61,6 @@ import glob import cagou.plugins import cagou.kv -from sat.core import sat_main from kivy import utils as kivy_utils import sys if kivy_utils.platform == "android": @@ -232,6 +232,7 @@ def __init__(self): if bridge_name == 'embedded': + from sat.core import sat_main self.sat = sat_main.SAT() bridge_module = dynamic_import.bridge(bridge_name, 'sat_frontends.bridge') if bridge_module is None: @@ -239,11 +240,11 @@ sys.exit(1) else: log.info(u"Loading {} bridge".format(bridge_name)) - super(Cagou, self).__init__(create_bridge=bridge_module.Bridge, xmlui=xmlui, check_options=quick_utils.check_options) + super(Cagou, self).__init__(bridge_factory=bridge_module.Bridge, xmlui=xmlui, check_options=quick_utils.check_options, connect_bridge=False) self._import_kv() self.app = CagouApp() self.app.host = self - self.media_dir = self.app.media_dir = self.bridge.getConfig("", "media_dir") + self.media_dir = self.app.media_dir = config.getConfig(main_config, '', 'media_dir') self.app.default_avatar = os.path.join(self.media_dir, "misc/default_avatar.png") self._plg_wids = [] # widget plugins self._import_plugins() @@ -255,8 +256,12 @@ for w in w_list: yield w + def _bridgeCb(self): + super(Cagou, self)._bridgeCb() + self.bridge.getReady(self.onBackendReady) + def run(self): - self.bridge.getReady(self.onBackendReady) + self.connectBridge() self.app.bind(on_stop=self.onStop) self.app.run()