comparison cagou/core/common_widgets.py @ 374:3002704318e3

core (common_widgets): fixed own jid detection in DeviceWidget + `name` property in Identities
author Goffi <goffi@goffi.org>
date Mon, 27 Jan 2020 21:17:09 +0100
parents 51520ce98154
children 4d660b252487
comparison
equal deleted inserted replaced
373:5d994be1161b 374:3002704318e3
75 75
76 self.identities = identities 76 self.identities = identities
77 77
78 @property 78 @property
79 def name(self): 79 def name(self):
80 return list(self.identities.values())[0].values()[0][0] 80 first_identity = next(iter(self.identities.values()))
81 names = next(iter(first_identity.values()))
82 return names[0]
81 83
82 84
83 class ItemWidget(TouchMenuItemBehaviour, BoxLayout): 85 class ItemWidget(TouchMenuItemBehaviour, BoxLayout):
84 name = properties.StringProperty() 86 name = properties.StringProperty()
85 base_width = properties.NumericProperty(dp(100)) 87 base_width = properties.NumericProperty(dp(100))
89 91
90 def __init__(self, main_wid, entity_jid, identities, **kw): 92 def __init__(self, main_wid, entity_jid, identities, **kw):
91 self.entity_jid = entity_jid 93 self.entity_jid = entity_jid
92 self.identities = identities 94 self.identities = identities
93 own_jid = next(iter(G.host.profiles.values())).whoami 95 own_jid = next(iter(G.host.profiles.values())).whoami
94 self.own_device = entity_jid.bare == own_jid 96 self.own_device = entity_jid.bare == own_jid.bare
95 if self.own_device: 97 if self.own_device:
96 name = self.identities.name 98 name = self.identities.name
97 elif self.entity_jid.node: 99 elif self.entity_jid.node:
98 name = self.entity_jid.node 100 name = self.entity_jid.node
99 elif self.entity_jid == own_jid.domain: 101 elif self.entity_jid == own_jid.domain: