void ibus_chewing_engine_property_activate(IBusEngine *engine, const gchar *prop_name, guint prop_state){ G_DEBUG_MSG(3,"[I3] property_activate(-, %s, %u)", prop_name, prop_state); Self *self=SELF(engine); gboolean needRefresh=TRUE; if (strcmp(prop_name,"chewing_chieng_prop")==0){ /* Toggle Chinese <-> English */ chewing_set_ChiEngMode(self->context, !chewing_get_ChiEngMode(self->context)); }else if (strcmp(prop_name,"chewing_alnumSize_prop")==0){ /* Toggle Full <-> Half */ chewing_set_ShapeMode(self->context, !chewing_get_ShapeMode(self->context)); }else if (strcmp(prop_name,"chewing_settings_prop")==0){ if (self->settings_prop->state==PROP_STATE_UNCHECKED){ if (gtk_dialog_run(GTK_DIALOG(self->setting_dialog))==GTK_RESPONSE_OK){ self_save_config_all(self); } gtk_widget_hide(self->setting_dialog); self->settings_prop->state=PROP_STATE_UNCHECKED; } }else{ G_DEBUG_MSG(3,"[I3] property_activate(-, %s, %u) not recognized",prop_name, prop_state); needRefresh=FALSE; } if (needRefresh) self_refresh_property(self,prop_name); }
static void listStore_append(GtkListStore *listStore,const gchar *str, const gchar *translationContext, MakerDialogPropertyFlags propertyFlags){ GtkTreeIter iter; gtk_list_store_append (listStore, &iter); if (propertyFlags & MAKER_DIALOG_PROPERTY_FLAG_HAS_TRANSLATION){ if (translationContext || propertyFlags & MAKER_DIALOG_PROPERTY_FLAG_TRANSLATION_WITH_CONTEXT){ G_DEBUG_MSG(5,"*** str=%s, _(str)=%s",str,g_dpgettext2(NULL,translationContext,str)); gtk_list_store_set (listStore, &iter, 0, str, 1, g_dpgettext2(NULL,translationContext,str), -1); }else{ G_DEBUG_MSG(5,"*** str=%s, _(str)=%s",str,_(str)); gtk_list_store_set (listStore, &iter, 0, str, 1, _(str), -1); } }else{ G_DEBUG_MSG(5,"*** str=%s",str); gtk_list_store_set (listStore, &iter, 0, str, -1); } }
static gint listStore_find_string(GtkListStore *listStore,const gchar *str, const gchar *translationContext, MakerDialogPropertyFlags propertyFlags){ g_assert(str); G_DEBUG_MSG(4,"*** listStore_find_string(%s,%u)",str,propertyFlags); int i=0,index=-1; GtkTreeIter iter; GValue gValue={0}; if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(listStore), &iter)){ do{ gtk_tree_model_get_value (GTK_TREE_MODEL(listStore), &iter,0,&gValue); if (strcmp(str,g_value_get_string(&gValue))==0){ index= i; break; } i++; g_value_unset(&gValue); }while(gtk_tree_model_iter_next (GTK_TREE_MODEL(listStore), &iter)); } if (index<0 && !(propertyFlags & MAKER_DIALOG_PROPERTY_FLAG_INEDITABLE)){ /* Add new item*/ listStore_append(listStore, str,translationContext,propertyFlags); index=i; } G_DEBUG_MSG(4,",listStore_find_string(%s,%u) index=%d",str,propertyFlags,index); return index; }
static void on_spinButton_value_changed_wrap (GtkSpinButton *button, gpointer user_data) { PropertyContext *ctx=(PropertyContext *)user_data; GValue value={0}; g_value_init(&value, ctx->spec->valueType); switch(ctx->spec->valueType){ case G_TYPE_INT: g_value_set_int(&value,(gint) gtk_spin_button_get_value(button)); G_DEBUG_MSG(2,"on_spinButton_value_changed_wrap(), key=%s value=%d", ctx->spec->key,g_value_get_int(&value)); break; case G_TYPE_UINT: g_value_set_uint(&value,(guint) gtk_spin_button_get_value(button)); G_DEBUG_MSG(2,"on_spinButton_value_changed_wrap(), key=%s value=%u", ctx->spec->key,g_value_get_uint(&value)); break; case G_TYPE_DOUBLE: g_value_set_uint(&value, gtk_spin_button_get_value(button)); G_DEBUG_MSG(2,"on_spinButton_value_changed_wrap(), key=%s value=%g", ctx->spec->key,g_value_get_double(&value)); break; default: break; } ctx->spec->setFunc(ctx,&value); }
/*=================================================== * Mouse events */ void ibus_chewing_engine_candidate_clicked(IBusEngine *engine, guint index, guint button, guint state){ G_DEBUG_MSG(2,"***[I2] candidate_clicked(-, %u, %u, %u) ... proceed.", index, button, state); IBusChewingEngine *self=IBUS_CHEWING_ENGINE(engine); if (index >= chewing_get_candPerPage(self->context) || index <0) { G_DEBUG_MSG(3,"[I3] candidate_clicked() index out of ranged"); return; } if (self->inputMode==CHEWING_INPUT_MODE_SELECTING){ self->_priv->key_last=(guint) self->selKeys[index]; ibus_chewing_engine_handle_Default(self, self->_priv->key_last, FALSE); self_update(self); } else { G_DEBUG_MSG(3,"[I3] candidate_clicked() ... Wrong mode: %u", self->inputMode); } }
void ibus_chewing_engine_handle_Default(IBusChewingEngine *self, guint keyval, gboolean shiftPressed){ G_DEBUG_MSG(2,"[I2] handle_Default(-,%u) plainZhuyin=%s inputMode=%d", keyval,(self->chewingFlags & CHEWING_FLAG_PLAIN_ZHUYIN)? "TRUE": "FALSE",self->inputMode); ibus_chewing_engine_set_status_flag(self, ENGINE_STATUS_NEED_COMMIT); self->hasCommit=0; #ifdef EASY_SYMBOL_INPUT_WORK_AROUND if (self->chewingFlags & CHEWING_FLAG_EASY_SYMBOL_INPUT){ /* If shift is pressed, turn on the easySymbolInput, turn off * otherwise */ chewing_set_easySymbolInput(self->context,(shiftPressed)? 1:0); } #endif if (self->chewingFlags & CHEWING_FLAG_FORCE_LOWERCASE_ENGLISH){ if (isupper(keyval) && !shiftPressed){ keyval=tolower(keyval); }else if (islower(keyval) && shiftPressed){ keyval=toupper(keyval); } } chewing_handle_Default(self->context,keyval); if (self->chewingFlags & CHEWING_FLAG_PLAIN_ZHUYIN){ if (self_is_selectKey(self,self->_priv->key_last) && self->inputMode==CHEWING_INPUT_MODE_SELECTING){ chewing_handle_Enter(self->context); self->inputMode= CHEWING_INPUT_MODE_SELECTION_DONE; } } }
static void on_comboBox_changed_wrap (GtkComboBox *comboBox, gpointer user_data) { PropertyContext *ctx=(PropertyContext *)user_data; GValue value={0}; combo_get_active_text(comboBox, &value); G_DEBUG_MSG(2,"on_comboBox_changed_wrap(), key=%s value=%s",ctx->spec->key,g_value_get_string(&value)); ctx->spec->setFunc(ctx,&value); }
static void on_toggleButton_toggled_wrap (GtkToggleButton *button, gpointer user_data) { PropertyContext *ctx=(PropertyContext *)user_data; GValue value={0}; g_value_init(&value, ctx->spec->valueType); g_value_set_boolean(&value, gtk_toggle_button_get_active(button)); G_DEBUG_MSG(2,"on_entry_activate_wrap(), key=%s value=%s",ctx->spec->key,g_value_get_string(&value)); ctx->spec->setFunc(ctx,&value); }
static void on_entry_activate_wrap (GtkEntry *entry, gpointer user_data) { PropertyContext *ctx=(PropertyContext *)user_data; GValue value={0}; g_value_init(&value, ctx->spec->valueType); g_value_set_string(&value,gtk_entry_get_text(entry)); G_DEBUG_MSG(2,"on_entry_activate_wrap(), key=%s value=%s",ctx->spec->key,g_value_get_string(&value)); ctx->spec->setFunc(ctx,&value); }
void ibus_chewing_engine_set_content_type(IBusEngine *engine, guint purpose, guint hints){ G_DEBUG_MSG(5,"[I5] set_content_type(%d, %d)", purpose, hints); Self *self=SELF(engine); if (purpose == IBUS_INPUT_PURPOSE_PASSWORD || purpose == IBUS_INPUT_PURPOSE_PIN) { ibus_chewing_engine_set_status_flag(self, ENGINE_STATUS_IS_PASSWORD); } else { ibus_chewing_engine_clear_status_flag(self, ENGINE_STATUS_IS_PASSWORD); } }
static void xml_tags_write(FILE *outF, const gchar *tagName, XmlTagsType type, const gchar *attribute, const gchar *value){ static int indentLevel=0; if (type==XML_TAG_TYPE_END_ONLY) indentLevel--; GString *strBuf=xml_tags_to_string(tagName, type, attribute, value, indentLevel); G_DEBUG_MSG(3,",xml_tags_write:%s",strBuf->str); fprintf(outF,"%s\n",strBuf->str); if (type==XML_TAG_TYPE_BEGIN_ONLY) indentLevel++; g_string_free(strBuf,TRUE); }
gboolean ibus_chewing_engine_process_key_event(IBusEngine *engine, guint keysym, guint keycode, guint modifiers){ gboolean result=TRUE; if (modifiers & IBUS_RELEASE_MASK){ /* Skip release event */ return TRUE; } IBusChewingEngine *self=IBUS_CHEWING_ENGINE(engine); guint kSym=ibus_chewing_engine_keycode_to_keysym(self,keysym, keycode, modifiers); G_DEBUG_MSG(2,"***[I2] process_key_event(-, %x(%s), %x, %x) orig keysym=%x... proceed.",kSym, keyName_get(kSym), keycode, modifiers,keysym); guint state= modifiers & (IBUS_SHIFT_MASK | IBUS_CONTROL_MASK | IBUS_MOD1_MASK); self->_priv->key_last=kSym; if (state==0){ guint kSym_tmp=keysym_KP_to_normal(kSym); if (kSym_tmp){ G_DEBUG_MSG(3,"***[I3] process_key_event(): %x is from keypad.", kSym_tmp); /* Is keypad key */ if ((self->chewingFlags & CHEWING_FLAG_NUMPAD_ALWAYS_NUMBER) && chewing_get_ChiEngMode(self->context)){ chewing_set_ChiEngMode(self->context, 0); self_handle_Default(self,kSym_tmp,FALSE); chewing_set_ChiEngMode(self->context,CHINESE_MODE); }else{ /* Convert kp numbers to normal */ self_handle_Default(self,kSym_tmp,FALSE); } }else{ switch (kSym){ case IBUS_Return: case IBUS_KP_Enter: chewing_handle_Enter(self->context); break; case IBUS_Escape: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; chewing_handle_Esc(self->context); break; case IBUS_BackSpace: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; chewing_handle_Backspace(self->context); break; case IBUS_Delete: case IBUS_KP_Delete: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; chewing_handle_Del(self->context); break; case IBUS_space: case IBUS_KP_Space: if (self->chewingFlags & CHEWING_FLAG_PLAIN_ZHUYIN) { if (chewing_cand_TotalChoice(self->context) == 0) { chewing_handle_Space(self->context); } } else { /** * Fix for space in Temporary English mode. */ chewing_handle_Space(self->context); } if (self->inputMode==CHEWING_INPUT_MODE_SELECTION_DONE || self->inputMode==CHEWING_INPUT_MODE_BYPASS ) ibus_chewing_engine_set_status_flag(self,ENGINE_STATUS_NEED_COMMIT); break; case IBUS_Page_Up: case IBUS_KP_Page_Up: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; IBUS_ENGINE_GET_CLASS(engine)->page_up(engine); break; case IBUS_Page_Down: case IBUS_KP_Page_Down: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; IBUS_ENGINE_GET_CLASS(engine)->page_down(engine); break; case IBUS_Up: case IBUS_KP_Up: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; IBUS_ENGINE_GET_CLASS(engine)->cursor_up(engine); break; case IBUS_Down: case IBUS_KP_Down: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; IBUS_ENGINE_GET_CLASS(engine)->cursor_down(engine); break; case IBUS_Left: case IBUS_KP_Left: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; chewing_handle_Left(self->context); break; case IBUS_Right: case IBUS_KP_Right: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; chewing_handle_Right(self->context); break; case IBUS_Home: case IBUS_KP_Home: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; chewing_handle_Home(self->context); break; case IBUS_End: case IBUS_KP_End: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; chewing_handle_End(self->context); break; case IBUS_Tab: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; chewing_handle_Tab(self->context); break; case IBUS_Caps_Lock: /* When Chi->Eng with incomplete character */ if (chewing_get_ChiEngMode(self->context) && !chewing_zuin_Check(self->context)){ /* chewing_zuin_Check==0 means incomplete character */ /* Send a space to finish the character */ chewing_handle_Space(self->context); } chewing_handle_Capslock(self->context); self_refresh_property(self,"chewing_chieng_prop"); break; case IBUS_Shift_L: case IBUS_Shift_R: /* Some QT application will sneak these through */ return FALSE; case IBUS_Alt_L: case IBUS_Alt_R: /* Some QT application will sneak these through */ return FALSE; case IBUS_Control_L: case IBUS_Control_R: /* Some QT application will sneak these through */ return FALSE; default: self_handle_Default(self,kSym,FALSE); break; } } }else if (state==IBUS_SHIFT_MASK){ switch(kSym){ case IBUS_Left: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; chewing_handle_ShiftLeft(self->context); break; case IBUS_Right: if (self->inputMode==CHEWING_INPUT_MODE_BYPASS) return FALSE; chewing_handle_ShiftRight(self->context); break; case IBUS_Up: case IBUS_KP_Up: case IBUS_Down: case IBUS_KP_Down: case IBUS_Page_Up: case IBUS_KP_Page_Up: case IBUS_Page_Down: case IBUS_KP_Page_Down: case IBUS_Home: case IBUS_End: if (self->_priv->statusFlags & ENGINE_STATUS_NEED_COMMIT) self_force_commit(self); return FALSE; case IBUS_space: case IBUS_KP_Space: chewing_handle_ShiftSpace(self->context); chewing_set_ShapeMode(self->context, !chewing_get_ShapeMode(self->context)); self_refresh_property(self,"chewing_alnumSize_prop"); break; default: if (kSym>127 || kSym<0){ /* Special keys, must let it through */ return FALSE; } self_handle_Default(self,kSym,TRUE); break; } }else if (state==IBUS_CONTROL_MASK){ if (kSym>=IBUS_0 && kSym<=IBUS_9){ chewing_handle_CtrlNum(self->context,kSym); // }else if (kSym==IBUS_v || kSym==IBUS_V){ // chewing_handle_Right(self->context); }else{ result=FALSE; } }else{ result=FALSE; } if (!result){ return FALSE; } return self_update(self); }