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

Commits:

9 changed files:

Changes:

  • gajim/chat_control.py
    ... ... @@ -99,13 +99,11 @@ class ChatControl(ChatControlBase):
    99 99
         # processed with this command host.
    
    100 100
         COMMAND_HOST = ChatCommands  # type: ClassVar[Type[CommandHost]]
    
    101 101
     
    
    102
    -    def __init__(self, parent_win, jid, acct, session, resource=None):
    
    102
    +    def __init__(self, account, jid):
    
    103 103
             ChatControlBase.__init__(self,
    
    104
    -                                 parent_win,
    
    105 104
                                      'chat_control',
    
    106
    -                                 jid,
    
    107
    -                                 acct,
    
    108
    -                                 resource)
    
    105
    +                                 account,
    
    106
    +                                 jid)
    
    109 107
     
    
    110 108
             self.last_recv_message_id = None
    
    111 109
             self.last_recv_message_marks = None
    
    ... ... @@ -245,7 +243,7 @@ def add_actions(self):
    245 243
                 action_name, func = action
    
    246 244
                 act = Gio.SimpleAction.new(action_name + self.control_id, None)
    
    247 245
                 act.connect('activate', func)
    
    248
    -            self.parent_win.window.add_action(act)
    
    246
    +            app.window.add_action(act)
    
    249 247
     
    
    250 248
             chatstate = self.contact.settings.get('send_chatstate')
    
    251 249
     
    
    ... ... @@ -254,7 +252,7 @@ def add_actions(self):
    254 252
                 GLib.VariantType.new("s"),
    
    255 253
                 GLib.Variant("s", chatstate))
    
    256 254
             act.connect('change-state', self._on_send_chatstate)
    
    257
    -        self.parent_win.window.add_action(act)
    
    255
    +        app.window.add_action(act)
    
    258 256
     
    
    259 257
             marker = self.contact.settings.get('send_marker')
    
    260 258
     
    
    ... ... @@ -263,10 +261,10 @@ def add_actions(self):
    263 261
                 None,
    
    264 262
                 GLib.Variant.new_boolean(marker))
    
    265 263
             act.connect('change-state', self._on_send_marker)
    
    266
    -        self.parent_win.window.add_action(act)
    
    264
    +        app.window.add_action(act)
    
    267 265
     
    
    268 266
         def update_actions(self):
    
    269
    -        win = self.parent_win.window
    
    267
    +        win = app.window
    
    270 268
             online = app.account_is_connected(self.account)
    
    271 269
     
    
    272 270
             # Add to roster
    
    ... ... @@ -366,7 +364,7 @@ def remove_actions(self):
    366 364
                 'send-marker-',
    
    367 365
             ]
    
    368 366
             for action in actions:
    
    369
    -            self.parent_win.window.remove_action(f'{action}{self.control_id}')
    
    367
    +            app.window.remove_action(f'{action}{self.control_id}')
    
    370 368
     
    
    371 369
         def focus(self):
    
    372 370
             self.msg_textview.grab_focus()
    
    ... ... @@ -377,7 +375,7 @@ def delegate_action(self, action):
    377 375
                 return res
    
    378 376
     
    
    379 377
             if action == 'show-contact-info':
    
    380
    -            self.parent_win.window.lookup_action(
    
    378
    +            app.window.lookup_action(
    
    381 379
                     'information-%s' % self.control_id).activate()
    
    382 380
                 return Gdk.EVENT_STOP
    
    383 381
     
    
    ... ... @@ -387,7 +385,7 @@ def delegate_action(self, action):
    387 385
                     app.interface.roster.tree.grab_focus()
    
    388 386
                     return Gdk.EVENT_PROPAGATE
    
    389 387
     
    
    390
    -            self.parent_win.window.lookup_action(
    
    388
    +            app.window.lookup_action(
    
    391 389
                     'send-file-%s' % self.control_id).activate()
    
    392 390
                 return Gdk.EVENT_STOP
    
    393 391
     
    
    ... ... @@ -499,8 +497,6 @@ def _on_location_received(self, _event):
    499 497
     
    
    500 498
         def _on_nickname_received(self, _event):
    
    501 499
             self.update_ui()
    
    502
    -        self.parent_win.redraw_tab(self)
    
    503
    -        self.parent_win.show_title()
    
    504 500
     
    
    505 501
         def _on_update_client_info(self, event):
    
    506 502
             contact = app.contacts.get_contact(
    
    ... ... @@ -527,7 +523,7 @@ def _on_caps_update(self, event):
    527 523
     
    
    528 524
         def _on_mam_message_received(self, event):
    
    529 525
             if event.properties.is_muc_pm:
    
    530
    -            if not event.properties.jid == self.contact.get_full_jid():
    
    526
    +            if not event.properties.jid == self.contact.jid:
    
    531 527
                     return
    
    532 528
             else:
    
    533 529
                 if not event.properties.jid.bare_match(self.contact.jid):
    
    ... ... @@ -608,19 +604,6 @@ def _nec_ping(self, event):
    608 604
             elif event.name == 'ping-error':
    
    609 605
                 self.add_info_message(event.error)
    
    610 606
     
    
    611
    -    def change_resource(self, resource):
    
    612
    -        old_full_jid = self.get_full_jid()
    
    613
    -        self.resource = resource
    
    614
    -        new_full_jid = self.get_full_jid()
    
    615
    -        # update app.last_message_time
    
    616
    -        if old_full_jid in app.last_message_time[self.account]:
    
    617
    -            app.last_message_time[self.account][new_full_jid] = \
    
    618
    -                    app.last_message_time[self.account][old_full_jid]
    
    619
    -        # update events
    
    620
    -        app.events.change_jid(self.account, old_full_jid, new_full_jid)
    
    621
    -        # update MessageWindow._controls
    
    622
    -        self.parent_win.change_jid(self.account, old_full_jid, new_full_jid)
    
    623
    -
    
    624 607
         # Jingle AV
    
    625 608
         def _on_start_call(self, *args):
    
    626 609
             audio_state = self.jingle['audio'].state
    
    ... ... @@ -771,7 +754,7 @@ def update_video(self):
    771 754
                 self.xml.outgoing_viewport.add(self._video_widget_self)
    
    772 755
     
    
    773 756
                 session = self._client.get_module('Jingle').get_jingle_session(
    
    774
    -                self.contact.get_full_jid(), self.jingle['video'].sid)
    
    757
    +                self.contact.jid, self.jingle['video'].sid)
    
    775 758
                 content = session.get_content('video')
    
    776 759
                 content.do_setup(sink_self, sink_other)
    
    777 760
     
    
    ... ... @@ -834,7 +817,7 @@ def close_jingle_content(self, jingle_type: str,
    834 817
                 return
    
    835 818
     
    
    836 819
             session = self._client.get_module('Jingle').get_jingle_session(
    
    837
    -            self.contact.get_full_jid(), jingle.sid)
    
    820
    +            self.contact.jid, jingle.sid)
    
    838 821
             if session:
    
    839 822
                 content = session.get_content(jingle_type)
    
    840 823
                 if content:
    
    ... ... @@ -857,7 +840,7 @@ def _on_jingle_button_toggled(self, jingle_types):
    857 840
             if all(item in jingle_types for item in ['audio', 'video']):
    
    858 841
                 # Both 'audio' and 'video' in jingle_types
    
    859 842
                 sid = self._client.get_module('Jingle').start_audio_video(
    
    860
    -                self.contact.get_full_jid())
    
    843
    +                self.contact.jid)
    
    861 844
                 self.set_jingle_state('audio', JingleState.CONNECTING, sid)
    
    862 845
                 self.set_jingle_state('video', JingleState.CONNECTING, sid)
    
    863 846
                 return
    
    ... ... @@ -867,7 +850,7 @@ def _on_jingle_button_toggled(self, jingle_types):
    867 850
                     self.close_jingle_content('audio')
    
    868 851
                 else:
    
    869 852
                     sid = self._client.get_module('Jingle').start_audio(
    
    870
    -                    self.contact.get_full_jid())
    
    853
    +                    self.contact.jid)
    
    871 854
                     self.set_jingle_state('audio', JingleState.CONNECTING, sid)
    
    872 855
     
    
    873 856
             if 'video' in jingle_types:
    
    ... ... @@ -875,12 +858,12 @@ def _on_jingle_button_toggled(self, jingle_types):
    875 858
                     self.close_jingle_content('video')
    
    876 859
                 else:
    
    877 860
                     sid = self._client.get_module('Jingle').start_video(
    
    878
    -                    self.contact.get_full_jid())
    
    861
    +                    self.contact.jid)
    
    879 862
                     self.set_jingle_state('video', JingleState.CONNECTING, sid)
    
    880 863
     
    
    881 864
         def _get_audio_content(self):
    
    882 865
             session = self._client.get_module('Jingle').get_jingle_session(
    
    883
    -            self.contact.get_full_jid(), self.jingle['audio'].sid)
    
    866
    +            self.contact.jid, self.jingle['audio'].sid)
    
    884 867
             return session.get_content('audio')
    
    885 868
     
    
    886 869
         def on_num_button_pressed(self, _widget, num):
    
    ... ... @@ -912,11 +895,11 @@ def on_location_eventbox_leave_notify_event(self, _widget, _event):
    912 895
             Just moved the mouse so show the cursor
    
    913 896
             """
    
    914 897
             cursor = get_cursor('default')
    
    915
    -        self.parent_win.window.get_window().set_cursor(cursor)
    
    898
    +        app.window.get_window().set_cursor(cursor)
    
    916 899
     
    
    917 900
         def on_location_eventbox_enter_notify_event(self, _widget, _event):
    
    918 901
             cursor = get_cursor('pointer')
    
    919
    -        self.parent_win.window.get_window().set_cursor(cursor)
    
    902
    +        app.window.get_window().set_cursor(cursor)
    
    920 903
     
    
    921 904
         def update_ui(self):
    
    922 905
             # The name banner is drawn here
    
    ... ... @@ -932,14 +915,14 @@ def draw_banner_text(self):
    932 915
             """
    
    933 916
             contact = self.contact
    
    934 917
             name = contact.name
    
    935
    -        if self.resource:
    
    936
    -            name += '/' + self.resource
    
    937
    -        if self._type.is_privatechat:
    
    938
    -            name = i18n.direction_mark + _(
    
    939
    -                '%(nickname)s from group chat %(room_name)s') % \
    
    940
    -                {'nickname': name, 'room_name': self.room_name}
    
    918
    +        # if self.resource:
    
    919
    +        #     name += '/' + self.resource
    
    920
    +        # if self._type.is_privatechat:
    
    921
    +        #     name = i18n.direction_mark + _(
    
    922
    +        #         '%(nickname)s from group chat %(room_name)s') % \
    
    923
    +        #         {'nickname': name, 'room_name': self.room_name}
    
    941 924
     
    
    942
    -        name = i18n.direction_mark + GLib.markup_escape_text(name)
    
    925
    +        # name = i18n.direction_mark + GLib.markup_escape_text(name)
    
    943 926
     
    
    944 927
             cs = self.contact.chatstate
    
    945 928
             if cs is not None:
    
    ... ... @@ -1091,17 +1074,6 @@ def shutdown(self):
    1091 1074
                 self.close_jingle_content(jingle_type, shutdown=True)
    
    1092 1075
             self.jingle.clear()
    
    1093 1076
     
    
    1094
    -        # disconnect self from session
    
    1095
    -        if self.session:
    
    1096
    -            self.session.control = None
    
    1097
    -
    
    1098
    -        # Clean events
    
    1099
    -        app.events.remove_events(
    
    1100
    -            self.account,
    
    1101
    -            self.get_full_jid(),
    
    1102
    -            types=['printed_%s' % self._type, str(self._type)])
    
    1103
    -        # Remove contact instance if contact has been removed
    
    1104
    -
    
    1105 1077
             super(ChatControl, self).shutdown()
    
    1106 1078
             app.check_finalize(self)
    
    1107 1079
     
    
    ... ... @@ -1112,7 +1084,7 @@ def safe_shutdown(self):
    1112 1084
             return False
    
    1113 1085
     
    
    1114 1086
         def allow_shutdown(self, method, on_yes, on_no, _on_minimize):
    
    1115
    -        time_ = app.last_message_time[self.account][self.get_full_jid()]
    
    1087
    +        time_ = app.last_message_time[self.account][self.contact.jid]
    
    1116 1088
             # 2 seconds
    
    1117 1089
             if time.time() - time_ < 2:
    
    1118 1090
                 no_log_for = app.settings.get_account_setting(
    
    ... ... @@ -1136,7 +1108,7 @@ def allow_shutdown(self, method, on_yes, on_no, _on_minimize):
    1136 1108
                      DialogButton.make('Remove',
    
    1137 1109
                                        text=_('_Close'),
    
    1138 1110
                                        callback=lambda: on_yes(self))],
    
    1139
    -                transient_for=self.parent_win.window).show()
    
    1111
    +                transient_for=app.window).show()
    
    1140 1112
                 return
    
    1141 1113
             on_yes(self)
    
    1142 1114
     
    
    ... ... @@ -1144,7 +1116,7 @@ def _on_avatar_update(self, _contact, _signal_name):
    1144 1116
             self._update_avatar()
    
    1145 1117
     
    
    1146 1118
         def _update_avatar(self):
    
    1147
    -        scale = self.parent_win.window.get_scale_factor()
    
    1119
    +        scale = app.window.get_scale_factor()
    
    1148 1120
             surface = self.contact.get_avatar(AvatarSize.CHAT, scale)
    
    1149 1121
             self.xml.avatar_image.set_from_surface(surface)
    
    1150 1122
     
    
    ... ... @@ -1200,7 +1172,6 @@ def _on_presence_received(self, event):
    1200 1172
             name = self.contact.name
    
    1201 1173
     
    
    1202 1174
             self.update_ui()
    
    1203
    -        self.parent_win.redraw_tab(self)
    
    1204 1175
     
    
    1205 1176
             if not app.settings.get('print_status_in_chats'):
    
    1206 1177
                 return
    

  • gajim/chat_control_base.py
    ... ... @@ -98,20 +98,17 @@ class ChatControlBase(ChatCommandProcessor, CommandTools, EventHelper):
    98 98
     
    
    99 99
         _type = None  # type: ControlType
    
    100 100
     
    
    101
    -    def __init__(self, parent_win, widget_name, jid, acct,
    
    102
    -                 resource=None):
    
    101
    +    def __init__(self, widget_name, account, jid):
    
    103 102
             EventHelper.__init__(self)
    
    104 103
             # Undo needs this variable to know if space has been pressed.
    
    105 104
             # Initialize it to True so empty textview is saved in undo list
    
    106 105
             self.space_pressed = True
    
    107 106
     
    
    108 107
             self.handlers = {}
    
    109
    -        self.parent_win = parent_win
    
    110 108
     
    
    111
    -        self.account = acct
    
    112
    -        self.resource = resource
    
    109
    +        self.account = account
    
    113 110
     
    
    114
    -        self._client = app.get_client(acct)
    
    111
    +        self._client = app.get_client(account)
    
    115 112
     
    
    116 113
             groupchat = self._type != ControlType.CHAT
    
    117 114
             self.contact = self._client.get_module('Contacts').get_contact(
    
    ... ... @@ -123,7 +120,7 @@ def __init__(self, parent_win, widget_name, jid, acct,
    123 120
             self.control_id = str(uuid.uuid4())
    
    124 121
             self.session = None
    
    125 122
     
    
    126
    -        app.last_message_time[self.account][self.get_full_jid()] = 0
    
    123
    +        app.last_message_time[self.account][self.contact.jid] = 0
    
    127 124
     
    
    128 125
             self.xml = get_builder('%s.ui' % widget_name)
    
    129 126
             self.xml.connect_signals(self)
    
    ... ... @@ -241,10 +238,10 @@ def __init__(self, parent_win, widget_name, jid, acct,
    241 238
     
    
    242 239
             self._client.get_module('Chatstate').set_active(self.contact)
    
    243 240
     
    
    244
    -        if parent_win is not None:
    
    245
    -            id_ = parent_win.window.connect('motion-notify-event',
    
    246
    -                                            self._on_window_motion_notify)
    
    247
    -            self.handlers[id_] = parent_win.window
    
    241
    +        # TODO
    
    242
    +        # id_ = app.window.connect('motion-notify-event',
    
    243
    +        #                          self._on_window_motion_notify)
    
    244
    +        # self.handlers[id_] = app.window
    
    248 245
     
    
    249 246
             self.encryption = self.get_encryption_state()
    
    250 247
             self.conversation_view.encryption_enabled = self.encryption is not None
    
    ... ... @@ -322,12 +319,6 @@ def is_privatechat(self):
    322 319
         def is_groupchat(self):
    
    323 320
             return self._type.is_groupchat
    
    324 321
     
    
    325
    -    def get_full_jid(self):
    
    326
    -        fjid = self.contact.jid
    
    327
    -        if self.resource:
    
    328
    -            fjid += '/' + self.resource
    
    329
    -        return fjid
    
    330
    -
    
    331 322
         def minimizable(self):
    
    332 323
             """
    
    333 324
             Called to check if control can be minimized
    
    ... ... @@ -360,15 +351,6 @@ def allow_shutdown(self, method, on_response_yes, on_response_no,
    360 351
         def focus(self):
    
    361 352
             raise NotImplementedError
    
    362 353
     
    
    363
    -    def get_nb_unread(self):
    
    364
    -        jid = self.contact.jid
    
    365
    -        if self.resource:
    
    366
    -            jid += '/' + self.resource
    
    367
    -        return len(app.events.get_events(
    
    368
    -            self.account,
    
    369
    -            jid,
    
    370
    -            ['printed_%s' % self._type, str(self._type)]))
    
    371
    -
    
    372 354
         def draw_banner(self):
    
    373 355
             """
    
    374 356
             Draw the fat line at the top of the window
    
    ... ... @@ -522,7 +504,7 @@ def add_actions(self):
    522 504
                 GLib.VariantType.new('s'),
    
    523 505
                 GLib.Variant('s', self.encryption or 'disabled'))
    
    524 506
             action.connect('change-state', self.change_encryption)
    
    525
    -        self.parent_win.window.add_action(action)
    
    507
    +        app.window.add_action(action)
    
    526 508
     
    
    527 509
             actions = {
    
    528 510
                 'send-message-%s': self._on_send_message,
    
    ... ... @@ -535,7 +517,7 @@ def add_actions(self):
    535 517
                 action = Gio.SimpleAction.new(name % self.control_id, None)
    
    536 518
                 action.connect('activate', func)
    
    537 519
                 action.set_enabled(False)
    
    538
    -            self.parent_win.window.add_action(action)
    
    520
    +            app.window.add_action(action)
    
    539 521
     
    
    540 522
         def remove_actions(self):
    
    541 523
             actions = [
    
    ... ... @@ -547,7 +529,7 @@ def remove_actions(self):
    547 529
             ]
    
    548 530
     
    
    549 531
             for action in actions:
    
    550
    -            self.parent_win.window.remove_action(f'{action}{self.control_id}')
    
    532
    +            app.window.remove_action(f'{action}{self.control_id}')
    
    551 533
     
    
    552 534
         def change_encryption(self, action, param):
    
    553 535
             encryption = param.get_string()
    
    ... ... @@ -783,9 +765,9 @@ def _paste_event_confirmed(self, is_checked, image):
    783 765
         def _get_pref_ft_method(self):
    
    784 766
             ft_pref = app.settings.get_account_setting(self.account,
    
    785 767
                                                        'filetransfer_preference')
    
    786
    -        httpupload = self.parent_win.window.lookup_action(
    
    768
    +        httpupload = app.window.lookup_action(
    
    787 769
                 'send-file-httpupload-%s' % self.control_id)
    
    788
    -        jingle = self.parent_win.window.lookup_action(
    
    770
    +        jingle = app.window.lookup_action(
    
    789 771
                 'send-file-jingle-%s' % self.control_id)
    
    790 772
     
    
    791 773
             if self._type.is_groupchat:
    
    ... ... @@ -1038,9 +1020,6 @@ def _on_window_motion_notify(self, *args):
    1038 1020
             """
    
    1039 1021
             It gets called no matter if it is the active window or not
    
    1040 1022
             """
    
    1041
    -        if not self.parent_win:
    
    1042
    -            # when a groupchat is minimized there is no parent window
    
    1043
    -            return
    
    1044 1023
             # TODO
    
    1045 1024
             return
    
    1046 1025
             if self.parent_win.get_active_jid() == self.contact.jid:
    
    ... ... @@ -1050,8 +1029,7 @@ def _on_window_motion_notify(self, *args):
    1050 1029
     
    
    1051 1030
         def _on_message_tv_buffer_changed(self, textbuffer):
    
    1052 1031
             has_text = self.msg_textview.has_text()
    
    1053
    -        if self.parent_win is not None:
    
    1054
    -            self.parent_win.window.lookup_action(
    
    1032
    +        app.window.lookup_action(
    
    1055 1033
                     'send-message-' + self.control_id).set_enabled(has_text)
    
    1056 1034
     
    
    1057 1035
             if textbuffer.get_char_count() and self.encryption:
    
    ... ... @@ -1124,7 +1102,7 @@ def add_message(self,
    1124 1102
             correct_id = (message_id, correct_id)
    
    1125 1103
             """
    
    1126 1104
             jid = self.contact.jid
    
    1127
    -        full_jid = self.get_full_jid()
    
    1105
    +        full_jid = self.contact.jid
    
    1128 1106
             end = False
    
    1129 1107
             if self.conversation_view.autoscroll or kind == 'outgoing':
    
    1130 1108
                 end = True
    
    ... ... @@ -1253,9 +1231,6 @@ def set_emoticon_popover(self):
    1253 1231
             if not app.settings.get('emoticons_theme'):
    
    1254 1232
                 return
    
    1255 1233
     
    
    1256
    -        if not self.parent_win:
    
    1257
    -            return
    
    1258
    -
    
    1259 1234
             if sys.platform in ('win32', 'darwin'):
    
    1260 1235
                 emoji_chooser.text_widget = self.msg_textview
    
    1261 1236
                 self.xml.emoticons_button.set_popover(emoji_chooser)
    
    ... ... @@ -1271,13 +1246,13 @@ def _on_emoticon_button_clicked(self, _widget):
    1271 1246
             self.xml.emoticons_button.set_property('active', False)
    
    1272 1247
     
    
    1273 1248
         def on_color_menuitem_activate(self, _widget):
    
    1274
    -        color_dialog = Gtk.ColorChooserDialog(None, self.parent_win.window)
    
    1249
    +        color_dialog = Gtk.ColorChooserDialog(None, app.window)
    
    1275 1250
             color_dialog.set_use_alpha(False)
    
    1276 1251
             color_dialog.connect('response', self.msg_textview.color_set)
    
    1277 1252
             color_dialog.show_all()
    
    1278 1253
     
    
    1279 1254
         def on_font_menuitem_activate(self, _widget):
    
    1280
    -        font_dialog = Gtk.FontChooserDialog(None, self.parent_win.window)
    
    1255
    +        font_dialog = Gtk.FontChooserDialog(None, app.window)
    
    1281 1256
             start, finish = self.msg_textview.get_active_iters()
    
    1282 1257
             font_dialog.connect('response', self.msg_textview.font_set, start, finish)
    
    1283 1258
             font_dialog.show_all()
    
    ... ... @@ -1370,7 +1345,7 @@ def set_control_active(self, state):
    1370 1345
                     if self._type.is_groupchat:
    
    1371 1346
                         type_ = ['printed_gc_msg', 'printed_marked_gc_msg']
    
    1372 1347
                     if not app.events.remove_events(self.account,
    
    1373
    -                                                self.get_full_jid(),
    
    1348
    +                                                self.contact.jid,
    
    1374 1349
                                                     types=type_):
    
    1375 1350
                         # There were events to remove
    
    1376 1351
                         self.redraw_after_event_removed(jid)
    
    ... ... @@ -1472,10 +1447,9 @@ def add_messages(self, messages):
    1472 1447
                     history=True)
    
    1473 1448
     
    
    1474 1449
         def has_focus(self):
    
    1475
    -        if self.parent_win:
    
    1476
    -            if self.parent_win.window.get_property('has-toplevel-focus'):
    
    1477
    -                if self == self.parent_win.get_active_control():
    
    1478
    -                    return True
    
    1450
    +        if app.window.get_property('has-toplevel-focus'):
    
    1451
    +            if self == app.window.get_active_control():
    
    1452
    +                return True
    
    1479 1453
             return False
    
    1480 1454
     
    
    1481 1455
         def scroll_messages(self, direction, msg_buf, msg_type):
    

  • gajim/common/modules/caps.py
    ... ... @@ -212,9 +212,11 @@ def preconditions_met(self):
    212 212
                 return False
    
    213 213
     
    
    214 214
             if self._from_muc:
    
    215
    -            muc = client.get_module('MUC').get_muc_data(self.entity.jid.bare)
    
    215
    +            contact = client.get_module('Contacts').get_contact(
    
    216
    +                self.entity.jid.bare,
    
    217
    +                groupchat=True)
    
    216 218
     
    
    217
    -            if muc is None or not muc.state.is_joined:
    
    219
    +            if not contact.is_joined:
    
    218 220
                     self.set_obsolete()
    
    219 221
                     return False
    
    220 222
     
    

  • gajim/common/modules/chat_markers.py
    ... ... @@ -45,9 +45,11 @@ def _process_chat_marker(self, _con, _stanza, properties):
    45 45
                 return
    
    46 46
     
    
    47 47
             if properties.type.is_groupchat:
    
    48
    -            muc_data = self._con.get_module('MUC').get_muc_data(
    
    49
    -                properties.muc_jid)
    
    50
    -            if muc_data is None:
    
    48
    +            contact = self._con.get_module('Contacts').get_contact(
    
    49
    +                properties.muc_jid,
    
    50
    +                groupchat=True)
    
    51
    +            if not contact.is_joined:
    
    52
    +                self._log.warning('Received chat marker while not joined')
    
    51 53
                     return
    
    52 54
     
    
    53 55
                 if properties.muc_nickname != muc_data.nick:
    

  • gajim/common/modules/contacts.py
    ... ... @@ -346,11 +346,6 @@ def __init__(self, logger, jid, account):
    346 346
         def is_groupchat(self):
    
    347 347
             return True
    
    348 348
     
    
    349
    -    @property
    
    350
    -    def state(self):
    
    351
    -        muc_data = self._module('MUC').get_muc_data(self._jid)
    
    352
    -        return muc_data.state
    
    353
    -
    
    354 349
         def add_resource(self, resource):
    
    355 350
             jid = self._jid.new_with(resource=resource)
    
    356 351
             contact = GroupchatParticipant(self._log, jid, self._account)
    
    ... ... @@ -392,6 +387,26 @@ def update_avatar(self, *args):
    392 387
             app.interface.avatar_storage.invalidate_cache(self._jid)
    
    393 388
             self.notify('avatar-update')
    
    394 389
     
    
    390
    +    def get_self(self):
    
    391
    +        nick = self.nickname
    
    392
    +        if nick is None:
    
    393
    +            return None
    
    394
    +        return self.get_resource(nick)
    
    395
    +
    
    396
    +    @property
    
    397
    +    def nickname(self):
    
    398
    +        muc_data = self._module('MUC').get_muc_data(self._jid)
    
    399
    +        if muc_data is None:
    
    400
    +            return None
    
    401
    +        return muc_data.nick
    
    402
    +
    
    403
    +    @property
    
    404
    +    def occupant_jid(self):
    
    405
    +        muc_data = self._module('MUC').get_muc_data(self._jid)
    
    406
    +        if muc_data is None:
    
    407
    +            return None
    
    408
    +        return muc_data.occupant_jid
    
    409
    +
    
    395 410
         @property
    
    396 411
         def is_joined(self):
    
    397 412
             muc_data = self._module('MUC').get_muc_data(self._jid)
    
    ... ... @@ -399,6 +414,20 @@ def is_joined(self):
    399 414
                 return False
    
    400 415
             return muc_data.state.is_joined
    
    401 416
     
    
    417
    +    @property
    
    418
    +    def is_joining(self):
    
    419
    +        muc_data = self._module('MUC').get_muc_data(self._jid)
    
    420
    +        if muc_data is None:
    
    421
    +            return False
    
    422
    +        return muc_data.state.is_joining
    
    423
    +
    
    424
    +    @property
    
    425
    +    def is_not_joined(self):
    
    426
    +        muc_data = self._module('MUC').get_muc_data(self._jid)
    
    427
    +        if muc_data is None:
    
    428
    +            return True
    
    429
    +        return muc_data.state.is_not_joined
    
    430
    +
    
    402 431
         def set_not_joined(self):
    
    403 432
             for contact in self._resources.values():
    
    404 433
                 contact.update_presence(UNKNOWN_MUC_PRESENCE, notify=False)
    

  • gajim/common/modules/muc.py
    ... ... @@ -116,7 +116,7 @@ def __init__(self, con):
    116 116
             self._muc_service_jid = None
    
    117 117
             self._joined_users = defaultdict(dict)
    
    118 118
             self._mucs = {}
    
    119
    -
    
    119
    +        self._muc_nicknames = {}
    
    120 120
     
    
    121 121
         def _on_resume_failed(self, _client, _signal_name):
    
    122 122
             self._reset_presence()
    
    ... ... @@ -147,6 +147,10 @@ def pass_disco(self, info):
    147 147
         def get_muc_data(self, room_jid):
    
    148 148
             return self._mucs.get(room_jid)
    
    149 149
     
    
    150
    +    def set_password(self, room_jid, password):
    
    151
    +        muc_data = self.get_muc_data(room_jid)
    
    152
    +        muc_data.password = password
    
    153
    +
    
    150 154
         def _get_mucs_with_state(self, states):
    
    151 155
             return [muc for muc in self._mucs.values() if muc.state in states]
    
    152 156
     
    

  • gajim/groupchat_control.py
    ... ... @@ -86,12 +86,11 @@ class GroupchatControl(ChatControlBase):
    86 86
         # will be processed with this command host.
    
    87 87
         COMMAND_HOST = GroupChatCommands
    
    88 88
     
    
    89
    -    def __init__(self, parent_win, jid, muc_data, acct):
    
    89
    +    def __init__(self, account, jid):
    
    90 90
             ChatControlBase.__init__(self,
    
    91
    -                                 parent_win,
    
    92 91
                                      'groupchat_control',
    
    93
    -                                 jid,
    
    94
    -                                 acct)
    
    92
    +                                 account,
    
    93
    +                                 jid)
    
    95 94
     
    
    96 95
             self._client.connect_signal('state-changed',
    
    97 96
                                         self._on_client_state_changed)
    
    ... ... @@ -119,12 +118,9 @@ def __init__(self, parent_win, jid, muc_data, acct):
    119 118
             self.xml.roster_revealer.add(self.roster)
    
    120 119
             self.roster.connect('row-activated', self._on_roster_row_activated)
    
    121 120
     
    
    122
    -        if parent_win is not None:
    
    123
    -            self.add_actions()
    
    124
    -            GLib.idle_add(self.update_actions)
    
    125
    -            self.scale_factor = parent_win.window.get_scale_factor()
    
    126
    -        else:
    
    127
    -            self.scale_factor = app.interface.roster.scale_factor
    
    121
    +        self.add_actions()
    
    122
    +        GLib.idle_add(self.update_actions)
    
    123
    +        self.scale_factor = app.window.get_scale_factor()
    
    128 124
     
    
    129 125
             if not app.settings.get('hide_groupchat_banner'):
    
    130 126
                 self.xml.banner_eventbox.set_no_show_all(False)
    
    ... ... @@ -246,45 +242,33 @@ def _connect_contact_signals(self):
    246 242
             })
    
    247 243
     
    
    248 244
         def _on_muc_state_changed(self, _contact, _signal_name):
    
    249
    -        state = self.contact.state
    
    250
    -        if state == MUCJoinedState.JOINING:
    
    245
    +        if self.contact.is_joining:
    
    251 246
                 self._groupchat_state.set_joining()
    
    252 247
     
    
    253
    -        if state == MUCJoinedState.JOINED:
    
    248
    +        if self.contact.is_joined:
    
    254 249
                 self._set_control_active()
    
    255 250
                 self.show_roster()
    
    256 251
                 self._groupchat_state.set_joined()
    
    257 252
     
    
    258
    -        elif state == MUCJoinedState.NOT_JOINED:
    
    253
    +        elif self.contact.is_not_joined:
    
    259 254
                 self._set_control_inactive()
    
    260 255
     
    
    261 256
         def _on_client_state_changed(self, _client, _signal_name, state):
    
    262 257
             pass
    
    263 258
     
    
    264
    -    @property
    
    265
    -    def _muc_data(self):
    
    266
    -        return self._client.get_module('MUC').get_muc_data(self.room_jid)
    
    267
    -
    
    268 259
         @property
    
    269 260
         def _nick_completion(self):
    
    270 261
             if self.__nick_completion is None:
    
    271
    -            self.__nick_completion = NickCompletionGenerator(self._muc_data.nick)
    
    262
    +            self.__nick_completion = NickCompletionGenerator(
    
    263
    +                self.contact.nickname)
    
    272 264
             return self.__nick_completion
    
    273 265
     
    
    274
    -    @property
    
    275
    -    def nick(self):
    
    276
    -        return self._muc_data.nick
    
    277
    -
    
    278 266
         @property
    
    279 267
         def subject(self):
    
    280 268
             if self._subject_data is None:
    
    281 269
                 return ''
    
    282 270
             return self._subject_data.subject
    
    283 271
     
    
    284
    -    @property
    
    285
    -    def room_name(self):
    
    286
    -        return self.contact.get_shown_name()
    
    287
    -
    
    288 272
         @property
    
    289 273
         def disco_info(self):
    
    290 274
             return app.storage.cache.get_last_disco_info(self.contact.jid)
    
    ... ... @@ -316,50 +300,51 @@ def add_actions(self):
    316 300
                     variant = GLib.VariantType.new(variant)
    
    317 301
                 act = Gio.SimpleAction.new(action_name + self.control_id, variant)
    
    318 302
                 act.connect("activate", func)
    
    319
    -            self.parent_win.window.add_action(act)
    
    303
    +            app.window.add_action(act)
    
    320 304
     
    
    321 305
         def update_actions(self, *args):
    
    322
    -        if self._muc_data is None:
    
    323
    -            return
    
    324
    -
    
    325
    -        contact = self.contact.get_resource(self.nick)
    
    306
    +        joined = self.contact.is_joined
    
    307
    +        if joined:
    
    308
    +            contact = self.contact.get_self()
    
    326 309
     
    
    327 310
             # Destroy Room
    
    328
    -        self._get_action('destroy-').set_enabled(self.is_connected and
    
    311
    +        self._get_action('destroy-').set_enabled(joined and
    
    329 312
                                                      contact.affiliation.is_owner)
    
    330 313
     
    
    331 314
             # Configure Room
    
    332 315
             self._get_action('configure-').set_enabled(
    
    333
    -            self.is_connected and contact.affiliation in (Affiliation.ADMIN,
    
    334
    -                                                          Affiliation.OWNER))
    
    316
    +            joined and contact.affiliation in (Affiliation.ADMIN,
    
    317
    +                                               Affiliation.OWNER))
    
    335 318
     
    
    336
    -        self._get_action('request-voice-').set_enabled(self.is_connected and
    
    319
    +        self._get_action('request-voice-').set_enabled(joined and
    
    337 320
                                                            contact.role.is_visitor)
    
    338 321
     
    
    322
    +        self._get_action('rename-groupchat-').set_enabled(joined)
    
    323
    +
    
    339 324
             # Change Subject
    
    340 325
             subject_change = self._is_subject_change_allowed()
    
    341
    -        self._get_action('change-subject-').set_enabled(self.is_connected and
    
    326
    +        self._get_action('change-subject-').set_enabled(joined and
    
    342 327
                                                             subject_change)
    
    343 328
     
    
    344 329
             # Change Nick
    
    345
    -        self._get_action('change-nickname-').set_enabled(self.is_connected)
    
    330
    +        self._get_action('change-nickname-').set_enabled(joined)
    
    346 331
     
    
    347 332
             # Execute command
    
    348
    -        self._get_action('execute-command-').set_enabled(self.is_connected)
    
    333
    +        self._get_action('execute-command-').set_enabled(joined)
    
    349 334
     
    
    350 335
             # Send message
    
    351 336
             has_text = self.msg_textview.has_text()
    
    352 337
             self._get_action('send-message-').set_enabled(
    
    353
    -            self.is_connected and has_text)
    
    338
    +            joined and has_text)
    
    354 339
     
    
    355 340
             # Send file (HTTP File Upload)
    
    356 341
             httpupload = self._get_action(
    
    357 342
                 'send-file-httpupload-')
    
    358
    -        httpupload.set_enabled(self.is_connected and
    
    343
    +        httpupload.set_enabled(joined and
    
    359 344
                                    self._client.get_module('HTTPUpload').available)
    
    360 345
             self._get_action('send-file-').set_enabled(httpupload.get_enabled())
    
    361 346
     
    
    362
    -        if self.is_connected and httpupload.get_enabled():
    
    347
    +        if joined and httpupload.get_enabled():
    
    363 348
                 tooltip_text = _('Send File…')
    
    364 349
                 max_file_size = self._client.get_module('HTTPUpload').max_file_size
    
    365 350
                 if max_file_size is not None:
    
    ... ... @@ -374,17 +359,17 @@ def update_actions(self, *args):
    374 359
             if self.disco_info is not None:
    
    375 360
                 vcard_support = self.disco_info.supports(Namespace.VCARD)
    
    376 361
             self._get_action('upload-avatar-').set_enabled(
    
    377
    -            self.is_connected and
    
    362
    +            joined and
    
    378 363
                 vcard_support and
    
    379 364
                 contact.affiliation.is_owner)
    
    380 365
     
    
    381
    -        self._get_action('contact-information-').set_enabled(self.is_connected)
    
    366
    +        self._get_action('contact-information-').set_enabled(joined)
    
    382 367
     
    
    383
    -        self._get_action('execute-command-').set_enabled(self.is_connected)
    
    368
    +        self._get_action('execute-command-').set_enabled(joined)
    
    384 369
     
    
    385
    -        self._get_action('ban-').set_enabled(self.is_connected)
    
    370
    +        self._get_action('ban-').set_enabled(joined)
    
    386 371
     
    
    387
    -        self._get_action('kick-').set_enabled(self.is_connected)
    
    372
    +        self._get_action('kick-').set_enabled(joined)
    
    388 373
     
    
    389 374
         def remove_actions(self):
    
    390 375
             super().remove_actions()
    
    ... ... @@ -409,10 +394,13 @@ def remove_actions(self):
    409 394
             ]
    
    410 395
     
    
    411 396
             for action in actions:
    
    412
    -            self.parent_win.window.remove_action(f'{action}{self.control_id}')
    
    397
    +            app.window.remove_action(f'{action}{self.control_id}')
    
    413 398
     
    
    414 399
         def _is_subject_change_allowed(self):
    
    415
    -        contact = self.contact.get_resource(self.nick)
    
    400
    +        contact = self.contact.get_self()
    
    401
    +        if contact is None:
    
    402
    +            return False
    
    403
    +
    
    416 404
             if contact.affiliation in (Affiliation.OWNER, Affiliation.ADMIN):
    
    417 405
                 return True
    
    418 406
     
    
    ... ... @@ -421,7 +409,7 @@ def _is_subject_change_allowed(self):
    421 409
             return self.disco_info.muc_subjectmod or False
    
    422 410
     
    
    423 411
         def _get_action(self, name):
    
    424
    -        win = self.parent_win.window
    
    412
    +        win = app.window
    
    425 413
             return win.lookup_action(name + self.control_id)
    
    426 414
     
    
    427 415
         def _show_page(self, name):
    
    ... ... @@ -519,7 +507,7 @@ def _on_configure_room(self, _action, _param):
    519 507
                 win.present()
    
    520 508
                 return
    
    521 509
     
    
    522
    -        contact = self.contact.get_resource(self.nick)
    
    510
    +        contact = self.contact.get_self()
    
    523 511
             if contact.affiliation.is_owner:
    
    524 512
                 self._client.get_module('MUC').request_config(
    
    525 513
                     self.room_jid, callback=self._on_configure_form_received)
    
    ... ... @@ -567,7 +555,7 @@ def _on_accept(filename):
    567 555
                     callback=self._on_upload_avatar_result)
    
    568 556
     
    
    569 557
             AvatarChooserDialog(_on_accept,
    
    570
    -                            transient_for=self.parent_win.window,
    
    558
    +                            transient_for=app.window,
    
    571 559
                                 modal=True)
    
    572 560
     
    
    573 561
         def _on_upload_avatar_result(self, task):
    
    ... ... @@ -623,23 +611,6 @@ def show_roster(self):
    623 611
             self.xml.roster_revealer.set_transition_type(transition)
    
    624 612
             self.xml.roster_revealer.set_reveal_child(show)
    
    625 613
     
    
    626
    -    def on_groupchat_maximize(self):
    
    627
    -        self.roster.enable_tooltips()
    
    628
    -        self.add_actions()
    
    629
    -        self.update_actions()
    
    630
    -        self.set_lock_image()
    
    631
    -        self.draw_banner_text()
    
    632
    -        type_ = ['printed_gc_msg', 'printed_marked_gc_msg']
    
    633
    -        if not app.events.remove_events(self.account,
    
    634
    -                                        self.get_full_jid(),
    
    635
    -                                        types=type_):
    
    636
    -            # XEP-0333 Send <displayed> marker
    
    637
    -            self._client.get_module('ChatMarkers').send_displayed_marker(
    
    638
    -                self.contact,
    
    639
    -                self.last_msg_id,
    
    640
    -                self._type)
    
    641
    -            self.last_msg_id = None
    
    642
    -
    
    643 614
         def _on_roster_row_activated(self, _roster, nick):
    
    644 615
             muc_prefer_direct_msg = app.settings.get('muc_prefer_direct_msg')
    
    645 616
             if not self.is_anonymous and muc_prefer_direct_msg:
    
    ... ... @@ -682,7 +653,7 @@ def on_approve():
    682 653
                 _('Voice Request'),
    
    683 654
                 _('Voice Request'),
    
    684 655
                 _('<b>%(nick)s</b> from <b>%(room_name)s</b> requests voice') % {
    
    685
    -                'nick': voice_request.nick, 'room_name': self.room_name},
    
    656
    +                'nick': voice_request.nick, 'room_name': self.contact.name},
    
    686 657
                 [DialogButton.make('Cancel'),
    
    687 658
                  DialogButton.make('Accept',
    
    688 659
                                    text=_('_Approve'),
    
    ... ... @@ -709,7 +680,7 @@ def _on_gc_message_received(self, event):
    709 680
                                  displaymarking=event.displaymarking,
    
    710 681
                                  additional_data=event.additional_data)
    
    711 682
             else:
    
    712
    -            if event.properties.muc_nickname == self.nick:
    
    683
    +            if event.properties.muc_nickname == self.contact.nickname:
    
    713 684
                     self.last_sent_txt = event.msgtxt
    
    714 685
                 stanza_id = None
    
    715 686
                 if event.properties.stanza_id:
    
    ... ... @@ -740,24 +711,17 @@ def add_message(self, text, contact='', tim=None,
    740 711
             if not contact:
    
    741 712
                 # Message from the server
    
    742 713
                 kind = 'status'
    
    743
    -        elif contact == self.nick: # it's us
    
    714
    +        elif contact == self.contact.nickname: # it's us
    
    744 715
                 kind = 'outgoing'
    
    745 716
             else:
    
    746 717
                 kind = 'incoming'
    
    747 718
                 # muc-specific chatstate
    
    748
    -            if self.parent_win:
    
    749
    -                self.parent_win.redraw_tab(self, 'newmsg')
    
    750 719
     
    
    751 720
             if kind == 'incoming': # it's a message NOT from us
    
    752 721
                 # highlighting and sounds
    
    753 722
                 highlight, _sound = self.highlighting_for_message(text, tim)
    
    754 723
                 other_tags_for_name.append('muc_nickname_color_%s' % contact)
    
    755 724
                 if highlight:
    
    756
    -                # muc-specific chatstate
    
    757
    -                if self.parent_win:
    
    758
    -                    self.parent_win.redraw_tab(self, 'attention')
    
    759
    -                else:
    
    760
    -                    self.attention_flag = True
    
    761 725
                     other_tags_for_name.append('bold')
    
    762 726
                     other_tags_for_text.append('marked')
    
    763 727
     
    
    ... ... @@ -828,7 +792,7 @@ def needs_visual_notification(self, text):
    828 792
             nick) appear
    
    829 793
             """
    
    830 794
             special_words = app.settings.get('muc_highlight_words').split(';')
    
    831
    -        special_words.append(self.nick)
    
    795
    +        special_words.append(self.contact.nickname)
    
    832 796
             special_words.append(self._client.get_own_jid().bare)
    
    833 797
             # Strip empties: ''.split(';') == [''] and would highlight everything.
    
    834 798
             # Also lowercase everything for case insensitive compare.
    
    ... ... @@ -865,7 +829,7 @@ def _on_room_subject(self, _contact, _signal_name, properties):
    865 829
                 text = '%s - %s' % (text, date)
    
    866 830
     
    
    867 831
             if (app.settings.get('show_subject_on_join') or
    
    868
    -                self._muc_data.state != MUCJoinedState.JOINING):
    
    832
    +                not self.contact.is_joining):
    
    869 833
                 self.add_info_message(text)
    
    870 834
     
    
    871 835
         def _on_room_config_changed(self, _contact, _signal_name, properties):
    
    ... ... @@ -926,14 +890,6 @@ def _nec_ping(self, event):
    926 890
             elif event.name == 'ping-error':
    
    927 891
                 self.add_info_message(event.error)
    
    928 892
     
    
    929
    -    @property
    
    930
    -    def is_connected(self) -> bool:
    
    931
    -        return app.gc_connected[self.account][self.room_jid]
    
    932
    -
    
    933
    -    @is_connected.setter
    
    934
    -    def is_connected(self, value: bool) -> None:
    
    935
    -        app.gc_connected[self.account][self.room_jid] = value
    
    936
    -
    
    937 893
         def _set_control_active(self):
    
    938 894
             self.xml.formattings_button.set_sensitive(True)
    
    939 895
             self.msg_textview.set_sensitive(True)
    
    ... ... @@ -941,8 +897,6 @@ def _set_control_active(self):
    941 897
     
    
    942 898
             self.roster.initial_draw()
    
    943 899
     
    
    944
    -        self.is_connected = True
    
    945
    -
    
    946 900
             self.xml.formattings_button.set_sensitive(True)
    
    947 901
     
    
    948 902
             self.conversation_view.update_avatars()
    
    ... ... @@ -957,8 +911,6 @@ def _set_control_inactive(self):
    957 911
             self.roster.enable_sort(False)
    
    958 912
             self.roster.clear()
    
    959 913
     
    
    960
    -        self.is_connected = False
    
    961
    -
    
    962 914
             self._client.get_module('Chatstate').remove_delay_timeout(self.contact)
    
    963 915
     
    
    964 916
             self.update_actions()
    
    ... ... @@ -975,13 +927,14 @@ def _on_user_joined(self, _contact, _signal_name, user_contact, properties):
    975 927
             nick = user_contact.name
    
    976 928
             if not properties.is_muc_self_presence:
    
    977 929
     
    
    978
    -            if self.is_connected and self.contact.settings.get('print_join_left'):
    
    930
    +            if (self.contact.is_joined and
    
    931
    +                    self.contact.settings.get('print_join_left')):
    
    979 932
                     self.add_info_message(_('%s has joined the group chat') % nick)
    
    980 933
                 return
    
    981 934
     
    
    982 935
             status_codes = properties.muc_status_codes or []
    
    983 936
     
    
    984
    -        if not self.is_connected:
    
    937
    +        if not self.contact.is_joined:
    
    985 938
                 # We just joined the room
    
    986 939
                 self.add_info_message(_('You (%s) joined the group chat') % nick)
    
    987 940
     
    
    ... ... @@ -1347,21 +1300,20 @@ def shutdown(self, reason=None):
    1347 1300
             # Remove unread events from systray
    
    1348 1301
             app.events.remove_events(self.account, self.room_jid)
    
    1349 1302
     
    
    1350
    -        if self.parent_win is not None:
    
    1351
    -            self.remove_actions()
    
    1303
    +        self.remove_actions()
    
    1352 1304
     
    
    1353 1305
             super(GroupchatControl, self).shutdown()
    
    1354 1306
             app.check_finalize(self)
    
    1355 1307
     
    
    1356 1308
         def safe_shutdown(self):
    
    1357 1309
             # whether to ask for confirmation before closing muc
    
    1358
    -        if app.settings.get('confirm_close_muc') and self.is_connected:
    
    1310
    +        if app.settings.get('confirm_close_muc') and self.contact.is_joined:
    
    1359 1311
                 return False
    
    1360 1312
             return True
    
    1361 1313
     
    
    1362 1314
         def allow_shutdown(self, method, on_yes, on_no):
    
    1363 1315
             # whether to ask for confirmation before closing muc
    
    1364
    -        if app.settings.get('confirm_close_muc') and self.is_connected:
    
    1316
    +        if app.settings.get('confirm_close_muc') and self.contact.is_joined:
    
    1365 1317
                 def on_ok(is_checked):
    
    1366 1318
                     if is_checked:
    
    1367 1319
                         # User does not want to be asked again
    
    ... ... @@ -1378,33 +1330,24 @@ def on_cancel(is_checked):
    1378 1330
                     _('Leave Group Chat'),
    
    1379 1331
                     _('Are you sure you want to leave this group chat?'),
    
    1380 1332
                     _('If you close this window, you will leave '
    
    1381
    -                  '\'%s\'.') % self.room_name,
    
    1333
    +                  '\'%s\'.') % self.contact.name,
    
    1382 1334
                     _('_Do not ask me again'),
    
    1383 1335
                     [DialogButton.make('Cancel',
    
    1384 1336
                                        callback=on_cancel),
    
    1385 1337
                      DialogButton.make('Accept',
    
    1386 1338
                                        text=_('_Leave'),
    
    1387 1339
                                        callback=on_ok)],
    
    1388
    -                transient_for=self.parent_win.window).show()
    
    1340
    +                transient_for=app.window).show()
    
    1389 1341
                 return
    
    1390 1342
     
    
    1391 1343
             on_yes(self)
    
    1392 1344
     
    
    1393 1345
         def _close_control(self, reason=None):
    
    1394
    -        # if self.parent_win is None:
    
    1395 1346
             self.shutdown(reason)
    
    1396
    -        # else:
    
    1397
    -            # self.parent_win.remove_tab(self, None, reason=reason, force=True)
    
    1398 1347
     
    
    1399 1348
         def set_control_active(self, state):
    
    1400
    -        # self.conv_textview.allow_focus_out_line = True
    
    1401 1349
             self.attention_flag = False
    
    1402 1350
             ChatControlBase.set_control_active(self, state)
    
    1403
    -        # if not state:
    
    1404
    -        #    # add the focus-out line to the tab we are leaving
    
    1405
    -        #    self.check_focus_out_line()
    
    1406
    -        # Sending active to undo unread state
    
    1407
    -        self.parent_win.redraw_tab(self, 'active')
    
    1408 1351
     
    
    1409 1352
         def _on_drag_data_received(self, widget, context, x, y, selection,
    
    1410 1353
                                    target_type, timestamp):
    
    ... ... @@ -1553,7 +1496,7 @@ def delegate_action(self, action):
    1553 1496
     
    
    1554 1497
             if action == 'change-nickname':
    
    1555 1498
                 control_action = '%s-%s' % (action, self.control_id)
    
    1556
    -            self.parent_win.window.lookup_action(control_action).activate()
    
    1499
    +            app.window.lookup_action(control_action).activate()
    
    1557 1500
                 return Gdk.EVENT_STOP
    
    1558 1501
     
    
    1559 1502
             if action == 'escape':
    
    ... ... @@ -1574,11 +1517,11 @@ def delegate_action(self, action):
    1574 1517
     
    
    1575 1518
             if action == 'change-subject':
    
    1576 1519
                 control_action = '%s-%s' % (action, self.control_id)
    
    1577
    -            self.parent_win.window.lookup_action(control_action).activate()
    
    1520
    +            app.window.lookup_action(control_action).activate()
    
    1578 1521
                 return Gdk.EVENT_STOP
    
    1579 1522
     
    
    1580 1523
             if action == 'show-contact-info':
    
    1581
    -            self.parent_win.window.lookup_action(
    
    1524
    +            app.window.lookup_action(
    
    1582 1525
                     'information-%s' % self.control_id).activate()
    
    1583 1526
                 return Gdk.EVENT_STOP
    
    1584 1527
     
    
    ... ... @@ -1652,14 +1595,14 @@ def _on_page_change(self, stack, _param):
    1652 1595
         def _on_change_nick(self, _action, _param):
    
    1653 1596
             if self._get_current_page() != 'groupchat':
    
    1654 1597
                 return
    
    1655
    -        self.xml.nickname_entry.set_text(self.nick)
    
    1598
    +        self.xml.nickname_entry.set_text(self.contact.nickname)
    
    1656 1599
             self.xml.nickname_entry.grab_focus()
    
    1657 1600
             self.xml.nickname_change_button.grab_default()
    
    1658 1601
             self._show_page('nickname')
    
    1659 1602
     
    
    1660 1603
         def _on_nickname_text_changed(self, entry, _param):
    
    1661 1604
             text = entry.get_text()
    
    1662
    -        if not text or text == self.nick:
    
    1605
    +        if not text or text == self.contact.nickname:
    
    1663 1606
                 self.xml.nickname_change_button.set_sensitive(False)
    
    1664 1607
             else:
    
    1665 1608
                 try:
    
    ... ... @@ -1677,7 +1620,7 @@ def _on_nickname_change_clicked(self, _button):
    1677 1620
         def _on_rename_groupchat(self, _action, _param):
    
    1678 1621
             if self._get_current_page() != 'groupchat':
    
    1679 1622
                 return
    
    1680
    -        self.xml.name_entry.set_text(self.room_name)
    
    1623
    +        self.xml.name_entry.set_text(self.contact.name)
    
    1681 1624
             self.xml.name_entry.grab_focus()
    
    1682 1625
             self.xml.rename_button.grab_default()
    
    1683 1626
             self._show_page('rename')
    
    ... ... @@ -1705,7 +1648,7 @@ def _on_subject_change_clicked(self, _button):
    1705 1648
     
    
    1706 1649
         def _on_password_set_clicked(self, _button):
    
    1707 1650
             password = self.xml.password_entry.get_text()
    
    1708
    -        self._muc_data.password = password
    
    1651
    +        self._client.get_module('MUC').set_password(self.room_jid, password)
    
    1709 1652
             self._client.get_module('MUC').join(self.room_jid)
    
    1710 1653
             self._show_page('groupchat')
    
    1711 1654
     
    
    ... ... @@ -1727,11 +1670,6 @@ def _on_room_captcha_challenge(self, _contact, _signal_name, properties):
    1727 1670
             self._captcha_request.show_all()
    
    1728 1671
             self.xml.captcha_box.add(self._captcha_request)
    
    1729 1672
     
    
    1730
    -        if self.parent_win:
    
    1731
    -            self.parent_win.redraw_tab(self, 'attention')
    
    1732
    -        else:
    
    1733
    -            self.attention_flag = True
    
    1734
    -
    
    1735 1673
             self._show_page('captcha')
    
    1736 1674
             self._captcha_request.focus_first_entry()
    
    1737 1675
     
    

  • gajim/gtk/chat_stack.py
    ... ... @@ -47,8 +47,7 @@ def add_chat(self, account, jid):
    47 47
                 # Control is already in the Stack
    
    48 48
                 return
    
    49 49
     
    
    50
    -        mw = self.get_toplevel()
    
    51
    -        chat_control = ChatControl(mw, jid, account, None, None)
    
    50
    +        chat_control = ChatControl(account, jid)
    
    52 51
             self._controls[(account, jid)] = chat_control
    
    53 52
             self.add_named(chat_control.widget, f'{account}:{jid}')
    
    54 53
             chat_control.widget.show_all()
    
    ... ... @@ -57,21 +56,13 @@ def add_group_chat(self, account, jid):
    57 56
             if self._controls.get((account, jid)) is not None:
    
    58 57
                 return
    
    59 58
     
    
    60
    -        # muc_data = self._create_muc_data(account,
    
    61
    -        #                                  room_jid,
    
    62
    -        #                                  nick,
    
    63
    -        #                                  password,
    
    64
    -        #                                  None)
    
    65
    -
    
    66
    -        mw = self.get_toplevel()
    
    67
    -        control = GroupchatControl(mw, jid, None, account)
    
    59
    +        control = GroupchatControl(account, jid)
    
    68 60
             self._controls[(account, jid)] = control
    
    69 61
             self.add_named(control.widget, f'{account}:{jid}')
    
    70 62
             control.widget.show_all()
    
    71 63
     
    
    72 64
         def add_private_chat(self, account, jid):
    
    73
    -        mw = self.get_toplevel()
    
    74
    -        control = PrivateChatControl(mw, jid, account)
    
    65
    +        control = PrivateChatControl(account, jid)
    
    75 66
             self._controls[(account, str(jid))] = control
    
    76 67
             self.add_named(control.widget, f'{account}:{jid}')
    
    77 68
             control.widget.show_all()
    

  • gajim/privatechat_control.py
    ... ... @@ -42,11 +42,11 @@ class PrivateChatControl(ChatControl):
    42 42
         # will be processed with this command host.
    
    43 43
         COMMAND_HOST = PrivateChatCommands
    
    44 44
     
    
    45
    -    def __init__(self, parent_win, jid, account):
    
    45
    +    def __init__(self, account, jid):
    
    46 46
             self._room_contact = self._client.get_module('Contacts').get_contact(
    
    47 47
                 jid.bare)
    
    48 48
     
    
    49
    -        ChatControl.__init__(self, parent_win, jid, account, None)
    
    49
    +        ChatControl.__init__(self, account, jid)
    
    50 50
     
    
    51 51
             # self.register_events([
    
    52 52
             #     ('update-gc-avatar', ged.GUI1, self._on_update_gc_avatar),