Mercurial > libervia-desktop-kivy
diff cagou/plugins/plugin_wid_file_sharing.py @ 491:203755bbe0fe
massive refactoring from camelCase -> snake_case. See backend commit log for more details
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:44:32 +0200 |
parents | 3c9ba4a694ef |
children |
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_file_sharing.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_wid_file_sharing.py Sat Apr 08 13:44:32 2023 +0200 @@ -107,7 +107,7 @@ def is_dir(self): return os.path.isdir(self.filepath) - def getMenuChoices(self): + def get_menu_choices(self): choices = [] if self.shared: choices.append(dict(text=_('unshare'), @@ -166,7 +166,7 @@ TouchMenuBehavior.__init__(self) self.mode_btn = ModeBtn(self) self.mode_btn.bind(on_release=self.change_mode) - self.headerInputAddExtra(self.mode_btn) + self.header_input_add_extra(self.mode_btn) self.bind(local_dir=self.update_view, remote_dir=self.update_view, remote_entity=self.update_view) @@ -174,14 +174,14 @@ if not FileSharing.signals_registered: # FIXME: we use this hack (registering the signal for the whole class) now # as there is currently no unregisterSignal available in bridges - G.host.registerSignal("FISSharedPathNew", + G.host.register_signal("fis_shared_path_new", handler=FileSharing.shared_path_new, iface="plugin") - G.host.registerSignal("FISSharedPathRemoved", + G.host.register_signal("fis_shared_path_removed", handler=FileSharing.shared_path_removed, iface="plugin") FileSharing.signals_registered = True - G.host.bridge.FISLocalSharesGet(self.profile, + G.host.bridge.fis_local_shares_get(self.profile, callback=self.fill_paths, errback=G.host.errback) @@ -208,11 +208,11 @@ def on_mode(self, instance, new_mode): self.update_view(None, self.local_dir) - def onHeaderInput(self): + def on_header_wid_input(self): if '/' in self.header_input.text or self.header_input.text == '~': self.current_dir = expanduser(self.header_input.text) - def onHeaderInputComplete(self, wid, text, **kwargs): + def on_header_wid_input_complete(self, wid, text, **kwargs): """we filter items when text is entered in input box""" if '/' in text: return @@ -227,7 +227,7 @@ ## remote sharing callback ## - def _discoFindByFeaturesCb(self, data): + def _disco_find_by_features_cb(self, data): entities_services, entities_own, entities_roster = data for entities_map, title in ((entities_services, _('services')), @@ -257,16 +257,16 @@ msg = _("can't find file information sharing namespace, " "is the plugin running?") log.warning(msg) - G.host.addNote(_("missing plugin"), msg, C.XMLUI_DATA_LVL_ERROR) + G.host.add_note(_("missing plugin"), msg, C.XMLUI_DATA_LVL_ERROR) return - self.host.bridge.discoFindByFeatures( + self.host.bridge.disco_find_by_features( [namespace], [], False, True, True, True, False, self.profile, - callback=self._discoFindByFeaturesCb, + callback=self._disco_find_by_features_cb, errback=partial(G.host.errback, title=_("shared folder error"), message=_("can't check sharing devices: {msg}"))) - def FISListCb(self, files_data): + def fis_list_cb(self, files_data): for file_data in files_data: filepath = os.path.join(self.current_dir, file_data['name']) item = RemotePathWidget( @@ -275,9 +275,9 @@ type_=file_data['type']) self.layout.add_widget(item) - def FISListEb(self, failure_): + def fis_list_eb(self, failure_): self.remote_dir = '' - G.host.addNote( + G.host.add_note( _("shared folder error"), _("can't list files for {remote_entity}: {msg}").format( remote_entity=self.remote_entity, @@ -302,7 +302,7 @@ msg = _("can't list files in \"{local_dir}\": {msg}").format( local_dir=self.local_dir, msg=e) - G.host.addNote( + G.host.add_note( _("shared folder error"), msg, level=C.XMLUI_DATA_LVL_WARNING) @@ -324,13 +324,13 @@ main_wid=self, type_ = C.FILE_TYPE_DIRECTORY) self.layout.add_widget(item) - self.host.bridge.FISList( + self.host.bridge.fis_list( str(self.remote_entity), self.remote_dir, {}, self.profile, - callback=self.FISListCb, - errback=self.FISListEb) + callback=self.fis_list_cb, + errback=self.fis_list_eb) ## Share methods ## @@ -341,12 +341,12 @@ else: access = {} - G.host.bridge.FISSharePath( + G.host.bridge.fis_share_path( item.name, item.filepath, json.dumps(access, ensure_ascii=False), self.profile, - callback=lambda name: G.host.addNote( + callback=lambda name: G.host.add_note( _("sharing folder"), _("{name} is now shared").format(name=name)), errback=partial(G.host.errback, @@ -362,18 +362,18 @@ def unshare(self, menu): item = self.menu_item self.clear_menu() - G.host.bridge.FISUnsharePath( + G.host.bridge.fis_unshare_path( item.filepath, self.profile, - callback=lambda: G.host.addNote( + callback=lambda: G.host.add_note( _("sharing folder"), _("{name} is not shared anymore").format(name=item.name)), errback=partial(G.host.errback, title=_("sharing folder"), message=_("can't unshare folder: {msg}"))) - def fileJingleRequestCb(self, progress_id, item, dest_path): - G.host.addNote( + def file_jingle_request_cb(self, progress_id, item, dest_path): + G.host.add_note( _("file request"), _("{name} download started at {dest_path}").format( name = item.name, @@ -389,14 +389,14 @@ assert self.remote_entity extra = {'path': path} dest_path = files_utils.get_unique_name(os.path.join(G.host.downloads_dir, name)) - G.host.bridge.fileJingleRequest(str(self.remote_entity), + G.host.bridge.file_jingle_request(str(self.remote_entity), str(dest_path), name, '', '', extra, self.profile, - callback=partial(self.fileJingleRequestCb, + callback=partial(self.file_jingle_request_cb, item=item, dest_path=dest_path), errback=partial(G.host.errback, @@ -405,13 +405,13 @@ @classmethod def shared_path_new(cls, shared_path, name, profile): - for wid in G.host.getVisibleList(cls): + for wid in G.host.get_visible_list(cls): if shared_path not in wid.shared_paths: wid.shared_paths.append(shared_path) @classmethod def shared_path_removed(cls, shared_path, profile): - for wid in G.host.getVisibleList(cls): + for wid in G.host.get_visible_list(cls): if shared_path in wid.shared_paths: wid.shared_paths.remove(shared_path) else: