Mercurial > libervia-desktop-kivy
diff cagou/plugins/plugin_wid_contact_list.py @ 491:203755bbe0fe
massive refactoring from camelCase -> snake_case. See backend commit log for more details
author | Goffi <goffi@goffi.org> |
---|---|
date | Sat, 08 Apr 2023 13:44:32 +0200 |
parents | 3c9ba4a694ef |
children |
line wrap: on
line diff
--- a/cagou/plugins/plugin_wid_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: