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

Commits:

2 changed files:

Changes:

  • gajim/data/gui/groupchat_control.ui
    ... ... @@ -233,6 +233,56 @@
    233 233
                                     <property name="position">1</property>
    
    234 234
                                   </packing>
    
    235 235
                                 </child>
    
    236
    +                            <child>
    
    237
    +                              <object class="GtkBox" id="visitor_box">
    
    238
    +                                <property name="can-focus">False</property>
    
    239
    +                                <property name="no-show-all">True</property>
    
    240
    +                                <property name="spacing">12</property>
    
    241
    +                                <child>
    
    242
    +                                  <object class="GtkLabel">
    
    243
    +                                    <property name="visible">True</property>
    
    244
    +                                    <property name="can-focus">False</property>
    
    245
    +                                    <property name="label" translatable="yes">You are a visitor</property>
    
    246
    +                                  </object>
    
    247
    +                                  <packing>
    
    248
    +                                    <property name="expand">False</property>
    
    249
    +                                    <property name="fill">True</property>
    
    250
    +                                    <property name="position">0</property>
    
    251
    +                                  </packing>
    
    252
    +                                </child>
    
    253
    +                                <child>
    
    254
    +                                  <object class="GtkMenuButton" id="visitor_menu_button">
    
    255
    +                                    <property name="visible">True</property>
    
    256
    +                                    <property name="can-focus">True</property>
    
    257
    +                                    <property name="focus-on-click">False</property>
    
    258
    +                                    <property name="receives-default">True</property>
    
    259
    +                                    <property name="tooltip-text" translatable="yes">What does this mean?</property>
    
    260
    +                                    <property name="valign">center</property>
    
    261
    +                                    <property name="popover">visitor_popover</property>
    
    262
    +                                    <child>
    
    263
    +                                      <object class="GtkImage">
    
    264
    +                                        <property name="visible">True</property>
    
    265
    +                                        <property name="can-focus">False</property>
    
    266
    +                                        <property name="icon-name">dialog-information-symbolic</property>
    
    267
    +                                      </object>
    
    268
    +                                    </child>
    
    269
    +                                    <style>
    
    270
    +                                      <class name="suggested-action"/>
    
    271
    +                                    </style>
    
    272
    +                                  </object>
    
    273
    +                                  <packing>
    
    274
    +                                    <property name="expand">False</property>
    
    275
    +                                    <property name="fill">True</property>
    
    276
    +                                    <property name="position">1</property>
    
    277
    +                                  </packing>
    
    278
    +                                </child>
    
    279
    +                              </object>
    
    280
    +                              <packing>
    
    281
    +                                <property name="expand">False</property>
    
    282
    +                                <property name="fill">True</property>
    
    283
    +                                <property name="position">2</property>
    
    284
    +                              </packing>
    
    285
    +                            </child>
    
    236 286
                                 <child>
    
    237 287
                                   <object class="GtkBox" id="account_badge_box">
    
    238 288
                                     <property name="can-focus">False</property>
    
    ... ... @@ -249,7 +299,7 @@
    249 299
                                   <packing>
    
    250 300
                                     <property name="expand">False</property>
    
    251 301
                                     <property name="fill">True</property>
    
    252
    -                                <property name="position">2</property>
    
    302
    +                                <property name="position">3</property>
    
    253 303
                                   </packing>
    
    254 304
                                 </child>
    
    255 305
                                 <child>
    
    ... ... @@ -301,7 +351,7 @@
    301 351
                                   <packing>
    
    302 352
                                     <property name="expand">False</property>
    
    303 353
                                     <property name="fill">True</property>
    
    304
    -                                <property name="position">3</property>
    
    354
    +                                <property name="position">4</property>
    
    305 355
                                   </packing>
    
    306 356
                                 </child>
    
    307 357
                               </object>
    
    ... ... @@ -2423,4 +2473,70 @@
    2423 2473
           </packing>
    
    2424 2474
         </child>
    
    2425 2475
       </object>
    
    2476
    +  <object class="GtkPopover" id="visitor_popover">
    
    2477
    +    <property name="can-focus">False</property>
    
    2478
    +    <property name="relative-to">visitor_menu_button</property>
    
    2479
    +    <property name="position">bottom</property>
    
    2480
    +    <child>
    
    2481
    +      <object class="GtkBox">
    
    2482
    +        <property name="visible">True</property>
    
    2483
    +        <property name="can-focus">False</property>
    
    2484
    +        <property name="orientation">vertical</property>
    
    2485
    +        <property name="spacing">6</property>
    
    2486
    +        <child>
    
    2487
    +          <object class="GtkLabel">
    
    2488
    +            <property name="visible">True</property>
    
    2489
    +            <property name="can-focus">False</property>
    
    2490
    +            <property name="label" translatable="yes">You are a visitor</property>
    
    2491
    +            <style>
    
    2492
    +              <class name="bold"/>
    
    2493
    +            </style>
    
    2494
    +          </object>
    
    2495
    +          <packing>
    
    2496
    +            <property name="expand">False</property>
    
    2497
    +            <property name="fill">True</property>
    
    2498
    +            <property name="position">0</property>
    
    2499
    +          </packing>
    
    2500
    +        </child>
    
    2501
    +        <child>
    
    2502
    +          <object class="GtkLabel">
    
    2503
    +            <property name="visible">True</property>
    
    2504
    +            <property name="can-focus">False</property>
    
    2505
    +            <property name="label" translatable="yes">In order to write messages in this chat, you need to request voice first.
    
    2506
    +A moderator will process your request.</property>
    
    2507
    +            <property name="wrap">True</property>
    
    2508
    +            <property name="max-width-chars">30</property>
    
    2509
    +          </object>
    
    2510
    +          <packing>
    
    2511
    +            <property name="expand">False</property>
    
    2512
    +            <property name="fill">True</property>
    
    2513
    +            <property name="position">1</property>
    
    2514
    +          </packing>
    
    2515
    +        </child>
    
    2516
    +        <child>
    
    2517
    +          <object class="GtkButton">
    
    2518
    +            <property name="label" translatable="yes">_Request</property>
    
    2519
    +            <property name="visible">True</property>
    
    2520
    +            <property name="can-focus">True</property>
    
    2521
    +            <property name="receives-default">True</property>
    
    2522
    +            <property name="halign">center</property>
    
    2523
    +            <property name="use-underline">True</property>
    
    2524
    +            <signal name="clicked" handler="_on_request_voice_clicked" swapped="no"/>
    
    2525
    +            <style>
    
    2526
    +              <class name="suggested-action"/>
    
    2527
    +            </style>
    
    2528
    +          </object>
    
    2529
    +          <packing>
    
    2530
    +            <property name="expand">False</property>
    
    2531
    +            <property name="fill">True</property>
    
    2532
    +            <property name="pack-type">end</property>
    
    2533
    +            <property name="position">2</property>
    
    2534
    +          </packing>
    
    2535
    +        </child>
    
    2536
    +        <style>
    
    2537
    +          <class name="padding-6"/>
    
    2538
    +        </style>
    
    2539
    +      </object>
    
    2540
    +    </child>
    
    2541
    +  </object>
    
    2426 2542
     </interface>

  • gajim/gtk/controls/groupchat.py
    ... ... @@ -40,6 +40,7 @@
    40 40
     from nbxmpp.errors import StanzaError
    
    41 41
     from nbxmpp.modules.security_labels import Displaymarking
    
    42 42
     from nbxmpp.modules.vcard_temp import VCard
    
    43
    +from nbxmpp.structs import PresenceProperties
    
    43 44
     
    
    44 45
     from gi.repository import Gtk
    
    45 46
     from gi.repository import Gdk
    
    ... ... @@ -55,6 +56,8 @@
    55 56
     from gajim.common.const import AvatarSize
    
    56 57
     
    
    57 58
     from gajim.common.i18n import _
    
    59
    +from gajim.common.modules.contacts import GroupchatContact
    
    60
    +from gajim.common.modules.contacts import GroupchatParticipant
    
    58 61
     from gajim.common.structs import OutgoingMessage
    
    59 62
     
    
    60 63
     from gajim.gui.controls.base import BaseControl
    
    ... ... @@ -310,7 +313,7 @@ def add_actions(self) -> None:
    310 313
                 act.connect("activate", func)
    
    311 314
                 app.window.add_action(act)
    
    312 315
     
    
    313
    -    def update_actions(self, *args):
    
    316
    +    def update_actions(self, *args: Any) -> None:
    
    314 317
             joined = self.contact.is_joined
    
    315 318
             if joined:
    
    316 319
                 contact = self.contact.get_self()
    
    ... ... @@ -564,10 +567,17 @@ def _on_configure_form_received(self, task):
    564 567
                 return
    
    565 568
             GroupchatConfig(self.account, result.jid, 'owner', result.form)
    
    566 569
     
    
    567
    -    def _on_request_voice(self, _action, _param):
    
    568
    -        """
    
    569
    -        Request voice in the current room
    
    570
    -        """
    
    570
    +    def _on_request_voice_clicked(self, _button: Gtk.Button) -> None:
    
    571
    +        self._request_voice()
    
    572
    +        self.xml.visitor_popover.popdown()
    
    573
    +
    
    574
    +    def _on_request_voice(self,
    
    575
    +                          _action: Gio.SimpleAction,
    
    576
    +                          _param: Optional[GLib.Variant]
    
    577
    +                          ) -> None:
    
    578
    +        self._request_voice()
    
    579
    +
    
    580
    +    def _request_voice(self) -> None:
    
    571 581
             self._client.get_module('MUC').request_voice(self.room_jid)
    
    572 582
     
    
    573 583
         def _on_execute_command(self, _action, param):
    
    ... ... @@ -882,7 +892,9 @@ def _set_message_input_sensitive(self, state: bool) -> None:
    882 892
     
    
    883 893
         def _set_control_active(self) -> None:
    
    884 894
             contact = self.contact.get_self()
    
    885
    -        if not contact.role.is_visitor:
    
    895
    +        if contact.role.is_visitor:
    
    896
    +            self.xml.visitor_box.show()
    
    897
    +        else:
    
    886 898
                 self._set_message_input_sensitive(True)
    
    887 899
     
    
    888 900
             self.roster.initial_draw()
    
    ... ... @@ -892,6 +904,7 @@ def _set_control_active(self) -> None:
    892 904
     
    
    893 905
         def _set_control_inactive(self) -> None:
    
    894 906
             self._set_message_input_sensitive(False)
    
    907
    +        self.xml.visitor_box.hide()
    
    895 908
     
    
    896 909
             self.roster.enable_sort(False)
    
    897 910
             self.roster.clear()
    
    ... ... @@ -971,10 +984,11 @@ def _on_user_status_show_changed(self,
    971 984
                 properties.is_muc_self_presence)
    
    972 985
     
    
    973 986
         def _on_user_affiliation_changed(self,
    
    974
    -                                     _contact,
    
    975
    -                                     _signal_name,
    
    976
    -                                     user_contact,
    
    977
    -                                     properties):
    
    987
    +                                     _contact: GroupchatContact,
    
    988
    +                                     _signal_name: str,
    
    989
    +                                     user_contact: GroupchatParticipant,
    
    990
    +                                     properties: PresenceProperties
    
    991
    +                                     ) -> None:
    
    978 992
             affiliation = helpers.get_uf_affiliation(user_contact.affiliation)
    
    979 993
             nick = user_contact.name
    
    980 994
             reason = properties.muc_user.reason
    
    ... ... @@ -1002,10 +1016,11 @@ def _on_user_affiliation_changed(self,
    1002 1016
             self.update_actions()
    
    1003 1017
     
    
    1004 1018
         def _on_user_role_changed(self,
    
    1005
    -                              _contact,
    
    1006
    -                              _signal_name,
    
    1007
    -                              user_contact,
    
    1008
    -                              properties):
    
    1019
    +                              _contact: GroupchatContact,
    
    1020
    +                              _signal_name: str,
    
    1021
    +                              user_contact: GroupchatParticipant,
    
    1022
    +                              properties: PresenceProperties
    
    1023
    +                              ) -> None:
    
    1009 1024
             role = helpers.get_uf_role(user_contact.role)
    
    1010 1025
             nick = user_contact.name
    
    1011 1026
             reason = properties.muc_user.reason
    
    ... ... @@ -1016,6 +1031,10 @@ def _on_user_role_changed(self,
    1016 1031
             actor = '' if actor is None else _(' by {actor}').format(actor=actor)
    
    1017 1032
     
    
    1018 1033
             if properties.is_muc_self_presence:
    
    1034
    +            if user_contact.role.is_visitor:
    
    1035
    +                self.xml.visitor_box.show()
    
    1036
    +            else:
    
    1037
    +                self.xml.visitor_box.hide()
    
    1019 1038
                 self._set_message_input_sensitive(not user_contact.role.is_visitor)
    
    1020 1039
                 message = _('** Your Role has been set to '
    
    1021 1040
                             '{role}{actor}{reason}').format(role=role,