Esempio n. 1
0
FCITX_EXPORT_API
FcitxAddonManager* fcitx_addon_manager_new(FcitxStandardPath* standardPath)
{
    FcitxAddonManager* manager = fcitx_utils_new(FcitxAddonManager);
    manager->resolvers = fcitx_dict_new(fcitx_addon_resolver_free);
    manager->standardPath = fcitx_standard_path_ref(standardPath);
    manager->addons = fcitx_dict_new((FcitxDestroyNotify) fcitx_addon_free);
    manager->loadedAddons = fcitx_ptr_array_new(NULL);
    manager->properties = fcitx_dict_new(NULL);
    return fcitx_addon_manager_ref(manager);
}
Esempio n. 2
0
File: ime.c Progetto: fcitx/fcitx-ng
FCITX_EXPORT_API
FcitxInputMethodManager* fcitx_input_method_manager_new(FcitxAddonManager* addonManager)
{
    FcitxInputMethodManager* self = fcitx_utils_new(FcitxInputMethodManager);
    self->addonManager = addonManager;
    self->groups = fcitx_ptr_array_new((FcitxDestroyNotify) fcitx_input_method_group_free);
    self->ims = fcitx_dict_new(NULL);
    return fcitx_input_method_manager_ref(self);
}
Esempio n. 3
0
FcitxComposeTable* _fcitx_compose_table_alloc(const char* locale)
{
    FcitxComposeTable* table = fcitx_utils_new(FcitxComposeTable);
    table->localeToTable = fcitx_dict_new(free);
    table->composeTable = utarray_new(&composeElementIcd);
    table->locale = locale ? strdup(locale) : strdup(_get_locale());
    char* p = table->locale;
    while(*p) {
        *p = fcitx_utils_toupper(*p);
        p++;
    }

    return fcitx_compose_table_ref(table);
}
Esempio n. 4
0
FcitxConfiguration* _fcitx_configuration_get(FcitxConfiguration* config, const char* path, bool createPath, FcitxConfiguration** parent, const char** lastPath)
{
    if (!config) {
        return NULL;
    }

    if (parent) {
        *parent = NULL;
        *lastPath = NULL;
    }
    while (path[0]) {
        if (path[0] == '/') {
            path ++;
        }
        char* seg = strchrnul(path, '/');
        size_t len = seg - path;
        if (parent) {
            *parent = config;
            *lastPath = path;
        }
        if (!config->subitems || !fcitx_dict_lookup(config->subitems, path, len, &config)) {
            if (!createPath) {
                return NULL;
            } else {
                FcitxConfiguration* newConfig = fcitx_configuration_new(NULL);
                newConfig->name = strndup(path, len);
                if (!config->subitems) {
                    config->subitems = fcitx_dict_new((FcitxDestroyNotify) fcitx_configuration_unref);
                }

                fcitx_dict_insert(config->subitems, path, len, newConfig, false);
                config = newConfig;
            }
        }

        path = seg;
    }

    return config;
}
Esempio n. 5
0
FCITX_EXPORT_API
void fcitx_addon_manager_register_default_resolver(FcitxAddonManager* mananger, FcitxStaticAddon* staticAddon)
{
    FcitxDict* staticAddonDict = fcitx_dict_new(NULL);
    while (staticAddon && staticAddon->name && staticAddon->entry) {
        fcitx_dict_insert_by_str(staticAddonDict, staticAddon->name, staticAddon->entry, false);
        staticAddon++;
    }

    FcitxAddonResolver staticLibraryResolver;
    memset(&staticLibraryResolver, 0, sizeof(staticLibraryResolver));
    staticLibraryResolver.destroyNotify = fcitx_static_library_resolver_free;
    staticLibraryResolver.resolve = fcitx_static_library_resolve;
    staticLibraryResolver.unload = fcitx_static_library_unload;
    staticLibraryResolver.data = staticAddonDict;

    FcitxAddonResolver sharedLibraryResolver;
    memset(&sharedLibraryResolver, 0, sizeof(sharedLibraryResolver));
    sharedLibraryResolver.resolve = fcitx_shared_library_resolve;
    sharedLibraryResolver.unload = fcitx_shared_library_unload;
    fcitx_addon_manager_register_resolver(mananger, "StaticLibrary", &staticLibraryResolver);
    fcitx_addon_manager_register_resolver(mananger, "SharedLibrary", &sharedLibraryResolver);
}
Esempio n. 6
0
FCITX_EXPORT_API
FcitxI18NString* fcitx_i18n_string_new()
{
    FcitxI18NString* dict = fcitx_dict_new(free);
    return dict;
}