changeset 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 a8190aecdd79
files cagou/plugins/plugin_wid_file_sharing.kv cagou/plugins/plugin_wid_file_sharing.py
diffstat 2 files changed, 25 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_file_sharing.kv	Fri May 25 12:01:47 2018 +0200
+++ b/cagou/plugins/plugin_wid_file_sharing.kv	Fri May 25 12:03:19 2018 +0200
@@ -73,7 +73,7 @@
     Symbol:
         size_hint: 1, None
         height: dp(80)
-        symbol: 'desktop'
+        symbol: root.getSymbol()
         margin: dp(40)
         color: 0, 0, 0, 1
     Label:
--- a/cagou/plugins/plugin_wid_file_sharing.py	Fri May 25 12:01:47 2018 +0200
+++ b/cagou/plugins/plugin_wid_file_sharing.py	Fri May 25 12:03:19 2018 +0200
@@ -87,6 +87,18 @@
         identities = {}
         for cat, type_, name in entity_ids:
             identities.setdefault(cat, {}).setdefault(type_, []).append(name)
+        client = identities.get('client', {})
+        if 'pc' in client:
+            self.type = 'desktop'
+        elif 'phone' in client:
+            self.type = 'phone'
+        elif 'web' in client:
+            self.type = 'web'
+        elif 'console' in client:
+            self.type = 'console'
+        else:
+            self.type = 'desktop'
+
         self.identities = identities
 
     @property
@@ -204,6 +216,18 @@
         name = self.identities.name if self.own_device else self.entity_jid.node
         super(DeviceWidget, self).__init__(sharing_wid, name)
 
+    def getSymbol(self):
+        if self.identities.type == 'desktop':
+            return 'desktop'
+        elif self.identities.type == 'phone':
+            return 'mobile'
+        elif self.identities.type == 'web':
+            return 'globe'
+        elif self.identities.type == 'console':
+            return 'terminal'
+        else:
+            return 'desktop'
+
     def do_item_action(self, touch):
         self.sharing_wid.remote_entity = self.entity_jid
         self.sharing_wid.remote_dir = u''