changeset 194:a68c9baa6694

plugin file sharing: use header hint to show current path, and open new path: - if header is empty, current path is shown as hint - if text is entered, it's used to filter files/dirs in the current path - if text is a path (i.e. if it contains a "/"), current path is changed to specified one when header is validated
author Goffi <goffi@goffi.org>
date Wed, 23 May 2018 18:44:15 +0200
parents 284cb5c467b0
children cf30cb1d1c12
files cagou/plugins/plugin_wid_file_sharing.py
diffstat 1 files changed, 9 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_file_sharing.py	Wed May 23 18:40:58 2018 +0200
+++ b/cagou/plugins/plugin_wid_file_sharing.py	Wed May 23 18:44:15 2018 +0200
@@ -49,6 +49,7 @@
 }
 MODE_VIEW = u"view"
 MODE_LOCAL = u"local"
+SELECT_INSTRUCTIONS = _(u"Please select entities to share with")
 
 
 dist = modernmenu.dist
@@ -269,9 +270,15 @@
         print(instance)
         self.update_view(None, self.local_dir)
 
+    def onHeaderInput(self):
+        if u'/' in self.header_input.text or self.header_input.text == u'~':
+            self.current_dir = os.path.expanduser(self.header_input.text)
+
     def onHeaderInputComplete(self, wid, text):
         """we filter items when text is entered in input box"""
         text = text.strip().lower()
+        if u'/' in text:
+            return
         filtering = len(text)>len(self._filter_last)
         self._filter_last = text
         for child in self.layout.children:
@@ -349,6 +356,8 @@
         log.debug(u'updating {}, {}'.format(self.current_dir, args))
         self.layout.clear_widgets()
         self.header_input.text = u''
+        self.header_input.hint_text = self.current_dir
+
         if self.mode == MODE_LOCAL:
             filepath = os.path.join(self.local_dir, u'..')
             self.layout.add_widget(LocalPathWidget(sharing_wid=self, filepath=filepath))