Mercurial > libervia-desktop-kivy
comparison src/cagou/plugins/plugin_wid_chat.py @ 105:ce6ef88f2cff
chat: avatar improvments:
- avatar source is not set anymore in kv but on MessageWidget init, so None value can be handled correclty
- Message widget add itself to mess_data before parsing kv, so call to properties in kv can update the widget correctly (specially important for embedded bridge)
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 15 Jan 2017 18:02:53 +0100 |
parents | c601e3d40342 |
children | 9909ed7a7a20 |
comparison
equal
deleted
inserted
replaced
104:663e44f30092 | 105:ce6ef88f2cff |
---|---|
527 mess_padding = (dp(5), dp(5)) | 527 mess_padding = (dp(5), dp(5)) |
528 avatar = properties.ObjectProperty() | 528 avatar = properties.ObjectProperty() |
529 delivery = properties.ObjectProperty() | 529 delivery = properties.ObjectProperty() |
530 | 530 |
531 def __init__(self, **kwargs): | 531 def __init__(self, **kwargs): |
532 # self must be registered in widgets before kv is parsed | |
533 kwargs['mess_data'].widgets.add(self) | |
532 super(MessageWidget, self).__init__(**kwargs) | 534 super(MessageWidget, self).__init__(**kwargs) |
533 self.mess_data.widgets.add(self) | 535 avatar_path = self.mess_data.avatar |
536 if avatar_path is not None: | |
537 self.avatar.source = avatar_path | |
534 | 538 |
535 @property | 539 @property |
536 def chat(self): | 540 def chat(self): |
537 """return parent Chat instance""" | 541 """return parent Chat instance""" |
538 return self.mess_data.parent | 542 return self.mess_data.parent |