comparison 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
comparison
equal deleted inserted replaced
352:434f770fe55b 353:19422bbd9c8e
378 378
379 class Chat(quick_chat.QuickChat, cagou_widget.CagouWidget): 379 class Chat(quick_chat.QuickChat, cagou_widget.CagouWidget):
380 message_input = properties.ObjectProperty() 380 message_input = properties.ObjectProperty()
381 messages_widget = properties.ObjectProperty() 381 messages_widget = properties.ObjectProperty()
382 history_scroll = properties.ObjectProperty() 382 history_scroll = properties.ObjectProperty()
383 collection_carousel = True
383 384
384 def __init__(self, host, target, type_=C.CHAT_ONE2ONE, nick=None, occupants=None, 385 def __init__(self, host, target, type_=C.CHAT_ONE2ONE, nick=None, occupants=None,
385 subject=None, statuses=None, profiles=None): 386 subject=None, statuses=None, profiles=None):
387 if statuses is None:
388 statuses = {}
386 quick_chat.QuickChat.__init__( 389 quick_chat.QuickChat.__init__(
387 self, host, target, type_, nick, occupants, subject, statuses, 390 self, host, target, type_, nick, occupants, subject, statuses,
388 profiles=profiles) 391 profiles=profiles)
389 self.otr_state_encryption = OTR_STATE_UNENCRYPTED 392 self.otr_state_encryption = OTR_STATE_UNENCRYPTED
390 self.otr_state_trust = OTR_STATE_UNTRUSTED 393 self.otr_state_trust = OTR_STATE_UNTRUSTED
402 self.extra_menu = ExtraMenu(chat=self) 405 self.extra_menu = ExtraMenu(chat=self)
403 extra_btn = ExtraButton(chat=self) 406 extra_btn = ExtraButton(chat=self)
404 self.headerInputAddExtra(extra_btn) 407 self.headerInputAddExtra(extra_btn)
405 self.header_input.hint_text = target 408 self.header_input.hint_text = target
406 self._history_prepend_lock = False 409 self._history_prepend_lock = False
407 Clock.schedule_once(lambda dt: self.postInit(), 0)
408 self.history_count = 0 410 self.history_count = 0
411
412 def on_kv_post(self, __):
413 self.postInit()
409 414
410 def __str__(self): 415 def __str__(self):
411 return "Chat({})".format(self.target) 416 return "Chat({})".format(self.target)
412 417
413 def __repr__(self): 418 def __repr__(self):