diff cagou/plugins/plugin_wid_chat.py @ 353:19422bbd9c8e

core (widgets handler): refactoring: - CagouWidget now has class properties (to be overridden when needed) which indicate how if the widget handle must add a wrapping ScreenManager (global_screen_manager) or show all instances of the class in a Carousel (collection_carousel). If none of those options is used, a ScrollView will be wrapping the widget, to be sure that the widget will be resized correctly when necessary (without it, the widget could still be drawn in the backround when the size is too small and overflow on the WidgetWrapper, this would be the case with WidgetSelector) - some helper methods/properties have been added to CagouWidget. Check docstrings for details - better handling of (in)visible widget in WidgetsHandler - thanks to the new wrapping ScrollView, WidgetSelect will show scroll bars if the available space is too small. - bugs fixes
author Goffi <goffi@goffi.org>
date Fri, 17 Jan 2020 18:44:35 +0100
parents 9688e5e9881e
children aa860c10acfc
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_chat.py	Fri Jan 17 18:44:35 2020 +0100
+++ b/cagou/plugins/plugin_wid_chat.py	Fri Jan 17 18:44:35 2020 +0100
@@ -380,9 +380,12 @@
     message_input = properties.ObjectProperty()
     messages_widget = properties.ObjectProperty()
     history_scroll = properties.ObjectProperty()
+    collection_carousel = True
 
     def __init__(self, host, target, type_=C.CHAT_ONE2ONE, nick=None, occupants=None,
                  subject=None, statuses=None, profiles=None):
+        if statuses is None:
+            statuses = {}
         quick_chat.QuickChat.__init__(
             self, host, target, type_, nick, occupants, subject, statuses,
             profiles=profiles)
@@ -404,9 +407,11 @@
         self.headerInputAddExtra(extra_btn)
         self.header_input.hint_text = target
         self._history_prepend_lock = False
-        Clock.schedule_once(lambda dt: self.postInit(), 0)
         self.history_count = 0
 
+    def on_kv_post(self, __):
+        self.postInit()
+
     def __str__(self):
         return "Chat({})".format(self.target)