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

Commits:

3 changed files:

Changes:

  • gajim/gtk/conversation/rows/message.py
    ... ... @@ -53,6 +53,7 @@
    53 53
     from ..message_widget import MessageWidget
    
    54 54
     from ...dialogs import InputDialog
    
    55 55
     from ...dialogs import DialogButton
    
    56
    +from ...menus import get_groupchat_participant_menu
    
    56 57
     from ...preview import PreviewWidget
    
    57 58
     from ...util import format_fingerprint
    
    58 59
     from ...util import get_cursor
    
    ... ... @@ -265,10 +266,43 @@ def _on_avatar_clicked(self,
    265 266
                                event: Gdk.EventButton,
    
    266 267
                                name: str
    
    267 268
                                ) -> int:
    
    268
    -        if event.type == Gdk.EventType.BUTTON_PRESS and event.button == 1:
    
    269
    -            app.window.activate_action('mention', GLib.Variant('s', name))
    
    269
    +        if event.type == Gdk.EventType.BUTTON_PRESS:
    
    270
    +            if event.button == 1:
    
    271
    +                app.window.activate_action('mention', GLib.Variant('s', name))
    
    272
    +            elif event.button == 3:
    
    273
    +                rect = Gdk.Rectangle()
    
    274
    +                rect.x, rect.y = int(event.x), int(event.y)
    
    275
    +                rect.height, rect.width = 1, 1
    
    276
    +                self._show_participant_menu(name, rect)
    
    277
    +
    
    270 278
             return Gdk.EVENT_STOP
    
    271 279
     
    
    280
    +    def _show_participant_menu(self, nick: str, rect: Gdk.Rectangle) -> None:
    
    281
    +        assert isinstance(self._contact, GroupchatContact)
    
    282
    +        if not self._contact.is_joined:
    
    283
    +            return
    
    284
    +
    
    285
    +        self_contact = self._contact.get_self()
    
    286
    +        assert self_contact is not None
    
    287
    +
    
    288
    +        if nick == self_contact.name:
    
    289
    +            # Don’t show menu for us
    
    290
    +            return
    
    291
    +
    
    292
    +        contact = self._contact.get_resource(nick)
    
    293
    +        menu = get_groupchat_participant_menu(self._contact.account,
    
    294
    +                                              self_contact,
    
    295
    +                                              contact)
    
    296
    +
    
    297
    +        def destroy(popover: Gtk.Popover) -> None:
    
    298
    +            app.check_finalize(popover)
    
    299
    +            GLib.idle_add(popover.set_relative_to, None)
    
    300
    +
    
    301
    +        popover = Gtk.Popover.new_from_model(self, menu)
    
    302
    +        popover.set_pointing_to(rect)
    
    303
    +        popover.connect('closed', destroy)
    
    304
    +        popover.popup()
    
    305
    +
    
    272 306
         @staticmethod
    
    273 307
         def _on_realize(event_box: Gtk.EventBox) -> None:
    
    274 308
             window = event_box.get_window()
    

  • gajim/gtk/groupchat_roster.py
    ... ... @@ -38,7 +38,7 @@
    38 38
     from gajim.common.events import MUCNicknameChanged
    
    39 39
     from gajim.common.modules.contacts import GroupchatContact
    
    40 40
     
    
    41
    -from .menus import get_groupchat_roster_menu
    
    41
    +from .menus import get_groupchat_participant_menu
    
    42 42
     from .tooltips import GCTooltip
    
    43 43
     from .builder import get_builder
    
    44 44
     from .util import EventHelper
    
    ... ... @@ -427,9 +427,9 @@ def _show_contact_menu(self, nick: str, rect: Gdk.Rectangle) -> None:
    427 427
             self_contact = self._contact.get_self()
    
    428 428
             assert self_contact is not None
    
    429 429
             contact = self._contact.get_resource(nick)
    
    430
    -        menu = get_groupchat_roster_menu(self._contact.account,
    
    431
    -                                         self_contact,
    
    432
    -                                         contact)
    
    430
    +        menu = get_groupchat_participant_menu(self._contact.account,
    
    431
    +                                              self_contact,
    
    432
    +                                              contact)
    
    433 433
     
    
    434 434
             def destroy(popover: Gtk.Popover) -> None:
    
    435 435
                 app.check_finalize(popover)
    

  • gajim/gtk/menus.py
    ... ... @@ -465,6 +465,10 @@ def get_groupchat_admin_menu(self_contact: types.GroupchatParticipant,
    465 465
     
    
    466 466
         menu = GajimMenu()
    
    467 467
     
    
    468
    +    if contact.real_jid is None:
    
    469
    +        menu.add_item(_('Not Available'), 'dummy', None)
    
    470
    +        return menu
    
    471
    +
    
    468 472
         action = 'win.muc-change-affiliation'
    
    469 473
     
    
    470 474
         if is_affiliation_change_allowed(self_contact, contact, 'owner'):
    
    ... ... @@ -499,6 +503,10 @@ def get_groupchat_mod_menu(self_contact: types.GroupchatParticipant,
    499 503
     
    
    500 504
         menu = GajimMenu()
    
    501 505
     
    
    506
    +    if not contact.is_available:
    
    507
    +        menu.add_item(_('Not Available'), 'dummy', None)
    
    508
    +        return menu
    
    509
    +
    
    502 510
         if is_role_change_allowed(self_contact, contact):
    
    503 511
             value = f'"{contact.name}"'
    
    504 512
             menu.add_item(_('Kick…'), 'win.muc-kick', value)
    
    ... ... @@ -519,10 +527,10 @@ def get_groupchat_mod_menu(self_contact: types.GroupchatParticipant,
    519 527
         return menu
    
    520 528
     
    
    521 529
     
    
    522
    -def get_groupchat_roster_menu(account: str,
    
    523
    -                              self_contact: types.GroupchatParticipant,
    
    524
    -                              contact: types.GroupchatParticipant
    
    525
    -                              ) -> GajimMenu:
    
    530
    +def get_groupchat_participant_menu(account: str,
    
    531
    +                                   self_contact: types.GroupchatParticipant,
    
    532
    +                                   contact: types.GroupchatParticipant
    
    533
    +                                   ) -> GajimMenu:
    
    526 534
     
    
    527 535
         value = f'"{contact.name}"'
    
    528 536