# HG changeset patch # User Goffi # Date 1581020181 -3600 # Node ID d15828ca9d86f083d96c1920a3fd1b5b40a320de # Parent e2f806779b53938be3df9d493d77f6a7fce95666 chat: use the new "implicit_update" and "to_show" properties for ChatSelector.jid_selector: - "implicit_update" is used to avoid double update on init - "to_show" is used to show opened chats, roster and bookmarks - update jid_selector when pre_entering the chat selector diff -r e2f806779b53 -r d15828ca9d86 cagou/plugins/plugin_wid_chat.kv --- a/cagou/plugins/plugin_wid_chat.kv Thu Feb 06 21:16:21 2020 +0100 +++ b/cagou/plugins/plugin_wid_chat.kv Thu Feb 06 21:16:21 2020 +0100 @@ -20,13 +20,7 @@ #:import SimpleXHTMLWidget cagou.core.simple_xhtml.SimpleXHTMLWidget #:import DelayedBoxLayout cagou.core.common_widgets.DelayedBoxLayout #:import ScrollEffect kivy.effects.scroll.ScrollEffect - - -# Chat Selector - -: - JidSelector: - on_select: root.on_select(args[1]) +#:import CategorySeparator cagou.core.common_widgets.CategorySeparator # Chat @@ -219,3 +213,24 @@ Rectangle: pos: self.pos size: self.size + + +# Chat Selector + +: + jid_selector: jid_selector + JidSelector: + id: jid_selector + # we call update() explicitly in on_pre_enter + implicit_update: False + on_select: root.on_select(args[1]) + to_show: + [ + CategorySeparator(text=_("Opened chats")), + "opened_chats", + CategorySeparator(text=_("Your contacts")), + "roster", + CategorySeparator(text=_("Your chat rooms")), + "bookmarks", + ] + diff -r e2f806779b53 -r d15828ca9d86 cagou/plugins/plugin_wid_chat.py --- a/cagou/plugins/plugin_wid_chat.py Thu Feb 06 21:16:21 2020 +0100 +++ b/cagou/plugins/plugin_wid_chat.py Thu Feb 06 21:16:21 2020 +0100 @@ -432,6 +432,7 @@ sel_screen = Screen(name='chat_selector') chat_selector = ChatSelector(profile=self.profile) sel_screen.add_widget(chat_selector) + sel_screen.bind(on_pre_enter=chat_selector.on_pre_enter) screen_manager.add_widget(sel_screen) if self.show_chat_selector: transition = screen_manager.transition @@ -896,9 +897,13 @@ class ChatSelector(cagou_widget.CagouWidget): + jid_selector = properties.ObjectProperty() profile = properties.StringProperty() plugin_info_class = Chat + def on_pre_enter(self, screen): + self.jid_selector.update() + def on_select(self, contact_button): contact_jid = jid.JID(contact_button.jid) plugin_info = G.host.getPluginInfo(main=Chat)