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

Commits:

2 changed files:

Changes:

  • gajim/gtk/menus.py
    ... ... @@ -84,11 +84,11 @@ def get_self_contact_menu(contact: types.BareContact) -> GajimMenu:
    84 84
     def get_singlechat_menu(contact: types.BareContact) -> GajimMenu:
    
    85 85
         account = contact.account
    
    86 86
     
    
    87
    -    value = f'"{contact.jid}"'
    
    88
    -
    
    89 87
         menu = GajimMenu()
    
    90 88
         menu.add_item(_('Details'), 'win.show-contact-info')
    
    91
    -    menu.add_item(_('Block Contact…'), f'app.{account}-block-contact', value)
    
    89
    +    menu.add_item(_('Block Contact…'),
    
    90
    +                  f'app.{account}-block-contact',
    
    91
    +                  str(contact.jid))
    
    92 92
     
    
    93 93
         submenu = get_send_file_submenu()
    
    94 94
         menu.append_submenu(_('Send File'), submenu)
    
    ... ... @@ -131,7 +131,7 @@ def get_groupchat_menu(contact: GroupchatContact) -> GajimMenu:
    131 131
             (_('Details'), 'win.show-contact-info', None),
    
    132 132
             (_('Change Nickname…'), 'win.muc-change-nickname', None),
    
    133 133
             (_('Request Voice'), 'win.muc-request-voice', None),
    
    134
    -        (_('Execute Command…'), 'win.muc-execute-command', '""'),
    
    134
    +        (_('Execute Command…'), 'win.muc-execute-command', ''),
    
    135 135
             (_('Search…'), 'win.search-history', None)
    
    136 136
         ]
    
    137 137
     
    
    ... ... @@ -140,26 +140,24 @@ def get_groupchat_menu(contact: GroupchatContact) -> GajimMenu:
    140 140
     
    
    141 141
     def get_account_menu(account: str) -> GajimMenu:
    
    142 142
     
    
    143
    -    val = f'"{account}"'
    
    144
    -
    
    145 143
         menuitems: MenuItemListT = [
    
    146
    -        (_('Profile'), f'app.{account}-profile', val),
    
    147
    -        (_('Discover Services…'), f'app.{account}-services', val),
    
    148
    -        (_('Server Info'), f'app.{account}-server-info', val),
    
    144
    +        (_('Profile'), f'app.{account}-profile', account),
    
    145
    +        (_('Discover Services…'), f'app.{account}-services', account),
    
    146
    +        (_('Server Info'), f'app.{account}-server-info', account),
    
    149 147
         ]
    
    150 148
     
    
    151 149
         menu = GajimMenu.from_list(menuitems)
    
    152 150
     
    
    153 151
         advanced_menuitems: MenuItemListT = [
    
    154
    -        (_('Archiving Preferences'), f'app.{account}-archive', val),
    
    155
    -        (_('Blocking List'), f'app.{account}-blocking', val),
    
    156
    -        (_('PEP Configuration'), f'app.{account}-pep-config', val),
    
    157
    -        (_('Synchronise History…'), f'app.{account}-sync-history', val),
    
    152
    +        (_('Archiving Preferences'), f'app.{account}-archive', account),
    
    153
    +        (_('Blocking List'), f'app.{account}-blocking', account),
    
    154
    +        (_('PEP Configuration'), f'app.{account}-pep-config', account),
    
    155
    +        (_('Synchronise History…'), f'app.{account}-sync-history', account),
    
    158 156
         ]
    
    159 157
     
    
    160 158
         if app.settings.get('developer_modus'):
    
    161 159
             advanced_menuitems.append(
    
    162
    -            (_('Bookmarks'), f'app.{account}-bookmarks', val))
    
    160
    +            (_('Bookmarks'), f'app.{account}-bookmarks', account))
    
    163 161
     
    
    164 162
         menu.append_submenu(_('Advanced'), GajimMenu.from_list(advanced_menuitems))
    
    165 163
     
    
    ... ... @@ -208,10 +206,10 @@ def build_accounts_menu() -> None:
    208 206
     def get_encryption_menu() -> GajimMenu:
    
    209 207
     
    
    210 208
         menuitems: MenuItemListT = [
    
    211
    -        (_('Disabled'), 'win.set-encryption', '""'),
    
    212
    -        ('OMEMO', 'win.set-encryption', '"OMEMO"'),
    
    213
    -        ('OpenPGP', 'win.set-encryption', '"OpenPGP"'),
    
    214
    -        ('PGP', 'win.set-encryption', '"PGP"'),
    
    209
    +        (_('Disabled'), 'win.set-encryption', ''),
    
    210
    +        ('OMEMO', 'win.set-encryption', 'OMEMO'),
    
    211
    +        ('OpenPGP', 'win.set-encryption', 'OpenPGP'),
    
    212
    +        ('PGP', 'win.set-encryption', 'PGP'),
    
    215 213
         ]
    
    216 214
     
    
    217 215
         return GajimMenu.from_list(menuitems)
    
    ... ... @@ -415,7 +413,7 @@ def get_roster_menu(account: str, jid: str, gateway: bool = False) -> GajimMenu:
    415 413
         if jid_is_blocked(account, jid):
    
    416 414
             block_label = _('Unblock')
    
    417 415
     
    
    418
    -    value = f'"{jid}"'
    
    416
    +    value = str(jid)
    
    419 417
     
    
    420 418
         menuitems: MenuItemListT = [
    
    421 419
             (_('Details'), f'app.{account}-contact-info', value),
    
    ... ... @@ -445,7 +443,7 @@ def get_subscription_menu(account: str, jid: JID) -> GajimMenu:
    445 443
                                      jid=jid,
    
    446 444
                                      type='contact',
    
    447 445
                                      select=True)
    
    448
    -    value = f'"{jid}"'
    
    446
    +    value = str(jid)
    
    449 447
         menuitems: MenuItemListT = [
    
    450 448
             (_('Start Chat'), 'win.add-chat', params),
    
    451 449
             (_('Details'), f'win.contact-info-{account}', value),
    
    ... ... @@ -545,26 +543,26 @@ def get_groupchat_admin_menu(self_contact: types.GroupchatParticipant,
    545 543
             return menu
    
    546 544
     
    
    547 545
         action = 'win.muc-change-affiliation'
    
    546
    +    real_jid = str(contact.real_jid)
    
    548 547
     
    
    549 548
         if is_affiliation_change_allowed(self_contact, contact, 'owner'):
    
    550
    -        value = f'["{contact.real_jid}", "owner"]'
    
    549
    +        value = GLib.Variant('as', [real_jid, 'owner'])
    
    551 550
             menu.add_item(_('Make Owner'), action, value)
    
    552 551
     
    
    553 552
         if is_affiliation_change_allowed(self_contact, contact, 'admin'):
    
    554
    -        value = f'["{contact.real_jid}", "admin"]'
    
    553
    +        value = GLib.Variant('as', [real_jid, 'admin'])
    
    555 554
             menu.add_item(_('Make Admin'), action, value)
    
    556 555
     
    
    557 556
         if is_affiliation_change_allowed(self_contact, contact, 'member'):
    
    558
    -        value = f'["{contact.real_jid}", "member"]'
    
    557
    +        value = GLib.Variant('as', [real_jid, 'member'])
    
    559 558
             menu.add_item(_('Make Member'), action, value)
    
    560 559
     
    
    561 560
         if is_affiliation_change_allowed(self_contact, contact, 'none'):
    
    562
    -        value = f'["{contact.real_jid}", "none"]'
    
    561
    +        value = GLib.Variant('as', [real_jid, 'none'])
    
    563 562
             menu.add_item(_('Revoke Member'), action, value)
    
    564 563
     
    
    565 564
         if is_affiliation_change_allowed(self_contact, contact, 'outcast'):
    
    566
    -        value = f'"{contact.real_jid}"'
    
    567
    -        menu.add_item(_('Ban…'), 'win.muc-ban', value)
    
    565
    +        menu.add_item(_('Ban…'), 'win.muc-ban', real_jid)
    
    568 566
     
    
    569 567
         if not menu.get_n_items():
    
    570 568
             menu.add_item(_('Not Available'), 'dummy', None)
    
    ... ... @@ -582,18 +580,19 @@ def get_groupchat_mod_menu(self_contact: types.GroupchatParticipant,
    582 580
             menu.add_item(_('Not Available'), 'dummy', None)
    
    583 581
             return menu
    
    584 582
     
    
    583
    +    contact_name = str(contact.name)
    
    584
    +
    
    585 585
         if is_role_change_allowed(self_contact, contact):
    
    586
    -        value = f'"{contact.name}"'
    
    587
    -        menu.add_item(_('Kick…'), 'win.muc-kick', value)
    
    586
    +        menu.add_item(_('Kick…'), 'win.muc-kick', contact_name)
    
    588 587
     
    
    589 588
         action = 'win.muc-change-role'
    
    590 589
     
    
    591 590
         if is_role_change_allowed(self_contact, contact):
    
    592 591
             if contact.role.is_visitor:
    
    593
    -            value = f'["{contact.name}", "participant"]'
    
    592
    +            value = GLib.Variant('as', [contact_name, 'participant'])
    
    594 593
                 menu.add_item(_('Grant Voice'), action, value)
    
    595 594
             else:
    
    596
    -            value = f'["{contact.name}", "visitor"]'
    
    595
    +            value = value = GLib.Variant('as', [contact_name, 'visitor'])
    
    597 596
                 menu.add_item(_('Revoke Voice'), action, value)
    
    598 597
     
    
    599 598
         if not menu.get_n_items():
    
    ... ... @@ -607,7 +606,7 @@ def get_groupchat_participant_menu(account: str,
    607 606
                                        contact: types.GroupchatParticipant
    
    608 607
                                        ) -> GajimMenu:
    
    609 608
     
    
    610
    -    value = f'"{contact.name}"'
    
    609
    +    value = str(contact.name)
    
    611 610
     
    
    612 611
         general_items: MenuItemListT = [
    
    613 612
             (_('Details'), 'win.muc-contact-info', value),
    
    ... ... @@ -616,7 +615,7 @@ def get_groupchat_participant_menu(account: str,
    616 615
     
    
    617 616
         real_contact = contact.get_real_contact()
    
    618 617
         if real_contact is not None and can_add_to_roster(real_contact):
    
    619
    -        value = f'["{account}", "{real_contact.jid}"]'
    
    618
    +        value = GLib.Variant('as', [account, str(real_contact.jid)])
    
    620 619
             action = f'app.{account}-add-contact'
    
    621 620
             general_items.insert(1, (_('Add to Contact List…'), action, value))
    
    622 621
     
    
    ... ... @@ -670,7 +669,7 @@ def get_chat_row_menu(contact: types.ChatContactT,
    670 669
         menu_items.append(
    
    671 670
             (p_('Message row action', 'Copy'),
    
    672 671
              'win.copy-message',
    
    673
    -         f'"{copy_text}"'))
    
    672
    +         copy_text))
    
    674 673
     
    
    675 674
         menu_items.append(
    
    676 675
             (p_('Message row action', 'Select Messages…'),
    
    ... ... @@ -687,9 +686,7 @@ def get_chat_row_menu(contact: types.ChatContactT,
    687 686
                 show_quote = False
    
    688 687
         if show_quote:
    
    689 688
             menu_items.append((
    
    690
    -            p_('Message row action', 'Quote…'),
    
    691
    -            'win.quote',
    
    692
    -            f'"{text}"'))
    
    689
    +            p_('Message row action', 'Quote…'), 'win.quote', text))
    
    693 690
     
    
    694 691
         show_correction = False
    
    695 692
         if message_id is not None:
    
    ... ... @@ -728,14 +725,13 @@ def get_chat_row_menu(contact: types.ChatContactT,
    728 725
     def get_preview_menu(preview: Preview) -> GajimMenu:
    
    729 726
         menu_items: MenuItemListT = []
    
    730 727
     
    
    731
    -    variant = GLib.Variant('s', preview.id)
    
    732
    -
    
    733
    -    download = (_('_Download'), 'win.preview-download', variant)
    
    734
    -    open_file = (_('_Open'), 'win.preview-open', variant)
    
    735
    -    save_as = (_('_Save as…'), 'win.preview-save-as', variant)
    
    736
    -    open_folder = (_('Open _Folder'), 'win.preview-open-folder', variant)
    
    737
    -    copy_link = (_('_Copy Link'), 'win.preview-copy-link', variant)
    
    738
    -    open_link = (_('Open Link in _Browser'), 'win.preview-open-link', variant)
    
    728
    +    download = (_('_Download'), 'win.preview-download', preview.id)
    
    729
    +    open_file = (_('_Open'), 'win.preview-open', preview.id)
    
    730
    +    save_as = (_('_Save as…'), 'win.preview-save-as', preview.id)
    
    731
    +    open_folder = (_('Open _Folder'), 'win.preview-open-folder', preview.id)
    
    732
    +    copy_link = (_('_Copy Link'), 'win.preview-copy-link', preview.id)
    
    733
    +    open_link = (_('Open Link in _Browser'), 'win.preview-open-link',
    
    734
    +                 preview.id)
    
    739 735
     
    
    740 736
         if preview.is_geo_uri:
    
    741 737
             menu_items.append(open_file)
    
    ... ... @@ -775,8 +771,8 @@ def get_workspace_menu(workspace_id: str, has_unread: bool) -> GajimMenu:
    775 771
             remove_action = 'win.remove-workspace'
    
    776 772
     
    
    777 773
         menuitems: MenuItemListT = [
    
    778
    -        (_('Edit…'), 'win.edit-workspace', f'"{workspace_id}"'),
    
    779
    -        (_('Remove'), remove_action, f'"{workspace_id}"'),
    
    774
    +        (_('Edit…'), 'win.edit-workspace', workspace_id),
    
    775
    +        (_('Remove'), remove_action, workspace_id),
    
    780 776
         ]
    
    781 777
     
    
    782 778
         if has_unread:
    
    ... ... @@ -784,7 +780,7 @@ def get_workspace_menu(workspace_id: str, has_unread: bool) -> GajimMenu:
    784 780
                 0,
    
    785 781
                 (_('Mark as read'),
    
    786 782
                  'win.mark-workspace-as-read',
    
    787
    -             f'"{workspace_id}"'))
    
    783
    +             workspace_id))
    
    788 784
     
    
    789 785
         return GajimMenu.from_list(menuitems)
    
    790 786
     
    

  • gajim/gtk/util.py
    ... ... @@ -898,7 +898,7 @@ def make_menu_item(label: str,
    898 898
     
    
    899 899
         item = Gio.MenuItem.new(label)
    
    900 900
         if isinstance(value, str):
    
    901
    -        item.set_detailed_action(f'{action}({value})')
    
    901
    +        item.set_action_and_target_value(action, GLib.Variant('s', value))
    
    902 902
         elif isinstance(value, VariantMixin):
    
    903 903
             item.set_action_and_target_value(action, value.to_variant())
    
    904 904
         else: