示例#1
0
static void
FcitxNotifyShowTipCallback(void *arg, uint32_t id, const char *action)
{
    FcitxNotifyShowTipData *data = arg;
    FCITX_UNUSED(id);
    if (!strcmp(action, "dont-show")) {
        fcitx_string_map_set(data->notify->hide_notify,
                             data->tip_id, true);
    }
}
示例#2
0
void test_string_map()
{
    FcitxStringMap* map = fcitx_string_map_new("a:true,b:false", ',');
    assert(fcitx_string_map_get(map, "a", false));
    assert(!fcitx_string_map_get(map, "b", false));
    assert(fcitx_string_map_get(map, "c", true));
    fcitx_string_map_set(map, "c", false);
    assert(!fcitx_string_map_get(map, "c", true));
    char* joined = fcitx_string_map_to_string(map, '\n');
    assert(strcmp(joined, "a:true\nb:false\nc:false") == 0);
    free(joined);

    fcitx_string_map_free(map);
}
示例#3
0
static void
FcitxNotifyShowTip(FcitxNotify *notify, const char *appName,
                   const char *appIcon, int32_t timeout, const char *tip_id,
                   const char *summary, const char *body)
{
    if (fcitx_unlikely(!tip_id) ||
        fcitx_string_map_get(notify->hide_notify, tip_id, false))
        return;
    fcitx_string_map_set(notify->hide_notify, tip_id, false);
    const FcitxFreedesktopNotifyAction actions[] = {
        {
            .id = "dont-show",
            .name = _("Do not show again"),
        }, {
示例#4
0
文件: chttrans.c 项目: haobug/fcitx
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);
}
示例#5
0
FCITX_EXPORT_API
void fcitx_string_map_from_string(FcitxStringMap* map, const char* str, char delim)
{
    fcitx_string_map_clear(map);
    UT_array* list = fcitx_utils_split_string(str, delim);
    utarray_foreach(s, list, char*) {
        UT_array* item = fcitx_utils_split_string(*s, ':');
        if (utarray_len(item) == 2) {
            char* key = *(char**) utarray_eltptr(item, 0);
            char* value = *(char**) utarray_eltptr(item, 1);
            boolean bvalue = strcmp(value, "true") == 0;
            fcitx_string_map_set(map, key, bvalue);
        }
        fcitx_utils_free_string_list(item);
    }