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

Commits:

6 changed files:

Changes:

  • gajim/common/config.py
    ... ... @@ -93,7 +93,6 @@ class Config:
    93 93
             'speller_language': [opt_str, '', _('Language used for spell checking.')],
    
    94 94
             '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.')],
    
    95 95
             'emoticons_theme': [opt_str, 'noto-emoticons', '', True],
    
    96
    -        'ascii_emoticons': [opt_bool, True, _('When enabled, ASCII emojis will be converted to graphical emojis.'), True],
    
    97 96
             'ascii_formatting': [opt_bool, True,
    
    98 97
                     _('Treat * / _ pairs as possible formatting characters.'), True],
    
    99 98
             'show_ascii_formatting_chars': [opt_bool, True, _('If enabled, do not '
    

  • gajim/common/setting_values.py
    ... ... @@ -41,7 +41,6 @@ class _ACCOUNT_DEFAULT:
    41 41
         'speller_language': '',
    
    42 42
         'print_time': 'always',
    
    43 43
         'emoticons_theme': 'noto-emoticons',
    
    44
    -    'ascii_emoticons': True,
    
    45 44
         'ascii_formatting': True,
    
    46 45
         'show_ascii_formatting_chars': True,
    
    47 46
         'sounds_on': True,
    

  • gajim/gtk/emoji_data.py
    ... ... @@ -144,45 +144,11 @@ def _replace_emojis(self):
    144 144
                         start(), end(), pixbuf.copy(), codepoint)
    
    145 145
     
    
    146 146
     
    
    147
    -class EmojiAsciiData(dict):
    
    148
    -    def get_regex(self):
    
    149
    -        # When an emoticon is bordered by an alphanumeric character it
    
    150
    -        # is NOT expanded.  e.g., foo:) NO, foo :) YES, (brb) NO,
    
    151
    -        # (:)) YES, etc. We still allow multiple emoticons
    
    152
    -        # side-by-side like :P:P:P
    
    153
    -
    
    154
    -        # TODO: Refactor this
    
    155
    -        keys = sorted(self.keys(), key=len, reverse=True)
    
    156
    -        pre_pattern = ''
    
    157
    -        post_pattern = ''
    
    158
    -        emoticon_length = 0
    
    159
    -        emoticons_pattern = ''
    
    160
    -        for emoticon in keys:
    
    161
    -            # escape regexp metachars
    
    162
    -            emoticon_escaped = re.escape(emoticon)
    
    163
    -            emoticons_pattern += emoticon_escaped + '|'
    
    164
    -            if emoticon_length != len(emoticon):
    
    165
    -                # Build up expressions to match emoticons next to others
    
    166
    -                pre_pattern = pre_pattern[:-1] + ')|(?<='
    
    167
    -                post_pattern = post_pattern[:-1] + ')|(?='
    
    168
    -                emoticon_length = len(emoticon)
    
    169
    -            pre_pattern += emoticon_escaped + '|'
    
    170
    -            post_pattern += emoticon_escaped + '|'
    
    171
    -        # We match from our list of emoticons, but they must either have
    
    172
    -        # whitespace, or another emoticon next to it to match successfully
    
    173
    -        # [\w.] alphanumeric and dot (for not matching 8) in (2.8))
    
    174
    -        emoticons_pattern = r'(?:(?<![\w.]' + \
    
    175
    -            pre_pattern[:-1] + '))' + '(?:' + \
    
    176
    -            emoticons_pattern[:-1] + ')' + r'(?:(?![\w]' + \
    
    177
    -            post_pattern[:-1] + '))'
    
    178
    -        return emoticons_pattern
    
    179
    -
    
    180
    -
    
    181 147
     emoji_pixbufs = EmojiPixbufs()
    
    182 148
     
    
    183 149
     # pylint: disable=line-too-long
    
    184 150
     
    
    185
    -emoji_ascii_data = EmojiAsciiData([
    
    151
    +emoji_ascii_data = dict([
    
    186 152
         ("':-D", '\U0001F605'),
    
    187 153
         (':)', '\U0001F642'),
    
    188 154
         (':-O', '\U0001F62e'),
    

  • gajim/gtk/emoji_data.pyi
    ... ... @@ -29,11 +29,8 @@ class EmojiData(OrderedDict):
    29 29
     class EmojiPixbufs(dict):
    
    30 30
         ...
    
    31 31
     
    
    32
    -class EmojiAsciiData(dict):
    
    33
    -    ...
    
    34
    -
    
    35 32
     emoji_pixbufs = EmojiPixbufs()
    
    36 33
     
    
    37
    -emoji_ascii_data = EmojiAsciiData()
    
    34
    +emoji_ascii_data: dict[str, str]
    
    38 35
     
    
    39 36
     emoji_data = EmojiData()

  • gajim/gtk/preferences.py
    ... ... @@ -103,6 +103,8 @@ def __init__(self):
    103 103
             self._ui.connect_signals(self)
    
    104 104
     
    
    105 105
             self.show_all()
    
    106
    +        if sys.platform not in ('win32', 'darwin'):
    
    107
    +            self._ui.emoji.hide()
    
    106 108
     
    
    107 109
         def get_ui(self):
    
    108 110
             return self._ui
    
    ... ... @@ -727,30 +729,24 @@ def _on_dark_theme(value, *args):
    727 729
     
    
    728 730
     class Emoji(PreferenceBox):
    
    729 731
         def __init__(self, *args):
    
    732
    +        if sys.platform not in ('win32', 'darwin'):
    
    733
    +            PreferenceBox.__init__(self, [])
    
    734
    +            return
    
    730 735
     
    
    731 736
             emoji_themes_items = []
    
    732 737
             for theme in helpers.get_available_emoticon_themes():
    
    733 738
                 emoji_themes_items.append(theme)
    
    734 739
     
    
    735 740
             settings = [
    
    736
    -            Setting(SettingKind.SWITCH,
    
    737
    -                    _('Convert ASCII Emojis'),
    
    741
    +            Setting(SettingKind.POPOVER,
    
    742
    +                    _('Emoji Theme'),
    
    738 743
                         SettingType.CONFIG,
    
    739
    -                    'ascii_emoticons',
    
    740
    -                    desc=_('Typing short codes like :-) will display emojis'),
    
    741
    -                    callback=self._on_ascii_emoticons),
    
    744
    +                    'emoticons_theme',
    
    745
    +                    desc=_('Choose from various emoji styles'),
    
    746
    +                    props={'entries': emoji_themes_items},
    
    747
    +                    callback=self._on_emoticons_theme)
    
    742 748
             ]
    
    743 749
     
    
    744
    -        if sys.platform in ('win32', 'darwin'):
    
    745
    -            settings.append(
    
    746
    -                Setting(SettingKind.POPOVER,
    
    747
    -                        _('Emoji Theme'),
    
    748
    -                        SettingType.CONFIG,
    
    749
    -                        'emoticons_theme',
    
    750
    -                        desc=_('Choose from various emoji styles'),
    
    751
    -                        props={'entries': emoji_themes_items},
    
    752
    -                        callback=self._on_emoticons_theme))
    
    753
    -
    
    754 750
             PreferenceBox.__init__(self, settings)
    
    755 751
     
    
    756 752
         def _on_emoticons_theme(self, *args):
    
    ... ... @@ -763,10 +759,6 @@ def _toggle_emoticons():
    763 759
             for ctrl in controls:
    
    764 760
                 ctrl.toggle_emoticons()
    
    765 761
     
    
    766
    -    @staticmethod
    
    767
    -    def _on_ascii_emoticons(*args):
    
    768
    -        app.interface.make_regexps()
    
    769
    -
    
    770 762
     
    
    771 763
     class StatusIcon(PreferenceBox):
    
    772 764
         def __init__(self, *args):
    

  • gajim/gui_interface.py
    ... ... @@ -102,7 +102,6 @@
    102 102
     from gajim.gui.dialogs import PassphraseDialog
    
    103 103
     from gajim.gui.filechoosers import FileChooserDialog
    
    104 104
     from gajim.gui.emoji_data import emoji_data
    
    105
    -from gajim.gui.emoji_data import emoji_ascii_data
    
    106 105
     from gajim.gui.filetransfer import FileTransfersWindow
    
    107 106
     from gajim.gui.filetransfer_progress import FileTransferProgress
    
    108 107
     from gajim.gui.roster_item_exchange import RosterItemExchangeWindow
    
    ... ... @@ -1392,8 +1391,6 @@ def make_regexps(self):
    1392 1391
             # because emoticons match later (in the string) they need to be after
    
    1393 1392
             # basic matches that may occur earlier
    
    1394 1393
             emoticons = emoji_data.get_regex()
    
    1395
    -        if app.settings.get('ascii_emoticons'):
    
    1396
    -            emoticons += '|%s' % emoji_ascii_data.get_regex()
    
    1397 1394
     
    
    1398 1395
             self.emot_and_basic = '%s|%s' % (basic_pattern, emoticons)
    
    1399 1396