void ChttransEnabledForIMFilter(FcitxGenericConfig* config, FcitxConfigGroup* group, FcitxConfigOption* option, void* value, FcitxConfigSync sync, void* arg) { FcitxChttrans* chttrans = (FcitxChttrans*) config; char** enableForIM = (char**) value; if (sync == Value2Raw) { fcitx_utils_free(*enableForIM); *enableForIM = fcitx_string_map_to_string(chttrans->enableIM, ','); } else if (sync == Raw2Value) { if (*enableForIM) { fcitx_string_map_from_string(chttrans->enableIM, *enableForIM, ','); } } }
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); }
static void FcitxNotifySaveDConfig(FcitxNotify *notify) { FILE *fp; fp = FcitxXDGGetFileUserWithPrefix("conf", "fcitx-notify.config", "w", NULL); if (fp) { FcitxDesktopGroup *grp; grp = fcitx_desktop_file_ensure_group(¬ify->dconfig, "Notify/Notify"); FcitxDesktopEntry *ety; ety = fcitx_desktop_group_ensure_entry(grp, "HiddenNotify"); char *val = fcitx_string_map_to_string(notify->hide_notify, ';'); fcitx_desktop_entry_set_value(ety, val); free(val); fcitx_desktop_file_write_fp(¬ify->dconfig, fp); fclose(fp); } }