comparison cagou/core/cagou_main.py @ 346:7b9a0e57df53

core: new "connected" property in CagouApp
author Goffi <goffi@goffi.org>
date Sat, 04 Jan 2020 16:24:57 +0100
parents 89799148f894
children 33244f944bd8
comparison
equal deleted inserted replaced
345:a3cefa7158dc 346:7b9a0e57df53
294 c_prim_light = properties.ListProperty(C.COLOR_PRIM_LIGHT) 294 c_prim_light = properties.ListProperty(C.COLOR_PRIM_LIGHT)
295 c_prim_dark = properties.ListProperty(C.COLOR_PRIM_DARK) 295 c_prim_dark = properties.ListProperty(C.COLOR_PRIM_DARK)
296 c_sec = properties.ListProperty(C.COLOR_SEC) 296 c_sec = properties.ListProperty(C.COLOR_SEC)
297 c_sec_light = properties.ListProperty(C.COLOR_SEC_LIGHT) 297 c_sec_light = properties.ListProperty(C.COLOR_SEC_LIGHT)
298 c_sec_dark = properties.ListProperty(C.COLOR_SEC_DARK) 298 c_sec_dark = properties.ListProperty(C.COLOR_SEC_DARK)
299 connected = properties.BooleanProperty(False)
299 # we have to put those constants here and not in core/constants.py 300 # we have to put those constants here and not in core/constants.py
300 # because of the use of dp(), which would import Kivy too early 301 # because of the use of dp(), which would import Kivy too early
301 # and prevent the log hack 302 # and prevent the log hack
302 MARGIN_LEFT = MARGIN_RIGHT = dp(10) 303 MARGIN_LEFT = MARGIN_RIGHT = dp(10)
303 304
496 self.app.root_window.softinput_mode = "below_target" 497 self.app.root_window.softinput_mode = "below_target"
497 profile_manager = self.app._profile_manager 498 profile_manager = self.app._profile_manager
498 del self.app._profile_manager 499 del self.app._profile_manager
499 super(Cagou, self).postInit(profile_manager) 500 super(Cagou, self).postInit(profile_manager)
500 501
502 def profilePlugged(self, profile):
503 super().profilePlugged(profile)
504 # FIXME: this won't work with multiple profiles
505 self.app.connected = self.profiles[profile].connected
506
501 def _defaultFactoryMain(self, plugin_info, target, profiles): 507 def _defaultFactoryMain(self, plugin_info, target, profiles):
502 """default factory used to create main widgets instances 508 """default factory used to create main widgets instances
503 509
504 used when PLUGIN_INFO["factory"] is not set 510 used when PLUGIN_INFO["factory"] is not set
505 @param plugin_info(dict): plugin datas 511 @param plugin_info(dict): plugin datas
878 log.info("Visible widgets dump:\n{data}".format( 884 log.info("Visible widgets dump:\n{data}".format(
879 data=pformat(self._visible_widgets))) 885 data=pformat(self._visible_widgets)))
880 else: 886 else:
881 return super(Cagou, self)._debugHandler(action, parameters, profile) 887 return super(Cagou, self)._debugHandler(action, parameters, profile)
882 888
889 def connectedHandler(self, jid_s, profile):
890 # FIXME: this won't work with multiple profiles
891 super().connectedHandler(jid_s, profile)
892 self.app.connected = True
893
894 def disconnectedHandler(self, profile):
895 # FIXME: this won't work with multiple profiles
896 super().disconnectedHandler(profile)
897 self.app.connected = False
898
883 ## misc ## 899 ## misc ##
884 900
885 def plugging_profiles(self): 901 def plugging_profiles(self):
886 self.app.root.changeWidget(widgets_handler.WidgetsHandler()) 902 self.app.root.changeWidget(widgets_handler.WidgetsHandler())
887 self.bridge.menusGet("", C.NO_SECURITY_LIMIT, callback=self._menusGetCb) 903 self.bridge.menusGet("", C.NO_SECURITY_LIMIT, callback=self._menusGetCb)