Welcome to mirror list, hosted at ThFree Co, Russian Federation.

const.py « gtk « gajim - dev.gajim.org/gajim/gajim.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: dd17857a0b050675f2840de4acbd30d882cb5806 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# This file is part of Gajim.
#
# Gajim is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published
# by the Free Software Foundation; version 3 only.
#
# Gajim is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Gajim. If not, see <http://www.gnu.org/licenses/>.

# Constants for the gtk module

from __future__ import annotations

from typing import Any
from typing import NamedTuple

from collections.abc import Callable
from collections.abc import Iterator
from enum import Enum
from enum import IntEnum
from enum import unique

from gajim.common.i18n import _
from gajim.common.setting_values import AllSettingsT


class Filter(NamedTuple):
    name: str
    pattern: str | list[str]
    default: bool


class Setting(NamedTuple):
    kind: SettingKind
    label: str
    type: SettingType
    value: AllSettingsT | None = None
    name: str | None = None
    callback: Callable[..., None] | None = None
    data: Any | None = None
    desc: str | None = None
    bind: str | None = None
    inverted: bool | None = None
    enabled_func: Callable[..., bool] | None = None
    props: dict[str, Any] | None = None


DEFAULT_WORKSPACE_COLOR = 'rgb(191,15,167)'

# Drag and drop target type URI list (for dropped files)
TARGET_TYPE_URI_LIST = 80

MAX_MESSAGE_LENGTH = 5000


@unique
class MuteState(IntEnum):
    UNMUTE = 0
    MIN_30 = 30
    MIN_60 = 60
    MIN_120 = 120
    MIN_480 = 480
    PERM = 100000000

    @classmethod
    def iter(cls) -> Iterator[tuple[int, str]]:
        yield from cls._labels.items()  # pyright: ignore

MuteState._labels = {  # pyright: ignore
        MuteState.MIN_30: _('30 minutes'),
        MuteState.MIN_60: _('1 hour'),
        MuteState.MIN_120: _('2 hours'),
        MuteState.MIN_480: _('8 hours'),
        MuteState.PERM: _('Permanently'),
    }


@unique
class Theme(IntEnum):
    NOT_DARK = 0
    DARK = 1
    SYSTEM = 2


@unique
class SettingKind(IntEnum):
    ENTRY = 0
    SWITCH = 1
    SPIN = 2
    ACTION = 3
    LOGIN = 4
    DIALOG = 5
    CALLBACK = 6
    HOSTNAME = 8
    PRIORITY = 9
    FILECHOOSER = 10
    CHANGEPASSWORD = 11
    COMBO = 12
    COLOR = 13
    POPOVER = 14
    AUTO_AWAY = 15
    AUTO_EXTENDED_AWAY = 16
    USE_STUN_SERVER = 17
    NOTIFICATIONS = 18


@unique
class SettingType(IntEnum):
    CONFIG = 0
    ACCOUNT_CONFIG = 1
    CONTACT = 2
    GROUP_CHAT = 3
    VALUE = 4
    ACTION = 5
    DIALOG = 6


class ControlType(Enum):
    CHAT = 'chat'
    GROUPCHAT = 'gc'
    PRIVATECHAT = 'pm'

    @property
    def is_chat(self):
        return self == ControlType.CHAT

    @property
    def is_groupchat(self):
        return self == ControlType.GROUPCHAT

    @property
    def is_privatechat(self):
        return self == ControlType.PRIVATECHAT

    def __str__(self):
        return self.value


WINDOW_MODULES = {
    'AccountsWindow': 'gajim.gtk.accounts',
    'AccountWizard': 'gajim.gtk.account_wizard',
    'AddContact': 'gajim.gtk.add_contact',
    'AdHocCommands': 'gajim.gtk.adhoc',
    'AdvancedConfig': 'gajim.gtk.advanced_config',
    'BlockingList': 'gajim.gtk.blocking',
    'Bookmarks': 'gajim.gtk.bookmarks',
    'CertificateDialog': 'gajim.gtk.certificate_dialog',
    'ChangePassword': 'gajim.gtk.change_password',
    'ContactInfo': 'gajim.gtk.contact_info',
    'CreateGroupchatWindow': 'gajim.gtk.groupchat_creation',
    'Features': 'gajim.gtk.features',
    'GroupchatDetails': 'gajim.gtk.groupchat_details',
    'GroupChatInvitation': 'gajim.gtk.groupchat_invitation',
    'GroupchatJoin': 'gajim.gtk.groupchat_join',
    'HistoryExport': 'gajim.gtk.history_export',
    'HistorySyncAssistant': 'gajim.gtk.history_sync',
    'MamPreferences': 'gajim.gtk.mam_preferences',
    'ManageProxies': 'gajim.gtk.proxies',
    'ManageSounds': 'gajim.gtk.manage_sounds',
    'PasswordDialog': 'gajim.gtk.password_dialog',
    'PEPConfig': 'gajim.gtk.pep_config',
    'PluginsWindow': 'gajim.gtk.plugins',
    'Preferences': 'gajim.gtk.preferences',
    'ProfileWindow': 'gajim.gtk.profile',
    'RemoveAccount': 'gajim.gtk.remove_account',
    'RosterItemExchange': 'gajim.gtk.roster_item_exchange',
    'ServerInfo': 'gajim.gtk.server_info',
    'ServiceDiscoveryWindow': 'gajim.gtk.discovery',
    'ServiceRegistration': 'gajim.gtk.service_registration',
    'SSLErrorDialog': 'gajim.gtk.ssl_error_dialog',
    'StartChatDialog': 'gajim.gtk.start_chat',
    'SynchronizeAccounts': 'gajim.gtk.synchronize_accounts',
    'Themes': 'gajim.gtk.themes',
    'WorkspaceDialog': 'gajim.gtk.workspace_dialog',
    'XMLConsoleWindow': 'gajim.gtk.xml_console',
}


