From: Jihoon Kim Date: Fri, 3 Dec 2010 08:31:49 +0000 (+0900) Subject: [ecore_imf] add ecore_imf_context_input_panel_callback_list_get X-Git-Tag: accepted/2.0/20130306.224007~264 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=babed948421382ac56db9ef7f97de676e64873a1;p=profile%2Fivi%2Fecore.git [ecore_imf] add ecore_imf_context_input_panel_callback_list_get --- diff --git a/src/lib/ecore_imf/Ecore_IMF.h b/src/lib/ecore_imf/Ecore_IMF.h index f99799e..adc97b0 100644 --- a/src/lib/ecore_imf/Ecore_IMF.h +++ b/src/lib/ecore_imf/Ecore_IMF.h @@ -143,14 +143,18 @@ extern "C" { ECORE_IMF_INPUT_PANEL_ORIENT_90_CCW /* CounterClockwise */ } Ecore_IMF_Input_Panel_Orient; - typedef struct + typedef struct _Disable_Key_Item Disable_Key_Item; + + struct _Disable_Key_Item { int layout_idx; int key_idx; Eina_Bool disabled; - } Disable_Key_Item; + }; + + typedef struct _Private_Key_Item Private_Key_Item; - typedef struct + struct _Private_Key_Item { int layout_idx; int key_idx; @@ -158,7 +162,7 @@ extern "C" { char data[128]; // label or image path int key_value; char key_string[32]; - } Private_Key_Item; + }; /* Events sent by the Input Method */ typedef struct _Ecore_IMF_Event_Preedit_Start Ecore_IMF_Event_Preedit_Start; @@ -404,6 +408,15 @@ extern "C" { unsigned int end_index; }; + typedef struct _Ecore_IMF_Input_Panel_Event_Callback Ecore_IMF_Input_Panel_Event_Callback; + + struct _Ecore_IMF_Input_Panel_Event_Callback + { + void (*func)(void *data, Ecore_IMF_Context *ctx, int value); + const void *data; + Ecore_IMF_Input_Panel_Event type; + }; + struct _Ecore_IMF_Context_Class { void (*add) (Ecore_IMF_Context *ctx); @@ -1106,7 +1119,7 @@ extern "C" { * } * @endcode */ - EAPI Ecore_IMF_Input_Panel_State ecore_imf_context_input_panel_state_get (Ecore_IMF_Context *ctx); + EAPI Ecore_IMF_Input_Panel_State ecore_imf_context_input_panel_state_get (Ecore_IMF_Context *ctx); /** * Application can register a callback function which will be called if there is change in ise state,language,mode etc. @@ -1178,9 +1191,11 @@ extern "C" { * } * @endcode */ - EAPI void ecore_imf_context_input_panel_key_disabled_set (Ecore_IMF_Context *ctx, int layout_index, int key_index, Eina_Bool disabled); + EAPI void ecore_imf_context_input_panel_key_disabled_set (Ecore_IMF_Context *ctx, int layout_index, int key_index, Eina_Bool disabled); + + EAPI Eina_List *ecore_imf_context_input_panel_key_disabled_list_get (Ecore_IMF_Context *ctx); - EAPI Eina_List *ecore_imf_context_input_panel_key_disabled_list_get (Ecore_IMF_Context *ctx); + EAPI Eina_List *ecore_imf_context_input_panel_event_callback_list_get (Ecore_IMF_Context *ctx); /** * Move the soft keyboard to the new position. @@ -1206,7 +1221,7 @@ extern "C" { * } * @endcode */ - EAPI void ecore_imf_context_input_panel_move (Ecore_IMF_Context *ctx, int x, int y); + EAPI void ecore_imf_context_input_panel_move (Ecore_IMF_Context *ctx, int x, int y); EAPI void ecore_imf_context_input_panel_caps_mode_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Caps_Mode mode); diff --git a/src/lib/ecore_imf/ecore_imf_context.c b/src/lib/ecore_imf/ecore_imf_context.c index b817cd8..cfe893a 100644 --- a/src/lib/ecore_imf/ecore_imf_context.c +++ b/src/lib/ecore_imf/ecore_imf_context.c @@ -235,8 +235,12 @@ ecore_imf_context_del(Ecore_IMF_Context *ctx) EINA_LIST_FREE(ctx->disabled_key_list, data) free(data); + EINA_LIST_FREE(ctx->callbacks, data) + free(data); + ctx->private_key_list = NULL; ctx->disabled_key_list = NULL; + ctx->callbacks = NULL; free(ctx); } @@ -631,6 +635,8 @@ ecore_imf_context_new(const Ecore_IMF_Context_Class *ctxc) ctx->input_panel_layout = ECORE_IMF_INPUT_PANEL_LAYOUT_NORMAL; ctx->input_panel_orient = ECORE_IMF_INPUT_PANEL_ORIENT_NONE; ctx->use_effect = EINA_TRUE; + ctx->disabled_key_list = NULL; + ctx->private_key_list = NULL; ctx->callbacks = NULL; return ctx; @@ -1105,7 +1111,7 @@ ecore_imf_context_input_panel_private_key_set (Ecore_IMF_Context *ctx, int layou return; } - if (label == NULL && img_path == NULL) + if (!label && !img_path) { printf ("input parameters error!!! \n"); return; @@ -1213,11 +1219,29 @@ ecore_imf_context_input_panel_key_disabled_set (Ecore_IMF_Context *ctx, int layo } EAPI Eina_List * -ecore_imf_context_input_panel_key_disabled_list_get (Ecore_IMF_Context *ctx) +ecore_imf_context_input_panel_key_disabled_list_get (Ecore_IMF_Context *ctx) { + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) + { + ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_key_disabled_list_get"); + return NULL; + } + return ctx->disabled_key_list; } +EAPI Eina_List * +ecore_imf_context_input_panel_event_callback_list_get (Ecore_IMF_Context *ctx) +{ + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) + { + ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_event_callback_list_get"); + return NULL; + } + + return ctx->callbacks; +} + EAPI void ecore_imf_context_input_panel_layout_set (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Layout layout) { @@ -1372,8 +1396,10 @@ ecore_imf_context_input_panel_state_get (Ecore_IMF_Context *ctx) } EAPI void -ecore_imf_context_input_panel_event_callback_add (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, void (*pEventCallBackFunc) (void *data, Ecore_IMF_Context *ctx, int value), const void *data) +ecore_imf_context_input_panel_event_callback_add (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, void (*func) (void *data, Ecore_IMF_Context *ctx, int value), const void *data) { + Ecore_IMF_Input_Panel_Event_Callback *it; + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) { ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_event_callback_add"); @@ -1382,13 +1408,25 @@ ecore_imf_context_input_panel_event_callback_add (Ecore_IMF_Context *ctx, Ecore_ if (ctx->klass->input_panel_event_callback_add) { - ctx->klass->input_panel_event_callback_add(ctx, type, pEventCallBackFunc, data); + it = calloc(1, sizeof(Ecore_IMF_Input_Panel_Event_Callback)); + if (!it) return; + + it->func = func; + it->data = data;; + it->type = type; + + ctx->callbacks = eina_list_append(ctx->callbacks, it); + + ctx->klass->input_panel_event_callback_add(ctx, type, func, data); } } EAPI void -ecore_imf_context_input_panel_event_callback_del (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, void (*pEventCallBackFunc) (void *data, Ecore_IMF_Context *ctx, int value)) +ecore_imf_context_input_panel_event_callback_del (Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, void (*func) (void *data, Ecore_IMF_Context *ctx, int value)) { + Eina_List *l; + Ecore_IMF_Input_Panel_Event_Callback *it; + if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) { ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,"ecore_imf_context_input_panel_event_callback_del"); @@ -1397,7 +1435,20 @@ ecore_imf_context_input_panel_event_callback_del (Ecore_IMF_Context *ctx, Ecore_ if (ctx->klass->input_panel_event_callback_del) { - ctx->klass->input_panel_event_callback_del(ctx, type, pEventCallBackFunc); + for (l = ctx->callbacks; l;) + { + it = (Ecore_IMF_Input_Panel_Event_Callback *)l->data; + + if (it && it->func == func && it->type == type) + { + ctx->callbacks = eina_list_remove(ctx->callbacks, it); + free(it); + break; + } + l = l->next; + } + + ctx->klass->input_panel_event_callback_del(ctx, type, func); } }