IBusProperty * ibus_property_new (const gchar *key, IBusPropType type, IBusText *label, const gchar *icon, IBusText *tooltip, gboolean sensitive, gboolean visible, IBusPropState state, IBusPropList *prop_list) { g_return_val_if_fail (key != NULL, NULL); g_return_val_if_fail (type >= PROP_TYPE_NORMAL && type <= PROP_TYPE_SEPARATOR, NULL); IBusProperty *prop; prop = (IBusProperty *)g_object_new (IBUS_TYPE_PROPERTY, NULL); prop->key = g_strdup (key); prop->type = type; ibus_property_set_label (prop, label); ibus_property_set_icon (prop, icon); ibus_property_set_tooltip (prop, tooltip); ibus_property_set_sensitive (prop, sensitive); ibus_property_set_visible (prop, visible); ibus_property_set_state (prop, state); ibus_property_set_sub_props (prop, prop_list); return prop; }
void SetupLauncher::init() { ibus_property_set_label (*this, m_info.label); ibus_property_set_icon (*this, m_info.icon.c_str()); ibus_property_set_tooltip (*this, m_info.tooltip); ibus_property_set_visible (*this, TRUE); }
void SunPinyinProperty::init(bool state) { m_state = state; int which = m_state ? 1 : 0; PropertyInfo& info = m_info[which]; ibus_property_set_label(*this, info.label); ibus_property_set_icon(*this, info.icon.c_str()); ibus_property_set_tooltip(*this, info.tooltip); ibus_property_set_visible(*this, TRUE); ibus_property_set_state(*this, state ? PROP_STATE_CHECKED : PROP_STATE_UNCHECKED); }
static void ibus_m17n_engine_callback (MInputContext *context, MSymbol command) { IBusM17NEngine *m17n = NULL; m17n = context->arg; g_return_if_fail (m17n != NULL); /* the callback may be called in minput_create_ic, in the time * m17n->context has not be assigned, so need assign it. */ if (m17n->context == NULL) { m17n->context = context; } if (command == Minput_preedit_start) { ibus_engine_hide_preedit_text ((IBusEngine *)m17n); } else if (command == Minput_preedit_draw) { ibus_m17n_engine_update_preedit (m17n); } else if (command == Minput_preedit_done) { ibus_engine_hide_preedit_text ((IBusEngine *)m17n); } else if (command == Minput_status_start) { ibus_engine_hide_preedit_text ((IBusEngine *)m17n); } else if (command == Minput_status_draw) { gchar *status; status = ibus_m17n_mtext_to_utf8 (m17n->context->status); if (status && strlen (status)) { IBusText *text; text = ibus_text_new_from_string (status); ibus_property_set_label (m17n->status_prop, text); ibus_property_set_visible (m17n->status_prop, TRUE); } else { ibus_property_set_label (m17n->status_prop, NULL); ibus_property_set_visible (m17n->status_prop, FALSE); } ibus_engine_update_property ((IBusEngine *)m17n, m17n->status_prop); g_free (status); } else if (command == Minput_status_done) { } else if (command == Minput_candidates_start) { ibus_engine_hide_lookup_table ((IBusEngine *) m17n); ibus_engine_hide_auxiliary_text ((IBusEngine *) m17n); } else if (command == Minput_candidates_draw) { ibus_m17n_engine_update_lookup_table (m17n); } else if (command == Minput_candidates_done) { ibus_engine_hide_lookup_table ((IBusEngine *) m17n); ibus_engine_hide_auxiliary_text ((IBusEngine *) m17n); } else if (command == Minput_set_spot) { } else if (command == Minput_toggle) { } else if (command == Minput_reset) { } /* ibus_engine_get_surrounding_text is only available in the current git master (1.3.99+) */ #ifdef HAVE_IBUS_ENGINE_GET_SURROUNDING_TEXT else if (command == Minput_get_surrounding_text && (((IBusEngine *) m17n)->client_capabilities & IBUS_CAP_SURROUNDING_TEXT) != 0) { IBusText *text; guint cursor_pos, nchars, nbytes; MText *mt, *surround; int len, pos; ibus_engine_get_surrounding_text ((IBusEngine *) m17n, &text, &cursor_pos); nchars = ibus_text_get_length (text); nbytes = g_utf8_offset_to_pointer (text->text, nchars) - text->text; mt = mconv_decode_buffer (Mcoding_utf_8, text->text, nbytes); g_object_unref (text); len = (long) mplist_value (m17n->context->plist); if (len < 0) { pos = cursor_pos + len; if (pos < 0) pos = 0; surround = mtext_duplicate (mt, pos, cursor_pos); } else if (len > 0) { pos = cursor_pos + len; if (pos > nchars) pos = nchars; surround = mtext_duplicate (mt, cursor_pos, pos); } else { surround = mtext (); } m17n_object_unref (mt); mplist_set (m17n->context->plist, Mtext, surround); m17n_object_unref (surround); } #endif /* !HAVE_IBUS_ENGINE_GET_SURROUNDING_TEXT */ else if (command == Minput_delete_surrounding_text && (((IBusEngine *) m17n)->client_capabilities & IBUS_CAP_SURROUNDING_TEXT) != 0) { int len; len = (long) mplist_value (m17n->context->plist); if (len < 0) ibus_engine_delete_surrounding_text ((IBusEngine *) m17n, len, -len); else if (len > 0) ibus_engine_delete_surrounding_text ((IBusEngine *) m17n, 0, len); } }
static void ibus_unikey_engine_property_activate(IBusEngine* engine, const gchar* prop_name, guint prop_state) { IBusProperty* prop; IBusText* label; guint i, j; unikey = (IBusUnikeyEngine*)engine; // input method active if (strncmp(prop_name, CONFIG_INPUTMETHOD, strlen(CONFIG_INPUTMETHOD)) == 0) { for (i=0; i<NUM_INPUTMETHOD; i++) { if (strcmp(prop_name + strlen(CONFIG_INPUTMETHOD)+1, Unikey_IMNames[i]) == 0) { unikey->im = Unikey_IM[i]; // update label for (j=0; j<unikey->prop_list->properties->len; j++) { prop = ibus_prop_list_get(unikey->prop_list, j); if (prop==NULL) return; else if (strcmp(ibus_property_get_key(prop), CONFIG_INPUTMETHOD) == 0) { label = ibus_text_new_from_static_string(Unikey_IMNames[i]); ibus_property_set_label(prop, label); break; } } // end update label // update property state for (j=0; j<unikey->menu_im->properties->len; j++) { prop = ibus_prop_list_get(unikey->menu_im, j); if (prop==NULL) return; else if (strcmp(ibus_property_get_key(prop), prop_name)==0) ibus_property_set_state(prop, PROP_STATE_CHECKED); else ibus_property_set_state(prop, PROP_STATE_UNCHECKED); } // end update property state break; } } } // end input method active // output charset active else if (strncmp(prop_name, CONFIG_OUTPUTCHARSET, strlen(CONFIG_OUTPUTCHARSET)) == 0) { for (i=0; i<NUM_OUTPUTCHARSET; i++) { if (strcmp(prop_name+strlen(CONFIG_OUTPUTCHARSET)+1, Unikey_OCNames[i]) == 0) { unikey->oc = Unikey_OC[i]; // update label for (j=0; j<unikey->prop_list->properties->len; j++) { prop = ibus_prop_list_get(unikey->prop_list, j); if (prop==NULL) return; else if (strcmp(ibus_property_get_key(prop), CONFIG_OUTPUTCHARSET)==0) { label = ibus_text_new_from_static_string(Unikey_OCNames[i]); ibus_property_set_label(prop, label); break; } } // end update label // update property state for (j=0; j<unikey->menu_oc->properties->len; j++) { prop = ibus_prop_list_get(unikey->menu_oc, j); if (prop==NULL) return; else if (strcmp(ibus_property_get_key(prop), prop_name) == 0) ibus_property_set_state(prop, PROP_STATE_CHECKED); else ibus_property_set_state(prop, PROP_STATE_UNCHECKED); } // end update property state break; } } } // end output charset active // spellcheck active else if (strcmp(prop_name, CONFIG_SPELLCHECK) == 0) { unikey->ukopt.spellCheckEnabled = !unikey->ukopt.spellCheckEnabled; // update state for (j = 0; j < unikey->menu_opt->properties->len ; j++) { prop = ibus_prop_list_get(unikey->menu_opt, j); if (prop == NULL) return; else if (strcmp(ibus_property_get_key(prop), CONFIG_SPELLCHECK) == 0) { ibus_property_set_state(prop, (unikey->ukopt.spellCheckEnabled == 1)? PROP_STATE_CHECKED:PROP_STATE_UNCHECKED); break; } } // end update state } // end spellcheck active // MacroEnabled active else if (strcmp(prop_name, CONFIG_MACROENABLED) == 0) { unikey->ukopt.macroEnabled = !unikey->ukopt.macroEnabled; // update state for (j = 0; j < unikey->menu_opt->properties->len ; j++) { prop = ibus_prop_list_get(unikey->menu_opt, j); if (prop == NULL) return; else if (strcmp(ibus_property_get_key(prop), CONFIG_MACROENABLED) == 0) { ibus_property_set_state(prop, (unikey->ukopt.macroEnabled == 1)? PROP_STATE_CHECKED:PROP_STATE_UNCHECKED); break; } } // end update state } // end MacroEnabled active // MouseCapture active else if (strcmp(prop_name, CONFIG_MOUSECAPTURE) == 0) { unikey->mouse_capture = !unikey->mouse_capture; // update state for (j = 0; j < unikey->menu_opt->properties->len ; j++) { prop = ibus_prop_list_get(unikey->menu_opt, j); if (prop == NULL) return; else if (strcmp(ibus_property_get_key(prop), CONFIG_MOUSECAPTURE) == 0) { ibus_property_set_state(prop, (unikey->mouse_capture == 1)? PROP_STATE_CHECKED:PROP_STATE_UNCHECKED); break; } } // end update state } // end MouseCapture active // if Run setup else if (strcmp(prop_name, "RunSetupGUI") == 0) { system(LIBEXECDIR "/ibus-setup-unikey &"); } // END Run setup ibus_unikey_engine_reset(engine); UnikeySetInputMethod(unikey->im); UnikeySetOutputCharset(unikey->oc); UnikeySetOptions(&unikey->ukopt); }