Philipp Hörist pushed to branch master at gajim / gajim

Commits:

7 changed files:

Changes:

  • gajim/common/contacts.py
    ... ... @@ -301,13 +301,6 @@ class LegacyContactsAPI:
    301 301
             self._metacontact_manager = MetacontactManager(self)
    
    302 302
             self._accounts = {}
    
    303 303
     
    
    304
    -    def change_account_name(self, old_name, new_name):
    
    305
    -        self._accounts[new_name] = self._accounts[old_name]
    
    306
    -        self._accounts[new_name].name = new_name
    
    307
    -        del self._accounts[old_name]
    
    308
    -
    
    309
    -        self._metacontact_manager.change_account_name(old_name, new_name)
    
    310
    -
    
    311 304
         def add_account(self, account_name):
    
    312 305
             self._accounts[account_name] = Account(account_name, Contacts(),
    
    313 306
                     GC_Contacts())
    
    ... ... @@ -779,10 +772,6 @@ class MetacontactManager():
    779 772
             self._metacontacts_tags = {}
    
    780 773
             self._contacts = contacts
    
    781 774
     
    
    782
    -    def change_account_name(self, old_name, new_name):
    
    783
    -        self._metacontacts_tags[new_name] = self._metacontacts_tags[old_name]
    
    784
    -        del self._metacontacts_tags[old_name]
    
    785
    -
    
    786 775
         def add_account(self, account):
    
    787 776
             if account not in self._metacontacts_tags:
    
    788 777
                 self._metacontacts_tags[account] = {}
    

  • gajim/common/events.py
    ... ... @@ -215,11 +215,6 @@ class Events:
    215 215
             for listener in self._event_removed_listeners:
    
    216 216
                 listener(event_list)
    
    217 217
     
    
    218
    -    def change_account_name(self, old_name, new_name):
    
    219
    -        if old_name in self._events:
    
    220
    -            self._events[new_name] = self._events[old_name]
    
    221
    -            del self._events[old_name]
    
    222
    -
    
    223 218
         def add_account(self, account):
    
    224 219
             self._events[account] = {}
    
    225 220
     
    

  • gajim/common/modules/discovery.py
    ... ... @@ -206,7 +206,7 @@ class Discovery(BaseModule):
    206 206
                             callback=self._muc_info_received,
    
    207 207
                             user_data=callback)
    
    208 208
     
    
    209
    -    def _muc_info_received(self, result, callback):
    
    209
    +    def _muc_info_received(self, result, callback=None):
    
    210 210
             self._log.info('MUC info received: %s', result.jid)
    
    211 211
             if not is_error_result(result):
    
    212 212
                 app.logger.set_last_disco_info(result.jid, result)
    

  • gajim/groupchat_control.py
    ... ... @@ -642,6 +642,7 @@ class GroupchatControl(ChatControlBase):
    642 642
                 return
    
    643 643
             win = self.parent_win.window
    
    644 644
             self.update_actions()
    
    645
    +        self.draw_banner_text()
    
    645 646
     
    
    646 647
             # After the room has been created, reevaluate threshold
    
    647 648
             if self.disco_info.has_mam:
    

  • gajim/message_window.py
    ... ... @@ -33,6 +33,7 @@ from gi.repository import Gio
    33 33
     
    
    34 34
     from gajim import common
    
    35 35
     from gajim.common import app
    
    36
    +from gajim.common import ged
    
    36 37
     from gajim.common.i18n import Q_
    
    37 38
     from gajim.common.i18n import _
    
    38 39
     
    
    ... ... @@ -153,6 +154,9 @@ class MessageWindow:
    153 154
             self.notebook.set_show_border(app.config.get('tabs_border'))
    
    154 155
             self.show_icon()
    
    155 156
     
    
    157
    +        app.ged.register_event_handler('muc-disco-update', ged.GUI1,
    
    158
    +                                       self._on_muc_disco_update)
    
    159
    +
    
    156 160
         def _add_actions(self):
    
    157 161
             actions = [
    
    158 162
                 ('change-nickname', ['<Control><Shift>n']),
    
    ... ... @@ -269,17 +273,6 @@ class MessageWindow:
    269 273
                 self.notebook.set_current_page(number - 1)
    
    270 274
                 return
    
    271 275
     
    
    272
    -    def change_account_name(self, old_name, new_name):
    
    273
    -        if old_name in self._controls:
    
    274
    -            self._controls[new_name] = self._controls[old_name]
    
    275
    -            del self._controls[old_name]
    
    276
    -
    
    277
    -        for ctrl in self.controls():
    
    278
    -            if ctrl.account == old_name:
    
    279
    -                ctrl.account = new_name
    
    280
    -        if self.account == old_name:
    
    281
    -            self.account = new_name
    
    282
    -
    
    283 276
         def change_jid(self, account, old_jid, new_jid):
    
    284 277
             """
    
    285 278
             Called when the full jid of the control is changed
    
    ... ... @@ -299,6 +292,16 @@ class MessageWindow:
    299 292
         def resize(self, width, height):
    
    300 293
             resize_window(self.window, width, height)
    
    301 294
     
    
    295
    +    def _on_muc_disco_update(self, event):
    
    296
    +        # If there is only one control in a window,
    
    297
    +        # the name is shown in the window title
    
    298
    +        if self.get_num_controls() != 1:
    
    299
    +            return
    
    300
    +        ctrl = self.get_active_control()
    
    301
    +        if ctrl.contact.jid != event.room_jid:
    
    302
    +            return
    
    303
    +        self.show_title()
    
    304
    +
    
    302 305
         def _on_window_focus(self, widget, event):
    
    303 306
             # on destroy() the window that was last focused gets the focus
    
    304 307
             # again. if destroy() is called from the StartChat Dialog, this
    
    ... ... @@ -500,7 +503,7 @@ class MessageWindow:
    500 503
                 urgent = False
    
    501 504
     
    
    502 505
             if control.type_id == message_control.TYPE_GC:
    
    503
    -            name = control.room_jid.split('@')[0]
    
    506
    +            name = control.contact.get_shown_name()
    
    504 507
                 urgent = (control.attention_flag or
    
    505 508
                           app.config.notify_for_muc(control.room_jid))
    
    506 509
             else:
    
    ... ... @@ -905,10 +908,6 @@ class MessageWindowMgr(GObject.GObject):
    905 908
     
    
    906 909
             Gtk.Window.set_default_icon_list(get_app_icon_list(parent_window))
    
    907 910
     
    
    908
    -    def change_account_name(self, old_name, new_name):
    
    909
    -        for win in self.windows():
    
    910
    -            win.change_account_name(old_name, new_name)
    
    911
    -
    
    912 911
         def _new_window(self, acct, type_):
    
    913 912
             parent_win = None
    
    914 913
             parent_paned = None
    

  • gajim/roster_window.py
    ... ... @@ -2635,6 +2635,9 @@ class RosterWindow:
    2635 2635
         def _nec_muc_subject_received(self, event):
    
    2636 2636
             self.draw_contact(event.room_jid, event.account)
    
    2637 2637
     
    
    2638
    +    def _on_muc_disco_update(self, event):
    
    2639
    +        self.draw_contact(str(event.room_jid), event.account)
    
    2640
    +
    
    2638 2641
         def _nec_metacontacts_received(self, obj):
    
    2639 2642
             self.redraw_metacontacts(obj.conn.name)
    
    2640 2643
     
    
    ... ... @@ -5679,3 +5682,5 @@ class RosterWindow:
    5679 5682
                 self._style_changed)
    
    5680 5683
             app.ged.register_event_handler('chatstate-received', ged.GUI1,
    
    5681 5684
                                            self._nec_chatstate_received)
    
    5685
    +        app.ged.register_event_handler('muc-disco-update', ged.GUI1,
    
    5686
    +                                       self._on_muc_disco_update)

  • test/no_gui/unit/test_contacts.py
    ... ... @@ -99,7 +99,6 @@ class TestContacts(unittest.TestCase):
    99 99
             self.contacts.add_account("one")
    
    100 100
             self.contacts.add_account("two")
    
    101 101
     
    
    102
    -        self.contacts.change_account_name("two", "old")
    
    103 102
             self.contacts.remove_account("one")
    
    104 103
     
    
    105 104
             self.assertEqual(["old"], self.contacts.get_accounts())