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

Commits:

5 changed files:

Changes:

  • gajim/app_actions.py deleted
    1
    -# Copyright (C) 2017 Philipp Hörist <philipp AT hoerist.com>
    
    2
    -#
    
    3
    -# This file is part of Gajim.
    
    4
    -#
    
    5
    -# Gajim is free software; you can redistribute it and/or modify
    
    6
    -# it under the terms of the GNU General Public License as published
    
    7
    -# by the Free Software Foundation; version 3 only.
    
    8
    -#
    
    9
    -# Gajim is distributed in the hope that it will be useful,
    
    10
    -# but WITHOUT ANY WARRANTY; without even the implied warranty of
    
    11
    -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    
    12
    -# GNU General Public License for more details.
    
    13
    -#
    
    14
    -# You should have received a copy of the GNU General Public License
    
    15
    -# along with Gajim. If not, see <http://www.gnu.org/licenses/>.
    
    16
    -
    
    17
    -from __future__ import annotations
    
    18
    -
    
    19
    -from typing import Optional
    
    20
    -
    
    21
    -from gi.repository import Gtk
    
    22
    -from gi.repository import Gdk
    
    23
    -from gi.repository import GLib
    
    24
    -from gi.repository import Gio
    
    25
    -
    
    26
    -from nbxmpp import JID
    
    27
    -
    
    28
    -from gajim.common import app
    
    29
    -from gajim.common import helpers
    
    30
    -from gajim.common.app import interface
    
    31
    -from gajim.common.exceptions import GajimGeneralException
    
    32
    -
    
    33
    -from gajim.gui.dialogs import ShortcutsWindow
    
    34
    -from gajim.gui.about import AboutDialog
    
    35
    -from gajim.gui.discovery import ServiceDiscoveryWindow
    
    36
    -from gajim.gui.util import open_window
    
    37
    -from gajim.gui.util import get_app_window
    
    38
    -
    
    39
    -# General Actions
    
    40
    -
    
    41
    -
    
    42
    -def on_add_contact_jid(_action: Gio.SimpleAction,
    
    43
    -                       param: GLib.Variant) -> None:
    
    44
    -    jid = param.get_string() or None
    
    45
    -    if jid is not None:
    
    46
    -        jid = JID.from_string(jid)
    
    47
    -    open_window('AddContact', account=None, jid=jid)
    
    48
    -
    
    49
    -
    
    50
    -# Application Menu Actions
    
    51
    -
    
    52
    -
    
    53
    -def on_preferences(_action: Gio.SimpleAction,
    
    54
    -                   _param: Optional[GLib.Variant]) -> None:
    
    55
    -    open_window('Preferences')
    
    56
    -
    
    57
    -
    
    58
    -def on_plugins(_action: Gio.SimpleAction,
    
    59
    -               _param: Optional[GLib.Variant]) -> None:
    
    60
    -    open_window('PluginsWindow')
    
    61
    -
    
    62
    -
    
    63
    -def on_accounts(_action: Gio.SimpleAction,
    
    64
    -                param: GLib.Variant) -> None:
    
    65
    -    window = open_window('AccountsWindow')
    
    66
    -    account = param.get_string()
    
    67
    -    if account:
    
    68
    -        window.select_account(account)
    
    69
    -
    
    70
    -
    
    71
    -def on_history_manager(_action: Gio.SimpleAction,
    
    72
    -                       _param: Optional[GLib.Variant]) -> None:
    
    73
    -    open_window('HistoryManager')
    
    74
    -
    
    75
    -
    
    76
    -def on_bookmarks(_action: Gio.SimpleAction,
    
    77
    -                 param: GLib.Variant) -> None:
    
    78
    -    account = param.get_string()
    
    79
    -    open_window('Bookmarks', account=account)
    
    80
    -
    
    81
    -
    
    82
    -def on_quit(_action: Gio.SimpleAction,
    
    83
    -            _param: Optional[GLib.Variant]) -> None:
    
    84
    -    app.window.quit()
    
    85
    -
    
    86
    -
    
    87
    -def on_new_chat(_action: Gio.SimpleAction,
    
    88
    -                param: GLib.Variant) -> None:
    
    89
    -    window = open_window('StartChatDialog')
    
    90
    -    search_text = param.get_string()
    
    91
    -    if search_text:
    
    92
    -        window.set_search_text(search_text)
    
    93
    -
    
    94
    -
    
    95
    -# Accounts Actions
    
    96
    -
    
    97
    -
    
    98
    -def on_profile(_action: Gio.SimpleAction,
    
    99
    -               param: GLib.Variant) -> None:
    
    100
    -    account = param.get_string()
    
    101
    -    open_window('ProfileWindow', account=account)
    
    102
    -
    
    103
    -
    
    104
    -def on_send_server_message(_action: Gio.SimpleAction,
    
    105
    -                           param: GLib.Variant) -> None:
    
    106
    -    account = param.get_string()
    
    107
    -    server = app.settings.get_account_setting(account, 'hostname')
    
    108
    -    server += '/announce/online'
    
    109
    -    open_window('SingleMessageWindow', account=account, recipients=server)
    
    110
    -
    
    111
    -
    
    112
    -def on_service_disco(_action: Gio.SimpleAction,
    
    113
    -                     param: GLib.Variant) -> None:
    
    114
    -    account = param.get_string()
    
    115
    -    server_jid = app.settings.get_account_setting(account, 'hostname')
    
    116
    -    if server_jid in interface.instances[account]['disco']:
    
    117
    -        interface.instances[account]['disco'][server_jid].\
    
    118
    -            window.present()
    
    119
    -    else:
    
    120
    -        try:
    
    121
    -            # Object will add itself to the window dict
    
    122
    -            ServiceDiscoveryWindow(account, address_entry=True)
    
    123
    -        except GajimGeneralException:
    
    124
    -            pass
    
    125
    -
    
    126
    -
    
    127
    -def on_create_gc(_action: Gio.SimpleAction,
    
    128
    -                 param: GLib.Variant) -> None:
    
    129
    -    account = param.get_string()
    
    130
    -    open_window('CreateGroupchatWindow', account=account or None)
    
    131
    -
    
    132
    -
    
    133
    -def on_add_contact(_action: Gio.SimpleAction,
    
    134
    -                   param: GLib.Variant) -> None:
    
    135
    -    account, jid = param.get_strv()
    
    136
    -    if jid is not None:
    
    137
    -        jid = JID.from_string(jid)
    
    138
    -    open_window('AddContact', account=account or None, jid=jid or None)
    
    139
    -
    
    140
    -
    
    141
    -def on_single_message(_action: Gio.SimpleAction,
    
    142
    -                      param: GLib.Variant) -> None:
    
    143
    -    account = param.get_string()
    
    144
    -    open_window('SingleMessageWindow', account=account)
    
    145
    -
    
    146
    -
    
    147
    -def on_add_account(_action: Gio.SimpleAction,
    
    148
    -                   _param: Optional[GLib.Variant]) -> None:
    
    149
    -    open_window('AccountWizard')
    
    150
    -
    
    151
    -
    
    152
    -def on_import_contacts(_action: Gio.SimpleAction,
    
    153
    -                       param: Optional[GLib.Variant]) -> None:
    
    154
    -    open_window('SynchronizeAccounts', account=param.get_string())
    
    155
    -
    
    156
    -
    
    157
    -# Advanced Actions
    
    158
    -
    
    159
    -def on_pep_config(_action: Gio.SimpleAction,
    
    160
    -                  param: GLib.Variant) -> None:
    
    161
    -    account = param.get_string()
    
    162
    -    open_window('PEPConfig', account=account)
    
    163
    -
    
    164
    -
    
    165
    -def on_mam_preferences(_action: Gio.SimpleAction,
    
    166
    -                       param: GLib.Variant) -> None:
    
    167
    -    account = param.get_string()
    
    168
    -    open_window('MamPreferences', account=account)
    
    169
    -
    
    170
    -
    
    171
    -def on_blocking_list(_action: Gio.SimpleAction,
    
    172
    -                     param: GLib.Variant) -> None:
    
    173
    -    account = param.get_string()
    
    174
    -    open_window('BlockingList', account=account)
    
    175
    -
    
    176
    -
    
    177
    -def on_history_sync(_action: Gio.SimpleAction,
    
    178
    -                    param: GLib.Variant) -> None:
    
    179
    -    account = param.get_string()
    
    180
    -    open_window('HistorySyncAssistant',
    
    181
    -                account=account)
    
    182
    -
    
    183
    -
    
    184
    -def on_server_info(_action: Gio.SimpleAction,
    
    185
    -                   param: GLib.Variant) -> None:
    
    186
    -    account = param.get_string()
    
    187
    -    open_window('ServerInfo', account=account)
    
    188
    -
    
    189
    -
    
    190
    -def on_xml_console(_action: Gio.SimpleAction,
    
    191
    -                   _param: Optional[GLib.Variant]) -> None:
    
    192
    -    open_window('XMLConsoleWindow')
    
    193
    -
    
    194
    -
    
    195
    -def on_manage_proxies(_action: Gio.SimpleAction,
    
    196
    -                      _param: Optional[GLib.Variant]) -> None:
    
    197
    -    open_window('ManageProxies')
    
    198
    -
    
    199
    -
    
    200
    -# Admin Actions
    
    201
    -
    
    202
    -
    
    203
    -def on_set_motd(_action: Gio.SimpleAction,
    
    204
    -                param: GLib.Variant) -> None:
    
    205
    -    account = param.get_string()
    
    206
    -    server = app.settings.get_account_setting(account, 'hostname')
    
    207
    -    server += '/announce/motd'
    
    208
    -    open_window('SingleMessageWindow', account=account, recipients=server)
    
    209
    -
    
    210
    -
    
    211
    -def on_update_motd(_action: Gio.SimpleAction,
    
    212
    -                   param: GLib.Variant) -> None:
    
    213
    -    account = param.get_string()
    
    214
    -    server = app.settings.get_account_setting(account, 'hostname')
    
    215
    -    server += '/announce/motd/update'
    
    216
    -    open_window('SingleMessageWindow', account=account, recipients=server)
    
    217
    -
    
    218
    -
    
    219
    -def on_delete_motd(_action: Gio.SimpleAction,
    
    220
    -                   param: GLib.Variant) -> None:
    
    221
    -    account = param.get_string()
    
    222
    -    app.connections[account].get_module('Announce').delete_motd()
    
    223
    -
    
    224
    -# Help Actions
    
    225
    -
    
    226
    -
    
    227
    -def on_contents(_action: Gio.SimpleAction,
    
    228
    -                _param: Optional[GLib.Variant]) -> None:
    
    229
    -    helpers.open_uri('https://dev.gajim.org/gajim/gajim/wikis')
    
    230
    -
    
    231
    -
    
    232
    -def on_faq(_action: Gio.SimpleAction,
    
    233
    -           _param: Optional[GLib.Variant]) -> None:
    
    234
    -    helpers.open_uri('https://dev.gajim.org/gajim/gajim/wikis/help/gajimfaq')
    
    235
    -
    
    236
    -
    
    237
    -def on_keyboard_shortcuts(_action: Gio.SimpleAction,
    
    238
    -                          _param: Optional[GLib.Variant]) -> None:
    
    239
    -    ShortcutsWindow()
    
    240
    -
    
    241
    -
    
    242
    -def on_features(_action: Gio.SimpleAction,
    
    243
    -                _param: Optional[GLib.Variant]) -> None:
    
    244
    -    open_window('Features')
    
    245
    -
    
    246
    -
    
    247
    -def on_about(_action: Gio.SimpleAction,
    
    248
    -             _param: Optional[GLib.Variant]) -> None:
    
    249
    -    AboutDialog()
    
    250
    -
    
    251
    -# View Actions
    
    252
    -
    
    253
    -
    
    254
    -def on_file_transfers(_action: Gio.SimpleAction,
    
    255
    -                      _param: Optional[GLib.Variant]) -> None:
    
    256
    -    if interface.instances['file_transfers']. \
    
    257
    -            window.get_property('visible'):
    
    258
    -        interface.instances['file_transfers'].window.present()
    
    259
    -    else:
    
    260
    -        interface.instances['file_transfers'].window.show_all()
    
    261
    -
    
    262
    -
    
    263
    -def on_open_event(_action: Gio.SimpleAction,
    
    264
    -                  param: GLib.Variant) -> None:
    
    265
    -    dict_ = param.unpack()
    
    266
    -    app.interface.handle_event(
    
    267
    -        dict_['account'], dict_['jid'], dict_['notif_detail'])
    
    268
    -
    
    269
    -
    
    270
    -def on_mark_as_read(_action: Gio.SimpleAction,
    
    271
    -                    param: GLib.Variant) -> None:
    
    272
    -    dict_ = param.unpack()
    
    273
    -    account, jid = dict_['account'], dict_['jid']
    
    274
    -    app.window.mark_as_read(account, JID.from_string(jid))
    
    275
    -
    
    276
    -# Other Actions
    
    277
    -
    
    278
    -
    
    279
    -def toggle_ipython(_action: Gio.SimpleAction,
    
    280
    -                   _param: Optional[GLib.Variant]) -> None:
    
    281
    -    """
    
    282
    -    Show/hide the ipython window
    
    283
    -    """
    
    284
    -    win = app.ipython_window
    
    285
    -    if win and win.window.is_visible():
    
    286
    -        win.present()
    
    287
    -    else:
    
    288
    -        app.interface.create_ipython_window()
    
    289
    -
    
    290
    -
    
    291
    -def open_mail(_action: Gio.SimpleAction,
    
    292
    -              param: GLib.Variant) -> None:
    
    293
    -    uri = param.get_string()
    
    294
    -    if not uri.startswith('mailto:'):
    
    295
    -        uri = 'mailto:%s' % uri
    
    296
    -    helpers.open_uri(uri)
    
    297
    -
    
    298
    -
    
    299
    -def open_link(_action: Gio.SimpleAction,
    
    300
    -              param: GLib.Variant) -> None:
    
    301
    -    account, uri = param.get_strv()
    
    302
    -    helpers.open_uri(uri, account=account)
    
    303
    -
    
    304
    -
    
    305
    -def copy_text(_action: Gio.SimpleAction,
    
    306
    -              param: GLib.Variant) -> None:
    
    307
    -    text = param.get_string()
    
    308
    -    clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
    
    309
    -    clip.set_text(text, -1)
    
    310
    -
    
    311
    -
    
    312
    -def start_chat(_action: Gio.SimpleAction,
    
    313
    -               param: GLib.Variant) -> None:
    
    314
    -    account, jid = param.get_strv()
    
    315
    -    app.interface.start_chat_from_jid(account, jid)
    
    316
    -
    
    317
    -def forget_groupchat(_action: Gio.SimpleAction,
    
    318
    -                     param: GLib.Variant) -> None:
    
    319
    -    account, jid = param.unpack()
    
    320
    -    room_jid = JID.from_string(jid)
    
    321
    -    window = get_app_window('StartChatDialog')
    
    322
    -    window.remove_row(account, str(room_jid))
    
    323
    -
    
    324
    -    client = app.get_client(account)
    
    325
    -    client.get_module('MUC').leave(room_jid)
    
    326
    -    client.get_module('Bookmarks').remove(room_jid)
    
    327
    -
    
    328
    -    app.storage.archive.remove_chat_history(
    
    329
    -        account, str(room_jid), groupchat=True)
    
    330
    -
    
    331
    -def on_groupchat_join(_action: Gio.SimpleAction,
    
    332
    -                      param: GLib.Variant) -> None:
    
    333
    -    account, jid = param.get_strv()
    
    334
    -    open_window('GroupchatJoin', account=account, jid=jid)

  • gajim/common/const.py
    ... ... @@ -895,6 +895,8 @@ def is_active(self):
    895 895
         'error'
    
    896 896
     ]
    
    897 897
     
    
    898
    +GAJIM_FAQ_URI = 'https://dev.gajim.org/gajim/gajim/wikis/help/gajimfaq'
    
    899
    +GAJIM_WIKI_URI = 'https://dev.gajim.org/gajim/gajim/wikis'
    
    898 900
     
    
    899 901
     URI_SCHEMES = {
    
    900 902
         'aaa://',
    

  • gajim/gtk/application.py
    ... ... @@ -53,6 +53,7 @@
    53 53
     from gi.repository import Gio
    
    54 54
     from gi.repository import GLib
    
    55 55
     from gi.repository import Gtk
    
    56
    +from gi.repository import Gdk
    
    56 57
     
    
    57 58
     import gajim
    
    58 59
     from gajim.common import app
    
    ... ... @@ -60,6 +61,8 @@
    60 61
     from gajim.common import configpaths
    
    61 62
     from gajim.common import logging_helpers
    
    62 63
     from gajim.common.client import Client
    
    64
    +from gajim.common.const import GAJIM_FAQ_URI
    
    65
    +from gajim.common.const import GAJIM_WIKI_URI
    
    63 66
     from gajim.common.i18n import _
    
    64 67
     from gajim.common.nec import NetworkEvent
    
    65 68
     from gajim.common.task_manager import TaskManager
    
    ... ... @@ -67,7 +70,19 @@
    67 70
     from gajim.common.storage.archive import MessageArchiveStorage
    
    68 71
     from gajim.common.settings import Settings
    
    69 72
     from gajim.common.settings import LegacyConfig
    
    73
    +from gajim.common.helpers import open_uri
    
    70 74
     from gajim.common.helpers import load_json
    
    75
    +from gajim.common.cert_store import CertificateStore
    
    76
    +from gajim.common.exceptions import GajimGeneralException
    
    77
    +
    
    78
    +from gajim.gui import menus
    
    79
    +from gajim.gui.builder import get_builder
    
    80
    +from gajim.gui.util import load_user_iconsets
    
    81
    +from gajim.gui.dialogs import ShortcutsWindow
    
    82
    +from gajim.gui.about import AboutDialog
    
    83
    +from gajim.gui.discovery import ServiceDiscoveryWindow
    
    84
    +from gajim.gui.util import open_window
    
    85
    +from gajim.gui.util import get_app_window
    
    71 86
     
    
    72 87
     
    
    73 88
     ActionListT = list[tuple[str,
    
    ... ... @@ -209,16 +224,15 @@ def _startup(self, _application: GajimApplication) -> None:
    209 224
             app.storage.archive = MessageArchiveStorage()
    
    210 225
             app.storage.archive.init()
    
    211 226
     
    
    212
    -        from gajim.gui.util import load_user_iconsets
    
    227
    +        icon_theme = Gtk.IconTheme.get_default()
    
    228
    +        icon_theme.append_search_path(str(configpaths.get('ICONS')))
    
    213 229
             load_user_iconsets()
    
    214 230
     
    
    215
    -        from gajim.common.cert_store import CertificateStore
    
    216 231
             app.cert_store = CertificateStore()
    
    217 232
             app.task_manager = TaskManager()
    
    218 233
     
    
    219 234
             # Set Application Menu
    
    220 235
             app.app = self
    
    221
    -        from gajim.gui.builder import get_builder
    
    222 236
             builder = get_builder('application_menu.ui')
    
    223 237
             self.set_menubar(cast(Gio.Menu, builder.get_object('menubar')))
    
    224 238
     
    
    ... ... @@ -227,7 +241,6 @@ def _startup(self, _application: GajimApplication) -> None:
    227 241
             self.interface.run(self)
    
    228 242
             self.add_actions()
    
    229 243
             self._load_shortcuts()
    
    230
    -        from gajim.gui import menus
    
    231 244
             menus.build_accounts_menu()
    
    232 245
             self.update_app_actions_state()
    
    233 246
     
    
    ... ... @@ -387,35 +400,30 @@ def warn_with_traceback(message: Union[Warning, str],
    387 400
             warnings.filterwarnings(action="always")
    
    388 401
     
    
    389 402
         def add_actions(self) -> None:
    
    390
    -        ''' Build Application Actions '''
    
    391
    -        from gajim import app_actions
    
    392
    -
    
    393
    -        # General Stateful Actions
    
    394 403
             actions: ActionListT = [
    
    395
    -            ('quit', None, app_actions.on_quit),
    
    396
    -            ('add-account', None,  app_actions.on_add_account),
    
    397
    -            ('add-contact', None,  app_actions.on_add_contact),
    
    398
    -            ('manage-proxies', None,  app_actions.on_manage_proxies),
    
    399
    -            ('history-manager', None,  app_actions.on_history_manager),
    
    400
    -            ('preferences', None,  app_actions.on_preferences),
    
    401
    -            ('plugins', None,  app_actions.on_plugins),
    
    402
    -            ('xml-console', None,  app_actions.on_xml_console),
    
    403
    -            ('file-transfer', None,  app_actions.on_file_transfers),
    
    404
    -            ('shortcuts', None,  app_actions.on_keyboard_shortcuts),
    
    405
    -            ('features', None,  app_actions.on_features),
    
    406
    -            ('content', None,  app_actions.on_contents),
    
    407
    -            ('about', None,  app_actions.on_about),
    
    408
    -            ('faq', None,  app_actions.on_faq),
    
    409
    -            ('ipython', None,  app_actions.toggle_ipython),
    
    410
    -            ('start-chat', 's', app_actions.on_new_chat),
    
    411
    -            ('accounts', 's', app_actions.on_accounts),
    
    412
    -            ('add-contact', 's', app_actions.on_add_contact_jid),
    
    413
    -            ('copy-text', 's', app_actions.copy_text),
    
    414
    -            ('open-link', 'as', app_actions.open_link),
    
    415
    -            ('open-mail', 's', app_actions.open_mail),
    
    416
    -            ('create-groupchat', 's', app_actions.on_create_gc),
    
    417
    -            ('forget-groupchat', 'as', app_actions.forget_groupchat),
    
    418
    -            ('groupchat-join', 'as', app_actions.on_groupchat_join),
    
    404
    +            ('quit', None, self._on_quit_action),
    
    405
    +            ('add-account', None,  self._on_add_account_action),
    
    406
    +            ('manage-proxies', None,  self._on_manage_proxies_action),
    
    407
    +            ('history-manager', None,  self._on_history_manager_action),
    
    408
    +            ('preferences', None,  self._on_preferences_action),
    
    409
    +            ('plugins', None,  self._on_plugins_action),
    
    410
    +            ('xml-console', None,  self._on_xml_console_action),
    
    411
    +            ('file-transfer', None,  self._on_file_transfer_action),
    
    412
    +            ('shortcuts', None,  self._on_shortcuts_action),
    
    413
    +            ('features', None,  self._on_features_action),
    
    414
    +            ('content', None,  self._on_content_action),
    
    415
    +            ('about', None,  self._on_about_action),
    
    416
    +            ('faq', None,  self._on_faq_action),
    
    417
    +            ('ipython', None,  self._on_ipython_action),
    
    418
    +            ('start-chat', 's', self._on_new_chat_action),
    
    419
    +            ('accounts', 's', self._on_accounts_action),
    
    420
    +            ('add-contact', 's', self._on_add_contact_action),
    
    421
    +            ('copy-text', 's', self._on_copy_text_action),
    
    422
    +            ('open-link', 'as', self._on_open_link_action),
    
    423
    +            ('open-mail', 's', self._on_open_mail_action),
    
    424
    +            ('create-groupchat', 's', self._on_create_groupchat_action),
    
    425
    +            ('forget-groupchat', 'as', self._on_forget_groupchat_action),
    
    426
    +            ('groupchat-join', 'as', self._on_groupchat_join_action),
    
    419 427
             ]
    
    420 428
     
    
    421 429
             for action in actions:
    
    ... ... @@ -436,33 +444,33 @@ def add_actions(self) -> None:
    436 444
             else:
    
    437 445
                 self.add_account_actions(accounts_list[0])
    
    438 446
     
    
    439
    -    @staticmethod
    
    440
    -    def _get_account_actions(account: str) -> list[tuple[str, Any, str, str]]:
    
    441
    -        from gajim import app_actions as a
    
    442
    -
    
    447
    +    def _get_account_actions(self,
    
    448
    +                             account: str) -> list[tuple[str, Any, str, str]]:
    
    443 449
             if account == 'Local':
    
    444 450
                 return []
    
    445 451
     
    
    452
    +        # pylint: disable=line-too-long
    
    446 453
             return [
    
    447
    -            ('-bookmarks', a.on_bookmarks, 'online', 's'),
    
    448
    -            ('-start-single-chat', a.on_single_message, 'online', 's'),
    
    449
    -            ('-start-chat', a.start_chat, 'online', 'as'),
    
    450
    -            ('-add-contact', a.on_add_contact, 'online', 'as'),
    
    451
    -            ('-services', a.on_service_disco, 'online', 's'),
    
    452
    -            ('-profile', a.on_profile, 'online', 's'),
    
    453
    -            ('-server-info', a.on_server_info, 'online', 's'),
    
    454
    -            ('-archive', a.on_mam_preferences, 'feature', 's'),
    
    455
    -            ('-pep-config', a.on_pep_config, 'online', 's'),
    
    456
    -            ('-sync-history', a.on_history_sync, 'online', 's'),
    
    457
    -            ('-blocking', a.on_blocking_list, 'feature', 's'),
    
    458
    -            ('-send-server-message', a.on_send_server_message, 'online', 's'),
    
    459
    -            ('-set-motd', a.on_set_motd, 'online', 's'),
    
    460
    -            ('-update-motd', a.on_update_motd, 'online', 's'),
    
    461
    -            ('-delete-motd', a.on_delete_motd, 'online', 's'),
    
    462
    -            ('-open-event', a.on_open_event, 'always', 'a{sv}'),
    
    463
    -            ('-mark-as-read', a.on_mark_as_read, 'always', 'a{sv}'),
    
    464
    -            ('-import-contacts', a.on_import_contacts, 'online', 's'),
    
    454
    +            ('-bookmarks', self._on_bookmarks_action, 'online', 's'),
    
    455
    +            ('-start-single-chat', self._on_start_single_message_action, 'online', 's'),
    
    456
    +            ('-open-chat', self._on_open_chat_action, 'online', 'as'),
    
    457
    +            ('-add-contact', self._on_add_contact_account_action, 'online', 'as'),
    
    458
    +            ('-services', self._on_services_action, 'online', 's'),
    
    459
    +            ('-profile', self._on_profile_action, 'online', 's'),
    
    460
    +            ('-server-info', self._on_server_info_action, 'online', 's'),
    
    461
    +            ('-archive', self._on_archive_action, 'feature', 's'),
    
    462
    +            ('-pep-config', self._on_pep_config_action, 'online', 's'),
    
    463
    +            ('-sync-history', self._on_sync_history_action, 'online', 's'),
    
    464
    +            ('-blocking', self._on_blocking_action, 'feature', 's'),
    
    465
    +            ('-send-server-message', self._on_send_server_message_action, 'online', 's'),
    
    466
    +            ('-set-motd', self._on_set_motd_action, 'online', 's'),
    
    467
    +            ('-update-motd', self._on_update_motd_action, 'online', 's'),
    
    468
    +            ('-delete-motd', self._on_delete_motd_action, 'online', 's'),
    
    469
    +            ('-open-event', self._on_open_event_action, 'always', 'a{sv}'),
    
    470
    +            ('-mark-as-read', self._on_mark_as_read_action, 'always', 'a{sv}'),
    
    471
    +            ('-import-contacts', self._on_import_contacts_action, 'online', 's'),
    
    465 472
             ]
    
    473
    +        # pylint: enable=line-too-long
    
    466 474
     
    
    467 475
         def add_account_actions(self, account: str) -> None:
    
    468 476
             for action in self._get_account_actions(account):
    
    ... ... @@ -555,3 +563,286 @@ def _on_disconnect(event: NetworkEvent) -> None:
    555 563
     
    
    556 564
             for client in accounts_to_disconnect.values():
    
    557 565
                 client.change_status('offline', kwargs.get('message', ''))
    
    566
    +
    
    567
    +    # Action Callbacks
    
    568
    +
    
    569
    +    @staticmethod
    
    570
    +    def _on_add_contact_action(_action: Gio.SimpleAction,
    
    571
    +                               param: GLib.Variant) -> None:
    
    572
    +        jid = param.get_string() or None
    
    573
    +        if jid is not None:
    
    574
    +            jid = JID.from_string(jid)
    
    575
    +        open_window('AddContact', account=None, jid=jid)
    
    576
    +
    
    577
    +    @staticmethod
    
    578
    +    def _on_preferences_action(_action: Gio.SimpleAction,
    
    579
    +                               _param: Optional[GLib.Variant]) -> None:
    
    580
    +        open_window('Preferences')
    
    581
    +
    
    582
    +    @staticmethod
    
    583
    +    def _on_plugins_action(_action: Gio.SimpleAction,
    
    584
    +                           _param: Optional[GLib.Variant]) -> None:
    
    585
    +        open_window('PluginsWindow')
    
    586
    +
    
    587
    +    @staticmethod
    
    588
    +    def _on_accounts_action(_action: Gio.SimpleAction,
    
    589
    +                            param: GLib.Variant) -> None:
    
    590
    +        window = open_window('AccountsWindow')
    
    591
    +        account = param.get_string()
    
    592
    +        if account:
    
    593
    +            window.select_account(account)
    
    594
    +
    
    595
    +    @staticmethod
    
    596
    +    def _on_history_manager_action(_action: Gio.SimpleAction,
    
    597
    +                                   _param: Optional[GLib.Variant]) -> None:
    
    598
    +        open_window('HistoryManager')
    
    599
    +
    
    600
    +    @staticmethod
    
    601
    +    def _on_bookmarks_action(_action: Gio.SimpleAction,
    
    602
    +                             param: GLib.Variant) -> None:
    
    603
    +        account = param.get_string()
    
    604
    +        open_window('Bookmarks', account=account)
    
    605
    +
    
    606
    +    @staticmethod
    
    607
    +    def _on_quit_action(_action: Gio.SimpleAction,
    
    608
    +                        _param: Optional[GLib.Variant]) -> None:
    
    609
    +        app.window.quit()
    
    610
    +
    
    611
    +    @staticmethod
    
    612
    +    def _on_new_chat_action(_action: Gio.SimpleAction,
    
    613
    +                            param: GLib.Variant) -> None:
    
    614
    +        window = open_window('StartChatDialog')
    
    615
    +        search_text = param.get_string()
    
    616
    +        if search_text:
    
    617
    +            window.set_search_text(search_text)
    
    618
    +
    
    619
    +    @staticmethod
    
    620
    +    def _on_profile_action(_action: Gio.SimpleAction,
    
    621
    +                           param: GLib.Variant) -> None:
    
    622
    +        account = param.get_string()
    
    623
    +        open_window('ProfileWindow', account=account)
    
    624
    +
    
    625
    +    @staticmethod
    
    626
    +    def _on_send_server_message_action(_action: Gio.SimpleAction,
    
    627
    +                                       param: GLib.Variant) -> None:
    
    628
    +        account = param.get_string()
    
    629
    +        server = app.settings.get_account_setting(account, 'hostname')
    
    630
    +        server += '/announce/online'
    
    631
    +        open_window('SingleMessageWindow', account=account, recipients=server)
    
    632
    +
    
    633
    +    @staticmethod
    
    634
    +    def _on_services_action(_action: Gio.SimpleAction,
    
    635
    +                            param: GLib.Variant) -> None:
    
    636
    +        account = param.get_string()
    
    637
    +        server_jid = app.settings.get_account_setting(account, 'hostname')
    
    638
    +        disco = app.interface.instances[account]['disco']
    
    639
    +        if server_jid in disco:
    
    640
    +            disco[server_jid].window.present()
    
    641
    +        else:
    
    642
    +            try:
    
    643
    +                # Object will add itself to the window dict
    
    644
    +                ServiceDiscoveryWindow(account, address_entry=True)
    
    645
    +            except GajimGeneralException:
    
    646
    +                pass
    
    647
    +
    
    648
    +    @staticmethod
    
    649
    +    def _on_create_groupchat_action(_action: Gio.SimpleAction,
    
    650
    +                                    param: GLib.Variant) -> None:
    
    651
    +        account = param.get_string()
    
    652
    +        open_window('CreateGroupchatWindow', account=account or None)
    
    653
    +
    
    654
    +    @staticmethod
    
    655
    +    def _on_add_contact_account_action(_action: Gio.SimpleAction,
    
    656
    +                                       param: GLib.Variant) -> None:
    
    657
    +        account, jid = param.get_strv()
    
    658
    +        if jid is not None:
    
    659
    +            jid = JID.from_string(jid)
    
    660
    +        open_window('AddContact', account=account or None, jid=jid or None)
    
    661
    +
    
    662
    +    @staticmethod
    
    663
    +    def _on_start_single_message_action(_action: Gio.SimpleAction,
    
    664
    +                                        param: GLib.Variant) -> None:
    
    665
    +        account = param.get_string()
    
    666
    +        open_window('SingleMessageWindow', account=account)
    
    667
    +
    
    668
    +    @staticmethod
    
    669
    +    def _on_add_account_action(_action: Gio.SimpleAction,
    
    670
    +                               _param: Optional[GLib.Variant]) -> None:
    
    671
    +        open_window('AccountWizard')
    
    672
    +
    
    673
    +    @staticmethod
    
    674
    +    def _on_import_contacts_action(_action: Gio.SimpleAction,
    
    675
    +                                   param: GLib.Variant) -> None:
    
    676
    +        open_window('SynchronizeAccounts', account=param.get_string())
    
    677
    +
    
    678
    +    @staticmethod
    
    679
    +    def _on_pep_config_action(_action: Gio.SimpleAction,
    
    680
    +                              param: GLib.Variant) -> None:
    
    681
    +        account = param.get_string()
    
    682
    +        open_window('PEPConfig', account=account)
    
    683
    +
    
    684
    +    @staticmethod
    
    685
    +    def _on_archive_action(_action: Gio.SimpleAction,
    
    686
    +                           param: GLib.Variant) -> None:
    
    687
    +        account = param.get_string()
    
    688
    +        open_window('MamPreferences', account=account)
    
    689
    +
    
    690
    +    @staticmethod
    
    691
    +    def _on_blocking_action(_action: Gio.SimpleAction,
    
    692
    +                            param: GLib.Variant) -> None:
    
    693
    +        account = param.get_string()
    
    694
    +        open_window('BlockingList', account=account)
    
    695
    +
    
    696
    +    @staticmethod
    
    697
    +    def _on_sync_history_action(_action: Gio.SimpleAction,
    
    698
    +                                param: GLib.Variant) -> None:
    
    699
    +        account = param.get_string()
    
    700
    +        open_window('HistorySyncAssistant',
    
    701
    +                    account=account)
    
    702
    +
    
    703
    +    @staticmethod
    
    704
    +    def _on_server_info_action(_action: Gio.SimpleAction,
    
    705
    +                               param: GLib.Variant) -> None:
    
    706
    +        account = param.get_string()
    
    707
    +        open_window('ServerInfo', account=account)
    
    708
    +
    
    709
    +    @staticmethod
    
    710
    +    def _on_xml_console_action(_action: Gio.SimpleAction,
    
    711
    +                               _param: Optional[GLib.Variant]) -> None:
    
    712
    +        open_window('XMLConsoleWindow')
    
    713
    +
    
    714
    +    @staticmethod
    
    715
    +    def _on_manage_proxies_action(_action: Gio.SimpleAction,
    
    716
    +                                  _param: Optional[GLib.Variant]) -> None:
    
    717
    +        open_window('ManageProxies')
    
    718
    +
    
    719
    +    @staticmethod
    
    720
    +    def _on_set_motd_action(_action: Gio.SimpleAction,
    
    721
    +                            param: GLib.Variant) -> None:
    
    722
    +        account = param.get_string()
    
    723
    +        server = app.settings.get_account_setting(account, 'hostname')
    
    724
    +        server += '/announce/motd'
    
    725
    +        open_window('SingleMessageWindow', account=account, recipients=server)
    
    726
    +
    
    727
    +    @staticmethod
    
    728
    +    def _on_update_motd_action(_action: Gio.SimpleAction,
    
    729
    +                               param: GLib.Variant) -> None:
    
    730
    +        account = param.get_string()
    
    731
    +        server = app.settings.get_account_setting(account, 'hostname')
    
    732
    +        server += '/announce/motd/update'
    
    733
    +        open_window('SingleMessageWindow', account=account, recipients=server)
    
    734
    +
    
    735
    +    @staticmethod
    
    736
    +    def _on_delete_motd_action(_action: Gio.SimpleAction,
    
    737
    +                               param: GLib.Variant) -> None:
    
    738
    +        account = param.get_string()
    
    739
    +        app.connections[account].get_module('Announce').delete_motd()
    
    740
    +
    
    741
    +    @staticmethod
    
    742
    +    def _on_content_action(_action: Gio.SimpleAction,
    
    743
    +                           _param: Optional[GLib.Variant]) -> None:
    
    744
    +        open_uri(GAJIM_WIKI_URI)
    
    745
    +
    
    746
    +    @staticmethod
    
    747
    +    def _on_faq_action(_action: Gio.SimpleAction,
    
    748
    +                       _param: Optional[GLib.Variant]) -> None:
    
    749
    +        open_uri(GAJIM_FAQ_URI)
    
    750
    +
    
    751
    +    @staticmethod
    
    752
    +    def _on_shortcuts_action(_action: Gio.SimpleAction,
    
    753
    +                             _param: Optional[GLib.Variant]) -> None:
    
    754
    +        ShortcutsWindow()
    
    755
    +
    
    756
    +    @staticmethod
    
    757
    +    def _on_features_action(_action: Gio.SimpleAction,
    
    758
    +                            _param: Optional[GLib.Variant]) -> None:
    
    759
    +        open_window('Features')
    
    760
    +
    
    761
    +    @staticmethod
    
    762
    +    def _on_about_action(_action: Gio.SimpleAction,
    
    763
    +                         _param: Optional[GLib.Variant]) -> None:
    
    764
    +        AboutDialog()
    
    765
    +
    
    766
    +    @staticmethod
    
    767
    +    def _on_file_transfer_action(_action: Gio.SimpleAction,
    
    768
    +                                 _param: Optional[GLib.Variant]) -> None:
    
    769
    +
    
    770
    +        ft = app.interface.instances['file_transfers']
    
    771
    +        if ft.window.get_property('visible'):
    
    772
    +            ft.window.present()
    
    773
    +        else:
    
    774
    +            ft.window.show_all()
    
    775
    +
    
    776
    +    @staticmethod
    
    777
    +    def _on_open_event_action(_action: Gio.SimpleAction,
    
    778
    +                              param: GLib.Variant) -> None:
    
    779
    +        dict_ = param.unpack()
    
    780
    +        app.interface.handle_event(
    
    781
    +            dict_['account'], dict_['jid'], dict_['notif_detail'])
    
    782
    +
    
    783
    +    @staticmethod
    
    784
    +    def _on_mark_as_read_action(_action: Gio.SimpleAction,
    
    785
    +                                param: GLib.Variant) -> None:
    
    786
    +        dict_ = param.unpack()
    
    787
    +        account, jid = dict_['account'], dict_['jid']
    
    788
    +        app.window.mark_as_read(account, JID.from_string(jid))
    
    789
    +
    
    790
    +    @staticmethod
    
    791
    +    def _on_ipython_action(_action: Gio.SimpleAction,
    
    792
    +                           _param: Optional[GLib.Variant]) -> None:
    
    793
    +        """
    
    794
    +        Show/hide the ipython window
    
    795
    +        """
    
    796
    +        win = app.ipython_window
    
    797
    +        if win and win.window.is_visible():
    
    798
    +            win.present()
    
    799
    +        else:
    
    800
    +            app.interface.create_ipython_window()
    
    801
    +
    
    802
    +    @staticmethod
    
    803
    +    def _on_open_mail_action(_action: Gio.SimpleAction,
    
    804
    +                             param: GLib.Variant) -> None:
    
    805
    +        uri = param.get_string()
    
    806
    +        if not uri.startswith('mailto:'):
    
    807
    +            uri = 'mailto:%s' % uri
    
    808
    +        open_uri(uri)
    
    809
    +
    
    810
    +    @staticmethod
    
    811
    +    def _on_open_link_action(_action: Gio.SimpleAction,
    
    812
    +                             param: GLib.Variant) -> None:
    
    813
    +        account, uri = param.get_strv()
    
    814
    +        open_uri(uri, account=account)
    
    815
    +
    
    816
    +    @staticmethod
    
    817
    +    def _on_copy_text_action(_action: Gio.SimpleAction,
    
    818
    +                             param: GLib.Variant) -> None:
    
    819
    +        text = param.get_string()
    
    820
    +        clip = Gtk.Clipboard.get(Gdk.SELECTION_CLIPBOARD)
    
    821
    +        clip.set_text(text, -1)
    
    822
    +
    
    823
    +    @staticmethod
    
    824
    +    def _on_open_chat_action(_action: Gio.SimpleAction,
    
    825
    +                             param: GLib.Variant) -> None:
    
    826
    +        account, jid = param.get_strv()
    
    827
    +        app.interface.start_chat_from_jid(account, jid)
    
    828
    +
    
    829
    +    @staticmethod
    
    830
    +    def _on_forget_groupchat_action(_action: Gio.SimpleAction,
    
    831
    +                                    param: GLib.Variant) -> None:
    
    832
    +        account, jid = param.unpack()
    
    833
    +        room_jid = JID.from_string(jid)
    
    834
    +        window = get_app_window('StartChatDialog')
    
    835
    +        window.remove_row(account, str(room_jid))
    
    836
    +
    
    837
    +        client = app.get_client(account)
    
    838
    +        client.get_module('MUC').leave(room_jid)
    
    839
    +        client.get_module('Bookmarks').remove(room_jid)
    
    840
    +
    
    841
    +        app.storage.archive.remove_chat_history(
    
    842
    +            account, str(room_jid), groupchat=True)
    
    843
    +
    
    844
    +    @staticmethod
    
    845
    +    def _on_groupchat_join_action(_action: Gio.SimpleAction,
    
    846
    +                                  param: GLib.Variant) -> None:
    
    847
    +        account, jid = param.get_strv()
    
    848
    +        open_window('GroupchatJoin', account=account, jid=jid)

  • gajim/gtk/menus.py
    ... ... @@ -364,7 +364,7 @@ def get_conv_uri_context_menu(account: str, uri: URI) -> Optional[Gtk.Menu]:
    364 364
             else:
    
    365 365
                 context_menu = [
    
    366 366
                     ('copy-text', _('Copy XMPP Address')),
    
    367
    -                ('-start-chat', _('Start Chat')),
    
    367
    +                ('-open-chat', _('Start Chat')),
    
    368 368
                     ('-add-contact', _('Add to Contact List…')),
    
    369 369
                 ]
    
    370 370
     
    
    ... ... @@ -390,7 +390,7 @@ def get_conv_uri_context_menu(account: str, uri: URI) -> Optional[Gtk.Menu]:
    390 390
             context_menu = [
    
    391 391
                 ('copy-text', _('Copy XMPP Address/Email')),
    
    392 392
                 ('open-mail', _('Open Email Composer')),
    
    393
    -            ('-start-chat', _('Start Chat')),
    
    393
    +            ('-open-chat', _('Start Chat')),
    
    394 394
                 ('groupchat-join', _('Join Groupchat')),
    
    395 395
                 ('-add-contact', _('Add to Contact List…')),
    
    396 396
             ]
    

  • gajim/gtk/util.py
    ... ... @@ -58,10 +58,6 @@
    58 58
     from .const import GajimIconSet
    
    59 59
     from .const import WINDOW_MODULES
    
    60 60
     
    
    61
    -_icon_theme = Gtk.IconTheme.get_default()
    
    62
    -if _icon_theme is not None:
    
    63
    -    _icon_theme.append_search_path(str(configpaths.get('ICONS')))
    
    64
    -
    
    65 61
     
    
    66 62
     log = logging.getLogger('gajim.gui.util')
    
    67 63
     
    
    ... ... @@ -155,7 +151,7 @@ def set_urgency_hint(window: Any, setting: bool) -> None:
    155 151
     
    
    156 152
     
    
    157 153
     def icon_exists(name: str) -> bool:
    
    158
    -    return _icon_theme.has_icon(name)
    
    154
    +    return Gtk.IconTheme.get_default().has_icon(name)
    
    159 155
     
    
    160 156
     
    
    161 157
     def load_icon_info(icon_name: str,
    
    ... ... @@ -170,14 +166,16 @@ def load_icon_info(icon_name: str,
    170 166
             log.warning('Could not determine scale factor')
    
    171 167
             scale = 1
    
    172 168
     
    
    169
    +    icon_theme = Gtk.IconTheme.get_default()
    
    170
    +
    
    173 171
         try:
    
    174
    -        iconinfo = _icon_theme.lookup_icon_for_scale(
    
    172
    +        iconinfo = icon_theme.lookup_icon_for_scale(
    
    175 173
                 icon_name, size, scale, flags)
    
    176 174
             if iconinfo is None:
    
    177 175
                 log.info('No icon found for %s', icon_name)
    
    178 176
                 return None
    
    179 177
             return iconinfo
    
    180
    -    except GLib.GError as error:
    
    178
    +    except GLib.Error as error:
    
    181 179
             log.error('Unable to load icon %s: %s', icon_name, str(error))
    
    182 180
         return None
    
    183 181
     
    
    ... ... @@ -240,11 +238,13 @@ def load_user_iconsets() -> None:
    240 238
         if not iconsets_path.exists():
    
    241 239
             return
    
    242 240
     
    
    241
    +    icon_theme = Gtk.IconTheme.get_default()
    
    242
    +
    
    243 243
         for path in iconsets_path.iterdir():
    
    244 244
             if not path.is_dir():
    
    245 245
                 continue
    
    246 246
             log.info('Found iconset: %s', path.stem)
    
    247
    -        _icon_theme.append_search_path(str(path))
    
    247
    +        icon_theme.append_search_path(str(path))
    
    248 248
     
    
    249 249
     
    
    250 250
     def get_available_iconsets() -> List[str]:
    
    ... ... @@ -405,8 +405,9 @@ def get_image_button(icon_name: str, tooltip: str,
    405 405
     
    
    406 406
     
    
    407 407
     def get_image_from_icon_name(icon_name: str, scale: int) -> Any:
    
    408
    +    icon_theme = Gtk.IconTheme.get_default()
    
    408 409
         icon = get_icon_name(icon_name)
    
    409
    -    surface = _icon_theme.load_surface(icon, 16, scale, None, 0)
    
    410
    +    surface = icon_theme.load_surface(icon, 16, scale, None, 0)
    
    410 411
         return Gtk.Image.new_from_surface(surface)
    
    411 412
     
    
    412 413