Beispiel #1
0
void QtApp::init() {
	// INIT
	INIT_QUEUE_CONTROLLER
	INIT_INPUT_CONTROLLER
	INIT_SHORTCUT_CONTROLLER
	INIT_RESOURCE_CONTROLLER
	INIT_UNDO_STACK

	INIT_MENU(main_frame);
	INIT_GUI(main_frame);
	INIT_SFML(main_frame);
	INIT_SPRITE_EDITOR();
}
Beispiel #2
0
static void*
FcitxKkcCreate(FcitxInstance *instance)
{
    FcitxKkc *kkc = fcitx_utils_new(FcitxKkc);
    bindtextdomain("fcitx-kkc", LOCALEDIR);
    bind_textdomain_codeset("fcitx-kkc", "UTF-8");
    kkc->owner = instance;

    if (!KkcLoadConfig(&kkc->config)) {
        free(kkc);
        return NULL;
    }

#if !GLIB_CHECK_VERSION(2, 36, 0)
    g_type_init();
#endif
    kkc_init();

    KkcLanguageModel* model = kkc_language_model_load("sorted3", NULL);
    if (!model) {
        free(kkc);
        return NULL;
    }

    FcitxXDGMakeDirUser("kkc/rules");
    FcitxXDGMakeDirUser("kkc/dictionary");

    kkc->model = model;
    kkc->context = kkc_context_new(model);

    if (!FcitxKkcLoadDictionary(kkc) || !FcitxKkcLoadRule(kkc)) {
        g_object_unref(kkc->context);
        free(kkc);
        return NULL;
    }
    kkc_context_set_punctuation_style(kkc->context, KKC_PUNCTUATION_STYLE_JA_JA);
    kkc_context_set_input_mode(kkc->context, KKC_INPUT_MODE_HIRAGANA);
    kkc->tempMsg = FcitxMessagesNew();


    FcitxKkcApplyConfig(kkc);

    FcitxIMIFace iface;
    memset(&iface, 0, sizeof(FcitxIMIFace));
    iface.Init = FcitxKkcInit;
    iface.DoInput = FcitxKkcDoInput;
    iface.DoReleaseInput = FcitxKkcDoReleaseInput;
    iface.GetCandWords = FcitxKkcGetCandWords;
    iface.Save = FcitxKkcSave;
    iface.ResetIM = FcitxKkcResetIM;
    iface.OnClose = FcitxKkcOnClose;

    FcitxInstanceRegisterIMv2(instance, kkc, "kkc", _("Kana Kanji"), "kkc", iface, 1, "ja");


#define INIT_MENU(VARNAME, NAME, I18NNAME, STATUS_NAME, STATUS_ARRAY, SIZE) \
    do { \
        FcitxUIRegisterComplexStatus(instance, kkc, \
            STATUS_NAME, \
            I18NNAME, \
            I18NNAME, \
            NULL, \
            FcitxKkcGet##NAME##IconName \
        ); \
        FcitxMenuInit(&VARNAME); \
        VARNAME.name = strdup(I18NNAME); \
        VARNAME.candStatusBind = strdup(STATUS_NAME); \
        VARNAME.UpdateMenu = FcitxKkcUpdate##NAME##Menu; \
        VARNAME.MenuAction = FcitxKkc##NAME##MenuAction; \
        VARNAME.priv = kkc; \
        VARNAME.isSubMenu = false; \
        int i; \
        for (i = 0; i < SIZE; i ++) \
            FcitxMenuAddMenuItem(&VARNAME, _(STATUS_ARRAY[i].label), MENUTYPE_SIMPLE, NULL); \
        FcitxUIRegisterMenu(instance, &VARNAME); \
        FcitxUISetStatusVisable(instance, STATUS_NAME, false); \
    } while(0)

    INIT_MENU(kkc->inputModeMenu, InputMode, _("Input Mode"), "kkc-input-mode", input_mode_status, KKC_INPUT_MODE_DIRECT);

    kkc->handler = g_signal_connect(kkc->context, "notify::input-mode", G_CALLBACK(_kkc_input_mode_changed_cb), kkc);
    FcitxKkcUpdateInputMode(kkc);

    kkc_context_set_input_mode(kkc->context, kkc->config.initialInputMode);

    FcitxIMEventHook hk;
    hk.arg = kkc;
    hk.func = FcitxKkcResetHook;
    FcitxInstanceRegisterResetInputHook(instance, hk);

    FcitxKkcAddFunctions(instance);
    return kkc;
}