diff src/cagou/core/cagou_main.py @ 97:5d2289127bb7

menu (upload): better menu using dedicated widget: upload menu now use a decicated widget instead of context menu. The menu take half the size of the main window, and show each upload option as an icon. Use can select upload or P2P sending, and a short text message explains how the file will be transmitted.
author Goffi <goffi@goffi.org>
date Thu, 29 Dec 2016 23:47:07 +0100
parents 520a9e1a659b
children d654bdfeb404
line wrap: on
line diff
--- a/src/cagou/core/cagou_main.py	Thu Dec 29 23:47:04 2016 +0100
+++ b/src/cagou/core/cagou_main.py	Thu Dec 29 23:47:07 2016 +0100
@@ -295,7 +295,7 @@
         self.app.default_avatar = os.path.join(self.media_dir, "misc/default_avatar.png")
         self.app.icon = os.path.join(self.media_dir, "icons/muchoslava/png/cagou_profil_bleu_96.png")
         self._plg_wids = []  # main widgets plugins
-        self._plg_wids_upload = []  # upload widgets plugins
+        self._plg_wids_transfer = []  # transfer widgets plugins
         self._import_plugins()
         self._visible_widgets = {}  # visible widgets by classes
 
@@ -357,13 +357,13 @@
         main_cls = plugin_info['main']
         return self.widgets.getOrCreateWidget(main_cls, target, on_new_widget=None, profiles=iter(self.profiles))
 
-    def _defaultFactoryUpload(self, plugin_info, callback, cancel_cb, profiles):
-        """default factory used to create upload widgets instances
+    def _defaultFactoryTransfer(self, plugin_info, callback, cancel_cb, profiles):
+        """default factory used to create transfer widgets instances
 
         @param plugin_info(dict): plugin datas
-        @param callback(callable): method to call with path to file to upload
-        @param cancel_cb(callable): call when upload is cancelled
-            upload widget must be used as first argument
+        @param callback(callable): method to call with path to file to transfer
+        @param cancel_cb(callable): call when transfer is cancelled
+            transfer widget must be used as first argument
         @param profiles(iterable): list of profiles
             None if not specified
         """
@@ -387,7 +387,7 @@
         plug_lst = [os.path.splitext(p)[0] for p in map(os.path.basename, glob.glob(os.path.join(plugins_path, plugin_glob)))]
 
         imported_names_main = set()  # used to avoid loading 2 times plugin with same import name
-        imported_names_upload = set()
+        imported_names_transfer = set()
         for plug in plug_lst:
             plugin_path = 'cagou.plugins.' + plug
 
@@ -402,9 +402,9 @@
             if plugin_type == C.PLUG_TYPE_WID:
                 imported_names = imported_names_main
                 default_factory = self._defaultFactoryMain
-            elif plugin_type == C.PLUG_TYPE_UPLOAD:
-                imported_names = imported_names_upload
-                default_factory = self._defaultFactoryUpload
+            elif plugin_type == C.PLUG_TYPE_TRANSFER:
+                imported_names = imported_names_transfer
+                default_factory = self._defaultFactoryTransfer
             else:
                 log.error(u"unknown plugin type {type_} for plugin {file_}, skipping".format(
                     type_ = plugin_type,
@@ -484,7 +484,7 @@
 
         # we want widgets sorted by names
         self._plg_wids.sort(key=lambda p: p['name'].lower())
-        self._plg_wids_upload.sort(key=lambda p: p['name'].lower())
+        self._plg_wids_transfer.sort(key=lambda p: p['name'].lower())
 
         if self.default_wid is None:
             # we have no selector widget, we use the first widget as default
@@ -493,8 +493,8 @@
     def _getPluginsSet(self, type_):
         if type_ == C.PLUG_TYPE_WID:
             return self._plg_wids
-        elif type_ == C.PLUG_TYPE_UPLOAD:
-            return self._plg_wids_upload
+        elif type_ == C.PLUG_TYPE_TRANSFER:
+            return self._plg_wids_transfer
         else:
             raise KeyError(u"{} plugin type is unknown".format(type_))