Exemplo n.º 1
0
boolean LoadChttransConfig(FcitxChttrans* transState)
{
    FcitxConfigFileDesc* configDesc = GetChttransConfigDesc();
    if (configDesc == NULL)
        return false;

    FILE *fp;
    char *file;
    fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-chttrans.config",
                                       "r", &file);
    FcitxLog(DEBUG, "Load Config File %s", file);
    free(file);
    if (!fp) {
        if (errno == ENOENT)
            SaveChttransConfig(transState);
    }

    FcitxConfigFile *cfile = FcitxConfigParseConfigFileFp(fp, configDesc);

    FcitxChttransConfigBind(transState, cfile, configDesc);
    FcitxConfigBindSync((FcitxGenericConfig*)transState);

    if (fp)
        fclose(fp);

    return true;
}
Exemplo n.º 2
0
void ToggleChttransState(void* arg)
{
    FcitxChttrans* transState = (FcitxChttrans*) arg;
    transState->enabled = !transState->enabled;
    FcitxUISetStatusString(transState->owner, "chttrans",
                           transState->enabled ? _("Convert to Traditional Chinese") :  _("Convert to Simplified Chinese"),
                          _("Toggle Simp/Trad Chinese Conversion"));
    FcitxUIUpdateInputWindow(transState->owner);
    SaveChttransConfig(transState);
}
Exemplo n.º 3
0
boolean LoadChttransConfig(FcitxChttrans* transState)
{
    FcitxConfigFileDesc* configDesc = GetChttransConfigDesc();
    if (configDesc == NULL)
        return false;

    FILE *fp;
    char *file;
    fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-chttrans.config", "r", &file);
    FcitxLog(DEBUG, "Load Config File %s", file);
    free(file);
    boolean newconfig = false;
    if (!fp) {
        if (errno == ENOENT)
            SaveChttransConfig(transState);
        newconfig = true;
    }

    FcitxConfigFile *cfile = FcitxConfigParseConfigFileFp(fp, configDesc);

    FcitxChttransConfigBind(transState, cfile, configDesc);
    FcitxConfigBindSync((FcitxGenericConfig*)transState);

    if (newconfig) {
        char *p = fcitx_utils_get_current_langcode();
        /* also check en_HK for default setting */
        if (strcmp(p, "zh_TW") == 0 || strcmp(p, "en_HK") == 0 || strcmp(p, "zh_HK") == 0) {
            transState->enabled = true;
            SaveChttransConfig(transState);
        }
        free(p);
    }

    if (fp)
        fclose(fp);

    return true;
}
Exemplo n.º 4
0
void ToggleChttransState(void* arg)
{
    FcitxChttrans* transState = (FcitxChttrans*) arg;
    FcitxIM* im = FcitxInstanceGetCurrentIM(transState->owner);
    if (!im)
        return;
    boolean enabled = !ChttransEnabled(transState);

    fcitx_string_map_set(transState->enableIM, im->uniqueName, enabled);
    FcitxUISetStatusString(transState->owner, "chttrans",
                           enabled ? _("Traditional Chinese") :  _("Simplified Chinese"),
                          _("Toggle Simp/Trad Chinese Conversion"));
    FcitxUIUpdateInputWindow(transState->owner);
    SaveChttransConfig(transState);
}