Mercurial > libervia-desktop-kivy
comparison cagou/plugins/plugin_wid_file_sharing.py @ 198:60b63c3e63a1
plugin file sharing: use new EntitiesSelectorMenu to select entities which can access shared files
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 23 May 2018 21:28:16 +0200 |
parents | 519b3a29743c |
children | b80d275e437f |
comparison
equal
deleted
inserted
replaced
197:c7d15ef4bfa8 | 198:60b63c3e63a1 |
---|---|
25 from sat.tools.common import files_utils | 25 from sat.tools.common import files_utils |
26 from sat_frontends.quick_frontend import quick_widgets | 26 from sat_frontends.quick_frontend import quick_widgets |
27 from sat_frontends.tools import jid | 27 from sat_frontends.tools import jid |
28 from cagou.core.constants import Const as C | 28 from cagou.core.constants import Const as C |
29 from cagou.core import cagou_widget | 29 from cagou.core import cagou_widget |
30 from cagou.core.menu import EntitiesSelectorMenu | |
30 from cagou.core.utils import FilterBehavior | 31 from cagou.core.utils import FilterBehavior |
31 from cagou import G | 32 from cagou import G |
32 from kivy import properties | 33 from kivy import properties |
33 from kivy.uix.label import Label | 34 from kivy.uix.label import Label |
34 from kivy.uix.button import Button | 35 from kivy.uix.button import Button |
406 self.menu.start_display(touch) | 407 self.menu.start_display(touch) |
407 self.menu_item = item | 408 self.menu_item = item |
408 | 409 |
409 ## Share methods ## | 410 ## Share methods ## |
410 | 411 |
411 def share(self, menu): | 412 def do_share(self, entities_jids, item): |
412 item = self.menu_item | 413 if entities_jids: |
413 self.clear_menu() | 414 access = {u'read': {u'type': 'whitelist', |
415 u'jids': entities_jids}} | |
416 else: | |
417 access = {} | |
418 | |
414 G.host.bridge.FISSharePath( | 419 G.host.bridge.FISSharePath( |
415 item.name, | 420 item.name, |
416 item.filepath, | 421 item.filepath, |
417 json.dumps({}, ensure_ascii=False), | 422 json.dumps(access, ensure_ascii=False), |
418 self.profile, | 423 self.profile, |
419 callback=lambda name: G.host.addNote( | 424 callback=lambda name: G.host.addNote( |
420 _(u"sharing folder"), | 425 _(u"sharing folder"), |
421 _(u"{name} is now shared").format(name=name)), | 426 _(u"{name} is now shared").format(name=name)), |
422 errback=partial(G.host.errback, | 427 errback=partial(G.host.errback, |
423 title=_(u"sharing folder"), | 428 title=_(u"sharing folder"), |
424 message=_(u"can't share folder: {msg}"))) | 429 message=_(u"can't share folder: {msg}"))) |
430 | |
431 def share(self, menu): | |
432 item = self.menu_item | |
433 self.clear_menu() | |
434 EntitiesSelectorMenu(instructions=SELECT_INSTRUCTIONS, | |
435 callback=partial(self.do_share, item=item)).show() | |
425 | 436 |
426 def unshare(self, menu): | 437 def unshare(self, menu): |
427 item = self.menu_item | 438 item = self.menu_item |
428 self.clear_menu() | 439 self.clear_menu() |
429 G.host.bridge.FISUnsharePath( | 440 G.host.bridge.FISUnsharePath( |