comparison cagou/core/common.py @ 405:84ff5c917064

widgets: implemented ordering in ContactItem and CagouWidget: ordering of slides in collection_carousel were using a specific key during the sort, this has been replaced by an ordering implemented directly into the classes. Ordering has also been implemented in ContactItem to have items appearing in a consistent order notably for opened chats.
author Goffi <goffi@goffi.org>
date Wed, 12 Feb 2020 20:02:58 +0100
parents f7476818f9fb
children 03554ad70846
comparison
equal deleted inserted replaced
404:f7476818f9fb 405:84ff5c917064
17 # along with this program. If not, see <http://www.gnu.org/licenses/>. 17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
18 18
19 """common simple widgets""" 19 """common simple widgets"""
20 20
21 import json 21 import json
22 from functools import partial 22 from functools import partial, total_ordering
23 from sat.core.i18n import _ 23 from sat.core.i18n import _
24 from sat.core import log as logging 24 from sat.core import log as logging
25 from kivy.uix.widget import Widget 25 from kivy.uix.widget import Widget
26 from kivy.uix.image import Image 26 from kivy.uix.image import Image
27 from kivy.uix.label import Label 27 from kivy.uix.label import Label
52 52
53 53
54 class NotifLabel(Label): 54 class NotifLabel(Label):
55 pass 55 pass
56 56
57 57 @total_ordering
58 class ContactItem(BoxLayout): 58 class ContactItem(BoxLayout):
59 """An item from ContactList 59 """An item from ContactList
60 60
61 The item will drawn as an icon (JID avatar) with its jid below. 61 The item will drawn as an icon (JID avatar) with its jid below.
62 If "notifs" are present in data, a notification counter will be drawn above the 62 If "notifs" are present in data, a notification counter will be drawn above the
83 self.avatar_layout.add_widget(self.badge) 83 self.avatar_layout.add_widget(self.badge)
84 else: 84 else:
85 if self.badge is not None: 85 if self.badge is not None:
86 self.avatar_layout.remove_widget(self.badge) 86 self.avatar_layout.remove_widget(self.badge)
87 self.badge = None 87 self.badge = None
88
89 def __lt__(self, other):
90 return self.jid < other.jid
88 91
89 92
90 class ContactButton(ButtonBehavior, ContactItem): 93 class ContactButton(ButtonBehavior, ContactItem):
91 pass 94 pass
92 95