hunspell_table.py 文件源码

python
阅读 25 收藏 0 点赞 0 评论 0

项目:ibus-typing-booster 作者: mike-fabian 项目源码 文件源码
def set_add_direct_input(self, mode, update_dconf=True):
        '''Set the current value of the “Add direct input” mode

        :param mode: Whether “Add direct input” mode is on or off
        :type mode: boolean
        :param update_dconf: Whether to write the change to dconf.
                             Set this to False if this method is
                             called because the dconf key changed
                             to avoid endless loops when the dconf
                             key is changed twice in a short time.
        :type update_dconf: boolean
        '''
        imes = self.get_current_imes()
        dictionary_names = self.db.hunspell_obj.get_dictionary_names()
        self._add_direct_input = mode
        if mode:
            if 'NoIme' not in imes:
                imes.append('NoIme')
            if 'en_GB' not in dictionary_names:
                dictionary_names.append('en_GB')
        else:
            imes = [x for x in imes if x != 'NoIme']
            if not imes:
                imes = ['NoIme']
            # always keep the first dictionary, i.e. always keep
            # the original one from the config file
            dictionary_names = (
                [dictionary_names[0]]
                + [x for x in dictionary_names[1:] if x != 'en_GB'])
        self.set_dictionary_names(dictionary_names, update_dconf=True)
        self.set_current_imes(imes, update_dconf=True)
        if update_dconf:
            self._config.set_value(
                self._config_section,
                'adddirectinput',
                GLib.Variant.new_boolean(mode))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号