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


Commits:
4f486209 by wurstsalat at 2022-07-23T21:32:48+02:00
imprv: Preview: Add setting to disable file preview

Fixes #10991

- - - - -


3 changed files:

- gajim/common/setting_values.py
- gajim/gtk/conversation/rows/message.py
- gajim/gtk/preferences.py


Changes:

=====================================
gajim/common/setting_values.py
=====================================
@@ -53,7 +53,9 @@ class _ACCOUNT_DEFAULT:
     'dev_force_bookmark_2',
     'dev_use_message_label',
     'developer_modus',
+    'enable_emoji_shortcodes',
     'enable_negative_priority',
+    'enable_file_preview',
     'escape_key_closes',
     'gc_notify_on_all_messages_private_default',
     'gc_notify_on_all_messages_public_default',
@@ -107,7 +109,6 @@ class _ACCOUNT_DEFAULT:
     'use_stun_server',
     'use_urgency_hint',
     'video_see_self',
-    'enable_emoji_shortcodes',
 ]
 
 IntSettings = Literal[
@@ -203,7 +204,9 @@ class _ACCOUNT_DEFAULT:
     'developer_modus': False,
     'dictionary_url': 'WIKTIONARY',
     'emoticons_theme': 'noto-emoticons',
+    'enable_emoji_shortcodes': True,
     'enable_negative_priority': False,
+    'enable_file_preview': True,
     'escape_key_closes': False,
     'file_transfers_port': 28011,
     'ft_add_hosts_to_send': '',
@@ -295,7 +298,6 @@ class _ACCOUNT_DEFAULT:
     'video_see_self': True,
     'video_size': '',
     'workspace_order': [],
-    'enable_emoji_shortcodes': True,
 }
 
 BoolAccountSettings = Literal[


=====================================
gajim/gtk/conversation/rows/message.py
=====================================
@@ -123,9 +123,11 @@ def __init__(self,
             from_us = kind == 'outgoing'
 
         is_previewable = False
-        if additional_data is not None:
+        preview_enabled = app.settings.get('enable_file_preview')
+        if additional_data is not None and preview_enabled:
             is_previewable = app.preview_manager.is_previewable(
                 text, additional_data)
+
         if is_previewable:
             context = None
             if self._is_groupchat:


=====================================
gajim/gtk/preferences.py
=====================================
@@ -445,11 +445,17 @@ def __init__(self, *args: Any) -> None:
         }
 
         settings = [
+            Setting(SettingKind.SWITCH,
+                    _('File Preview'),
+                    SettingType.CONFIG,
+                    'enable_file_preview',
+                    desc=_('Show previews for files')),
             Setting(SettingKind.SPIN,
                     _('Preview Size'),
                     SettingType.CONFIG,
                     'preview_size',
                     desc=_('Size of preview image'),
+                    bind='enable_file_preview',
                     props={'range_': (100, 1000)}),
 
             Setting(SettingKind.POPOVER,
@@ -457,6 +463,7 @@ def __init__(self, *args: Any) -> None:
                     SettingType.CONFIG,
                     'preview_max_file_size',
                     desc=_('Maximum file size for preview generation'),
+                    bind='enable_file_preview',
                     props={'entries': sizes}),
 
             Setting(SettingKind.SWITCH,
@@ -464,27 +471,31 @@ def __init__(self, *args: Any) -> None:
                     SettingType.CONFIG,
                     'preview_anonymous_muc',
                     desc=_('Generate preview automatically in public '
-                           'group chats (may disclose your data)')),
+                           'group chats (may disclose your data)'),
+                    bind='enable_file_preview'),
 
             Setting(SettingKind.SWITCH,
                     _('Preview all Image URLs'),
                     SettingType.CONFIG,
                     'preview_allow_all_images',
                     desc=_('Generate preview for any URLs containing images '
-                           '(may be unsafe)')),
+                           '(may be unsafe)'),
+                    bind='enable_file_preview'),
 
             Setting(SettingKind.POPOVER,
                     _('Left Click Action'),
                     SettingType.CONFIG,
                     'preview_leftclick_action',
                     desc=_('Action when left-clicking a preview'),
+                    bind='enable_file_preview',
                     props={'entries': actions}),
 
             Setting(SettingKind.SWITCH,
                     _('HTTPS Verification'),
                     SettingType.CONFIG,
                     'preview_verify_https',
-                    desc=_('Whether to check for a valid certificate')),
+                    desc=_('Whether to check for a valid certificate'),
+                    bind='enable_file_preview'),
         ]
 
         PreferenceBox.__init__(self, settings)



View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/4f486209083c62ca2914fee5c9f758e45167bd4b

-- 
View it on GitLab: 
https://dev.gajim.org/gajim/gajim/-/commit/4f486209083c62ca2914fee5c9f758e45167bd4b
You're receiving this email because of your account on dev.gajim.org.


_______________________________________________
Commits mailing list
[email protected]
https://lists.gajim.org/cgi-bin/listinfo/commits

Reply via email to