Register a addon in Fcitx


Each addon needs a configuration file. A common configuration file is like this one, fcitx-pinyin.conf.in.

[Addon]
Name=fcitx-pinyin
_GeneralName=Pinyin
_Comment=Simple Pinyin support for Fcitx
Category=InputMethod
Enabled=True
Library=fcitx-pinyin.so
Type=SharedLibrary
SubConfig=Shuang Pin Schema:native:pinyin/sp.dat,Symbol:native:pinyin/pySym.mb,fcitx:domain
            

All Fcitx config file are using ini style format, GeneralName and Comment are I18NString that can be translated into other languages. Here is a example configuration file of fcitx-pinyin merged with translation.

[Addon]
Name=fcitx-pinyin
GeneralName=Pinyin
GeneralName[zh_CN]=拼音
Comment=Simple Pinyin support for Fcitx
Comment[zh_CN]=Fcitx 简单的拼音支持
Category=InputMethod
Enabled=True
Library=fcitx-pinyin.so
Type=SharedLibrary
SubConfig=Shuang Pin Schema:native:pinyin/sp.dat,Symbol:native:pinyin/pySym.mb,fcitx:domain
        

fcitx_add_addon_conf_file(CONFFILENAME) can be used in CMakeLists.txt to automatically merge the translation into this file. And use extract_fcitx_addon_conf_postring() to extract strings of those conf.in files from POTFILES.in.

For addon which type is SharedLibrary, each different category requires export a different symbol.

FcitxFrontend frontend; /* for frontend */
FcitxIMClass ime; /* for input method */
FcitxModule module; /* for module */
FcitxUI ui; /* for user interface */
            

Each of this symbol consist a set of callback functions.