APP_ACTIONS = [
    ('about', None),
    ('accounts', 's'),
    ('add-account', None),
    ('add-contact', 's'),
    ('content', None),
    ('copy-text', 's'),
    ('create-groupchat', 's'),
    ('faq', None),
    ('privacy-policy', None),
    ('features', None),
    ('file-transfer', None),
    ('forget-groupchat', 'a{sv}'),
    ('join-support-chat', None),
    ('manage-proxies', None),
    ('open-link', 'as'),
    ('plugins', None),
    ('preferences', None),
    ('quit', None),
    ('remove-history', 'a{sv}'),
    ('shortcuts', None),
    ('show', None),
    ('start-chat', 'as'),
    ('open-chat', 'as'),
    ('mute-chat', 'a{sv}'),
    ('xml-console', None),
]


MAIN_WIN_ACTIONS = [
    # action name, variant type, enabled
    ('input-bold', None, True),
    ('input-italic', None, True),
    ('input-strike', None, True),
    ('input-clear', None, True),
    ('show-emoji-chooser', None, True),
    ('activate-message-selection', 'u', True),
    ('delete-message-locally', 'u', True),
    ('correct-message', None, False),
    ('copy-message', 's', True),
    ('retract-message', 'a{sv}', False),
    ('quote', 's', False),
    ('quote-next', None, True),
    ('quote-prev', None, True),
    ('mention', 's', False),
    ('send-file-httpupload', 'as', False),
    ('send-file-jingle', 'as', False),
    ('send-file', 'as', False),
    ('add-to-roster', None, True),
    ('start-voice-call', None, False),
    ('start-video-call', None, False),
    ('show-contact-info', None, True),
    ('send-message', None, False),
    ('muc-change-nickname', None, False),
    ('muc-invite', None, False),
    ('muc-contact-info', 's', False),
    ('muc-execute-command', 's', False),
    ('muc-ban', 's', False),
    ('muc-kick', 's', False),
    ('muc-change-role', 'as', False),
    ('muc-change-affiliation', 'as', False),
    ('muc-request-voice', None, False),
    ('scroll-view-up', None, True),
    ('scroll-view-down', None, True),
    ('change-nickname', None, True),
    ('change-subject', None, True),
    ('escape', None, True),
    ('close-chat', None, True),
    ('restore-chat', None, True),
    ('switch-next-chat', None, True),
    ('switch-prev-chat', None, True),
    ('switch-next-unread-chat', None, True),
    ('switch-prev-unread-chat', None, True),
    ('switch-chat-1', None, True),
    ('switch-chat-2', None, True),
    ('switch-chat-3', None, True),
    ('switch-chat-4', None, True),
    ('switch-chat-5', None, True),
    ('switch-chat-6', None, True),
    ('switch-chat-7', None, True),
    ('switch-chat-8', None, True),
    ('switch-chat-9', None, True),
    ('switch-workspace-1', None, True),
    ('switch-workspace-2', None, True),
    ('switch-workspace-3', None, True),
    ('switch-workspace-4', None, True),
    ('switch-workspace-5', None, True),
    ('switch-workspace-6', None, True),
    ('switch-workspace-7', None, True),
    ('switch-workspace-8', None, True),
    ('switch-workspace-9', None, True),
    ('increase-app-font-size', None, True),
    ('decrease-app-font-size', None, True),
    ('reset-app-font-size', None, True),
    ('toggle-chat-list', None, True),
    ('add-workspace', 's', True),
    ('edit-workspace', 's', True),
    ('remove-workspace', 's', True),
    ('activate-workspace', 's', True),
    ('mark-workspace-as-read', 's', True),
    ('add-chat', 'a{sv}', True),
    ('add-group-chat', 'as', True),
    ('add-to-roster', 'a{sv}', True),
    ('preview-open', 's', True),
    ('preview-save-as', 's', True),
    ('preview-open-folder', 's', True),
    ('preview-copy-link', 's', True),
    ('preview-open-link', 's', True),
    ('preview-download', 's', True),
]


ACCOUNT_ACTIONS = [
    ('add-contact', 'as'),
    ('contact-info', 's'),
    ('block-contact', 's'),
    ('remove-contact', 's'),
    ('execute-command', 's'),
    ('modify-gateway', 's'),
    ('archive', 's'),
    ('blocking', 's'),
    ('bookmarks', 's'),
    ('export-history', 's'),
    ('import-contacts', 's'),
    ('mark-as-read', 'a{sv}'),
    ('open-event', 'a{sv}'),
    ('pep-config', 's'),
    ('profile', 's'),
    ('server-info', 's'),
    ('services', 's'),
    ('sync-history', 's'),
]


ALWAYS_ACCOUNT_ACTIONS = {
    'export-history',
    'import-contacts',
    'open-event',
}


ONLINE_ACCOUNT_ACTIONS = {
    'add-contact',
    'remove-contact',
    'contact-info',
    'execute-command',
    'modify-gateway',
    'bookmarks',
    'import-contacts',
    'pep-config',
    'profile',
    'server-info',
    'services',
    'sync-history',
    'mark-as-read',
}


FEATURE_ACCOUNT_ACTIONS = {
    'archive',
    'blocking',
    'block-contact',
}