void ToggleFullWidthState(void* arg) { FcitxFullWidthChar* fwchar = (FcitxFullWidthChar*)arg; FcitxProfile* profile = FcitxInstanceGetProfile(fwchar->owner); profile->bUseFullWidthChar = !profile->bUseFullWidthChar; FcitxProfileSave(profile); FcitxInstanceResetInput(fwchar->owner); }
void ToggleRemindState(void* arg) { FcitxInstance* instance = (FcitxInstance*) arg; instance->profile->bUseRemind = !instance->profile->bUseRemind; FcitxUISetStatusString(instance, "remind", instance->profile->bUseRemind ? _("Use remind") : _("No remind"), _("Toggle Remind")); FcitxProfileSave(instance->profile); }
void ToggleFullWidthState(void* arg) { FcitxFullWidthChar* fwchar = (FcitxFullWidthChar*)arg; FcitxProfile* profile = FcitxInstanceGetProfile(fwchar->owner); profile->bUseFullWidthChar = !profile->bUseFullWidthChar; FcitxUISetStatusString(fwchar->owner, "fullwidth", profile->bUseFullWidthChar ? _("Full width Character") : _("Half width Character"), _("Toggle Half/Full width Character")); FcitxProfileSave(profile); }
void TogglePuncState(void* arg) { FcitxPuncState* puncState = (FcitxPuncState*)arg; FcitxInstance* instance = puncState->owner; FcitxProfile* profile = FcitxInstanceGetProfile(instance); profile->bUseWidePunc = !profile->bUseWidePunc; FcitxUISetStatusString(puncState->owner, "punc", profile->bUseWidePunc ? _("Full width punct") : _("Latin punct"), _("Toggle Full Width Punctuation")); FcitxProfileSave(profile); }
FCITX_EXPORT_API void FcitxInstanceEnd(FcitxInstance* instance) { /* avoid duplicate destroy */ if (instance->destroy) return; if (!instance->initialized) { if (!instance->loadingFatalError) { if (!instance->quietQuit) FcitxLog(ERROR, "Exiting."); instance->loadingFatalError = true; sem_post(instance->sem); } return; } instance->destroy = true; FcitxProfileSave(instance->profile); FcitxInstanceSaveAllIM(instance); if (instance->uinormal && instance->uinormal->ui->Destroy) instance->uinormal->ui->Destroy(instance->uinormal->addonInstance); if (instance->uifallback && instance->uifallback->ui->Destroy) instance->uifallback->ui->Destroy(instance->uifallback->addonInstance); instance->uifallback = NULL; instance->ui = NULL; instance->uinormal = NULL; /* handle exit */ FcitxAddon** pimclass; FcitxAddon** pfrontend; FcitxFrontend* frontend; FcitxInputContext* rec = NULL; for (pimclass = (FcitxAddon**) utarray_front(&instance->imeclasses); pimclass != NULL; pimclass = (FcitxAddon**) utarray_next(&instance->imeclasses, pimclass) ) { if ((*pimclass)->imclass->Destroy) (*pimclass)->imclass->Destroy((*pimclass)->addonInstance); } for (rec = instance->ic_list; rec != NULL; rec = rec->next) { pfrontend = (FcitxAddon**) utarray_eltptr(&instance->frontends, rec->frontendid); frontend = (*pfrontend)->frontend; frontend->CloseIM((*pfrontend)->addonInstance, rec); } for (rec = instance->ic_list; rec != NULL; rec = rec->next) { pfrontend = (FcitxAddon**) utarray_eltptr(&instance->frontends, rec->frontendid); frontend = (*pfrontend)->frontend; frontend->DestroyIC((*pfrontend)->addonInstance, rec); } for (pfrontend = (FcitxAddon**) utarray_front(&instance->frontends); pfrontend != NULL; pfrontend = (FcitxAddon**) utarray_next(&instance->frontends, pfrontend) ) { if (pfrontend == NULL) continue; FcitxFrontend* frontend = (*pfrontend)->frontend; frontend->Destroy((*pfrontend)->addonInstance); } FcitxAddon** pmodule; for (pmodule = (FcitxAddon**) utarray_front(&instance->modules); pmodule != NULL; pmodule = (FcitxAddon**) utarray_next(&instance->modules, pmodule) ) { if (pmodule == NULL) return; FcitxModule* module = (*pmodule)->module; if (module->Destroy) module->Destroy((*pmodule)->addonInstance); } sem_post(instance->sem); /* don't return to main loop, wait for exit */ int countDown = 5; while(countDown--) { sleep(1000); } exit(0); }
FCITX_EXPORT_API void FcitxInstanceRealEnd(FcitxInstance* instance) { FcitxProfileSave(instance->profile); FcitxInstanceSaveAllIM(instance); if (instance->uinormal && instance->uinormal->ui->Destroy) instance->uinormal->ui->Destroy(instance->uinormal->addonInstance); if (instance->uifallback && instance->uifallback->ui->Destroy) instance->uifallback->ui->Destroy(instance->uifallback->addonInstance); instance->uifallback = NULL; instance->ui = NULL; instance->uinormal = NULL; /* handle exit */ FcitxAddon** pimclass; FcitxAddon** pfrontend; FcitxFrontend* frontend; FcitxInputContext* rec = NULL; for (pimclass = (FcitxAddon**)utarray_front(&instance->imeclasses); pimclass != NULL; pimclass = (FcitxAddon**)utarray_next(&instance->imeclasses, pimclass) ) { if ((*pimclass)->imclass->Destroy) (*pimclass)->imclass->Destroy((*pimclass)->addonInstance); } for (rec = instance->ic_list; rec != NULL; rec = rec->next) { pfrontend = (FcitxAddon**)utarray_eltptr(&instance->frontends, (unsigned int)rec->frontendid); frontend = (*pfrontend)->frontend; frontend->CloseIM((*pfrontend)->addonInstance, rec); } for (rec = instance->ic_list; rec != NULL; rec = rec->next) { pfrontend = (FcitxAddon**)utarray_eltptr(&instance->frontends, (unsigned int)rec->frontendid); frontend = (*pfrontend)->frontend; frontend->DestroyIC((*pfrontend)->addonInstance, rec); } for (pfrontend = (FcitxAddon**)utarray_front(&instance->frontends); pfrontend != NULL; pfrontend = (FcitxAddon**)utarray_next(&instance->frontends, pfrontend) ) { if (pfrontend == NULL) continue; FcitxFrontend* frontend = (*pfrontend)->frontend; frontend->Destroy((*pfrontend)->addonInstance); } FcitxAddon** pmodule; for (pmodule = (FcitxAddon**) utarray_front(&instance->modules); pmodule != NULL; pmodule = (FcitxAddon**) utarray_next(&instance->modules, pmodule)) { if (pmodule == NULL) return; FcitxModule* module = (*pmodule)->module; if (module->Destroy) module->Destroy((*pmodule)->addonInstance); } sem_post(instance->sem); }
void ToggleRemindState(void* arg) { FcitxInstance* instance = (FcitxInstance*) arg; instance->profile->bUseRemind = !instance->profile->bUseRemind; FcitxProfileSave(instance->profile); }