comparison cagou/plugins/plugin_wid_file_sharing.py @ 206:890b48e41998

plugin file sharing: use appropriate symbol when discovering devices
author Goffi <goffi@goffi.org>
date Fri, 25 May 2018 12:03:19 +0200
parents 9cefc9f8efc9
children b25d03403898
comparison
equal deleted inserted replaced
205:9cefc9f8efc9 206:890b48e41998
85 85
86 def __init__(self, entity_ids): 86 def __init__(self, entity_ids):
87 identities = {} 87 identities = {}
88 for cat, type_, name in entity_ids: 88 for cat, type_, name in entity_ids:
89 identities.setdefault(cat, {}).setdefault(type_, []).append(name) 89 identities.setdefault(cat, {}).setdefault(type_, []).append(name)
90 client = identities.get('client', {})
91 if 'pc' in client:
92 self.type = 'desktop'
93 elif 'phone' in client:
94 self.type = 'phone'
95 elif 'web' in client:
96 self.type = 'web'
97 elif 'console' in client:
98 self.type = 'console'
99 else:
100 self.type = 'desktop'
101
90 self.identities = identities 102 self.identities = identities
91 103
92 @property 104 @property
93 def name(self): 105 def name(self):
94 return self.identities.values()[0].values()[0][0] 106 return self.identities.values()[0].values()[0][0]
201 self.entity_jid = entity_jid 213 self.entity_jid = entity_jid
202 self.identities = identities 214 self.identities = identities
203 self.own_device = entity_jid.bare == next(G.host.profiles.itervalues()).whoami 215 self.own_device = entity_jid.bare == next(G.host.profiles.itervalues()).whoami
204 name = self.identities.name if self.own_device else self.entity_jid.node 216 name = self.identities.name if self.own_device else self.entity_jid.node
205 super(DeviceWidget, self).__init__(sharing_wid, name) 217 super(DeviceWidget, self).__init__(sharing_wid, name)
218
219 def getSymbol(self):
220 if self.identities.type == 'desktop':
221 return 'desktop'
222 elif self.identities.type == 'phone':
223 return 'mobile'
224 elif self.identities.type == 'web':
225 return 'globe'
226 elif self.identities.type == 'console':
227 return 'terminal'
228 else:
229 return 'desktop'
206 230
207 def do_item_action(self, touch): 231 def do_item_action(self, touch):
208 self.sharing_wid.remote_entity = self.entity_jid 232 self.sharing_wid.remote_entity = self.entity_jid
209 self.sharing_wid.remote_dir = u'' 233 self.sharing_wid.remote_dir = u''
210 234