Philipp Hörist pushed to branch master at gajim / gajim
Commits: 573af5cd by Philipp Hörist at 2019-08-17T20:02:09Z Remove obsolete code
- - - - - 6b010672 by Philipp Hörist at 2019-08-17T20:20:43Z Update MUC name on disco update
- Update name in Roster - Update name in MessageWindow - Update name in GroupchatControl
- - - - - d800ca8e by Philipp Hörist at 2019-08-17T20:24:15Z Discovery: Make callback default to None
If disco_muc is called without callback, user_data is None. If user_data is None, nbxmpp does not pass it as argument to the callback
- - - - -
7 changed files:
- gajim/common/contacts.py - gajim/common/events.py - gajim/common/modules/discovery.py - gajim/groupchat_control.py - gajim/message_window.py - gajim/roster_window.py - test/no_gui/unit/test_contacts.py
Changes:
===================================== gajim/common/contacts.py ===================================== @@ -301,13 +301,6 @@ class LegacyContactsAPI: self._metacontact_manager = MetacontactManager(self) self._accounts = {}
- def change_account_name(self, old_name, new_name): - self._accounts[new_name] = self._accounts[old_name] - self._accounts[new_name].name = new_name - del self._accounts[old_name] - - self._metacontact_manager.change_account_name(old_name, new_name) - def add_account(self, account_name): self._accounts[account_name] = Account(account_name, Contacts(), GC_Contacts()) @@ -779,10 +772,6 @@ class MetacontactManager(): self._metacontacts_tags = {} self._contacts = contacts
- def change_account_name(self, old_name, new_name): - self._metacontacts_tags[new_name] = self._metacontacts_tags[old_name] - del self._metacontacts_tags[old_name] - def add_account(self, account): if account not in self._metacontacts_tags: self._metacontacts_tags[account] = {}
===================================== gajim/common/events.py ===================================== @@ -215,11 +215,6 @@ class Events: for listener in self._event_removed_listeners: listener(event_list)
- def change_account_name(self, old_name, new_name): - if old_name in self._events: - self._events[new_name] = self._events[old_name] - del self._events[old_name] - def add_account(self, account): self._events[account] = {}
===================================== gajim/common/modules/discovery.py ===================================== @@ -206,7 +206,7 @@ class Discovery(BaseModule): callback=self._muc_info_received, user_data=callback)
- def _muc_info_received(self, result, callback): + def _muc_info_received(self, result, callback=None): self._log.info('MUC info received: %s', result.jid) if not is_error_result(result): app.logger.set_last_disco_info(result.jid, result)
===================================== gajim/groupchat_control.py ===================================== @@ -642,6 +642,7 @@ class GroupchatControl(ChatControlBase): return win = self.parent_win.window self.update_actions() + self.draw_banner_text()
# After the room has been created, reevaluate threshold if self.disco_info.has_mam:
===================================== gajim/message_window.py ===================================== @@ -33,6 +33,7 @@ from gi.repository import Gio
from gajim import common from gajim.common import app +from gajim.common import ged from gajim.common.i18n import Q_ from gajim.common.i18n import _
@@ -153,6 +154,9 @@ class MessageWindow: self.notebook.set_show_border(app.config.get('tabs_border')) self.show_icon()
+ app.ged.register_event_handler('muc-disco-update', ged.GUI1, + self._on_muc_disco_update) + def _add_actions(self): actions = [ ('change-nickname', ['<Control><Shift>n']), @@ -269,17 +273,6 @@ class MessageWindow: self.notebook.set_current_page(number - 1) return
- def change_account_name(self, old_name, new_name): - if old_name in self._controls: - self._controls[new_name] = self._controls[old_name] - del self._controls[old_name] - - for ctrl in self.controls(): - if ctrl.account == old_name: - ctrl.account = new_name - if self.account == old_name: - self.account = new_name - def change_jid(self, account, old_jid, new_jid): """ Called when the full jid of the control is changed @@ -299,6 +292,16 @@ class MessageWindow: def resize(self, width, height): resize_window(self.window, width, height)
+ def _on_muc_disco_update(self, event): + # If there is only one control in a window, + # the name is shown in the window title + if self.get_num_controls() != 1: + return + ctrl = self.get_active_control() + if ctrl.contact.jid != event.room_jid: + return + self.show_title() + def _on_window_focus(self, widget, event): # on destroy() the window that was last focused gets the focus # again. if destroy() is called from the StartChat Dialog, this @@ -500,7 +503,7 @@ class MessageWindow: urgent = False
if control.type_id == message_control.TYPE_GC: - name = control.room_jid.split('@')[0] + name = control.contact.get_shown_name() urgent = (control.attention_flag or app.config.notify_for_muc(control.room_jid)) else: @@ -905,10 +908,6 @@ class MessageWindowMgr(GObject.GObject):
Gtk.Window.set_default_icon_list(get_app_icon_list(parent_window))
- def change_account_name(self, old_name, new_name): - for win in self.windows(): - win.change_account_name(old_name, new_name) - def _new_window(self, acct, type_): parent_win = None parent_paned = None
===================================== gajim/roster_window.py ===================================== @@ -2635,6 +2635,9 @@ class RosterWindow: def _nec_muc_subject_received(self, event): self.draw_contact(event.room_jid, event.account)
+ def _on_muc_disco_update(self, event): + self.draw_contact(str(event.room_jid), event.account) + def _nec_metacontacts_received(self, obj): self.redraw_metacontacts(obj.conn.name)
@@ -5679,3 +5682,5 @@ class RosterWindow: self._style_changed) app.ged.register_event_handler('chatstate-received', ged.GUI1, self._nec_chatstate_received) + app.ged.register_event_handler('muc-disco-update', ged.GUI1, + self._on_muc_disco_update)
===================================== test/no_gui/unit/test_contacts.py ===================================== @@ -99,7 +99,6 @@ class TestContacts(unittest.TestCase): self.contacts.add_account("one") self.contacts.add_account("two")
- self.contacts.change_account_name("two", "old") self.contacts.remove_account("one")
self.assertEqual(["old"], self.contacts.get_accounts())
View it on GitLab: https://dev.gajim.org/gajim/gajim/compare/1a5395cf6f71269af9c22436a67965e2ff...