__EXPORT_API void FcitxChewingReset(void* arg) { FcitxChewing* chewing = (FcitxChewing*) arg; chewing_Reset(chewing->context); #if 0 FcitxUIStatus* puncStatus = FcitxUIGetStatusByName(chewing->owner, "punc"); if (puncStatus) { if (puncStatus->getCurrentStatus(puncStatus->arg)) chewing_set_ShapeMode(chewing->context, FULLSHAPE_MODE); else chewing_set_ShapeMode(chewing->context, HALFSHAPE_MODE); } #endif }
void FcitxDBusMenuFillProperty(FcitxNotificationItem* notificationitem, int32_t id, FcitxStringHashSet* properties, DBusMessageIter* iter) { FcitxInstance* instance = notificationitem->owner; /* append a{sv} */ DBusMessageIter sub; dbus_message_iter_open_container(iter, DBUS_TYPE_ARRAY, "{sv}", &sub); int32_t menu = ACTION_MENU(id); int32_t index = ACTION_INDEX(id); /* index == 0 means it has a sub menu */ if (index == 0) { const char* value = "submenu"; FcitxDBusMenuAppendProperty(&sub, properties, "children-display", DBUS_TYPE_STRING, &value); } if (menu == 0) { if (index <= 8 && index > 0) { const char* value; switch(index) { case 1: value = _("Online Help"); FcitxDBusMenuAppendProperty(&sub, properties, "label", DBUS_TYPE_STRING, &value); value = "help-contents"; FcitxDBusMenuAppendProperty(&sub, properties, "icon-name", DBUS_TYPE_STRING, &value); break; case 2: case 3: case 8: value = "separator"; FcitxDBusMenuAppendProperty(&sub, properties, "type", DBUS_TYPE_STRING, &value); break; case 4: value = _("Configure Current Input Method"); FcitxDBusMenuAppendProperty(&sub, properties, "label", DBUS_TYPE_STRING, &value); break; case 5: value = _("Configure"); FcitxDBusMenuAppendProperty(&sub, properties, "label", DBUS_TYPE_STRING, &value); /* this icon sucks on KDE, why configure doesn't have "configure" */ #if 0 value = "preferences-system"; FcitxDBusMenuAppendProperty(&sub, properties, "icon-name", DBUS_TYPE_STRING, &value); #endif break; case 6: value = _("Restart"); FcitxDBusMenuAppendProperty(&sub, properties, "label", DBUS_TYPE_STRING, &value); value = "view-refresh"; FcitxDBusMenuAppendProperty(&sub, properties, "icon-name", DBUS_TYPE_STRING, &value); break; case 7: value = _("Exit"); FcitxDBusMenuAppendProperty(&sub, properties, "label", DBUS_TYPE_STRING, &value); value = "application-exit"; FcitxDBusMenuAppendProperty(&sub, properties, "icon-name", DBUS_TYPE_STRING, &value); break; } } else { int index = STATUS_INDEX(id); const char* name = NULL; const char* icon = NULL; char* needfree = NULL; if (STATUS_ISCOMP(id)) { UT_array* uicompstats = FcitxInstanceGetUIComplexStats(instance); FcitxUIComplexStatus* compstatus = (FcitxUIComplexStatus*) utarray_eltptr(uicompstats, index); if (compstatus) { name = compstatus->shortDescription; icon = compstatus->getIconName(compstatus->arg); if (CheckAddPrefix(&icon)) { fcitx_utils_alloc_cat_str(needfree, "fcitx-", icon); icon = needfree; } } } else { UT_array* uistats = FcitxInstanceGetUIStats(instance); FcitxUIStatus* status = (FcitxUIStatus*) utarray_eltptr(uistats, index); if (status) { name = status->shortDescription; fcitx_utils_alloc_cat_str(needfree, "fcitx-", status->name, ((status->getCurrentStatus(status->arg)) ? "-active" : "-inactive")); icon = needfree; } } if (name) { FcitxDBusMenuAppendProperty(&sub, properties, "label", DBUS_TYPE_STRING, &name); } if (icon) { FcitxDBusMenuAppendProperty(&sub, properties, "icon-name", DBUS_TYPE_STRING, &icon); } fcitx_utils_free(needfree); } } else { UT_array* uimenus = FcitxInstanceGetUIMenus(instance); FcitxUIMenu** menupp = (FcitxUIMenu**) utarray_eltptr(uimenus, menu - 1), *menup; if (menupp) { menup = *menupp; if (index == 0) { FcitxDBusMenuAppendProperty(&sub, properties, "label", DBUS_TYPE_STRING, &menup->name); } else if (index > 0) { FcitxMenuItem* item = (FcitxMenuItem*) utarray_eltptr(&menup->shell, index - 1); if (item) { FcitxDBusMenuAppendProperty(&sub, properties, "label", DBUS_TYPE_STRING, &item->tipstr); if (menup->mark != -1) { const char* radio = "radio"; FcitxDBusMenuAppendProperty(&sub, properties, "toggle-type", DBUS_TYPE_STRING, &radio); int32_t toggleState = 0; if (menup->mark == index - 1) { toggleState = 1; } FcitxDBusMenuAppendProperty(&sub, properties, "toggle-state", DBUS_TYPE_INT32, &toggleState); } } } } } dbus_message_iter_close_container(iter, &sub); }