Mercurial > libervia-desktop-kivy
changeset 491:203755bbe0fe
massive refactoring from camelCase -> snake_case. See backend commit log for more details
line wrap: on
line diff
--- a/cagou/core/behaviors.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/behaviors.py Sat Apr 08 13:44:32 2023 +0200 @@ -34,7 +34,7 @@ main_wid attribute must be set to the class inheriting from TouchMenuBehavior do_item_action is the method called on simple click - getMenuChoices must return a list of menus for long press + get_menu_choices must return a list of menus for long press menus there are dict as expected by ModernMenu (translated text, index and callback) """ @@ -63,7 +63,7 @@ self.main_wid.open_menu(self, touch) del touch.ud['menu_timeout'] - def getMenuChoices(self): + def get_menu_choices(self): """return choice adapted to selected item @return (list[dict]): choices ad expected by ModernMenu @@ -108,7 +108,7 @@ return self.clear_menu() pos = self.to_widget(*touch.pos) - choices = item.getMenuChoices() + choices = item.get_menu_choices() if not choices: return self.menu = TouchMenu(choices=choices,
--- a/cagou/core/cagou_main.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/cagou_main.py Sat Apr 08 13:44:32 2023 +0200 @@ -42,8 +42,8 @@ import kivy kivy.require('1.11.0') import kivy.support -main_config = config.parseMainConf(log_filenames=True) -bridge_name = config.getConfig(main_config, '', 'bridge', 'dbus') +main_config = config.parse_main_conf(log_filenames=True) +bridge_name = config.config_get(main_config, '', 'bridge', 'dbus') # FIXME: event loop is choosen according to bridge_name, a better way should be used if 'dbus' in bridge_name: kivy.support.install_gobject_iteration() @@ -107,7 +107,7 @@ callback, args, kwargs = self.notifs.pop(0) callback(*args, **kwargs) - def addNotif(self, callback, *args, **kwargs): + def add_notif(self, callback, *args, **kwargs): self.notifs.append((callback, args, kwargs)) @@ -159,7 +159,7 @@ def on_select(self, action_kwargs): app = App.get_running_app() - app.host.doAction(**action_kwargs) + app.host.do_action(**action_kwargs) class RootHeadWidget(BoxLayout): @@ -175,15 +175,15 @@ self.notes_event = None self.notes_drop = NotesDrop(self.notes) - def addNotif(self, callback, *args, **kwargs): + def add_notif(self, callback, *args, **kwargs): """add a notification with a callback attached when notification is pressed, callback is called @param *args, **kwargs: arguments of callback """ - self.notifs_icon.addNotif(callback, *args, **kwargs) + self.notifs_icon.add_notif(callback, *args, **kwargs) - def addNote(self, title, message, level, symbol, action): + def add_note(self, title, message, level, symbol, action): kwargs = { 'title': title, 'message': message, @@ -196,17 +196,17 @@ note = Note(**kwargs) self.notes.append(note) if self.notes_event is None: - self.notes_event = Clock.schedule_interval(self._displayNextNote, 5) - self._displayNextNote() + self.notes_event = Clock.schedule_interval(self._display_next_note, 5) + self._display_next_note() - def addNotifUI(self, ui): - self.notifs_icon.addNotif(ui.show, force=True) + def add_notif_ui(self, ui): + self.notifs_icon.add_notif(ui.show, force=True) - def addNotifWidget(self, widget): + def add_notif_widget(self, widget): app = App.get_running_app() - self.notifs_icon.addNotif(app.host.showExtraUI, widget=widget) + self.notifs_icon.add_notif(app.host.show_extra_ui, widget=widget) - def _displayNextNote(self, __=None): + def _display_next_note(self, __=None): screen = Screen() try: idx = self.notes.index(self.notes_last) + 1 @@ -248,7 +248,7 @@ self._manager.add_widget(extra_screen) self.root_body.add_widget(self._manager) - def changeWidget(self, widget, screen_name="main"): + def change_widget(self, widget, screen_name="main"): """change main widget""" if self._manager.transition.is_active: # FIXME: workaround for what seems a Kivy bug @@ -271,18 +271,18 @@ self._manager.transition = RiseInTransition() self._manager.current = screen - def newAction(self, handler, action_data, id_, security_limit, profile): + def new_action(self, handler, action_data, id_, security_limit, profile): """Add a notification for an action""" - self.head_widget.addNotif(handler, action_data, id_, security_limit, profile) + self.head_widget.add_notif(handler, action_data, id_, security_limit, profile) - def addNote(self, title, message, level, symbol, action): - self.head_widget.addNote(title, message, level, symbol, action) + def add_note(self, title, message, level, symbol, action): + self.head_widget.add_note(title, message, level, symbol, action) - def addNotifUI(self, ui): - self.head_widget.addNotifUI(ui) + def add_notif_ui(self, ui): + self.head_widget.add_notif_ui(ui) - def addNotifWidget(self, widget): - self.head_widget.addNotifWidget(widget) + def add_notif_widget(self, widget): + self.head_widget.add_notif_widget(widget) class CagouApp(App): @@ -311,9 +311,9 @@ local_platform.on_app_build(wid) return wid - def showProfileManager(self): + def show_profile_manager(self): self._profile_manager = ProfileManager() - self.root.changeWidget(self._profile_manager) + self.root.change_widget(self._profile_manager) def expand(self, path, *args, **kwargs): """expand path and replace known values @@ -326,9 +326,9 @@ """ return os.path.expanduser(path).format(*args, media=self.host.media_dir, **kwargs) - def initFrontendState(self): + def init_frontend_state(self): """Init state to handle paused/stopped/running on mobile OSes""" - local_platform.on_initFrontendState() + local_platform.on_init_frontend_state() def on_pause(self): return local_platform.on_pause() @@ -339,7 +339,7 @@ def on_stop(self): return local_platform.on_stop() - def showHeadWidget(self, show=None, animation=True): + def show_head_widget(self, show=None, animation=True): """Show/Hide the head widget @param show(bool, None): True to show, False to hide, None to switch @@ -386,7 +386,7 @@ return True elif key == 110 and 'alt' in modifier: # M-n we hide/show notifications - self.showHeadWidget() + self.show_head_widget() return True else: return False @@ -418,16 +418,16 @@ sys.exit(3) else: log.debug(f"Loading {bridge_name} bridge") - super(Cagou, self).__init__(bridge_factory=bridge_module.Bridge, + super(Cagou, self).__init__(bridge_factory=bridge_module.bridge, xmlui=xmlui, check_options=quick_utils.check_options, connect_bridge=False) self._import_kv() self.app = CagouApp() self.app.host = self - self.media_dir = self.app.media_dir = config.getConfig(main_config, '', + self.media_dir = self.app.media_dir = config.config_get(main_config, '', 'media_dir') - self.downloads_dir = self.app.downloads_dir = config.getConfig(main_config, '', + self.downloads_dir = self.app.downloads_dir = config.config_get(main_config, '', 'downloads_dir') if not os.path.exists(self.downloads_dir): try: @@ -449,16 +449,16 @@ # used to keep track of last selected widget in "main" screen when changing # root screen self._selected_widget_main = None - self.backend_version = sat.__version__ # will be replaced by getVersion() + self.backend_version = sat.__version__ # will be replaced by version_get() if C.APP_VERSION.endswith('D'): self.version = "{} {}".format( C.APP_VERSION, - sat_utils.getRepositoryData(cagou) + sat_utils.get_repository_data(cagou) ) else: self.version = C.APP_VERSION - self.tls_validation = not C.bool(config.getConfig(main_config, + self.tls_validation = not C.bool(config.config_get(main_config, C.CONFIG_SECTION, 'no_certificate_validation', C.BOOL_FALSE)) @@ -484,7 +484,7 @@ @QuickApp.sync.setter def sync(self, state): QuickApp.sync.fset(self, state) - # widget are resynchronised in onVisible event, + # widget are resynchronised in on_visible event, # so we must call resync for widgets which are already visible if state: for w in self.visible_widgets: @@ -496,14 +496,14 @@ resync() self.contact_lists.fill() - def getConfig(self, section, name, default=None): - return config.getConfig(main_config, section, name, default) + def config_get(self, section, name, default=None): + return config.config_get(main_config, section, name, default) - def onBridgeConnected(self): - super(Cagou, self).onBridgeConnected() - self.registerSignal("otrState", iface="plugin") + def on_bridge_connected(self): + super(Cagou, self).on_bridge_connected() + self.register_signal("otr_state", iface="plugin") - def _bridgeEb(self, failure): + def _bridge_eb(self, failure): if bridge_name == "pb" and sys.platform == "android": try: self.retried += 1 @@ -513,12 +513,12 @@ and self.retried < 100)): if self.retried % 20 == 0: log.debug("backend not ready, retrying ({})".format(self.retried)) - Clock.schedule_once(lambda __: self.connectBridge(), 0.05) + Clock.schedule_once(lambda __: self.connect_bridge(), 0.05) return - super(Cagou, self)._bridgeEb(failure) + super(Cagou, self)._bridge_eb(failure) def run(self): - self.connectBridge() + self.connect_bridge() self.app.bind(on_stop=self.onStop) self.app.run() @@ -530,42 +530,42 @@ else: sat_instance.stopService() - def _getVersionCb(self, version): + def _get_version_cb(self, version): self.backend_version = version - def onBackendReady(self): - super().onBackendReady() - self.app.showProfileManager() - self.bridge.getVersion(callback=self._getVersionCb) - self.app.initFrontendState() - if local_platform.do_postInit(): - self.postInit() + def on_backend_ready(self): + super().on_backend_ready() + self.app.show_profile_manager() + self.bridge.version_get(callback=self._get_version_cb) + self.app.init_frontend_state() + if local_platform.do_post_init(): + self.post_init() - def postInit(self, __=None): + def post_init(self, __=None): # FIXME: resize doesn't work with SDL2 on android, so we use below_target for now self.app.root_window.softinput_mode = "below_target" profile_manager = self.app._profile_manager del self.app._profile_manager - super(Cagou, self).postInit(profile_manager) + super(Cagou, self).post_init(profile_manager) - def profilePlugged(self, profile): - super().profilePlugged(profile) + def profile_plugged(self, profile): + super().profile_plugged(profile) # FIXME: this won't work with multiple profiles self.app.connected = self.profiles[profile].connected - def _bookmarksListCb(self, bookmarks_dict, profile): + def _bookmarks_list_cb(self, bookmarks_dict, profile): bookmarks = set() for data in bookmarks_dict.values(): bookmarks.update({jid.JID(k) for k in data.keys()}) self.profiles[profile]._bookmarks = sorted(bookmarks) - def profileConnected(self, profile): - self.bridge.bookmarksList( + def profile_connected(self, profile): + self.bridge.bookmarks_list( "muc", "all", profile, - callback=partial(self._bookmarksListCb, profile=profile), + callback=partial(self._bookmarks_list_cb, profile=profile), errback=partial(self.errback, title=_("Bookmark error"))) - def _defaultFactoryMain(self, plugin_info, target, profiles): + def _default_factory_main(self, plugin_info, target, profiles): """default factory used to create main widgets instances used when PLUGIN_INFO["factory"] is not set @@ -574,12 +574,12 @@ @param profiles(iterable): list of profiles """ main_cls = plugin_info['main'] - return self.widgets.getOrCreateWidget(main_cls, + return self.widgets.get_or_create_widget(main_cls, target, on_new_widget=None, profiles=iter(self.profiles)) - def _defaultFactoryTransfer(self, plugin_info, callback, cancel_cb, profiles): + def _default_factory_transfer(self, plugin_info, callback, cancel_cb, profiles): """default factory used to create transfer widgets instances @param plugin_info(dict): plugin datas @@ -637,10 +637,10 @@ # and select the variable to use according to type if plugin_type == C.PLUG_TYPE_WID: imported_names = imported_names_main - default_factory = self._defaultFactoryMain + default_factory = self._default_factory_main elif plugin_type == C.PLUG_TYPE_TRANSFER: imported_names = imported_names_transfer - default_factory = self._defaultFactoryTransfer + default_factory = self._default_factory_transfer else: log.error("unknown plugin type {type_} for plugin {file_}, skipping" .format( @@ -648,7 +648,7 @@ file_ = plug )) continue - plugins_set = self._getPluginsSet(plugin_type) + plugins_set = self._get_plugins_set(plugin_type) mod = import_module(plugin_path) try: @@ -701,7 +701,7 @@ plugin_info['main'] = main_cls # factory is used to create the instance - # if not found, we use a defaut one with getOrCreateWidget + # if not found, we use a defaut one with get_or_create_widget if 'factory' not in plugin_info: plugin_info['factory'] = default_factory @@ -731,7 +731,7 @@ # we have no selector widget, we use the first widget as default self.default_wid = self._plg_wids[0] - def _getPluginsSet(self, type_): + def _get_plugins_set(self, type_): if type_ == C.PLUG_TYPE_WID: return self._plg_wids elif type_ == C.PLUG_TYPE_TRANSFER: @@ -739,7 +739,7 @@ else: raise KeyError("{} plugin type is unknown".format(type_)) - def getPluggedWidgets(self, type_=C.PLUG_TYPE_WID, except_cls=None): + def get_plugged_widgets(self, type_=C.PLUG_TYPE_WID, except_cls=None): """get available widgets plugin infos @param type_(unicode): type of widgets to get @@ -748,13 +748,13 @@ widgets from this class will be excluded @return (iter[dict]): available widgets plugin infos """ - plugins_set = self._getPluginsSet(type_) + plugins_set = self._get_plugins_set(type_) for plugin_data in plugins_set: if plugin_data['main'] == except_cls: continue yield plugin_data - def getPluginInfo(self, type_=C.PLUG_TYPE_WID, **kwargs): + def get_plugin_info(self, type_=C.PLUG_TYPE_WID, **kwargs): """get first plugin info corresponding to filters @param type_(unicode): type of widgets to get @@ -763,7 +763,7 @@ exist and be of the same value in requested plugin info @return (dict, None): found plugin info or None """ - plugins_set = self._getPluginsSet(type_) + plugins_set = self._get_plugins_set(type_) for plugin_info in plugins_set: for k, w in kwargs.items(): try: @@ -775,12 +775,12 @@ ## widgets handling - def newWidget(self, widget): + def new_widget(self, widget): log.debug("new widget created: {}".format(widget)) if isinstance(widget, quick_chat.QuickChat) and widget.type == C.CHAT_GROUP: - self.addNote("", _("room {} has been joined").format(widget.target)) + self.add_note("", _("room {} has been joined").format(widget.target)) - def switchWidget(self, old, new=None): + def switch_widget(self, old, new=None): """Replace old widget by new one @param old(CagouWidget, None): CagouWidget instance or a child @@ -790,7 +790,7 @@ @return (CagouWidget): new widget """ if old is None: - old = self.getWidgetToSwitch() + old = self.get_widget_to_switch() if new is None: factory = self.default_wid['factory'] try: @@ -811,15 +811,15 @@ raise exceptions.InternalError("no CagouWidget found when " "trying to switch widget") - # selected_widget can be modified in changeWidget, so we need to set it before + # selected_widget can be modified in change_widget, so we need to set it before self.selected_widget = new if to_change == new: - log.debug("switchWidget called with old==new, nothing to do") + log.debug("switch_widget called with old==new, nothing to do") return new - to_change.whwrapper.changeWidget(new) + to_change.whwrapper.change_widget(new) return new - def _addVisibleWidget(self, widget): + def _add_visible_widget(self, widget): """declare a widget visible for internal use only! @@ -827,10 +827,10 @@ assert isinstance(widget, CagouWidget) log.debug(f"Visible widget: {widget}") self._visible_widgets.setdefault(widget.__class__, set()).add(widget) - log.debug(f"visible widgets list: {self.getVisibleList(None)}") - widget.onVisible() + log.debug(f"visible widgets list: {self.get_visible_list(None)}") + widget.on_visible() - def _removeVisibleWidget(self, widget, ignore_missing=False): + def _remove_visible_widget(self, widget, ignore_missing=False): """declare a widget not visible anymore for internal use only! @@ -842,13 +842,13 @@ if not ignore_missing: log.error(f"trying to remove a not visible widget ({widget}): {e}") return - log.debug(f"visible widgets list: {self.getVisibleList(None)}") + log.debug(f"visible widgets list: {self.get_visible_list(None)}") if isinstance(widget, CagouWidget): - widget.onNotVisible() + widget.on_not_visible() if isinstance(widget, quick_widgets.QuickWidget): - self.widgets.deleteWidget(widget) + self.widgets.delete_widget(widget) - def getVisibleList(self, cls): + def get_visible_list(self, cls): """get list of visible widgets for a given class @param cls(type): type of widgets to get @@ -866,7 +866,7 @@ except KeyError: return set() - def deleteUnusedWidgetInstances(self, widget): + def delete_unused_widget_instances(self, widget): """Delete instance of this widget which are not attached to a WHWrapper @param widget(quick_widgets.QuickWidget): reference widget @@ -874,14 +874,14 @@ """ to_delete = [] if isinstance(widget, quick_widgets.QuickWidget): - for w in self.widgets.getWidgetInstances(widget): + for w in self.widgets.get_widget_instances(widget): if w.whwrapper is None and w != widget: to_delete.append(w) for w in to_delete: log.debug("cleaning widget: {wid}".format(wid=w)) - self.widgets.deleteWidget(w) + self.widgets.delete_widget(w) - def getOrClone(self, widget, **kwargs): + def get_or_clone(self, widget, **kwargs): """Get a QuickWidget if it is not in a WHWrapper, else clone it if an other instance of this widget exist without being in a WHWrapper @@ -890,26 +890,26 @@ if widget.whwrapper is None: if widget.parent is not None: widget.parent.remove_widget(widget) - self.deleteUnusedWidgetInstances(widget) + self.delete_unused_widget_instances(widget) return widget - for w in self.widgets.getWidgetInstances(widget): + for w in self.widgets.get_widget_instances(widget): if w.whwrapper is None: if w.parent is not None: w.parent.remove_widget(w) - self.deleteUnusedWidgetInstances(w) + self.delete_unused_widget_instances(w) return w targets = list(widget.targets) - w = self.widgets.getOrCreateWidget(widget.__class__, + w = self.widgets.get_or_create_widget(widget.__class__, targets[0], on_new_widget=None, on_existing_widget=C.WIDGET_RECREATE, profiles=widget.profiles, **kwargs) for t in targets[1:]: - w.addTarget(t) + w.add_target(t) return w - def getWidgetToSwitch(self): + def get_widget_to_switch(self): """Choose best candidate when we need to switch widget and old is not specified @return (CagouWidget): widget to switch @@ -931,7 +931,7 @@ # no default widget found, we return the first widget return next(iter(self.visible_widgets)) - def doAction(self, action, target, profiles): + def do_action(self, action, target, profiles): """Launch an action handler by a plugin @param action(unicode): action to do, can be: @@ -943,14 +943,14 @@ try: # FIXME: Q&D way to get chat plugin, should be replaced by a clean method # in host - plg_infos = [p for p in self.getPluggedWidgets() + plg_infos = [p for p in self.get_plugged_widgets() if action in p['import_name']][0] except IndexError: log.warning("No plugin widget found to do {action}".format(action=action)) else: try: # does the widget already exist? - wid = next(self.widgets.getWidgets( + wid = next(self.widgets.get_widgets( plg_infos['main'], target=target, profiles=profiles)) @@ -959,93 +959,93 @@ factory = plg_infos['factory'] wid = factory(plg_infos, target=target, profiles=profiles) - return self.switchWidget(None, wid) + return self.switch_widget(None, wid) ## bridge handlers ## - def otrStateHandler(self, state, dest_jid, profile): + def otr_state_handler(self, state, dest_jid, profile): """OTR state has changed for on destinee""" # XXX: this method could be in QuickApp but it's here as # it's only used by Cagou so far dest_jid = jid.JID(dest_jid) bare_jid = dest_jid.bare - for widget in self.widgets.getWidgets(quick_chat.QuickChat, profiles=(profile,)): + for widget in self.widgets.get_widgets(quick_chat.QuickChat, profiles=(profile,)): if widget.type == C.CHAT_ONE2ONE and widget.target == bare_jid: - widget.onOTRState(state, dest_jid, profile) + widget.on_otr_state(state, dest_jid, profile) - def _debugHandler(self, action, parameters, profile): + def _debug_handler(self, action, parameters, profile): if action == "visible_widgets_dump": from pprint import pformat log.info("Visible widgets dump:\n{data}".format( data=pformat(self._visible_widgets))) else: - return super(Cagou, self)._debugHandler(action, parameters, profile) + return super(Cagou, self)._debug_handler(action, parameters, profile) - def connectedHandler(self, jid_s, profile): + def connected_handler(self, jid_s, profile): # FIXME: this won't work with multiple profiles - super().connectedHandler(jid_s, profile) + super().connected_handler(jid_s, profile) self.app.connected = True - def disconnectedHandler(self, profile): + def disconnected_handler(self, profile): # FIXME: this won't work with multiple profiles - super().disconnectedHandler(profile) + super().disconnected_handler(profile) self.app.connected = False ## misc ## def plugging_profiles(self): self.widgets_handler = widgets_handler.WidgetsHandler() - self.app.root.changeWidget(self.widgets_handler) + self.app.root.change_widget(self.widgets_handler) - def setPresenceStatus(self, show='', status=None, profile=C.PROF_KEY_NONE): + def set_presence_status(self, show='', status=None, profile=C.PROF_KEY_NONE): log.info("Profile presence status set to {show}/{status}".format(show=show, status=status)) def errback(self, failure_, title=_('error'), message=_('error while processing: {msg}')): - self.addNote(title, message.format(msg=failure_), level=C.XMLUI_DATA_LVL_WARNING) + self.add_note(title, message.format(msg=failure_), level=C.XMLUI_DATA_LVL_WARNING) - def addNote(self, title, message, level=C.XMLUI_DATA_LVL_INFO, symbol=None, + def add_note(self, title, message, level=C.XMLUI_DATA_LVL_INFO, symbol=None, action=None): """add a note (message which disappear) to root widget's header""" - self.app.root.addNote(title, message, level, symbol, action) + self.app.root.add_note(title, message, level, symbol, action) - def addNotifUI(self, ui): + def add_notif_ui(self, ui): """add a notification with a XMLUI attached @param ui(xmlui.XMLUIPanel): XMLUI instance to show when notification is selected """ - self.app.root.addNotifUI(ui) + self.app.root.add_notif_ui(ui) - def addNotifWidget(self, widget): + def add_notif_widget(self, widget): """add a notification with a Kivy widget attached @param widget(kivy.uix.Widget): widget to attach to notification """ - self.app.root.addNotifWidget(widget) + self.app.root.add_notif_widget(widget) - def showUI(self, ui): + def show_ui(self, ui): """show a XMLUI""" - self.app.root.changeWidget(ui, "xmlui") + self.app.root.change_widget(ui, "xmlui") self.app.root.show("xmlui") self._selected_widget_main = self.selected_widget self.selected_widget = ui - def showExtraUI(self, widget): + def show_extra_ui(self, widget): """show any extra widget""" - self.app.root.changeWidget(widget, "extra") + self.app.root.change_widget(widget, "extra") self.app.root.show("extra") self._selected_widget_main = self.selected_widget self.selected_widget = widget - def closeUI(self): + def close_ui(self): self.app.root.show() self.selected_widget = self._selected_widget_main self._selected_widget_main = None screen = self.app.root._manager.get_screen("extra") screen.clear_widgets() - def getDefaultAvatar(self, entity=None): + def get_default_avatar(self, entity=None): return self.app.default_avatar def _dialog_cb(self, cb, *args, **kwargs): @@ -1054,13 +1054,13 @@ close dialog then call the callback with given arguments """ def callback(): - self.closeUI() + self.close_ui() cb(*args, **kwargs) return callback - def showDialog(self, message, title, type="info", answer_cb=None, answer_data=None): + def show_dialog(self, message, title, type="info", answer_cb=None, answer_data=None): if type in ('info', 'warning', 'error'): - self.addNote(title, message, type) + self.add_note(title, message, type) elif type == "yes/no": wid = dialog.ConfirmDialog(title=title, message=message, yes_cb=self._dialog_cb(answer_cb, @@ -1070,19 +1070,19 @@ False, answer_data) ) - self.addNotifWidget(wid) + self.add_notif_widget(wid) else: log.warning(_("unknown dialog type: {dialog_type}").format(dialog_type=type)) def share(self, media_type, data): share_wid = ShareWidget(media_type=media_type, data=data) try: - self.showExtraUI(share_wid) + self.show_extra_ui(share_wid) except Exception as e: log.error(e) - self.closeUI() + self.close_ui() - def downloadURL( + def download_url( self, url, callback, errback=None, options=None, dest=C.FILE_DEST_DOWNLOAD, profile=C.PROF_KEY_NONE): """Download an URL (decrypt it if necessary) @@ -1094,7 +1094,7 @@ @param dest(str): where the file should be downloaded: - C.FILE_DEST_DOWNLOAD: in platform download directory - C.FILE_DEST_CACHE: in SàT cache - @param options(dict, None): options to pass to bridge.fileDownloadComplete + @param options(dict, None): options to pass to bridge.file_download_complete """ if not isinstance(url, urlparse.ParseResult): url = urlparse.urlparse(url) @@ -1111,7 +1111,7 @@ dest_path = '' else: raise exceptions.InternalError(f"Invalid dest_path: {dest_path!r}") - self.bridge.fileDownloadComplete( + self.bridge.file_download_complete( data_format.serialise({"uri": url.geturl()}), str(dest_path), '' if not options else data_format.serialise(options), @@ -1146,13 +1146,13 @@ msg = e)) notification = None - def getParentWHWrapper(self, wid): + def get_parent_wh_wrapper(self, wid): """Retrieve parent WHWrapper instance managing a widget @param wid(Widget): widget to check @return (WHWrapper, None): found instance if any, else None """ - wh = self.getAncestorWidget(wid, widgets_handler.WHWrapper) + wh = self.get_ancestor_widget(wid, widgets_handler.WHWrapper) if wh is None: # we may have a screen try: @@ -1160,10 +1160,10 @@ except (exceptions.InternalError, exceptions.NotFound): return None else: - wh = self.getAncestorWidget(sm, widgets_handler.WHWrapper) + wh = self.get_ancestor_widget(sm, widgets_handler.WHWrapper) return wh - def getAncestorWidget(self, wid, cls): + def get_ancestor_widget(self, wid, cls): """Retrieve an ancestor of given class @param wid(Widget): current widget
--- a/cagou/core/cagou_widget.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/cagou_widget.py Sat Apr 08 13:44:32 2023 +0200 @@ -45,7 +45,7 @@ def __init__(self, **kwargs): super().__init__(**kwargs) - self.bind(on_release=lambda btn: self.cagou_widget.switchWidget( + self.bind(on_release=lambda btn: self.cagou_widget.switch_widget( self.plugin_info)) @@ -62,7 +62,7 @@ def __init__(self, cagou_widget): super(HeaderWidgetSelector, self).__init__() plg_info_cls = cagou_widget.plugin_info_class or cagou_widget.__class__ - for plugin_info in G.host.getPluggedWidgets(except_cls=plg_info_cls): + for plugin_info in G.host.get_plugged_widgets(except_cls=plg_info_cls): choice = HeaderChoiceWidget( cagou_widget=cagou_widget, plugin_info=plugin_info, @@ -102,7 +102,7 @@ def __init__(self, **kwargs): plg_info_cls = self.plugin_info_class or self.__class__ - for p in G.host.getPluggedWidgets(): + for p in G.host.get_plugged_widgets(): if p['main'] == plg_info_cls: self.plugin_info = p break @@ -115,8 +115,8 @@ multiline=False, ) self.header_input.bind( - on_text_validate=lambda *args: self.onHeaderInput(), - text=self.onHeaderInputComplete, + on_text_validate=lambda *args: self.on_header_wid_input(), + text=self.on_header_wid_input_complete, ) self.header_box.add_widget(self.header_input) @@ -139,7 +139,7 @@ raise exceptions.InternalError( "screen_manager property can't be used if global_screen_manager is not " "set") - screen = self.getAncestor(Screen) + screen = self.get_ancestor(Screen) if screen is None: raise exceptions.NotFound("Can't find parent Screen") if screen.manager is None: @@ -149,36 +149,36 @@ @property def whwrapper(self): """Retrieve parent widget handler""" - return G.host.getParentWHWrapper(self) + return G.host.get_parent_wh_wrapper(self) - def screenManagerInit(self, screen_manager): + def screen_manager_init(self, screen_manager): """Override this method to do init when ScreenManager is instantiated This is only called once even if collection_carousel is used. """ if not self.global_screen_manager: - raise exceptions.InternalError("screenManagerInit should not be called") + raise exceptions.InternalError("screen_manager_init should not be called") - def getAncestor(self, cls): - """Helper method to use host.getAncestorWidget with self""" - return G.host.getAncestorWidget(self, cls) + def get_ancestor(self, cls): + """Helper method to use host.get_ancestor_widget with self""" + return G.host.get_ancestor_widget(self, cls) - def switchWidget(self, plugin_info): + def switch_widget(self, plugin_info): self.selector.dismiss() factory = plugin_info["factory"] new_widget = factory(plugin_info, None, iter(G.host.profiles)) - G.host.switchWidget(self, new_widget) + G.host.switch_widget(self, new_widget) def key_input(self, window, key, scancode, codepoint, modifier): if key == 27: # we go back to root screen - G.host.switchWidget(self) + G.host.switch_widget(self) return True - def onHeaderInput(self): + def on_header_wid_input(self): log.info("header input text entered") - def onHeaderInputComplete(self, wid, text): + def on_header_wid_input_complete(self, wid, text): return def on_touch_down(self, touch): @@ -186,14 +186,14 @@ G.host.selected_widget = self return super(CagouWidget, self).on_touch_down(touch) - def headerInputAddExtra(self, widget): + def header_input_add_extra(self, widget): """add a widget on the right of header input""" self.header_box.add_widget(widget) - def onVisible(self): + def on_visible(self): pass # log.debug(u"{self} is visible".format(self=self)) - def onNotVisible(self): + def on_not_visible(self): pass # log.debug(u"{self} is not visible anymore".format(self=self))
--- a/cagou/core/common.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/common.py Sat Apr 08 13:44:32 2023 +0200 @@ -53,11 +53,11 @@ def on_kv_post(self, __): if not self.source: - self.source = G.host.getDefaultAvatar() + self.source = G.host.get_default_avatar() def on_data(self, __, data): if data is None: - self.source = G.host.getDefaultAvatar() + self.source = G.host.get_default_avatar() else: self.source = data['path'] @@ -84,9 +84,9 @@ def on_kv_post(self, __): if ((self.profile and self.jid and self.data is not None and ('avatar' not in self.data or 'nicknames' not in self.data))): - G.host.bridge.identityGet( + G.host.bridge.identity_get( self.jid, ['avatar', 'nicknames'], True, self.profile, - callback=self._identityGetCb, + callback=self._identity_get_cb, errback=partial( G.host.errback, message=_("Can't retrieve identity for {jid}: {{msg}}").format( @@ -94,7 +94,7 @@ ) ) - def _identityGetCb(self, identity_raw): + def _identity_get_cb(self, identity_raw): identity_data = data_format.deserialise(identity_raw) self.data.update(identity_data) @@ -131,25 +131,25 @@ def on_avatar(self, wid, jid_): if self.jid and self.profile: - self.getImage() + self.get_image() def on_jid(self, wid, jid_): if self.profile and self.avatar: - self.getImage() + self.get_image() def on_profile(self, wid, profile): if self.jid and self.avatar: - self.getImage() + self.get_image() - def getImage(self): + def get_image(self): host = G.host - if host.contact_lists[self.profile].isRoom(self.jid.bare): + if host.contact_lists[self.profile].is_room(self.jid.bare): self.avatar.opacity = 0 self.avatar.source = "" else: self.avatar.source = ( - host.getAvatar(self.jid, profile=self.profile) - or host.getDefaultAvatar(self.jid) + host.get_avatar(self.jid, profile=self.profile) + or host.get_default_avatar(self.jid) ) @@ -315,36 +315,36 @@ def on_parent(self, wid, parent): if parent is None: log.debug("removing listeners") - G.host.removeListener("contactsFilled", self.onContactsFilled) - G.host.removeListener("notification", self.onNotification) - G.host.removeListener("notificationsClear", self.onNotificationsClear) + G.host.removeListener("contactsFilled", self.on_contacts_filled) + G.host.removeListener("notification", self.on_notification) + G.host.removeListener("notificationsClear", self.on_notifications_clear) G.host.removeListener( - "widgetNew", self.onWidgetNew, ignore_missing=True) + "widgetNew", self.on_widget_new, ignore_missing=True) G.host.removeListener( - "widgetDeleted", self.onWidgetDeleted, ignore_missing=True) + "widgetDeleted", self.on_widget_deleted, ignore_missing=True) else: log.debug("adding listeners") - G.host.addListener("contactsFilled", self.onContactsFilled) - G.host.addListener("notification", self.onNotification) - G.host.addListener("notificationsClear", self.onNotificationsClear) + G.host.addListener("contactsFilled", self.on_contacts_filled) + G.host.addListener("notification", self.on_notification) + G.host.addListener("notificationsClear", self.on_notifications_clear) - def onContactsFilled(self, profile): - log.debug("onContactsFilled event received") + def on_contacts_filled(self, profile): + log.debug("on_contacts_filled event received") self.update() - def onNotification(self, entity, notification_data, profile): + def on_notification(self, entity, notification_data, profile): for item in self.items_map.get(entity.bare, []): - notifs = list(G.host.getNotifs(entity.bare, profile=profile)) + notifs = list(G.host.get_notifs(entity.bare, profile=profile)) item.badge_text = str(len(notifs)) - def onNotificationsClear(self, entity, type_, profile): + def on_notifications_clear(self, entity, type_, profile): for item in self.items_map.get(entity.bare, []): item.badge_text = '' - def onWidgetNew(self, wid): + def on_widget_new(self, wid): if not isinstance(wid, quick_chat.QuickChat): return - item = self.getItemFromWid(wid) + item = self.get_item_from_wid(wid) if item is None: return idx = 0 @@ -354,7 +354,7 @@ idx+=1 self.opened_chats.add_widget(item, index=idx) - def onWidgetDeleted(self, wid): + def on_widget_deleted(self, wid): if not isinstance(wid, quick_chat.QuickChat): return @@ -365,7 +365,7 @@ self.opened_chats.remove_widget(child) break - def _createItem(self, **kwargs): + def _create_item(self, **kwargs): item = self.item_class(**kwargs) jid = kwargs['jid'] self.items_map.setdefault(jid, []).append(item) @@ -377,11 +377,11 @@ for item in self.to_show: if isinstance(item, str): if item == 'roster': - self.addRosterItems() + self.add_roster_items() elif item == 'bookmarks': - self.addBookmarksItems() + self.add_bookmarks_items() elif item == 'opened_chats': - self.addOpenedChatsItems() + self.add_opened_chats_items() else: log.error(f'unknown "to_show" magic string {item!r}') elif isinstance(item, Widget): @@ -389,13 +389,13 @@ elif callable(item): items_kwargs = item() for item_kwargs in items_kwargs: - item = self._createItem(**items_kwargs) + item = self._create_item(**items_kwargs) item.bind(on_press=partial(self.dispatch, 'on_select')) self.layout.add_widget(item) else: log.error(f"unmanaged to_show item type: {item!r}") - def addCategoryLayout(self, label=None): + def add_category_layout(self, label=None): category_layout = JidSelectorCategoryLayout() if label and self.add_separators: @@ -405,16 +405,16 @@ self.items_layouts.append(category_layout) return category_layout - def getItemFromWid(self, wid): + def get_item_from_wid(self, wid): """create JidSelector item from QuickChat widget""" contact_list = G.host.contact_lists[wid.profile] try: - data=contact_list.getItem(wid.target) + data=contact_list.get_item(wid.target) except KeyError: log.warning(f"Can't find item data for {wid.target}") data={} try: - item = self._createItem( + item = self._create_item( jid=wid.target, data=data, profile=wid.profile, @@ -422,42 +422,42 @@ except Exception as e: log.warning(f"Can't add contact {wid.target}: {e}") return - notifs = list(G.host.getNotifs(wid.target, profile=wid.profile)) + notifs = list(G.host.get_notifs(wid.target, profile=wid.profile)) if notifs: item.badge_text = str(len(notifs)) item.bind(on_press=partial(self.dispatch, 'on_select')) return item - def addOpenedChatsItems(self): - G.host.addListener("widgetNew", self.onWidgetNew) - G.host.addListener("widgetDeleted", self.onWidgetDeleted) - self.opened_chats = category_layout = self.addCategoryLayout(_("Opened chats")) - widgets = sorted(G.host.widgets.getWidgets( + def add_opened_chats_items(self): + G.host.addListener("widgetNew", self.on_widget_new) + G.host.addListener("widgetDeleted", self.on_widget_deleted) + self.opened_chats = category_layout = self.add_category_layout(_("Opened chats")) + widgets = sorted(G.host.widgets.get_widgets( quick_chat.QuickChat, profiles = G.host.profiles, with_duplicates=False)) for wid in widgets: - item = self.getItemFromWid(wid) + item = self.get_item_from_wid(wid) if item is None: continue category_layout.add_widget(item) - def addRosterItems(self): - self.roster = category_layout = self.addCategoryLayout(_("Your contacts")) + def add_roster_items(self): + self.roster = category_layout = self.add_category_layout(_("Your contacts")) for profile in G.host.profiles: contact_list = G.host.contact_lists[profile] for entity_jid in sorted(contact_list.roster): - item = self._createItem( + item = self._create_item( jid=entity_jid, - data=contact_list.getItem(entity_jid), + data=contact_list.get_item(entity_jid), profile=profile, ) item.bind(on_press=partial(self.dispatch, 'on_select')) category_layout.add_widget(item) - def addBookmarksItems(self): - self.bookmarks = category_layout = self.addCategoryLayout(_("Your chat rooms")) + def add_bookmarks_items(self): + self.bookmarks = category_layout = self.add_category_layout(_("Your chat rooms")) for profile in G.host.profiles: profile_manager = G.host.profiles[profile] try: @@ -469,10 +469,10 @@ contact_list = G.host.contact_lists[profile] for entity_jid in bookmarks: try: - cache = contact_list.getItem(entity_jid) + cache = contact_list.get_item(entity_jid) except KeyError: cache = {} - item = self._createItem( + item = self._create_item( jid=entity_jid, data=cache, profile=profile,
--- a/cagou/core/common_widgets.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/common_widgets.py Sat Apr 08 13:44:32 2023 +0200 @@ -109,7 +109,7 @@ def profile(self): return self.main_wid.profile - def getSymbol(self): + def get_symbol(self): if self.identities.type == 'desktop': return 'desktop' elif self.identities.type == 'phone': @@ -158,7 +158,7 @@ def on_parent(self, __, parent): # we hide the head widget to have full screen - G.host.app.showHeadWidget(not bool(parent), animation=False) + G.host.app.show_head_widget(not bool(parent), animation=False) def on_sources(self, __, sources): if not sources or not self.carousel: @@ -178,5 +178,5 @@ def key_input(self, window, key, scancode, codepoint, modifier): if key == 27: - G.host.closeUI() + G.host.close_ui() return True
--- a/cagou/core/config.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/config.py Sat Apr 08 13:44:32 2023 +0200 @@ -20,8 +20,8 @@ """This module keep an open instance of sat configuration""" from sat.tools import config -sat_conf = config.parseMainConf() +sat_conf = config.parse_main_conf() -def getConfig(section, name, default): - return config.getConfig(sat_conf, section, name, default) +def config_get(section, name, default): + return config.config_get(sat_conf, section, name, default)
--- a/cagou/core/image.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/image.py Sat Apr 08 13:44:32 2023 +0200 @@ -36,19 +36,19 @@ self.register_event_type('on_error') super().__init__(**kwargs) - def _imageConvertCb(self, path): + def _image_convert_cb(self, path): self.source = path def texture_update(self, *largs): if self.source: if mimetypes.guess_type(self.source, strict=False)[0] == 'image/svg+xml': log.debug(f"Converting SVG image at {self.source} to PNG") - G.host.bridge.imageConvert( + G.host.bridge.image_convert( self.source, "", data_format.serialise(self.SVG_CONVERT_EXTRA), "", - callback=self._imageConvertCb, + callback=self._image_convert_cb, errback=partial( G.host.errback, message=f"Can't load image at {self.source}: {{msg}}"
--- a/cagou/core/kivy_hack.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/kivy_hack.py Sat Apr 08 13:44:32 2023 +0200 @@ -29,10 +29,10 @@ sys.argv = sys.argv[:1] from .constants import Const as C from sat.core import log_config - log_config.satConfigure(C.LOG_BACKEND_STANDARD, C) + log_config.sat_configure(C.LOG_BACKEND_STANDARD, C) from . import config - kivy_level = config.getConfig(C.CONFIG_SECTION, CONF_KIVY_LEVEL, 'follow').upper() + kivy_level = config.config_get(C.CONFIG_SECTION, CONF_KIVY_LEVEL, 'follow').upper() # kivy handles its own loggers, we don't want that! import logging
--- 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"),
--- a/cagou/core/platform_/android.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/platform_/android.py Sat Apr 08 13:44:32 2023 +0200 @@ -93,9 +93,9 @@ self.cache.append((self.on_new_intent, mActivity.getIntent())) self.last_selected_wid = None self.restore_selected_wid = True - host.addListener('profilePlugged', self.onProfilePlugged) - host.addListener('selected', self.onSelectedWidget) - local_dir = Path(host.getConfig('', 'local_dir')).resolve() + host.addListener('profile_plugged', self.on_profile_plugged) + host.addListener('selected', self.on_selected_widget) + local_dir = Path(host.config_get('', 'local_dir')).resolve() self.tmp_dir = local_dir / 'tmp' # we assert to avoid disaster if `/ 'tmp'` is removed by mistake on the line # above @@ -105,7 +105,7 @@ shutil.rmtree(self.tmp_dir) self.tmp_dir.mkdir(0o700, parents=True) - def on_initFrontendState(self): + def on_init_frontend_state(self): # XXX: we use a separated socket instead of bridge because if we # try to call a bridge method in on_pause method, the call data # is not written before the actual pause @@ -114,14 +114,14 @@ s.connect(os.path.join(SOCKET_DIR, SOCKET_FILE)) s.sendall(STATE_RUNNING) - def profileAutoconnectGetCb(self, profile=None): + def profile_autoconnect_get_cb(self, profile=None): if profile is not None: G.host.options.profile = profile - G.host.postInit() + G.host.post_init() - def profileAutoconnectGetEb(self, failure_): + def profile_autoconnect_get_eb(self, failure_): log.error(f"Error while getting profile to autoconnect: {failure_}") - G.host.postInit() + G.host.post_init() def _show_perm_warning(self, permissions): root_wid = G.host.app.root @@ -166,16 +166,16 @@ request_permissions(PERMISSION_MANDATORY, callback=self.permission_cb) return - Clock.schedule_once(lambda *args: G.host.bridge.profileAutoconnectGet( - callback=self.profileAutoconnectGetCb, - errback=self.profileAutoconnectGetEb), + Clock.schedule_once(lambda *args: G.host.bridge.profile_autoconnect_get( + callback=self.profile_autoconnect_get_cb, + errback=self.profile_autoconnect_get_eb), 0) - def do_postInit(self): + def do_post_init(self): request_permissions(PERMISSION_MANDATORY, callback=self.permission_cb) return False - def privateDataGetCb(self, data_s, profile): + def private_data_get_cb(self, data_s, profile): data = data_format.deserialise(data_s, type_check=None) if data is not None and self.restore_selected_wid: log.debug(f"restoring previous widget {data}") @@ -187,38 +187,38 @@ return if target: target = jid.JID(data['target']) - plugin_info = G.host.getPluginInfo(name=name) + plugin_info = G.host.get_plugin_info(name=name) if plugin_info is None: log.warning("Can't restore unknown plugin: {name}") return factory = plugin_info['factory'] - G.host.switchWidget( + G.host.switch_widget( None, factory(plugin_info, target=target, profiles=[profile]) ) - def onProfilePlugged(self, profile): - log.debug("ANDROID profilePlugged") - G.host.bridge.setParam( + def on_profile_plugged(self, profile): + log.debug("ANDROID profile_plugged") + G.host.bridge.param_set( "autoconnect_backend", C.BOOL_TRUE, "Connection", -1, profile, callback=lambda: log.info(f"profile {profile} autoconnection set"), errback=lambda: log.error(f"can't set {profile} autoconnection")) for method, *args in self.cache: method(*args) del self.cache - G.host.removeListener("profilePlugged", self.onProfilePlugged) + G.host.removeListener("profile_plugged", self.on_profile_plugged) # we restore the stored widget if any # user will then go back to where they was when the frontend was closed - G.host.bridge.privateDataGet( + G.host.bridge.private_data_get( "cagou", "selected_widget", profile, - callback=partial(self.privateDataGetCb, profile=profile), + callback=partial(self.private_data_get_cb, profile=profile), errback=partial( G.host.errback, title=_("can't get selected widget"), message=_("error while retrieving selected widget: {msg}")) ) - def onSelectedWidget(self, wid): + def on_selected_widget(self, wid): """Store selected widget in backend, to restore it on next startup""" if self.last_selected_wid == None: self.last_selected_wid = wid @@ -254,7 +254,7 @@ "target": target, } - G.host.bridge.privateDataSet( + G.host.bridge.private_data_set( "cagou", "selected_widget", data_format.serialise(data), profile, errback=partial( G.host.errback, @@ -285,14 +285,14 @@ return True def _disconnect(self, profile): - G.host.bridge.setParam( + G.host.bridge.param_set( "autoconnect_backend", C.BOOL_FALSE, "Connection", -1, profile, callback=lambda: log.info(f"profile {profile} autoconnection unset"), errback=lambda: log.error(f"can't unset {profile} autoconnection")) G.host.profiles.unplug(profile) G.host.bridge.disconnect(profile) - G.host.app.showProfileManager() - G.host.closeUI() + G.host.app.show_profile_manager() + G.host.close_ui() def _on_disconnect(self): current_profile = next(iter(G.host.profiles)) @@ -303,14 +303,14 @@ "any notification until you connect it again, is this really what you " "want?").format(profile=current_profile), yes_cb=partial(self._disconnect, profile=current_profile), - no_cb=G.host.closeUI, + no_cb=G.host.close_ui, ) - G.host.showExtraUI(wid) + G.host.show_extra_ui(wid) def on_extra_menu_init(self, extra_menu): - extra_menu.addItem(_('disconnect'), self._on_disconnect) + extra_menu.add_item(_('disconnect'), self._on_disconnect) - def updateParamsExtra(self, extra): + def update_params_extra(self, extra): # on Android, we handle autoconnection automatically, # user must not modify those parameters extra.update( @@ -323,7 +323,7 @@ } ) - def getColDataFromUri(self, uri, col_name): + def get_col_data_from_uri(self, uri, col_name): cursor = mActivity.getContentResolver().query(uri, None, None, None, None) if cursor is None: return None @@ -336,8 +336,8 @@ finally: cursor.close() - def getFilenameFromUri(self, uri, media_type): - filename = self.getColDataFromUri(uri, DISPLAY_NAME) + def get_filename_from_uri(self, uri, media_type): + filename = self.get_col_data_from_uri(uri, DISPLAY_NAME) if filename is None: uri_p = Path(uri.toString()) filename = uri_p.name or "unnamed" @@ -347,11 +347,11 @@ filename = filename + suffix return filename - def getPathFromUri(self, uri): + def get_path_from_uri(self, uri): # FIXME: using DATA is not recommended (and DATA is deprecated) # we should read directly the file with # ContentResolver#openFileDescriptor(Uri, String) - path = self.getColDataFromUri(uri, DATA) + path = self.get_col_data_from_uri(uri, DATA) return uri.getPath() if path is None else path def on_new_intent(self, intent): @@ -378,7 +378,7 @@ # and now we open the widget linked to the intent current_profile = next(iter(G.host.profiles)) Clock.schedule_once( - lambda *args: G.host.doAction( + lambda *args: G.host.do_action( widget, jid.JID(target), [current_profile]), 0) else: @@ -400,7 +400,7 @@ uri = cast('android.net.Uri', item) if uri.getScheme() == 'content': # Android content, we'll dump it to a temporary file - filename = self.getFilenameFromUri(uri, intent_type) + filename = self.get_filename_from_uri(uri, intent_type) filepath = self.tmp_dir / filename input_stream = mActivity.getContentResolver().openInputStream(uri) buff = bytearray(4096) @@ -415,7 +415,7 @@ data['path'] = path = str(filepath) else: data['uri'] = uri.toString() - path = self.getPathFromUri(uri) + path = self.get_path_from_uri(uri) if path is not None and path not in data: data['path'] = path else:
--- a/cagou/core/platform_/base.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/platform_/base.py Sat Apr 08 13:44:32 2023 +0200 @@ -50,10 +50,10 @@ def on_host_init(self, host): pass - def on_initFrontendState(self): + def on_init_frontend_state(self): pass - def do_postInit(self): + def do_post_init(self): return True def on_pause(self): @@ -79,9 +79,9 @@ subprocess.Popen(sys.argv) def on_extra_menu_init(self, extra_menu): - extra_menu.addItem(_('new window'), self._on_new_window) + extra_menu.add_item(_('new window'), self._on_new_window) - def updateParamsExtra(self, extra): + def update_params_extra(self, extra): pass def check_plugin_permissions(self, plug_info, callback, errback): @@ -116,13 +116,13 @@ if parsed_url.scheme == "aesgcm" and wid is not None: # aesgcm files need to be decrypted first # so we download them before opening - quick_widget = G.host.getAncestorWidget(wid, QuickWidget) + quick_widget = G.host.get_ancestor_widget(wid, QuickWidget) if quick_widget is None: msg = f"Can't find ancestor QuickWidget of {wid}" log.error(msg) G.host.errback(exceptions.InternalError(msg)) return - G.host.downloadURL( + G.host.download_url( parsed_url, self.open_url, G.host.errback, profile=quick_widget.profile ) else:
--- a/cagou/core/profile_manager.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/profile_manager.py Sat Apr 08 13:44:32 2023 +0200 @@ -45,21 +45,21 @@ super(NewProfileScreen, self).__init__(name='new_profile') self.pm = pm - def onCreationFailure(self, failure): + def on_creation_failure(self, failure): msg = [l for l in str(failure).split('\n') if l][-1] self.error_msg = str(msg) - def onCreationSuccess(self, profile): + def on_creation_success(self, profile): self.pm.profiles_screen.reload() - G.host.bridge.profileStartSession( + G.host.bridge.profile_start_session( self.password.text, profile, - callback=lambda __: self._sessionStarted(profile), - errback=self.onCreationFailure) + callback=lambda __: self._session_started(profile), + errback=self.on_creation_failure) - def _sessionStarted(self, profile): + def _session_started(self, profile): jid = self.jid.text.strip() - G.host.bridge.setParam("JabberID", jid, "Connection", -1, profile) - G.host.bridge.setParam("Password", self.password.text, "Connection", -1, profile) + G.host.bridge.param_set("JabberID", jid, "Connection", -1, profile) + G.host.bridge.param_set("Password", self.password.text, "Connection", -1, profile) self.pm.screen_manager.transition.direction = 'right' self.pm.screen_manager.current = 'profiles' @@ -67,10 +67,10 @@ name = self.profile_name.text.strip() # XXX: we use XMPP password for profile password to simplify # if user want to change profile password, he can do it in preferences - G.host.bridge.profileCreate( + G.host.bridge.profile_create( name, self.password.text, '', - callback=lambda: self.onCreationSuccess(name), - errback=self.onCreationFailure) + callback=lambda: self.on_creation_success(name), + errback=self.on_creation_failure) class DeleteProfilesScreen(Screen): @@ -79,12 +79,12 @@ self.pm = pm super(DeleteProfilesScreen, self).__init__(name='delete_profiles') - def doDelete(self): + def do_delete(self): """This method will delete *ALL* selected profiles""" - to_delete = self.pm.getProfiles() + to_delete = self.pm.get_profiles() deleted = [0] - def deleteInc(): + def delete_inc(): deleted[0] += 1 if deleted[0] == len(to_delete): self.pm.profiles_screen.reload() @@ -93,8 +93,8 @@ for profile in to_delete: log.info("Deleteing profile [{}]".format(profile)) - G.host.bridge.asyncDeleteProfile( - profile, callback=deleteInc, errback=deleteInc) + G.host.bridge.profile_delete_async( + profile, callback=delete_inc, errback=delete_inc) class ProfilesScreen(Screen): @@ -106,7 +106,7 @@ super(ProfilesScreen, self).__init__(name='profiles') self.reload() - def _profilesListGetCb(self, profiles): + def _profiles_list_get_cb(self, profiles): profiles.sort() self.profiles = profiles for idx, profile in enumerate(profiles): @@ -121,7 +121,7 @@ def reload(self): """Reload profiles list""" self.layout.clear_widgets() - G.host.bridge.profilesListGet(callback=self._profilesListGetCb) + G.host.bridge.profiles_list_get(callback=self._profiles_list_get_cb) class ProfileManager(QuickProfileManager, BoxLayout): @@ -141,20 +141,20 @@ self.screen_manager.add_widget(self.delete_profiles_screen) self.add_widget(self.screen_manager) - def closeUI(self, xmlui, reason=None): + def close_ui(self, xmlui, reason=None): self.screen_manager.transition.direction = 'right' self.screen_manager.current = 'profiles' - def showUI(self, xmlui): - xmlui.setCloseCb(self.closeUI) + def show_ui(self, xmlui): + xmlui.set_close_cb(self.close_ui) if xmlui.type == 'popup': - xmlui.bind(on_touch_up=lambda obj, value: self.closeUI(xmlui)) + xmlui.bind(on_touch_up=lambda obj, value: self.close_ui(xmlui)) self.xmlui_screen.clear_widgets() self.xmlui_screen.add_widget(xmlui) self.screen_manager.transition.direction = 'left' self.screen_manager.current = 'xmlui' - def selectProfile(self, profile_item): + def select_profile(self, profile_item): if not profile_item.selected: return def authenticate_cb(data, cb_id, profile): @@ -166,13 +166,13 @@ # state may have been modified so we need to be sure it's down profile_item.state = 'down' self.selected = profile_item - G.host.actionManager(data, callback=authenticate_cb, ui_show_cb=self.showUI, + G.host.action_manager(data, callback=authenticate_cb, ui_show_cb=self.show_ui, profile=profile) - G.host.launchAction(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, + G.host.action_launch(C.AUTHENTICATE_PROFILE_ID, callback=authenticate_cb, profile=profile_item.text) - def getProfiles(self): + def get_profiles(self): # for now we restrict to a single profile in Cagou # TODO: handle multi-profiles return [self.selected.text] if self.selected else []
--- a/cagou/core/share_widget.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/share_widget.py Sat Apr 08 13:44:32 2023 +0200 @@ -52,23 +52,23 @@ reduce_layout = ObjectProperty() reduce_checkbox = ObjectProperty() - def _checkImageCb(self, report_raw): + def _check_image_cb(self, report_raw): self.report = data_format.deserialise(report_raw) if self.report['too_large']: self.reduce_layout.opacity = 1 self.reduce_layout.height = self.reduce_layout.minimum_height + dp(10) self.reduce_layout.padding = [0, dp(5)] - def _checkImageEb(self, failure_): + def _check_image_eb(self, failure_): log.error(f"Can't check image: {failure_}") def on_path(self, wid, path): - G.host.bridge.imageCheck( - path, callback=self._checkImageCb, errback=self._checkImageEb) + G.host.bridge.image_check( + path, callback=self._check_image_cb, errback=self._check_image_eb) - def resizeImage(self, data, callback, errback): + def resize_image(self, data, callback, errback): - def imageResizeCb(new_path): + def image_resize_cb(new_path): new_path = Path(new_path) log.debug(f"image {data['path']} resized at {new_path}") data['path'] = new_path @@ -77,15 +77,15 @@ path = data['path'] width, height = self.report['recommended_size'] - G.host.bridge.imageResize( + G.host.bridge.image_resize( path, width, height, - callback=imageResizeCb, + callback=image_resize_cb, errback=errback ) - def getFilter(self): + def get_filter(self): if self.report['too_large'] and self.reduce_checkbox.active: - return self.resizeImage + return self.resize_image else: return lambda data, callback, errback: callback(data) @@ -110,43 +110,43 @@ self.preview_box.add_widget(GenericPreview(path=self.data['path'])) def close(self): - G.host.closeUI() + G.host.close_ui() - def getFilteredData(self, callback, errback): + def get_filtered_data(self, callback, errback): """Apply filter if suitable, and call callback with with modified data""" try: - getFilter = self.preview_box.children[0].getFilter + get_filter = self.preview_box.children[0].get_filter except AttributeError: callback(self.data) else: - filter_ = getFilter() + filter_ = get_filter() filter_(self.data, callback=callback, errback=errback) - def filterDataCb(self, data, contact_jid, profile): - chat_wid = G.host.doAction('chat', contact_jid, [profile]) + def filter_data_cb(self, data, contact_jid, profile): + chat_wid = G.host.do_action('chat', contact_jid, [profile]) if self.type == 'text' and 'text' in self.data: text = self.data['text'] chat_wid.message_input.text += text else: path = self.data['path'] - chat_wid.transferFile(path, cleaning_cb=data.get('cleaning_cb')) + chat_wid.transfer_file(path, cleaning_cb=data.get('cleaning_cb')) self.close() - def filterDataEb(self, failure_): - G.host.addNote( + def filter_data_eb(self, failure_): + G.host.add_note( _("file filter error"), _("Can't apply filter to file: {msg}").format(msg=failure_), level=C.XMLUI_DATA_LVL_ERROR) def on_select(self, contact_button): contact_jid = jid.JID(contact_button.jid) - self.getFilteredData( + self.get_filtered_data( partial( - self.filterDataCb, + self.filter_data_cb, contact_jid=contact_jid, profile=contact_button.profile), - self.filterDataEb + self.filter_data_eb ) def key_input(self, window, key, scancode, codepoint, modifier):
--- a/cagou/core/simple_xhtml.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/simple_xhtml.py Sat Apr 08 13:44:32 2023 +0200 @@ -43,7 +43,7 @@ if parent is not None: self.font_size = parent.font_size - def _addUrlMarkup(self, text): + def _add_url_markup(self, text): text_elts = [] idx = 0 links = 0 @@ -74,7 +74,7 @@ # this would result in infinite loop (because self.text # is changed if an URL is found, and in this case markup too) if text and not self.markup: - self._addUrlMarkup(text) + self._add_url_markup(text) def on_ref_press(self, ref): url = self.ref_urls[ref] @@ -115,7 +115,7 @@ xhtml = ET.fromstring(xhtml.encode()) self.current_wid = None self.styles = [] - self._callParseMethod(xhtml) + self._call_parse_method(xhtml) if len(self.children) > 1: self._do_split_labels() @@ -137,7 +137,7 @@ new_text = [] current_tag = [] current_value = [] - current_wid = self._createText() + current_wid = self._create_text() value = False close = False # we will parse the text and create a new widget @@ -184,7 +184,7 @@ new_text = [] self.add_widget(current_wid) log.debug("new widget: {}".format(current_wid.text)) - current_wid = self._createText() + current_wid = self._create_text() for t, v in styles: new_text.append('[{tag}{value}]'.format( tag = t, @@ -207,7 +207,7 @@ # XHTML parsing methods - def _callParseMethod(self, e): + def _call_parse_method(self, e): """Call the suitable method to parse the element self.xhtml_[tag] will be called if it exists, else @@ -221,7 +221,7 @@ method = self.xhtml_generic method(e) - def _addStyle(self, tag, value=None, append_to_list=True): + def _add_style(self, tag, value=None, append_to_list=True): """add a markup style to label @param tag(unicode): markup tag @@ -230,7 +230,7 @@ self.styles is needed to keep track of styles to remove should most probably be set to True """ - label = self._getLabel() + label = self._get_label() label.text += '[{tag}{value}]'.format( tag = tag, value = '={}'.format(value) if value else '' @@ -238,14 +238,14 @@ if append_to_list: self.styles.append((tag, value)) - def _removeStyle(self, tag, remove_from_list=True): + def _remove_style(self, tag, remove_from_list=True): """remove a markup style from the label @param tag(unicode): markup tag to remove @param remove_from_list(bool): if True, remove from self.styles too should most probably be set to True """ - label = self._getLabel() + label = self._get_label() label.text += '[/{tag}]'.format( tag = tag ) @@ -256,30 +256,30 @@ del self.styles[tag_idx] break - def _getLabel(self): + def _get_label(self): """get current Label if it exists, or create a new one""" if not isinstance(self.current_wid, Label): - self._addLabel() + self._add_label() return self.current_wid - def _addLabel(self): + def _add_label(self): """add a new Label current styles will be closed and reopened if needed """ - self._closeLabel() - self.current_wid = self._createText() + self._close_label() + self.current_wid = self._create_text() for tag, value in self.styles: - self._addStyle(tag, value, append_to_list=False) + self._add_style(tag, value, append_to_list=False) self.add_widget(self.current_wid) - def _createText(self): + def _create_text(self): label = SimpleXHTMLWidgetText(color=self.color, markup=True) self.bind(color=label.setter('color')) label.bind(texture_size=label.setter('size')) return label - def _closeLabel(self): + def _close_label(self): """close current style tags in current label needed when you change label to keep style between @@ -287,9 +287,9 @@ """ if isinstance(self.current_wid, Label): for tag, value in reversed(self.styles): - self._removeStyle(tag, remove_from_list=False) + self._remove_style(tag, remove_from_list=False) - def _parseCSS(self, e): + def _parse_css(self, e): """parse CSS found in "style" attribute of element self._css_styles will be created and contained markup styles added by this method @@ -313,14 +313,14 @@ method(e, value) self._css_styles = self.styles[styles_limit:] - def _closeCSS(self): + def _close_css(self): """removed CSS styles styles in self._css_styles will be removed and the attribute will be deleted """ for tag, __ in reversed(self._css_styles): - self._removeStyle(tag) + self._remove_style(tag) del self._css_styles def xhtml_generic(self, elem, style=True, markup=None): @@ -337,33 +337,33 @@ tag, value = markup, None else: tag, value = markup - self._addStyle(tag, value) + self._add_style(tag, value) style_ = 'style' in elem.attrib and style if style_: - self._parseCSS(elem) + self._parse_css(elem) # then content if elem.text: - self._getLabel().text += escape_markup(elem.text) + self._get_label().text += escape_markup(elem.text) # we parse the children for child in elem: - self._callParseMethod(child) + self._call_parse_method(child) # closing CSS style and markup if style_: - self._closeCSS() + self._close_css() if markup is not None: - self._removeStyle(tag) + self._remove_style(tag) # and the tail, which is regular text if elem.tail: - self._getLabel().text += escape_markup(elem.tail) + self._get_label().text += escape_markup(elem.tail) # method handling XHTML elements def xhtml_br(self, elem): - label = self._getLabel() + label = self._get_label() label.text+='\n' self.xhtml_generic(elem, style=False) @@ -406,12 +406,12 @@ # methods handling CSS properties def css_color(self, elem, value): - self._addStyle("color", css_color.parse(value)) + self._add_style("color", css_color.parse(value)) def css_text_decoration(self, elem, value): if value == 'underline': - self._addStyle('u') + self._add_style('u') elif value == 'line-through': - self._addStyle('s') + self._add_style('s') else: log.warning("unhandled text decoration: {}".format(value))
--- a/cagou/core/widgets_handler.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/widgets_handler.py Sat Apr 08 13:44:32 2023 +0200 @@ -144,9 +144,9 @@ "former_screen_wid can only be used if ScreenManager is used") if self._former_screen_name is None: return None - return self.getScreenWidget(self._former_screen_name) + return self.get_screen_widget(self._former_screen_name) - def getScreenWidget(self, screen_name): + def get_screen_widget(self, screen_name): """Return screen main widget, handling carousel if necessary""" if self.carousel is not None and screen_name == '': return self.carousel.current_slide @@ -324,7 +324,7 @@ # and update there side widgets list for top in self._top_wids.copy(): if top.height <= REMOVE_WID_LIMIT: - G.host._removeVisibleWidget(top.current_slide) + G.host._remove_visible_widget(top.current_slide) for w in top._top_wids: w._bottom_wids.remove(top) w._bottom_wids.update(top._bottom_wids) @@ -341,7 +341,7 @@ # and update there side widgets list for left in self._left_wids.copy(): if left.width <= REMOVE_WID_LIMIT: - G.host._removeVisibleWidget(left.current_slide) + G.host._remove_visible_widget(left.current_slide) for w in left._left_wids: w._right_wids.remove(left) w._right_wids.update(left._right_wids) @@ -360,7 +360,7 @@ def clear_widgets(self): current_slide = self.current_slide if current_slide is not None: - G.host._removeVisibleWidget(current_slide, ignore_missing=True) + G.host._remove_visible_widget(current_slide, ignore_missing=True) super().clear_widgets() @@ -387,8 +387,8 @@ parent = Screen() self.screen_manager.add_widget(parent) self._former_screen_name = '' - self.screen_manager.bind(current=self.onScreenChange) - wid.screenManagerInit(self.screen_manager) + self.screen_manager.bind(current=self.on_screen_change) + wid.screen_manager_init(self.screen_manager) else: parent = self.main_container @@ -401,15 +401,15 @@ loop = True, ) self._slides_update_lock = 0 - self.carousel.bind(current_slide=self.onSlideChange) + self.carousel.bind(current_slide=self.on_slide_change) parent.add_widget(self.carousel) self.carousel.add_widget(wid, index) else: # no Carousel requested, we add the widget as a direct child parent.add_widget(wid) - G.host._addVisibleWidget(wid) + G.host._add_visible_widget(wid) - def changeWidget(self, new_widget): + def change_widget(self, new_widget): """Change currently displayed widget slides widgets will be updated @@ -419,7 +419,7 @@ # we have the same class, we reuse carousel and screen manager setting if self.carousel.current_slide != new_widget: - # slides update need to be blocked to avoid the update in onSlideChange + # slides update need to be blocked to avoid the update in on_slide_change # which would mess the removal of current widgets self._slides_update_lock += 1 new_wid = None @@ -429,23 +429,23 @@ continue self.carousel.remove_widget(w) if isinstance(w, quick_widgets.QuickWidget): - G.host.widgets.deleteWidget(w) + G.host.widgets.delete_widget(w) if new_wid is None: - new_wid = G.host.getOrClone(new_widget) + new_wid = G.host.get_or_clone(new_widget) self.carousel.add_widget(new_wid) - self._updateHiddenSlides() + self._update_hidden_slides() self._slides_update_lock -= 1 if self.screen_manager is not None: self.screen_manager.clear_widgets([ s for s in self.screen_manager.screens if s.name != '']) - new_wid.screenManagerInit(self.screen_manager) + new_wid.screen_manager_init(self.screen_manager) else: # else, we restart fresh self.clear_widgets() - self.set_widget(G.host.getOrClone(new_widget)) + self.set_widget(G.host.get_or_clone(new_widget)) - def onScreenChange(self, screen_manager, new_screen): + def on_screen_change(self, screen_manager, new_screen): try: new_screen_wid = self.current_slide except IndexError: @@ -453,32 +453,32 @@ log.warning("Switching to a screen without children") if new_screen == '' and self.carousel is not None: # carousel may have been changed in the background, so we update slides - self._updateHiddenSlides() + self._update_hidden_slides() former_screen_wid = self.former_screen_wid if isinstance(former_screen_wid, cagou_widget.CagouWidget): - G.host._removeVisibleWidget(former_screen_wid) + G.host._remove_visible_widget(former_screen_wid) if isinstance(new_screen_wid, cagou_widget.CagouWidget): - G.host._addVisibleWidget(new_screen_wid) + G.host._add_visible_widget(new_screen_wid) self._former_screen_name = new_screen G.host.selected_widget = new_screen_wid - def onSlideChange(self, handler, new_slide): + def on_slide_change(self, handler, new_slide): if self._former_slide is new_slide: # FIXME: workaround for Kivy a95d67f (and above?), Carousel.current_slide - # binding now calls onSlideChange twice with the same widget (here + # binding now calls on_slide_change twice with the same widget (here # "new_slide"). To be checked with Kivy team. return log.debug(f"Slide change: new_slide = {new_slide}") if self._former_slide is not None: - G.host._removeVisibleWidget(self._former_slide, ignore_missing=True) + G.host._remove_visible_widget(self._former_slide, ignore_missing=True) self._former_slide = new_slide if self.carousel_active: G.host.selected_widget = new_slide if new_slide is not None: - G.host._addVisibleWidget(new_slide) - self._updateHiddenSlides() + G.host._add_visible_widget(new_slide) + self._update_hidden_slides() - def hiddenList(self, visible_list, ignore=None): + def hidden_list(self, visible_list, ignore=None): """return widgets of same class as carousel current one, if they are hidden @param visible_list(list[QuickWidget]): widgets visible @@ -488,7 +488,7 @@ # we want to avoid recreated widgets added = [w.widget_hash for w in visible_list] current_slide = self.carousel.current_slide - for w in G.host.widgets.getWidgets(current_slide.__class__, + for w in G.host.widgets.get_widgets(current_slide.__class__, profiles=current_slide.profiles): wid_hash = w.widget_hash if w in visible_list or wid_hash in added: @@ -498,7 +498,7 @@ yield w - def _updateHiddenSlides(self): + def _update_hidden_slides(self): """adjust carousel slides according to visible widgets""" if self._slides_update_lock or not self.carousel_active: return @@ -507,10 +507,10 @@ return # lock must be used here to avoid recursions self._slides_update_lock += 1 - visible_list = G.host.getVisibleList(current_slide.__class__) + visible_list = G.host.get_visible_list(current_slide.__class__) # we ignore current_slide as it may not be visible yet (e.g. if an other # screen is shown - hidden = list(self.hiddenList(visible_list, ignore=current_slide)) + hidden = list(self.hidden_list(visible_list, ignore=current_slide)) slides_sorted = sorted(set(hidden + [current_slide])) to_remove = set(self.carousel.slides).difference({current_slide}) for w in to_remove: @@ -523,10 +523,10 @@ next_slide = slides_sorted[current_idx+1] except IndexError: next_slide = slides_sorted[0] - self.carousel.add_widget(G.host.getOrClone(next_slide)) + self.carousel.add_widget(G.host.get_or_clone(next_slide)) if len(hidden)>1: previous_slide = slides_sorted[current_idx-1] - self.carousel.add_widget(G.host.getOrClone(previous_slide)) + self.carousel.add_widget(G.host.get_or_clone(previous_slide)) self._slides_update_lock -= 1
--- a/cagou/core/xmlui.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/core/xmlui.py Sat Apr 08 13:44:32 2023 +0200 @@ -47,7 +47,7 @@ self._xmlui_onchange_cb = None self._got_focus = False - def _xmluiOnChange(self, callback): + def _xmlui_on_change(self, callback): self._xmlui_onchange_cb = callback def on_focus(self, instance, focus): @@ -88,10 +88,10 @@ TextInputOnChange.__init__(self) self.readonly = read_only - def _xmluiSetValue(self, value): + def _xmlui_set_value(self, value): self.text = value - def _xmluiGetValue(self): + def _xmlui_get_value(self): return self.text @@ -110,7 +110,7 @@ self.text = value self.callback = click_callback - def _xmluiOnClick(self, callback): + def _xmlui_on_click(self, callback): self.callback = callback def on_release(self): @@ -155,8 +155,8 @@ self.multi = 'single' not in flags self._values = [] for option in options: - self.addValue(option) - self._xmluiSelectValues(selected) + self.add_value(option) + self._xmlui_select_values(selected) self._on_change = None @property @@ -165,11 +165,11 @@ def select(self, item): if not self.multi: - self._xmluiSelectValues([item.value]) + self._xmlui_select_values([item.value]) if self._on_change is not None: self._on_change(self) - def addValue(self, option, selected=False): + def add_value(self, option, selected=False): """add a value in the list @param option(tuple): value, label in a tuple @@ -180,24 +180,24 @@ item.selected = selected self.layout.add_widget(item) - def _xmluiSelectValue(self, value): - self._xmluiSelectValues([value]) + def _xmlui_select_value(self, value): + self._xmlui_select_values([value]) - def _xmluiSelectValues(self, values): + def _xmlui_select_values(self, values): for item in self.items: item.selected = item.value in values if item.selected and not self.multi: self.text = item.text - def _xmluiGetSelectedValues(self): + def _xmlui_get_selected_values(self): return [item.value for item in self.items if item.selected] - def _xmluiAddValues(self, values, select=True): + def _xmlui_add_values(self, values, select=True): values = set(values).difference([c.value for c in self.items]) for v in values: - self.addValue(v, select) + self.add_value(v, select) - def _xmluiOnChange(self, callback): + def _xmlui_on_change(self, callback): self._on_change = callback @@ -215,10 +215,10 @@ text=value, readonly=read_only, size=(100,25), size_hint=(1,None)) TextInputOnChange.__init__(self) - def _xmluiSetValue(self, value): + def _xmlui_set_value(self, value): self.text = value - def _xmluiGetValue(self): + def _xmlui_get_value(self): return self.text @@ -229,13 +229,13 @@ if read_only: self.disabled = True - def _xmluiSetValue(self, value): + def _xmlui_set_value(self, value): self.active = value - def _xmluiGetValue(self): + def _xmlui_get_value(self): return C.BOOL_TRUE if self.active else C.BOOL_FALSE - def _xmluiOnChange(self, callback): + def _xmlui_on_change(self, callback): self.bind(active=lambda instance, value: callback(instance)) @@ -247,10 +247,10 @@ if read_only: self.disabled = True - def _xmluiSetValue(self, value): + def _xmlui_set_value(self, value): self.text = value - def _xmluiGetValue(self): + def _xmlui_get_value(self): return self.text @@ -263,7 +263,7 @@ self.xmlui_parent = xmlui_parent BoxLayout.__init__(self) - def _xmluiAppend(self, widget): + def _xmlui_append(self, widget): self.add_widget(widget) @@ -273,7 +273,7 @@ self.xmlui_parent = xmlui_parent GridLayout.__init__(self) - def _xmluiAppend(self, widget): + def _xmlui_append(self, widget): self.add_widget(widget) @@ -284,7 +284,7 @@ class TabsPanelContainer(TabbedPanelItem): layout = properties.ObjectProperty(None) - def _xmluiAppend(self, widget): + def _xmlui_append(self, widget): self.layout.add_widget(widget) @@ -294,7 +294,7 @@ self.xmlui_parent = xmlui_parent TabbedPanel.__init__(self, do_default_tab=False) - def _xmluiAddTab(self, label, selected): + def _xmlui_add_tab(self, label, selected): tab = TabsPanelContainer(text=label) self.add_widget(tab) return tab @@ -319,7 +319,7 @@ log.error("Can't find parent AdvancedListContainer") else: if parent.selectable: - self.selected = parent._xmluiToggleSelected(self) + self.selected = parent._xmlui_toggle_selected(self) return super(AdvancedListRow, self).on_touch_down(touch) @@ -335,7 +335,7 @@ self._selected = [] self._xmlui_select_cb = None - def _xmluiToggleSelected(self, row): + def _xmlui_toggle_selected(self, row): """inverse selection status of an AdvancedListRow @param row(AdvancedListRow): row to (un)select @@ -351,27 +351,27 @@ else: return False - def _xmluiAppend(self, widget): + def _xmlui_append(self, widget): if self._current_row is None: log.error("No row set, ignoring append") return self._current_row.add_widget(widget) - def _xmluiAddRow(self, idx): + def _xmlui_add_row(self, idx): self._current_row = AdvancedListRow() self._current_row.cols = self._columns self._current_row.index = idx self.add_widget(self._current_row) - def _xmluiGetSelectedWidgets(self): + def _xmlui_get_selected_widgets(self): return self._selected - def _xmluiGetSelectedIndex(self): + def _xmlui_get_selected_index(self): if not self._selected: return None return self._selected[0].index - def _xmluiOnSelect(self, callback): + def _xmlui_on_select(self, callback): """ Call callback with widget as only argument """ self._xmlui_select_cb = callback @@ -385,8 +385,8 @@ xmlui.NoteDialog.__init__(self, _xmlui_parent) self.title, self.message, self.level = title, message, level - def _xmluiShow(self): - G.host.addNote(self.title, self.message, self.level) + def _xmlui_show(self): + G.host.add_note(self.title, self.message, self.level) class MessageDialog(xmlui.MessageDialog, dialog.MessageDialog): @@ -400,16 +400,16 @@ xmlui.MessageDialog.__init__(self, _xmlui_parent) def close_cb(self): - self._xmluiClose() + self._xmlui_close() - def _xmluiShow(self): - G.host.addNotifUI(self) + def _xmlui_show(self): + G.host.add_notif_ui(self) - def _xmluiClose(self, reason=None): - G.host.closeUI() + def _xmlui_close(self, reason=None): + G.host.close_ui() def show(self, *args, **kwargs): - G.host.showUI(self) + G.host.show_ui(self) class ConfirmDialog(xmlui.ConfirmDialog, dialog.ConfirmDialog): @@ -423,22 +423,22 @@ self.yes_cb = self.yes_cb def no_cb(self): - G.host.closeUI() - self._xmluiCancelled() + G.host.close_ui() + self._xmlui_cancelled() def yes_cb(self): - G.host.closeUI() - self._xmluiValidated() + G.host.close_ui() + self._xmlui_validated() - def _xmluiShow(self): - G.host.addNotifUI(self) + def _xmlui_show(self): + G.host.add_notif_ui(self) - def _xmluiClose(self, reason=None): - G.host.closeUI() + def _xmlui_close(self, reason=None): + G.host.close_ui() def show(self, *args, **kwargs): assert kwargs["force"] - G.host.showUI(self) + G.host.show_ui(self) class FileDialog(xmlui.FileDialog, BoxLayout): @@ -451,26 +451,26 @@ if filetype == C.XMLUI_DATA_FILETYPE_DIR: self.file_chooser.dirselect = True - def _xmluiShow(self): - G.host.addNotifUI(self) + def _xmlui_show(self): + G.host.add_notif_ui(self) - def _xmluiClose(self, reason=None): + def _xmlui_close(self, reason=None): # FIXME: notif UI is not removed if dialog is not shown yet - G.host.closeUI() + G.host.close_ui() - def onSelect(self, path): + def on_select(self, path): try: path = path[0] except IndexError: path = None if not path: - self._xmluiCancelled() + self._xmlui_cancelled() else: - self._xmluiValidated({'path': path}) + self._xmlui_validated({'path': path}) def show(self, *args, **kwargs): assert kwargs["force"] - G.host.showUI(self) + G.host.show_ui(self) ## Factory ## @@ -531,7 +531,7 @@ ignore=ignore, whitelist=whitelist, profile=profile) - self.bind(height=self.onHeight) + self.bind(height=self.on_height) def on_touch_down(self, touch, after=False): if self._skip_scroll_events: @@ -551,33 +551,33 @@ else: return super(XMLUIPanel, self).on_touch_move(touch) - def setCloseCb(self, close_cb): + def set_close_cb(self, close_cb): self.close_cb = close_cb - def _xmluiClose(self, __=None, reason=None): + def _xmlui_close(self, __=None, reason=None): if self.close_cb is not None: self.close_cb(self, reason) else: - G.host.closeUI() + G.host.close_ui() - def onParamChange(self, ctrl): - super(XMLUIPanel, self).onParamChange(ctrl) + def on_param_change(self, ctrl): + super(XMLUIPanel, self).on_param_change(ctrl) self.save_btn.disabled = False - def addPostTreat(self, callback): + def add_post_treat(self, callback): self._post_treats.append(callback) - def _postTreatCb(self): + def _post_treat_cb(self): for cb in self._post_treats: cb() del self._post_treats - def _saveButtonCb(self, button): + def _save_button_cb(self, button): button.disabled = True - self.onSaveParams(button) + self.on_save_params(button) - def constructUI(self, parsed_dom): - xmlui.XMLUIPanel.constructUI(self, parsed_dom, self._postTreatCb) + def construct_ui(self, parsed_dom): + xmlui.XMLUIPanel.construct_ui(self, parsed_dom, self._post_treat_cb) if self.xmlui_title: self.layout.add_widget(Title(text=self.xmlui_title)) if isinstance(self.main_cont, TabsContainer): @@ -586,23 +586,23 @@ self.layout.add_widget(self.main_cont) if self.type == 'form': submit_btn = SubmitButton() - submit_btn.bind(on_press=self.onFormSubmitted) + submit_btn.bind(on_press=self.on_form_submitted) self.layout.add_widget(submit_btn) if not 'NO_CANCEL' in self.flags: cancel_btn = CancelButton(text=_("Cancel")) - cancel_btn.bind(on_press=self.onFormCancelled) + cancel_btn.bind(on_press=self.on_form_cancelled) self.layout.add_widget(cancel_btn) elif self.type == 'param': self.save_btn = SaveButton(text=_("Save"), disabled=True) - self.save_btn.bind(on_press=self._saveButtonCb) + self.save_btn.bind(on_press=self._save_button_cb) self.layout.add_widget(self.save_btn) elif self.type == 'window': cancel_btn = CancelButton(text=_("Cancel")) cancel_btn.bind( - on_press=partial(self._xmluiClose, reason=C.XMLUI_DATA_CANCELLED)) + on_press=partial(self._xmlui_close, reason=C.XMLUI_DATA_CANCELLED)) self.layout.add_widget(cancel_btn) - def onHeight(self, __, height): + def on_height(self, __, height): if isinstance(self.main_cont, TabsContainer): other_children_height = sum([c.height for c in self.layout.children if c is not self.main_cont]) @@ -610,9 +610,9 @@ def show(self, *args, **kwargs): if not self.user_action and not kwargs.get("force", False): - G.host.addNotifUI(self) + G.host.add_notif_ui(self) else: - G.host.showUI(self) + G.host.show_ui(self) class XMLUIDialog(xmlui.XMLUIDialog):
--- a/cagou/kv/common_widgets.kv Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/kv/common_widgets.kv Sat Apr 08 13:44:32 2023 +0200 @@ -27,7 +27,7 @@ size_hint: 1, None height: dp(80) font_size: dp(40) - symbol: root.getSymbol() + symbol: root.get_symbol() color: 0, 0, 0, 1 Label: size_hint: None, None
--- a/cagou/kv/menu.kv Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/kv/menu.kv Sat Apr 08 13:44:32 2023 +0200 @@ -35,7 +35,7 @@ bg_color: 0.23, 0.23, 0.23, 1 ExtraMenuItem: text: _("About") - on_press: root.onAbout() + on_press: root.on_about() Widget: # to push content to the top @@ -48,7 +48,7 @@ spacing: dp(5) transfer_info: transfer_info upload_btn: upload_btn - on_encrypted: self.updateTransferInfo() + on_encrypted: self.update_transfer_info() canvas.after: Color: rgba: app.c_prim_dark @@ -66,7 +66,7 @@ text: _(u"upload") group: "transfer" state: "down" - on_state: root.updateTransferInfo() + on_state: root.update_transfer_info() SymbolToggleLabel id: send_btn symbol: "loop-alt"
--- a/cagou/kv/profile_manager.kv Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/kv/profile_manager.kv Sat Apr 08 13:44:32 2023 +0200 @@ -134,7 +134,7 @@ cols: 2 PMButton: text: "Delete" - on_press: root.doDelete() + on_press: root.do_delete() PMButton: text: "Cancel" @@ -181,7 +181,7 @@ size_hint: 1, None height: dp(40) disabled: not root.pm.selected - on_press: root.pm._onConnectProfiles() + on_press: root.pm._on_connect_profiles() <ProfileItem>: @@ -193,5 +193,5 @@ selected: self.state == 'down' color: 0,0,0,1 background_color: self.selected_color if self.selected else self.deselected_color - on_press: self.ps.pm.selectProfile(self) + on_press: self.ps.pm.select_profile(self) height: dp(30)
--- a/cagou/kv/share_widget.kv Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/kv/share_widget.kv Sat Apr 08 13:44:32 2023 +0200 @@ -50,7 +50,7 @@ size_hint: 1, None height: C.BTN_HEIGHT text: _("cancel") - on_press: app.host.closeUI() + on_press: app.host.close_ui() <TextPreview>:
--- a/cagou/kv/xmlui.kv Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/kv/xmlui.kv Sat Apr 08 13:44:32 2023 +0200 @@ -184,7 +184,7 @@ size_hint: 1, None height: dp(50) text: "choose" - on_release: root.onSelect(file_chooser.selection) + on_release: root.on_select(file_chooser.selection) Button: size_hint: 1, None height: dp(50)
--- a/cagou/plugins/plugin_transfer_android_photo.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_transfer_android_photo.py Sat Apr 08 13:44:32 2023 +0200 @@ -49,13 +49,13 @@ self.callback = callback self.cancel_cb = cancel_cb filename = time.strftime("%Y-%m-%d_%H:%M:%S.jpg", time.gmtime()) - tmp_dir = self.getTmpDir() + tmp_dir = self.get_tmp_dir() tmp_file = os.path.join(tmp_dir, filename) log.debug("Picture will be saved to {}".format(tmp_file)) camera.take_picture(tmp_file, self.callback) # we don't delete the file, as it is nice to keep it locally - def getTmpDir(self): + def get_tmp_dir(self): if sys.platform == "android": dcim_path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath() return dcim_path
--- a/cagou/plugins/plugin_transfer_android_video.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_transfer_android_video.py Sat Apr 08 13:44:32 2023 +0200 @@ -49,13 +49,13 @@ self.callback = callback self.cancel_cb = cancel_cb filename = time.strftime("%Y-%m-%d_%H:%M:%S.mpg", time.gmtime()) - tmp_dir = self.getTmpDir() + tmp_dir = self.get_tmp_dir() tmp_file = os.path.join(tmp_dir, filename) log.debug("Video will be saved to {}".format(tmp_file)) camera.take_video(tmp_file, self.callback) # we don't delete the file, as it is nice to keep it locally - def getTmpDir(self): + def get_tmp_dir(self): if sys.platform == "android": dcim_path = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM).getAbsolutePath() return dcim_path
--- a/cagou/plugins/plugin_transfer_file.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_transfer_file.py Sat Apr 08 13:44:32 2023 +0200 @@ -58,23 +58,23 @@ super(FileTransmitter, self).__init__(*args, **kwargs) if self.native_filechooser: - thread = threading.Thread(target=self._nativeFileChooser) + thread = threading.Thread(target=self._native_file_chooser) thread.start() else: self.add_widget(FileChooserBox(default_path = self.default_path, - callback=self.onFiles, + callback=self.on_files, cancel_cb=partial(self.cancel_cb, self))) - def _nativeFileChooser(self, *args, **kwargs): + def _native_file_chooser(self, *args, **kwargs): title=_("Please select a file to upload") files = filechooser.open_file(title=title, path=self.default_path, multiple=False, preview=True) - # we want to leave the thread when calling onFiles, so we use Clock - Clock.schedule_once(lambda *args: self.onFiles(files=files), 0) + # we want to leave the thread when calling on_files, so we use Clock + Clock.schedule_once(lambda *args: self.on_files(files=files), 0) - def onFiles(self, files): + def on_files(self, files): if files: self.callback(files[0]) else:
--- a/cagou/plugins/plugin_transfer_voice.kv Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_transfer_voice.kv Sat Apr 08 13:44:32 2023 +0200 @@ -47,14 +47,14 @@ allow_stretch: True size_hint: None, None size: dp(60), dp(60) - on_release: root.switchRecording() + on_release: root.switch_recording() IconButton: opacity: 0 if root.recording or not root.time and not root.playing else 1 source: app.expand("{media}/icons/muchoslava/png/") + ("stop_50.png" if root.playing else "play_50.png") allow_stretch: True size_hint: None, None size: dp(60), dp(60) - on_release: root.playRecord() + on_release: root.play_record() Widget Widget: size_hint: 1, None
--- a/cagou/plugins/plugin_transfer_voice.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_transfer_voice.py Sat Apr 08 13:44:32 2023 +0200 @@ -56,12 +56,12 @@ self.audio = audio self.audio.file_path = "/sdcard/cagou_record.3gp" - def _updateTimer(self, dt): + def _update_timer(self, dt): self.time = int(time.time() - self._started_at) - def switchRecording(self): + def switch_recording(self): if self.playing: - self._stopPlaying() + self._stop_playing() if self.recording: try: audio.stop() @@ -75,13 +75,13 @@ audio.start() self._started_at = time.time() self.time = 0 - self._counter_timer = Clock.schedule_interval(self._updateTimer, 1) + self._counter_timer = Clock.schedule_interval(self._update_timer, 1) self.recording = not self.recording - def _stopPlaying(self, __=None): + def _stop_playing(self, __=None): if self.record_time is None: - log.error("_stopPlaying should no be called when record_time is None") + log.error("_stop_playing should no be called when record_time is None") return audio.stop() self.playing = False @@ -89,11 +89,11 @@ if self._counter_timer is not None: self._counter_timer.cancel() - def playRecord(self): + def play_record(self): if self.recording: return if self.playing: - self._stopPlaying() + self._stop_playing() else: try: audio.play() @@ -106,7 +106,7 @@ self.playing = True self.record_time = self.time - Clock.schedule_once(self._stopPlaying, self.time + 1) + Clock.schedule_once(self._stop_playing, self.time + 1) self._started_at = time.time() self.time = 0 - self._counter_timer = Clock.schedule_interval(self._updateTimer, 0.5) + self._counter_timer = Clock.schedule_interval(self._update_timer, 0.5)
--- a/cagou/plugins/plugin_wid_blog.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_wid_blog.py Sat Apr 08 13:44:32 2023 +0200 @@ -70,7 +70,7 @@ size_hint_open = (1, 0.9) def _publish_cb(self, item_id: str) -> None: - G.host.addNote( + G.host.add_note( _("blog post published"), _("your blog post has been published with ID {item_id}").format( item_id=item_id @@ -79,7 +79,7 @@ self.blog.load_blog() def _publish_eb(self, exc: BridgeException) -> None: - G.host.addNote( + G.host.add_note( _("Problem while publish blog post"), _("Can't publish blog post at {node!r} from {service}: {problem}").format( node=self.blog.node or G.host.ns_map.get("microblog"), @@ -105,7 +105,7 @@ title = title.strip() if title: mb_data["title_rich"] = title - G.host.bridge.mbSend( + G.host.bridge.mb_send( self.blog.service, self.blog.node, data_format.serialise(mb_data), @@ -135,9 +135,9 @@ quick_widgets.QuickWidget.__init__(self, G.host, target, profiles) cagou_widget.CagouWidget.__init__(self) search_btn = SearchButton(blog=self) - self.headerInputAddExtra(search_btn) + self.header_input_add_extra(search_btn) new_post_btn = NewPostButton(blog=self) - self.headerInputAddExtra(new_post_btn) + self.header_input_add_extra(new_post_btn) self.load_blog() def on_kv_post(self, __): @@ -146,7 +146,7 @@ node=lambda __, value: self.load_blog(), ) - def onHeaderInput(self): + def on_header_wid_input(self): text = self.header_input.text.strip() # for now we only use text as node self.node = text @@ -164,7 +164,7 @@ self, exc: BridgeException, ) -> None: - G.host.addNote( + G.host.add_note( _("Problem while getting blog data"), _("Can't get blog for {node!r} at {service}: {problem}").format( node=self.node or G.host.ns_map.get("microblog"), @@ -180,7 +180,7 @@ """Retrieve a blog and display it""" extra = {} self.posts_widget.clear_widgets() - G.host.bridge.mbGet( + G.host.bridge.mb_get( self.service, self.node, 20,
--- a/cagou/plugins/plugin_wid_chat.kv Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_wid_chat.kv Sat Apr 08 13:44:32 2023 +0200 @@ -114,7 +114,7 @@ MessAvatar: id: avatar source: root.mess_data.avatar['path'] if root.mess_data and root.mess_data.avatar else app.default_avatar - on_press: root.chat.addNick(root.nick) + on_press: root.chat.add_nick(root.nick) Widget: # use to push the avatar on the top size_hint: 1, 1 @@ -228,7 +228,7 @@ ScrollView: id: history_scroll scroll_y: 0 - on_scroll_y: root.onScroll(*args) + on_scroll_y: root.on_scroll(*args) do_scroll_x: False scroll_type: ['bars', 'content'] bar_width: dp(10) @@ -254,7 +254,7 @@ height: min(self.minimum_height, dp(250)) multiline: True hint_text: _(u"Enter your message here") - on_text_validate: root.onSend(args[0]) + on_text_validate: root.on_send(args[0]) SymbolButton: # "send" button, permanent visibility depends on platform symbol: "forward" @@ -299,8 +299,8 @@ <EncryptionMainButton>: size_hint: None, 1 width: dp(30) - color: self.getColor() - symbol: self.getSymbol() + color: self.get_color() + symbol: self.get_symbol() <TrustManagementButton>: symbol: "shield"
--- a/cagou/plugins/plugin_wid_chat.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_wid_chat.py Sat Apr 08 13:44:32 2023 +0200 @@ -100,9 +100,9 @@ show_resize = properties.BooleanProperty(False) def on_kv_post(self, __): - self.attachments.bind(children=self.onAttachment) + self.attachments.bind(children=self.on_attachment) - def onAttachment(self, __, attachments): + def on_attachment(self, __, attachments): if len(attachments) == 0: self.show_resize = False @@ -140,7 +140,7 @@ def on_press(self): full_size_source = self.data.get('path', self.data.get('url')) gallery = ImagesGallery(sources=[full_size_source]) - G.host.showExtraUI(gallery) + G.host.show_extra_ui(gallery) def on_kv_post(self, __): self.on_data(None, self.data) @@ -158,21 +158,21 @@ chat = properties.ObjectProperty() mess_data = properties.ObjectProperty() - def _setPreview(self, attachment, wid, preview_path): + def _set_preview(self, attachment, wid, preview_path): attachment['preview'] = preview_path wid.source = preview_path - def _setPath(self, attachment, wid, path): + def _set_path(self, attachment, wid, path): attachment['path'] = path if wid is not None: # we also need a preview for the widget if 'preview' in attachment: wid.source = attachment['preview'] else: - G.host.bridge.imageGeneratePreview( + G.host.bridge.image_generate_preview( path, self.chat.profile, - callback=partial(self._setPreview, attachment, wid), + callback=partial(self._set_preview, attachment, wid), ) def on_kv_post(self, __): @@ -194,15 +194,15 @@ if idx < 3 or len(attachments) <= 4: if ((self.mess_data.own_mess - or self.chat.contact_list.isInRoster(self.mess_data.from_jid))): + or self.chat.contact_list.is_in_roster(self.mess_data.from_jid))): wid = AsyncImage(size_hint=(1, 1), source="data/images/image-loading.gif") if 'preview' in attachment: wid.source = attachment["preview"] elif 'path' in attachment: - G.host.bridge.imageGeneratePreview( + G.host.bridge.image_generate_preview( attachment['path'], self.chat.profile, - callback=partial(self._setPreview, attachment, wid), + callback=partial(self._set_preview, attachment, wid), ) elif url is None: log.warning(f"Can't find any source for {attachment}") @@ -220,9 +220,9 @@ if to_download: # the file needs to be downloaded, the widget source, # attachment path, and preview will then be completed - G.host.downloadURL( + G.host.download_url( url, - callback=partial(self._setPath, attachment, wid), + callback=partial(self._set_path, attachment, wid), dest=C.FILE_DEST_CACHE, profile=self.chat.profile, ) @@ -243,7 +243,7 @@ else: sources.append(source) gallery = ImagesGallery(sources=sources) - G.host.showExtraUI(gallery) + G.host.show_extra_ui(gallery) class AttachmentToSendItem(AttachmentItem): @@ -322,7 +322,7 @@ if 'avatar' in update_dict: avatar_data = update_dict['avatar'] if avatar_data is None: - source = G.host.getDefaultAvatar() + source = G.host.get_default_avatar() else: source = avatar_data['path'] self.avatar.source = source @@ -330,7 +330,7 @@ status = update_dict['status'] self.delivery.text = '\u2714' if status == 'delivered' else '' - def _setPath(self, data, path): + def _set_path(self, data, path): """Set path of decrypted file to an item""" data['path'] = path @@ -372,7 +372,7 @@ # to avoid leaking IP address, we only display image if the contact is in # roster if ((self.mess_data.own_mess - or self.chat.contact_list.isInRoster(self.mess_data.from_jid))): + or self.chat.contact_list.is_in_roster(self.mess_data.from_jid))): try: url = urlparse(attachment['url']) except KeyError: @@ -383,9 +383,9 @@ # the local decrypted version del attachment['url'] item = AttachmentImageItem(data=attachment) - G.host.downloadURL( + G.host.download_url( url.geturl(), - callback=partial(self._setPath, item.data), + callback=partial(self._set_path, item.data), dest=C.FILE_DEST_CACHE, profile=self.chat.profile, ) @@ -432,7 +432,7 @@ def on_release(self, *args): menu.TransferMenu( encrypted=self.chat.encrypted, - callback=self.chat.transferFile, + callback=self.chat.transfer_file, ).show(self) @@ -441,19 +441,19 @@ def on_select(self, menu): if menu == 'bookmark': - G.host.bridge.menuLaunch(C.MENU_GLOBAL, ("groups", "bookmarks"), + G.host.bridge.menu_launch(C.MENU_GLOBAL, ("groups", "bookmarks"), {}, C.NO_SECURITY_LIMIT, self.chat.profile, callback=partial( - G.host.actionManager, profile=self.chat.profile), + G.host.action_manager, profile=self.chat.profile), errback=G.host.errback) elif menu == 'close': if self.chat.type == C.CHAT_GROUP: # for MUC, we have to indicate the backend that we've left - G.host.bridge.mucLeave(self.chat.target, self.chat.profile) + G.host.bridge.muc_leave(self.chat.target, self.chat.profile) else: # for one2one, backend doesn't keep any state, so we just delete the # widget here in the frontend - G.host.widgets.deleteWidget( + G.host.widgets.delete_widget( self.chat, all_instances=True, explicit_close=True) else: raise exceptions.InternalError("Unknown menu: {}".format(menu)) @@ -474,7 +474,7 @@ super(EncryptionMainButton, self).__init__(**kwargs) self.bind(on_release=self.encryption_menu.open) - def selectAlgo(self, name): + def select_algo(self, name): """Mark an encryption algorithm as selected. This will also deselect all other button @@ -486,7 +486,7 @@ for button in buttons[:-1]: button.selected = button.text == name - def getColor(self): + def get_color(self): if self.chat.otr_state_encryption == OTR_STATE_UNENCRYPTED: return (0.4, 0.4, 0.4, 1) elif self.chat.otr_state_trust == OTR_STATE_TRUSTED: @@ -494,7 +494,7 @@ else: return (0.4, 0.4, 0.4, 1) - def getSymbol(self): + def get_symbol(self): if self.chat.otr_state_encryption == OTR_STATE_UNENCRYPTED: return 'lock-open' elif self.chat.otr_state_trust == OTR_STATE_TRUSTED: @@ -557,83 +557,83 @@ trust_button=True, ) btn.bind( - on_release=partial(self.startEncryption, plugin=plugin), - on_trust_release=partial(self.getTrustUI, plugin=plugin), + on_release=partial(self.start_encryption, plugin=plugin), + on_trust_release=partial(self.get_trust_ui, plugin=plugin), ) self.add_widget(btn) log.info("added encryption: {}".format(plugin['name'])) - def messageEncryptionStopCb(self): + def message_encryption_stop_cb(self): log.info(_("Session with {destinee} is now in plain text").format( destinee = self.chat.target)) - def messageEncryptionStopEb(self, failure_): + def message_encryption_stop_eb(self, failure_): msg = _("Error while stopping encryption with {destinee}: {reason}").format( destinee = self.chat.target, reason = failure_) log.warning(msg) - G.host.addNote(_("encryption problem"), msg, C.XMLUI_DATA_LVL_ERROR) + G.host.add_note(_("encryption problem"), msg, C.XMLUI_DATA_LVL_ERROR) def unencrypted(self, button): self.dismiss() - G.host.bridge.messageEncryptionStop( + G.host.bridge.message_encryption_stop( str(self.chat.target), self.chat.profile, - callback=self.messageEncryptionStopCb, - errback=self.messageEncryptionStopEb) + callback=self.message_encryption_stop_cb, + errback=self.message_encryption_stop_eb) - def messageEncryptionStartCb(self, plugin): + def message_encryption_start_cb(self, plugin): log.info(_("Session with {destinee} is now encrypted with {encr_name}").format( destinee = self.chat.target, encr_name = plugin['name'])) - def messageEncryptionStartEb(self, failure_): + def message_encryption_start_eb(self, failure_): msg = _("Session can't be encrypted with {destinee}: {reason}").format( destinee = self.chat.target, reason = failure_) log.warning(msg) - G.host.addNote(_("encryption problem"), msg, C.XMLUI_DATA_LVL_ERROR) + G.host.add_note(_("encryption problem"), msg, C.XMLUI_DATA_LVL_ERROR) - def startEncryption(self, button, plugin): + def start_encryption(self, button, plugin): """Request encryption with given plugin for this session @param button(EncryptionButton): button which has been pressed @param plugin(dict): plugin data """ self.dismiss() - G.host.bridge.messageEncryptionStart( + G.host.bridge.message_encryption_start( str(self.chat.target), plugin['namespace'], True, self.chat.profile, - callback=partial(self.messageEncryptionStartCb, plugin=plugin), - errback=self.messageEncryptionStartEb) + callback=partial(self.message_encryption_start_cb, plugin=plugin), + errback=self.message_encryption_start_eb) - def encryptionTrustUIGetCb(self, xmlui_raw): + def encryption_trust_ui_get_cb(self, xmlui_raw): xml_ui = xmlui.create( G.host, xmlui_raw, profile=self.chat.profile) xml_ui.show() - def encryptionTrustUIGetEb(self, failure_): + def encryption_trust_ui_get_eb(self, failure_): msg = _("Trust manager interface can't be retrieved: {reason}").format( reason = failure_) log.warning(msg) - G.host.addNote(_("encryption trust management problem"), msg, + G.host.add_note(_("encryption trust management problem"), msg, C.XMLUI_DATA_LVL_ERROR) - def getTrustUI(self, button, plugin): + def get_trust_ui(self, button, plugin): """Request and display trust management UI @param button(EncryptionButton): button which has been pressed @param plugin(dict): plugin data """ self.dismiss() - G.host.bridge.encryptionTrustUIGet( + G.host.bridge.encryption_trust_ui_get( str(self.chat.target), plugin['namespace'], self.chat.profile, - callback=self.encryptionTrustUIGetCb, - errback=self.encryptionTrustUIGetEb) + callback=self.encryption_trust_ui_get_cb, + errback=self.encryption_trust_ui_get_eb) class Chat(quick_chat.QuickChat, cagou_widget.CagouWidget): @@ -663,21 +663,21 @@ self._hi_comp_allowed = True cagou_widget.CagouWidget.__init__(self) transfer_btn = TransferButton(chat=self) - self.headerInputAddExtra(transfer_btn) + self.header_input_add_extra(transfer_btn) if (type_ == C.CHAT_ONE2ONE or "REALJID_PUBLIC" in statuses): self.encryption_btn = EncryptionMainButton(self) - self.headerInputAddExtra(self.encryption_btn) + self.header_input_add_extra(self.encryption_btn) self.extra_menu = ExtraMenu(chat=self) extra_btn = ExtraButton(chat=self) - self.headerInputAddExtra(extra_btn) + self.header_input_add_extra(extra_btn) self.header_input.hint_text = target self._history_prepend_lock = False self.history_count = 0 def on_kv_post(self, __): - self.postInit() + self.post_init() - def screenManagerInit(self, screen_manager): + def screen_manager_init(self, screen_manager): screen_manager.transition = screenmanager.SlideTransition(direction='down') sel_screen = Screen(name='chat_selector') chat_selector = ChatSelector(profile=self.profile) @@ -705,8 +705,8 @@ target = G.host.profiles[profiles[0]].whoami else: show_chat_selector = False - wid = G.host.widgets.getOrCreateWidget(cls, target, on_new_widget=None, - on_existing_widget=G.host.getOrClone, + wid = G.host.widgets.get_or_create_widget(cls, target, on_new_widget=None, + on_existing_widget=G.host.get_or_clone, profiles=profiles) wid.show_chat_selector = show_chat_selector return wid @@ -727,21 +727,21 @@ ## drop ## def on_drop_file(self, path): - self.addAttachment(path) + self.add_attachment(path) ## header ## - def changeWidget(self, jid_): + def change_widget(self, jid_): """change current widget for a new one with given jid @param jid_(jid.JID): jid of the widget to create """ - plugin_info = G.host.getPluginInfo(main=Chat) + plugin_info = G.host.get_plugin_info(main=Chat) factory = plugin_info['factory'] - G.host.switchWidget(self, factory(plugin_info, jid_, profiles=[self.profile])) + G.host.switch_widget(self, factory(plugin_info, jid_, profiles=[self.profile])) self.header_input.text = '' - def onHeaderInput(self): + def on_header_wid_input(self): text = self.header_input.text.strip() try: if text.count('@') != 1 or text.count(' '): @@ -751,31 +751,31 @@ log.info("entered text is not a jid") return - def discoCb(disco): + def disco_cb(disco): # TODO: check if plugin XEP-0045 is activated if "conference" in [i[0] for i in disco[1]]: - G.host.bridge.mucJoin(str(jid_), "", "", self.profile, - callback=self._mucJoinCb, errback=self._mucJoinEb) + G.host.bridge.muc_join(str(jid_), "", "", self.profile, + callback=self._muc_join_cb, errback=self._muc_join_eb) else: - self.changeWidget(jid_) + self.change_widget(jid_) - def discoEb(failure): + def disco_eb(failure): log.warning("Disco failure, ignore this text: {}".format(failure)) - G.host.bridge.discoInfos( + G.host.bridge.disco_infos( jid_.domain, profile_key=self.profile, - callback=discoCb, - errback=discoEb) + callback=disco_cb, + errback=disco_eb) - def onHeaderInputCompleted(self, input_wid, completed_text): + def on_header_wid_input_completed(self, input_wid, completed_text): self._hi_comp_allowed = False input_wid.text = completed_text self._hi_comp_allowed = True self._hi_comp_dropdown.dismiss() - self.onHeaderInput() + self.on_header_wid_input() - def onHeaderInputComplete(self, wid, text): + def on_header_wid_input_complete(self, wid, text): if not self._hi_comp_allowed: return text = text.lstrip() @@ -813,7 +813,7 @@ profile = profile, size_hint = (0.5, None), nick = nick, - on_release=lambda __, txt=jid_.bare: self.onHeaderInputCompleted(wid, txt) + on_release=lambda __, txt=jid_.bare: self.on_header_wid_input_completed(wid, txt) ) dropdown.add_widget(btn) else: @@ -828,17 +828,17 @@ dropdown.open(wid) self._hi_comp_last = text - def messageDataConverter(self, idx, mess_id): + def message_data_converter(self, idx, mess_id): return {"mess_data": self.messages[mess_id]} - def _onHistoryPrinted(self): + def _on_history_printed(self): """Refresh or scroll down the focus after the history is printed""" # self.adapter.data = self.messages for mess_data in self.messages.values(): self.appendMessage(mess_data) - super(Chat, self)._onHistoryPrinted() + super(Chat, self)._on_history_printed() - def createMessage(self, message): + def create_message(self, message): self.appendMessage(message) # we need to render immediatly next 2 layouts to avoid an unpleasant flickering # when sending or receiving a message @@ -849,12 +849,12 @@ @param mess_data(quick_chat.Message): message data """ - if self.handleUserMoved(mess_data): + if self.handle_user_moved(mess_data): return self.messages_widget.add_widget(MessageWidget(mess_data=mess_data)) self.notify(mess_data) - def prependMessage(self, mess_data): + def prepend_message(self, mess_data): """Prepend a message Widget to the history @param mess_data(quick_chat.Message): message data @@ -877,7 +877,7 @@ For group chat, note will be added on mention, with a desktop notification if window has not focus or is not visible. """ - visible_clones = [w for w in G.host.getVisibleList(self.__class__) + visible_clones = [w for w in G.host.get_visible_list(self.__class__) if w.target == self.target] if len(visible_clones) > 1 and visible_clones.index(self) > 0: # to avoid multiple notifications in case of multiple cloned widgets @@ -896,7 +896,7 @@ profile=self.profile ) if not is_visible: - G.host.addNote( + G.host.add_note( _("private message"), notif_msg, symbol = "chat", @@ -908,7 +908,7 @@ else: if mess_data.mention: notif_msg = self._get_notif_msg(mess_data) - G.host.addNote( + G.host.add_note( _("mention"), notif_msg, symbol = "chat", @@ -930,19 +930,19 @@ # message input - def _attachmentProgressCb(self, item, metadata, profile): + def _attachment_progress_cb(self, item, metadata, profile): item.parent.remove_widget(item) log.info(f"item {item.data.get('path')} uploaded successfully") - def _attachmentProgressEb(self, item, err_msg, profile): + def _attachment_progress_eb(self, item, err_msg, profile): item.parent.remove_widget(item) path = item.data.get('path') msg = _("item {path} could not be uploaded: {err_msg}").format( path=path, err_msg=err_msg) - G.host.addNote(_("can't upload file"), msg, C.XMLUI_DATA_LVL_WARNING) + G.host.add_note(_("can't upload file"), msg, C.XMLUI_DATA_LVL_WARNING) log.warning(msg) - def _progressGetCb(self, item, metadata): + def _progress_get_cb(self, item, metadata): try: position = int(metadata["position"]) size = int(metadata["size"]) @@ -960,23 +960,23 @@ if item.parent is not None: # the item is not yet fully received, we reschedule an update Clock.schedule_once( - partial(self._attachmentProgressUpdate, item), + partial(self._attachment_progress_update, item), PROGRESS_UPDATE) - def _attachmentProgressUpdate(self, item, __): - G.host.bridge.progressGet( + def _attachment_progress_update(self, item, __): + G.host.bridge.progress_get( item.data["progress_id"], self.profile, - callback=partial(self._progressGetCb, item), + callback=partial(self._progress_get_cb, item), errback=G.host.errback, ) - def addNick(self, nick): + def add_nick(self, nick): """Add a nickname to message_input if suitable""" if (self.type == C.CHAT_GROUP and not self.message_input.text.startswith(nick)): self.message_input.text = f'{nick}: {self.message_input.text}' - def onSend(self, input_widget): + def on_send(self, input_widget): extra = {} for item in self.attachments_to_send.attachments.children: if item.sending: @@ -999,17 +999,17 @@ attachments.append(attachment) Clock.schedule_once( - partial(self._attachmentProgressUpdate, item), + partial(self._attachment_progress_update, item), PROGRESS_UPDATE) - G.host.registerProgressCbs( + G.host.register_progress_cbs( progress_id, - callback=partial(self._attachmentProgressCb, item), - errback=partial(self._attachmentProgressEb, item) + callback=partial(self._attachment_progress_cb, item), + errback=partial(self._attachment_progress_eb, item) ) - G.host.messageSend( + G.host.message_send( self.target, # TODO: handle language {'': input_widget.text}, @@ -1021,13 +1021,13 @@ ) input_widget.text = '' - def _imageCheckCb(self, report_raw): + def _image_check_cb(self, report_raw): report = data_format.deserialise(report_raw) if report['too_large']: self.attachments_to_send.show_resize=True self.attachments_to_send.reduce_checkbox.active=True - def addAttachment(self, file_path, media_type=None): + def add_attachment(self, file_path, media_type=None): file_path = Path(file_path) if media_type is None: media_type = mimetypes.guess_type(str(file_path), strict=False)[0] @@ -1037,9 +1037,9 @@ # default. main_type = media_type.split('/')[0] if main_type == "image": - G.host.bridge.imageCheck( + G.host.bridge.image_check( str(file_path), - callback=self._imageCheckCb, + callback=self._image_check_cb, errback=partial( G.host.errback, title=_("Can't check image size"), @@ -1060,10 +1060,10 @@ AttachmentToSendItem(data=data) ) - def transferFile(self, file_path, transfer_type=C.TRANSFER_UPLOAD, cleaning_cb=None): + def transfer_file(self, file_path, transfer_type=C.TRANSFER_UPLOAD, cleaning_cb=None): # FIXME: cleaning_cb is not managed if transfer_type == C.TRANSFER_UPLOAD: - self.addAttachment(file_path) + self.add_attachment(file_path) elif transfer_type == C.TRANSFER_SEND: if self.type == C.CHAT_GROUP: log.warning("P2P transfer is not possible for group chat") @@ -1072,35 +1072,35 @@ else: jid_ = self.target if not jid_.resource: - jid_ = G.host.contact_lists[self.profile].getFullJid(jid_) - G.host.bridge.fileSend(str(jid_), str(file_path), "", "", "", + jid_ = G.host.contact_lists[self.profile].get_full_jid(jid_) + G.host.bridge.file_send(str(jid_), str(file_path), "", "", "", profile=self.profile) # TODO: notification of sending/failing else: raise log.error("transfer of type {} are not handled".format(transfer_type)) - def messageEncryptionStarted(self, plugin_data): - quick_chat.QuickChat.messageEncryptionStarted(self, plugin_data) + def message_encryption_started(self, plugin_data): + quick_chat.QuickChat.message_encryption_started(self, plugin_data) self.encryption_btn.symbol = SYMBOL_ENCRYPTED self.encryption_btn.color = COLOR_ENCRYPTED - self.encryption_btn.selectAlgo(plugin_data['name']) + self.encryption_btn.select_algo(plugin_data['name']) - def messageEncryptionStopped(self, plugin_data): - quick_chat.QuickChat.messageEncryptionStopped(self, plugin_data) + def message_encryption_stopped(self, plugin_data): + quick_chat.QuickChat.message_encryption_stopped(self, plugin_data) self.encryption_btn.symbol = SYMBOL_UNENCRYPTED self.encryption_btn.color = COLOR_UNENCRYPTED - self.encryption_btn.selectAlgo(None) + self.encryption_btn.select_algo(None) - def _mucJoinCb(self, joined_data): + def _muc_join_cb(self, joined_data): joined, room_jid_s, occupants, user_nick, subject, statuses, profile = joined_data - self.host.mucRoomJoinedHandler(*joined_data[1:]) + self.host.muc_room_joined_handler(*joined_data[1:]) jid_ = jid.JID(room_jid_s) - self.changeWidget(jid_) + self.change_widget(jid_) - def _mucJoinEb(self, failure): + def _muc_join_eb(self, failure): log.warning("Can't join room: {}".format(failure)) - def onOTRState(self, state, dest_jid, profile): + def on_otr_state(self, state, dest_jid, profile): assert profile in self.profiles if state in OTR_STATE_ENCRYPTION: self.otr_state_encryption = state @@ -1109,17 +1109,17 @@ else: log.error(_("Unknown OTR state received: {}".format(state))) return - self.encryption_btn.symbol = self.encryption_btn.getSymbol() - self.encryption_btn.color = self.encryption_btn.getColor() + self.encryption_btn.symbol = self.encryption_btn.get_symbol() + self.encryption_btn.color = self.encryption_btn.get_color() - def onVisible(self): + def on_visible(self): if not self.sync: self.resync() - def onSelected(self): - G.host.clearNotifs(self.target, profile=self.profile) + def on_selected(self): + G.host.clear_notifs(self.target, profile=self.profile) - def onDelete(self, **kwargs): + def on_delete(self, **kwargs): if kwargs.get('explicit_close', False): wrapper = self.whwrapper if wrapper is not None: @@ -1132,7 +1132,7 @@ return True # we always keep one widget, so it's available when swiping # TODO: delete all widgets when chat is closed - nb_instances = sum(1 for _ in self.host.widgets.getWidgetInstances(self)) + nb_instances = sum(1 for _ in self.host.widgets.get_widget_instances(self)) # we want to keep at least one instance of Chat by WHWrapper nb_to_keep = len(G.host.widgets_handler.children) if nb_instances <= nb_to_keep: @@ -1141,8 +1141,8 @@ def _history_unlock(self, __): self._history_prepend_lock = False log.debug("history prepend unlocked") - # we call manually onScroll, to check if we are still in the scrolling zone - self.onScroll(self.history_scroll, self.history_scroll.scroll_y) + # we call manually on_scroll, to check if we are still in the scrolling zone + self.on_scroll(self.history_scroll, self.history_scroll.scroll_y) def _history_scroll_adjust(self, __, scroll_start_height): # history scroll position must correspond to where it was before new messages @@ -1155,7 +1155,7 @@ # again Clock.schedule_once(self._history_unlock, 1.5) - def _backHistoryGetCb_post(self, __, history, scroll_start_height): + def _back_history_get_cb_post(self, __, history, scroll_start_height): if len(history) == 0: # we don't unlock self._history_prepend_lock if there is no history, as there # is no sense to try to retrieve more in this case. @@ -1170,8 +1170,8 @@ log.debug( f"{len(history)} messages prepended to history (last: {history[0][0]})") - def _backHistoryGetCb(self, history): - # TODO: factorise with QuickChat._historyGetCb + def _back_history_get_cb(self, history): + # TODO: factorise with QuickChat._history_get_cb scroll_start_height = self.messages_widget.height * self.history_scroll.scroll_y for data in reversed(history): uid, timestamp, from_jid, to_jid, message, subject, type_, extra_s = data @@ -1192,14 +1192,14 @@ self.profile, ) self.messages.move_to_end(uid, last=False) - self.prependMessage(message) + self.prepend_message(message) Clock.schedule_once(partial( - self._backHistoryGetCb_post, + self._back_history_get_cb_post, history=history, scroll_start_height=scroll_start_height)) - def _backHistoryGetEb(self, failure_): - G.host.addNote( + def _back_history_get_eb(self, failure_): + G.host.add_note( _("Problem while getting back history"), _("Can't back history for {target}: {problem}").format( target=self.target, problem=failure_), @@ -1207,7 +1207,7 @@ # we don't unlock self._history_prepend_lock on purpose, no need # to try to get more history if something is wrong - def onScroll(self, scroll_view, scroll_y): + def on_scroll(self, scroll_view, scroll_y): if self._history_prepend_lock: return if (1-scroll_y) * self.messages_widget.height < INFINITE_SCROLL_LIMIT: @@ -1217,15 +1217,15 @@ first_uid = next(iter(self.messages.keys())) filters = self.history_filters.copy() filters['before_uid'] = first_uid - self.host.bridge.historyGet( + self.host.bridge.history_get( str(self.host.profiles[self.profile].whoami.bare), str(self.target), 30, True, {k: str(v) for k,v in filters.items()}, self.profile, - callback=self._backHistoryGetCb, - errback=self._backHistoryGetEb, + callback=self._back_history_get_cb, + errback=self._back_history_get_eb, ) @@ -1237,7 +1237,7 @@ def on_select(self, contact_button): contact_jid = jid.JID(contact_button.jid) - plugin_info = G.host.getPluginInfo(main=Chat) + plugin_info = G.host.get_plugin_info(main=Chat) factory = plugin_info['factory'] self.screen_manager.transition.direction = 'up' carousel = self.whwrapper.carousel @@ -1248,11 +1248,11 @@ carousel.index = idx self.screen_manager.current = '' else: - G.host.switchWidget( + G.host.switch_widget( self, factory(plugin_info, contact_jid, profiles=[self.profile])) - def onHeaderInput(self): + def on_header_wid_input(self): text = self.header_input.text.strip() try: if text.count('@') != 1 or text.count(' '): @@ -1261,9 +1261,9 @@ except ValueError: log.info("entered text is not a jid") return - G.host.doAction("chat", jid_, [self.profile]) + G.host.do_action("chat", jid_, [self.profile]) - 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""" for layout in self.jid_selector.items_layouts: self.do_filter(
--- a/cagou/plugins/plugin_wid_contact_list.kv Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_wid_contact_list.kv Sat Apr 08 13:44:32 2023 +0200 @@ -37,7 +37,7 @@ size_hint: 1, None height: sp(50) text: _("add this contact") - on_release: root.addContact(contact_jid.text) + on_release: root.contact_add(contact_jid.text) Widget: @@ -87,7 +87,7 @@ SymbolButtonLabel: symbol: 'plus-circled' text: _("add a contact") - on_release: root.addContactMenu() + on_release: root.add_contact_menu() Widget: FloatLayout: id: float_layout
--- a/cagou/plugins/plugin_wid_contact_list.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_wid_contact_list.py Sat Apr 08 13:44:32 2023 +0200 @@ -56,7 +56,7 @@ log.warning(_("profile not set in AddContactMenu")) self.profile = next(iter(G.host.profiles)) - def addContact(self, contact_jid): + def contact_add(self, contact_jid): """Actually add the contact @param contact_jid(unicode): jid of the contact to add @@ -67,9 +67,9 @@ if not contact_jid or not re.match(r"[^@ ]+@[^@ ]+", contact_jid): return contact_jid = jid.JID(contact_jid).bare - G.host.bridge.addContact(str(contact_jid), + G.host.bridge.contact_add(str(contact_jid), self.profile, - callback=lambda: G.host.addNote( + callback=lambda: G.host.add_note( _("contact request"), _("a contact request has been sent to {contact_jid}").format( contact_jid=contact_jid)), @@ -88,9 +88,9 @@ def do_delete_contact(self): self.hide() - G.host.bridge.delContact(str(self.contact_item.jid.bare), + G.host.bridge.contact_del(str(self.contact_item.jid.bare), self.contact_item.profile, - callback=lambda: G.host.addNote( + callback=lambda: G.host.add_note( _("contact removed"), _("{contact_jid} has been removed from your contacts list").format( contact_jid=self.contact_item.jid.bare)), @@ -105,13 +105,13 @@ assert self.profile # XXX: for now clicking on an item launch the corresponding Chat widget # behaviour should change in the future - G.host.doAction('chat', jid.JID(self.jid), [self.profile]) + G.host.do_action('chat', jid.JID(self.jid), [self.profile]) - def getMenuChoices(self): + def get_menu_choices(self): choices = [] choices.append(dict(text=_('delete'), index=len(choices)+1, - callback=self.main_wid.removeContact)) + callback=self.main_wid.remove_contact)) return choices @@ -126,23 +126,23 @@ cagou_widget.CagouWidget.__init__(self) FilterBehavior.__init__(self) self._wid_map = {} # (profile, bare_jid) to widget map - self.postInit() + self.post_init() if len(self.profiles) != 1: raise NotImplementedError('multi profiles is not implemented yet') self.update(profile=next(iter(self.profiles))) - def addContactMenu(self): + def add_contact_menu(self): """Show the "add a contact" menu""" # FIXME: for now we add contact to the first profile we find profile = next(iter(self.profiles)) AddContactMenu(profile=profile).show() - def removeContact(self, menu_label): + def remove_contact(self, menu_label): item = self.menu_item self.clear_menu() DelContactMenu(contact_item=item).show() - def onHeaderInputComplete(self, wid, text): + def on_header_wid_input_complete(self, wid, text): self.do_filter(self.layout, text, lambda c: c.jid, @@ -150,14 +150,14 @@ height_cb=lambda c: c.minimum_height, ) - def _addContactItem(self, bare_jid, profile): + def _add_contact_item(self, bare_jid, profile): """Create a new CLContactItem instance, and add it item will be added in a sorted position @param bare_jid(jid.JID): entity bare JID @param profile(unicode): profile where the contact is """ - data = G.host.contact_lists[profile].getItem(bare_jid) + data = G.host.contact_lists[profile].get_item(bare_jid) wid = CLContactItem(profile=profile, data=data, jid=bare_jid, main_wid=self) child_jids = [c.jid for c in reversed(self.layout.children)] idx = bisect.bisect_right(child_jids, bare_jid) @@ -182,10 +182,10 @@ for entity in entities: entity_bare = entity.bare wid = self._wid_map[(profile, entity_bare)] - wid.data = G.host.contact_lists[profile].getItem(entity_bare) + wid.data = G.host.contact_lists[profile].get_item(entity_bare) elif type_ == C.UPDATE_ADD: for entity in entities: - self._addContactItem(entity.bare, profile) + self._add_contact_item(entity.bare, profile) elif type_ == C.UPDATE_DELETE: for entity in entities: try:
--- 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:
--- a/cagou/plugins/plugin_wid_remote.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_wid_remote.py Sat Apr 08 13:44:32 2023 +0200 @@ -75,7 +75,7 @@ def profile(self): return self.main_wid.profile - def updateUI(self, action_data): + def update_ui(self, action_data): xmlui_raw = action_data['xmlui'] ui_tpl = template_xmlui.create(G.host, xmlui_raw) self.ui_tpl = ui_tpl @@ -92,33 +92,33 @@ elif playback_status == "Stopped": self.status = "play" else: - G.host.addNote( + G.host.add_note( title=NOTE_TITLE, message=_("Unknown playback status: playback_status") .format(playback_status=playback_status), level=C.XMLUI_DATA_LVL_WARNING) self.commands = {v:k for k,v in ui_tpl.widgets['command'].options} - def adHocRunCb(self, xmlui_raw): + def ad_hoc_run_cb(self, xmlui_raw): ui_tpl = template_xmlui.create(G.host, xmlui_raw) data = {xmlui.XMLUIPanel.escape("media_player"): self.remote_item.node, "session_id": ui_tpl.session_id} - G.host.bridge.launchAction( + G.host.bridge.action_launch( ui_tpl.submit_id, data, self.profile, - callback=self.updateUI, + callback=self.update_ui, errback=self.main_wid.errback) def on_remote_item(self, __, remote): NS_MEDIA_PLAYER = G.host.ns_map["mediaplayer"] - G.host.bridge.adHocRun(str(remote.device_jid), NS_MEDIA_PLAYER, self.profile, - callback=self.adHocRunCb, + G.host.bridge.ad_hoc_run(str(remote.device_jid), NS_MEDIA_PLAYER, self.profile, + callback=self.ad_hoc_run_cb, errback=self.main_wid.errback) def do_cmd(self, command): try: cmd_value = self.commands[command] except KeyError: - G.host.addNote( + G.host.add_note( title=NOTE_TITLE, message=_("{command} command is not managed").format(command=command), level=C.XMLUI_DATA_LVL_WARNING) @@ -130,44 +130,44 @@ hidden = {xmlui.XMLUIPanel.escape(k):v for k,v in self.ui_tpl.hidden.items()} data.update(hidden) - G.host.bridge.launchAction( + G.host.bridge.action_launch( self.ui_tpl.submit_id, data, self.profile, - callback=self.updateUI, + callback=self.update_ui, errback=self.main_wid.errback) class RemoteDeviceWidget(DeviceWidget): - def xmluiCb(self, data, cb_id, profile): + def xmlui_cb(self, data, cb_id, profile): if 'xmlui' in data: xml_ui = xmlui.create( - G.host, data['xmlui'], callback=self.xmluiCb, profile=profile) + G.host, data['xmlui'], callback=self.xmlui_cb, profile=profile) if isinstance(xml_ui, xmlui.XMLUIDialog): - self.main_wid.showRootWidget() + self.main_wid.show_root_widget() xml_ui.show() else: - xml_ui.setCloseCb(self.onClose) + xml_ui.set_close_cb(self.on_close) self.main_wid.layout.add_widget(xml_ui) else: if data: log.warning(_("Unhandled data: {data}").format(data=data)) - self.main_wid.showRootWidget() + self.main_wid.show_root_widget() - def onClose(self, __, reason): + def on_close(self, __, reason): if reason == C.XMLUI_DATA_CANCELLED: - self.main_wid.showRootWidget() + self.main_wid.show_root_widget() else: self.main_wid.layout.clear_widgets() - def adHocRunCb(self, data): - xml_ui = xmlui.create(G.host, data, callback=self.xmluiCb, profile=self.profile) - xml_ui.setCloseCb(self.onClose) + def ad_hoc_run_cb(self, data): + xml_ui = xmlui.create(G.host, data, callback=self.xmlui_cb, profile=self.profile) + xml_ui.set_close_cb(self.on_close) self.main_wid.layout.add_widget(xml_ui) def do_item_action(self, touch): self.main_wid.layout.clear_widgets() - G.host.bridge.adHocRun(str(self.entity_jid), '', self.profile, - callback=self.adHocRunCb, errback=self.main_wid.errback) + G.host.bridge.ad_hoc_run(str(self.entity_jid), '', self.profile, + callback=self.ad_hoc_run_cb, errback=self.main_wid.errback) class DevicesLayout(FloatLayout): @@ -186,22 +186,22 @@ FilterBehavior.__init__(self) TouchMenuBehavior.__init__(self) self.stack_layout = None - self.showRootWidget() + self.show_root_widget() def errback(self, failure_): """Generic errback which add a warning note and go back to root widget""" - G.host.addNote( + G.host.add_note( title=NOTE_TITLE, message=_("Can't use remote control: {reason}").format(reason=failure_), level=C.XMLUI_DATA_LVL_WARNING) - self.showRootWidget() + self.show_root_widget() def key_input(self, window, key, scancode, codepoint, modifier): if key == 27: - self.showRootWidget() + self.show_root_widget() return True - def showRootWidget(self): + def show_root_widget(self): self.layout.clear_widgets() devices_layout = DevicesLayout() self.stack_layout = devices_layout.layout @@ -210,12 +210,12 @@ self.get_remotes(found) self.discover_devices(found) - def adHocRemotesGetCb(self, remotes_data, found): + def ad_hoc_remotes_get_cb(self, remotes_data, found): found.insert(0, remotes_data) if len(found) == 2: self.show_devices(found) - def adHocRemotesGetEb(self, failure_, found): + def ad_hoc_remotes_get_eb(self, failure_, found): G.host.errback(failure_, title=_("discovery error"), message=_("can't check remote controllers: {msg}")) found.insert(0, []) @@ -223,17 +223,17 @@ self.show_devices(found) def get_remotes(self, found): - self.host.bridge.adHocRemotesGet( + self.host.bridge.ad_hoc_remotes_get( self.profile, - callback=partial(self.adHocRemotesGetCb, found=found), - errback=partial(self.adHocRemotesGetEb,found=found)) + callback=partial(self.ad_hoc_remotes_get_cb, found=found), + errback=partial(self.ad_hoc_remotes_get_eb,found=found)) - def _discoFindByFeaturesCb(self, data, found): + def _disco_find_by_features_cb(self, data, found): found.append(data) if len(found) == 2: self.show_devices(found) - def _discoFindByFeaturesEb(self, failure_, found): + def _disco_find_by_features_eb(self, failure_, found): G.host.errback(failure_, title=_("discovery error"), message=_("can't check devices: {msg}")) found.append(({}, {}, {})) @@ -247,12 +247,12 @@ except KeyError: msg = _("can't find ad-hoc commands 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=partial(self._discoFindByFeaturesCb, found=found), - errback=partial(self._discoFindByFeaturesEb, found=found)) + callback=partial(self._disco_find_by_features_cb, found=found), + errback=partial(self._disco_find_by_features_eb, found=found)) def show_devices(self, found): remotes_data, (entities_services, entities_own, entities_roster) = found
--- a/cagou/plugins/plugin_wid_settings.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_wid_settings.py Sat Apr 08 13:44:32 2023 +0200 @@ -52,23 +52,23 @@ self.loading_widget = Widget() self.add_widget(self.loading_widget) extra = {} - G.local_platform.updateParamsExtra(extra) - G.host.bridge.getParamsUI( + G.local_platform.update_params_extra(extra) + G.host.bridge.param_ui_get( -1, C.APP_NAME, data_format.serialise(extra), self.profile, - callback=self.getParamsUICb, - errback=self.getParamsUIEb) + callback=self.get_params_ui_cb, + errback=self.get_params_ui_eb) - def changeWidget(self, widget): + def change_widget(self, widget): self.clear_widgets([self.loading_widget]) del self.loading_widget self.add_widget(widget) - def getParamsUICb(self, xmlui): - G.host.actionManager({"xmlui": xmlui}, ui_show_cb=self.changeWidget, profile=self.profile) + def get_params_ui_cb(self, xmlui): + G.host.action_manager({"xmlui": xmlui}, ui_show_cb=self.change_widget, profile=self.profile) - def getParamsUIEb(self, failure): - self.changeWidget(Label( + def get_params_ui_eb(self, failure): + self.change_widget(Label( text=_("Can't load parameters!"), bold=True, color=(1,0,0,1))) - G.host.showDialog("Can't load params UI", str(failure), "error") + G.host.show_dialog("Can't load params UI", str(failure), "error")
--- a/cagou/plugins/plugin_wid_widget_selector.py Sat Apr 08 13:34:55 2023 +0200 +++ b/cagou/plugins/plugin_wid_widget_selector.py Sat Apr 08 13:44:32 2023 +0200 @@ -45,7 +45,7 @@ def on_release(self, *args): log.debug("widget selection: {}".format(self.plugin_info["name"])) factory = self.plugin_info["factory"] - G.host.switchWidget( + G.host.switch_widget( self, factory(self.plugin_info, None, profiles=iter(G.host.profiles))) @@ -55,7 +55,7 @@ def __init__(self): super(WidgetSelector, self).__init__() self.items = [] - for plugin_info in G.host.getPluggedWidgets(except_cls=self.__class__): + for plugin_info in G.host.get_plugged_widgets(except_cls=self.__class__): item = WidgetSelItem(plugin_info=plugin_info) self.items.append(item.item) item.item.bind(minimum_width=self.adjust_width)
--- a/service/main.py Sat Apr 08 13:34:55 2023 +0200 +++ b/service/main.py Sat Apr 08 13:44:32 2023 +0200 @@ -24,7 +24,7 @@ from sat.core.constants import Const as C from sat.core import log_config # SàT log conf must be done before calling Kivy -log_config.satConfigure(C.LOG_BACKEND_STANDARD, C) +log_config.sat_configure(C.LOG_BACKEND_STANDARD, C) # if this module is called, we should be on android, # but just in case... from kivy import utils as kivy_utils