comparison cagou/plugins/plugin_wid_contact_list.py @ 404:f7476818f9fb

core (common): JidSelector + behaviors various improvments: - renamed *Behaviour => *Behavior to be consistent with Kivy + moved to new "core.behaviors" modules - use a dedicated property in ContactItem for notification counter (which is now named "badge") - in JidSelector, well-known strings now create use a dedicated layout, add separator (except if new `add_separators` property is set to False), and are added to attribute of the same name - a new `item_class` property is now used to indicate the class to instanciate for items (by default it's a ContactItem) - FilterBahavior.do_filter now expect the parent layout instead of directly the children, this is to allow a FilterBahavior to manage several children layout at once (used with JidSelector) - core.utils has been removed, as the behavior there has been moved to core.behaviors
author Goffi <goffi@goffi.org>
date Wed, 12 Feb 2020 20:02:58 +0100
parents d61bbbac4160
children 167c3e198f73
comparison
equal deleted inserted replaced
403:b0af45a92055 404:f7476818f9fb
28 from kivy import properties 28 from kivy import properties
29 from cagou import G 29 from cagou import G
30 from ..core import cagou_widget 30 from ..core import cagou_widget
31 from ..core.constants import Const as C 31 from ..core.constants import Const as C
32 from ..core.common import ContactItem 32 from ..core.common import ContactItem
33 from ..core.utils import FilterBehavior 33 from ..core.behaviors import FilterBehavior, TouchMenuBehavior, TouchMenuItemBehavior
34 from ..core.menu import SideMenu, TouchMenuBehaviour, TouchMenuItemBehaviour 34 from ..core.menu import SideMenu
35 35
36 36
37 log = logging.getLogger(__name__) 37 log = logging.getLogger(__name__)
38 38
39 39
97 errback=partial(G.host.errback, 97 errback=partial(G.host.errback,
98 title=_("can't remove contact"), 98 title=_("can't remove contact"),
99 message=_("error while trying to remove contact: {msg}"))) 99 message=_("error while trying to remove contact: {msg}")))
100 100
101 101
102 class CLContactItem(TouchMenuItemBehaviour, ContactItem): 102 class CLContactItem(TouchMenuItemBehavior, ContactItem):
103 103
104 def do_item_action(self, touch): 104 def do_item_action(self, touch):
105 assert self.profile 105 assert self.profile
106 # XXX: for now clicking on an item launch the corresponding Chat widget 106 # XXX: for now clicking on an item launch the corresponding Chat widget
107 # behaviour should change in the future 107 # behaviour should change in the future
114 callback=self.main_wid.removeContact)) 114 callback=self.main_wid.removeContact))
115 return choices 115 return choices
116 116
117 117
118 class ContactList(QuickContactList, cagou_widget.CagouWidget, FilterBehavior, 118 class ContactList(QuickContactList, cagou_widget.CagouWidget, FilterBehavior,
119 TouchMenuBehaviour): 119 TouchMenuBehavior):
120 float_layout = properties.ObjectProperty() 120 float_layout = properties.ObjectProperty()
121 layout = properties.ObjectProperty() 121 layout = properties.ObjectProperty()
122 use_header_input = True 122 use_header_input = True
123 123
124 def __init__(self, host, target, profiles): 124 def __init__(self, host, target, profiles):
141 item = self.menu_item 141 item = self.menu_item
142 self.clear_menu() 142 self.clear_menu()
143 DelContactMenu(contact_item=item).show() 143 DelContactMenu(contact_item=item).show()
144 144
145 def onHeaderInputComplete(self, wid, text): 145 def onHeaderInputComplete(self, wid, text):
146 self.do_filter(self.layout.children, 146 self.do_filter(self.layout,
147 text, 147 text,
148 lambda c: c.jid, 148 lambda c: c.jid,
149 width_cb=lambda c: c.base_width, 149 width_cb=lambda c: c.base_width,
150 height_cb=lambda c: c.minimum_height, 150 height_cb=lambda c: c.minimum_height,
151 ) 151 )