Daniel Brötzmann pushed to branch newcontrol at gajim / gajim

Commits:

3 changed files:

Changes:

  • gajim/gtk/chat_banner.py
    ... ... @@ -17,6 +17,7 @@
    17 17
     from typing import Any
    
    18 18
     from typing import Optional
    
    19 19
     
    
    20
    +from gi.repository import Gio
    
    20 21
     from gi.repository import Gtk
    
    21 22
     
    
    22 23
     import cairo
    
    ... ... @@ -72,6 +73,9 @@ def __init__(self) -> None:
    72 73
                 'hide_groupchat_occupants_list',
    
    73 74
                 self._set_toggle_roster_button_icon)
    
    74 75
     
    
    76
    +        action = Gio.SimpleAction.new('request-voice', None)
    
    77
    +        app.window.add_action(action)
    
    78
    +
    
    75 79
             self.show_all()
    
    76 80
     
    
    77 81
         def switch_contact(self,
    
    ... ... @@ -177,8 +181,7 @@ def _on_user_role_changed(self,
    177 181
                                   user_contact: GroupchatParticipant,
    
    178 182
                                   properties: PresenceProperties
    
    179 183
                                   ) -> None:
    
    180
    -        if properties.is_muc_self_presence:
    
    181
    -            self._ui.visitor_box.set_visible(user_contact.role.is_visitor)
    
    184
    +        self._update_content()
    
    182 185
     
    
    183 186
         def _on_user_nickname_changed(self,
    
    184 187
                                       user_contact: GroupchatParticipant,
    
    ... ... @@ -269,6 +272,8 @@ def _update_content(self) -> None:
    269 272
                 self_contact = self._contact.get_self()
    
    270 273
                 if self_contact:
    
    271 274
                     self._ui.visitor_box.set_visible(self_contact.role.is_visitor)
    
    275
    +                app.window.get_action('request-voice').set_enabled(
    
    276
    +                    self_contact.role.is_visitor)
    
    272 277
     
    
    273 278
         def _update_account_badge(self) -> None:
    
    274 279
             if self._account_badge is not None:
    
    ... ... @@ -282,10 +287,7 @@ def _update_account_badge(self) -> None:
    282 287
     
    
    283 288
         def _on_request_voice_clicked(self, _button: Gtk.Button) -> None:
    
    284 289
             self._ui.visitor_popover.popdown()
    
    285
    -        control = app.window.get_active_control()
    
    286
    -        if control is not None:
    
    287
    -            app.window.activate_action(
    
    288
    -                f'request-voice-{control.control_id}', None)
    
    290
    +        app.window.activate_action('request-voice', None)
    
    289 291
     
    
    290 292
         def _on_toggle_roster_clicked(self, _button: Gtk.Button) -> None:
    
    291 293
             state = app.settings.get('hide_groupchat_occupants_list')
    

  • gajim/gtk/chat_stack.py
    ... ... @@ -32,7 +32,7 @@
    32 32
     from gajim.common.modules.contacts import GroupchatContact
    
    33 33
     from gajim.common.modules.contacts import GroupchatParticipant
    
    34 34
     from gajim.common.structs import OutgoingMessage
    
    35
    -from gajim.common.types import BareContactT, ChatContactT
    
    35
    +from gajim.common.types import ChatContactT
    
    36 36
     
    
    37 37
     from .chat_banner import ChatBanner
    
    38 38
     from .control_stack import ControlStack
    
    ... ... @@ -103,6 +103,7 @@ def _connect_actions(self) -> None:
    103 103
                 'start-video-call',
    
    104 104
                 'start-voice-call',
    
    105 105
                 'send-message',
    
    106
    +            'request-voice',
    
    106 107
             ]
    
    107 108
     
    
    108 109
             stateful_actions = [
    
    ... ... @@ -120,7 +121,7 @@ def _connect_actions(self) -> None:
    120 121
                 assert action is not None
    
    121 122
                 action.connect('change-state', self._on_stateful_action)
    
    122 123
     
    
    123
    -    def _update_base_actions(self, contact: ChatContactT):
    
    124
    +    def _update_base_actions(self, contact: ChatContactT) -> None:
    
    124 125
             client = app.get_client(contact.account)
    
    125 126
             online = app.account_is_connected(contact.account)
    
    126 127
     
    
    ... ... @@ -166,7 +167,12 @@ def _update_chat_actions(self, contact: BareContact) -> None:
    166 167
                 sys.platform != 'win32')
    
    167 168
     
    
    168 169
         def _update_group_chat_actions(self, contact: GroupchatContact) -> None:
    
    169
    -        pass
    
    170
    +        is_visitor = False
    
    171
    +        if contact.is_joined:
    
    172
    +            self_contact = contact.get_self()
    
    173
    +            assert self_contact
    
    174
    +            is_visitor = self_contact.role.is_visitor
    
    175
    +        app.window.get_action('request-voice').set_enabled(is_visitor)
    
    170 176
     
    
    171 177
         def _update_participant_actions(self,
    
    172 178
                                         contact: GroupchatParticipant) -> None:
    
    ... ... @@ -180,6 +186,7 @@ def _on_action(self,
    180 186
             contact = self._current_contact
    
    181 187
             assert contact is not None
    
    182 188
             account = contact.account
    
    189
    +        client = app.get_client(account)
    
    183 190
             jid = contact.jid
    
    184 191
     
    
    185 192
             if action_name == 'send-message':
    
    ... ... @@ -230,6 +237,8 @@ def _on_action(self,
    230 237
                     open_window('GroupchatDetails', contact=contact)
    
    231 238
                 else:
    
    232 239
                     app.window.contact_info(account, jid)
    
    240
    +        elif action_name == 'request-voice':
    
    241
    +            client.get_module('MUC').request_voice(contact.jid)
    
    233 242
     
    
    234 243
         def _on_stateful_action(self,
    
    235 244
                                 action: Gio.SimpleAction,
    

  • gajim/gtk/controls/groupchat.py
    ... ... @@ -216,7 +216,6 @@ def add_actions(self) -> None:
    216 216
             actions = [
    
    217 217
                 ('change-nickname-', None, self._on_change_nick),
    
    218 218
                 ('destroy-', None, self._on_destroy_room),
    
    219
    -            ('request-voice-', None, self._on_request_voice),
    
    220 219
                 # ('groupchat-details-', None, self._on_details),
    
    221 220
                 ('invite-', None, self._on_invite),
    
    222 221
                 ('contact-information-', 's', self._on_contact_information),
    
    ... ... @@ -236,13 +235,7 @@ def add_actions(self) -> None:
    236 235
                 app.window.add_action(act)
    
    237 236
     
    
    238 237
         def update_actions(self, *args: Any) -> None:
    
    239
    -        request_voice = False
    
    240 238
             joined = self.contact.is_joined
    
    241
    -        if joined:
    
    242
    -            contact = self.contact.get_self()
    
    243
    -            request_voice = contact.role.is_visitor
    
    244
    -
    
    245
    -        self._get_action('request-voice-').set_enabled(request_voice)
    
    246 239
     
    
    247 240
             # Change Nick
    
    248 241
             self._get_action('change-nickname-').set_enabled(
    
    ... ... @@ -291,7 +284,6 @@ def remove_actions(self) -> None:
    291 284
                 'change-nickname-',
    
    292 285
                 'destroy-',
    
    293 286
                 'configure-',
    
    294
    -            'request-voice-',
    
    295 287
                 'groupchat-details-',
    
    296 288
                 'invite-',
    
    297 289
                 'contact-information-',
    
    ... ... @@ -385,19 +377,6 @@ def _on_destroy_confirm(self, _button: Gtk.Button) -> None:
    385 377
             self._client.get_module('MUC').destroy(self.room_jid, reason, jid)
    
    386 378
             self._show_page('groupchat')
    
    387 379
     
    
    388
    -    def _on_request_voice_clicked(self, _button: Gtk.Button) -> None:
    
    389
    -        self._request_voice()
    
    390
    -        self.xml.visitor_popover.popdown()
    
    391
    -
    
    392
    -    def _on_request_voice(self,
    
    393
    -                          _action: Gio.SimpleAction,
    
    394
    -                          _param: Optional[GLib.Variant]
    
    395
    -                          ) -> None:
    
    396
    -        self._request_voice()
    
    397
    -
    
    398
    -    def _request_voice(self) -> None:
    
    399
    -        self._client.get_module('MUC').request_voice(self.room_jid)
    
    400
    -
    
    401 380
         def _on_execute_command(self,
    
    402 381
                                 _action: Gio.SimpleAction,
    
    403 382
                                 param: GLib.Variant