diff --git a/gajim/common/config.py b/gajim/common/config.py index 88f28fb801479c852388321745eafbfb8387692f..101956e04cd58cc793da406cd42da32830c9da28 100644 --- a/gajim/common/config.py +++ b/gajim/common/config.py @@ -93,7 +93,6 @@ class Config: 'speller_language': [opt_str, '', _('Language used for spell checking.')], 'print_time': [opt_str, 'always', _('\'always\' - print time for every message.\n\'sometimes\' - print time every print_ichat_every_foo_minutes minute.\n\'never\' - never print time.')], 'emoticons_theme': [opt_str, 'noto-emoticons', '', True], - 'ascii_emoticons': [opt_bool, True, _('When enabled, ASCII emojis will be converted to graphical emojis.'), True], 'ascii_formatting': [opt_bool, True, _('Treat * / _ pairs as possible formatting characters.'), True], 'show_ascii_formatting_chars': [opt_bool, True, _('If enabled, do not ' diff --git a/gajim/common/setting_values.py b/gajim/common/setting_values.py index e28dc1ec5cc0b491afd9781f3f36673c843a653c..0ab6cf363da435d025ceb9c5b95e77dfd16d324e 100644 --- a/gajim/common/setting_values.py +++ b/gajim/common/setting_values.py @@ -41,7 +41,6 @@ class _ACCOUNT_DEFAULT: 'speller_language': '', 'print_time': 'always', 'emoticons_theme': 'noto-emoticons', - 'ascii_emoticons': True, 'ascii_formatting': True, 'show_ascii_formatting_chars': True, 'sounds_on': True, diff --git a/gajim/gtk/emoji_data.py b/gajim/gtk/emoji_data.py index 31dc643ac946dc3ff88b4e137c8eeb9fce8da8de..5f1b62d00ac0880f179c329fe9bbdec9526fdda3 100644 --- a/gajim/gtk/emoji_data.py +++ b/gajim/gtk/emoji_data.py @@ -144,45 +144,11 @@ def _replace_emojis(self): start(), end(), pixbuf.copy(), codepoint) -class EmojiAsciiData(dict): - def get_regex(self): - # When an emoticon is bordered by an alphanumeric character it - # is NOT expanded. e.g., foo:) NO, foo :) YES, (brb) NO, - # (:)) YES, etc. We still allow multiple emoticons - # side-by-side like :P:P:P - - # TODO: Refactor this - keys = sorted(self.keys(), key=len, reverse=True) - pre_pattern = '' - post_pattern = '' - emoticon_length = 0 - emoticons_pattern = '' - for emoticon in keys: - # escape regexp metachars - emoticon_escaped = re.escape(emoticon) - emoticons_pattern += emoticon_escaped + '|' - if emoticon_length != len(emoticon): - # Build up expressions to match emoticons next to others - pre_pattern = pre_pattern[:-1] + ')|(?<=' - post_pattern = post_pattern[:-1] + ')|(?=' - emoticon_length = len(emoticon) - pre_pattern += emoticon_escaped + '|' - post_pattern += emoticon_escaped + '|' - # We match from our list of emoticons, but they must either have - # whitespace, or another emoticon next to it to match successfully - # [\w.] alphanumeric and dot (for not matching 8) in (2.8)) - emoticons_pattern = r'(?:(?<![\w.]' + \ - pre_pattern[:-1] + '))' + '(?:' + \ - emoticons_pattern[:-1] + ')' + r'(?:(?![\w]' + \ - post_pattern[:-1] + '))' - return emoticons_pattern - - emoji_pixbufs = EmojiPixbufs() # pylint: disable=line-too-long -emoji_ascii_data = EmojiAsciiData([ +emoji_ascii_data = dict([ ("':-D", '\U0001F605'), (':)', '\U0001F642'), (':-O', '\U0001F62e'), diff --git a/gajim/gtk/emoji_data.pyi b/gajim/gtk/emoji_data.pyi index 3607a61a0ac372c878532977106dcf3b1a7d7ed0..de25e945847965a8fe01593724fb02d136339cee 100644 --- a/gajim/gtk/emoji_data.pyi +++ b/gajim/gtk/emoji_data.pyi @@ -29,11 +29,8 @@ class EmojiData(OrderedDict): class EmojiPixbufs(dict): ... -class EmojiAsciiData(dict): - ... - emoji_pixbufs = EmojiPixbufs() -emoji_ascii_data = EmojiAsciiData() +emoji_ascii_data: dict[str, str] emoji_data = EmojiData() diff --git a/gajim/gtk/preferences.py b/gajim/gtk/preferences.py index 6e5a5f9ebd1062fab5e3ea9848149998c5206c1f..f2ba543c1cd411021ddbd6c312c87a125d4340c6 100644 --- a/gajim/gtk/preferences.py +++ b/gajim/gtk/preferences.py @@ -103,6 +103,8 @@ def __init__(self): self._ui.connect_signals(self) self.show_all() + if sys.platform not in ('win32', 'darwin'): + self._ui.emoji.hide() def get_ui(self): return self._ui @@ -727,30 +729,24 @@ def _on_dark_theme(value, *args): class Emoji(PreferenceBox): def __init__(self, *args): + if sys.platform not in ('win32', 'darwin'): + PreferenceBox.__init__(self, []) + return emoji_themes_items = [] for theme in helpers.get_available_emoticon_themes(): emoji_themes_items.append(theme) settings = [ - Setting(SettingKind.SWITCH, - _('Convert ASCII Emojis'), + Setting(SettingKind.POPOVER, + _('Emoji Theme'), SettingType.CONFIG, - 'ascii_emoticons', - desc=_('Typing short codes like :-) will display emojis'), - callback=self._on_ascii_emoticons), + 'emoticons_theme', + desc=_('Choose from various emoji styles'), + props={'entries': emoji_themes_items}, + callback=self._on_emoticons_theme) ] - if sys.platform in ('win32', 'darwin'): - settings.append( - Setting(SettingKind.POPOVER, - _('Emoji Theme'), - SettingType.CONFIG, - 'emoticons_theme', - desc=_('Choose from various emoji styles'), - props={'entries': emoji_themes_items}, - callback=self._on_emoticons_theme)) - PreferenceBox.__init__(self, settings) def _on_emoticons_theme(self, *args): @@ -763,10 +759,6 @@ def _toggle_emoticons(): for ctrl in controls: ctrl.toggle_emoticons() - @staticmethod - def _on_ascii_emoticons(*args): - app.interface.make_regexps() - class StatusIcon(PreferenceBox): def __init__(self, *args): diff --git a/gajim/gui_interface.py b/gajim/gui_interface.py index dfd03606f935f0bf44b035172850e1e5f0d5509b..da0bbaefa3e8a2133ac60d51d878511b7046dc11 100644 --- a/gajim/gui_interface.py +++ b/gajim/gui_interface.py @@ -102,7 +102,6 @@ from gajim.gui.dialogs import PassphraseDialog from gajim.gui.filechoosers import FileChooserDialog from gajim.gui.emoji_data import emoji_data -from gajim.gui.emoji_data import emoji_ascii_data from gajim.gui.filetransfer import FileTransfersWindow from gajim.gui.filetransfer_progress import FileTransferProgress from gajim.gui.roster_item_exchange import RosterItemExchangeWindow @@ -1392,8 +1391,6 @@ def make_regexps(self): # because emoticons match later (in the string) they need to be after # basic matches that may occur earlier emoticons = emoji_data.get_regex() - if app.settings.get('ascii_emoticons'): - emoticons += '|%s' % emoji_ascii_data.get_regex() self.emot_and_basic = '%s|%s' % (basic_pattern, emoticons)