diff src/cagou/core/menu.py @ 88:3dc526bb4a5a

upload: plugin android gallery, first draft: - added "external" key in PLUGIN_INFO which indicate that a plugin doesn't create a widget when set to True - callback and cancel_cb method in UploadMenu now use a cleaning_cb arguments which can be None. If set, the callback will be called without argument once the file is uploaded - the AndroidGallery plugin looks for images on Android, then save the content to a temporary file an upload it, then clean the file. This plugin is only active on android platform.
author Goffi <goffi@goffi.org>
date Sun, 25 Dec 2016 22:53:50 +0100
parents c711be670ecd
children 5d2289127bb7
line wrap: on
line diff
--- a/src/cagou/core/menu.py	Sun Dec 25 16:41:25 2016 +0100
+++ b/src/cagou/core/menu.py	Sun Dec 25 22:53:50 2016 +0100
@@ -160,6 +160,7 @@
 
 
 class UploadMenu(contextmenu.ContextMenu):
+    """upload menu which handle display and callbacks"""
     # callback will be called with path to file to upload
     callback = properties.ObjectProperty()
     # cancel callback need to remove the widget for UI
@@ -191,8 +192,10 @@
     def _closeUI(self, wid):
         G.host.closeUI()
 
-    def onUploadCancelled(self, wid):
+    def onUploadCancelled(self, wid, cleaning_cb=None):
         self._closeUI(wid)
+        if cleaning_cb is not None:
+            cleaning_cb()
 
     def do_callback(self, plug_info):
         self.hide()
@@ -200,8 +203,11 @@
             log.warning(u"UploadMenu callback is not set")
         else:
             wid = None
-            def onUploadCb(file_path):
-                self._closeUI(wid)
-                self.callback(file_path)
+            external = plug_info.get('external', False)
+            def onUploadCb(file_path, cleaning_cb=None):
+                if not external:
+                    self._closeUI(wid)
+                self.callback(file_path, cleaning_cb)
             wid = plug_info['factory'](plug_info, onUploadCb, self.cancel_cb, self.profiles)
-            G.host.showExtraUI(wid)
+            if not external:
+                G.host.showExtraUI(wid)