Mercurial > libervia-desktop-kivy
diff cagou/core/menu.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 | 3693c662fa88 |
children |
line wrap: on
line diff
--- a/cagou/core/menu.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/menu.py Sat Apr 08 13:44:32 2023 +0200 @@ -99,7 +99,7 @@ def __init__(self, **kwargs): super(SideMenu, self).__init__(**kwargs) if self.cancel_cb is None: - self.cancel_cb = self.onMenuCancelled + self.cancel_cb = self.on_menu_cancelled def _set_anim_kw(self, kw, size_hint, size): """Set animation keywords @@ -128,7 +128,7 @@ self._set_anim_kw(kw, self.size_hint_open, self.size_open) Animation(**kw).start(self) - def _removeFromParent(self, anim, menu): + def _remove_from_parent(self, anim, menu): # self.parent can already be None if the widget has been removed by a callback # before the animation started. if self.parent is not None: @@ -139,7 +139,7 @@ kw = {'d': 0.2} self._set_anim_kw(kw, self.size_hint_close, self.size_close) anim = Animation(**kw) - anim.bind(on_complete=self._removeFromParent) + anim.bind(on_complete=self._remove_from_parent) anim.start(self) if self.callback_on_close: self.do_callback() @@ -159,13 +159,13 @@ self.hide() return True - def onMenuCancelled(self, wid, cleaning_cb=None): - self._closeUI(wid) + def on_menu_cancelled(self, wid, cleaning_cb=None): + self._close_ui(wid) if cleaning_cb is not None: cleaning_cb() - def _closeUI(self, wid): - G.host.closeUI() + def _close_ui(self, wid): + G.host.close_ui() def do_callback(self, *args, **kwargs): log.warning("callback not implemented") @@ -182,20 +182,20 @@ super().__init__(**kwargs) G.local_platform.on_extra_menu_init(self) - def addItem(self, label, callback): + def add_item(self, label, callback): self.add_widget( ExtraMenuItem( text=label, - on_press=partial(self.onItemPress, callback=callback), + on_press=partial(self.on_item_press, callback=callback), ), # we want the new item above "About" and last empty Widget index=2) - def onItemPress(self, *args, callback): + def on_item_press(self, *args, callback): self.hide() callback() - def onAbout(self): + def on_about(self): self.hide() about = AboutPopup() about.title = ABOUT_TITLE @@ -228,16 +228,16 @@ super(TransferMenu, self).__init__(**kwargs) if self.profiles is None: self.profiles = iter(G.host.profiles) - for plug_info in G.host.getPluggedWidgets(type_=C.PLUG_TYPE_TRANSFER): + for plug_info in G.host.get_plugged_widgets(type_=C.PLUG_TYPE_TRANSFER): item = TransferItem( plug_info = plug_info ) self.items_layout.add_widget(item) def on_kv_post(self, __): - self.updateTransferInfo() + self.update_transfer_info() - def getTransferInfo(self): + def get_transfer_info(self): if self.upload_btn.state == "down": # upload if self.encrypted: @@ -270,13 +270,13 @@ "server if direct connection is not possible)." ) - def updateTransferInfo(self): - self.transfer_info.text = self.getTransferInfo() + def update_transfer_info(self): + self.transfer_info.text = self.get_transfer_info() - def _onTransferCb(self, file_path, cleaning_cb=None, external=False, wid_cont=None): + def _on_transfer_cb(self, file_path, cleaning_cb=None, external=False, wid_cont=None): if not external: wid = wid_cont[0] - self._closeUI(wid) + self._close_ui(wid) self.callback( file_path, transfer_type = (C.TRANSFER_UPLOAD @@ -289,11 +289,11 @@ wid_cont = [] wid_cont.append(plug_info['factory']( plug_info, - partial(self._onTransferCb, external=external, wid_cont=wid_cont), + partial(self._on_transfer_cb, external=external, wid_cont=wid_cont), self.cancel_cb, self.profiles)) if not external: - G.host.showExtraUI(wid_cont[0]) + G.host.show_extra_ui(wid_cont[0]) def do_callback(self, plug_info): self.parent.remove_widget(self) @@ -303,7 +303,7 @@ G.local_platform.check_plugin_permissions( plug_info, callback=partial(self._check_plugin_permissions_cb, plug_info), - errback=lambda: G.host.addNote( + errback=lambda: G.host.add_note( _("permission refused"), _("this transfer menu can't be used if you refuse the requested " "permission"),