ecore_imf: Add ecore_imf_context_input_panel_event_callback_call, clear API

This commit is contained in:
Jihoon Kim 2013-04-13 17:11:32 +09:00
parent 58d7c5c1dc
commit af31393a09
5 changed files with 119 additions and 6 deletions

View File

@ -1,6 +1,7 @@
2013-04-13 Jihoon Kim
* Ecore_IMF: Add ecore_imf_input_panel_hide () API
* Ecore_IMF: Add ecore_imf_context_input_panel_event_callback_call, clear API
2013-04-10 Rafael Antognolli

1
NEWS
View File

@ -93,6 +93,7 @@ Additions:
* ecore_imf:
- Add ecore_imf_context_input_panel_layout_variation_set/get API
- Add ecore_imf_input_panel_hide API
- Add ecore_imf_context_input_panel_event_callback_call, clear API
* Add edje_object_part_text_input_panel_layout_variation_set/get API
* Evil:
- Add mkdtemp.

View File

@ -1474,6 +1474,28 @@ EAPI void ecore_imf_context_input_panel_event_callback_
*/
EAPI void 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));
/**
* Call a given input panel callback on the context @p ctx.
*
* @param ctx Ecore_IMF_Context.
* @param type The type of event that will trigger the callback
* @param value the event value
* @ingroup Ecore_IMF_Context_Group
* @since 1.8.0
*/
EAPI void ecore_imf_context_input_panel_event_callback_call(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, int value);
/**
* Delete all input panel callback on the context @p ctx.
*
* Delete all input panel callback to be registered by ecore_imf_context_input_panel_event_callback_add()
*
* @param ctx Ecore_IMF_Context.
* @ingroup Ecore_IMF_Context_Group
* @since 1.8.0
*/
EAPI void ecore_imf_context_input_panel_event_callback_clear(Ecore_IMF_Context *ctx);
/**
* Get the current language locale of the input panel.
*

View File

@ -190,6 +190,12 @@ ecore_imf_context_del(Ecore_IMF_Context *ctx)
free(fn);
}
if (ctx->input_panel_callbacks)
{
EINA_LIST_FREE(ctx->input_panel_callbacks, fn)
free(fn);
}
ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE);
free(ctx);
}
@ -268,7 +274,6 @@ ecore_imf_context_hide(Ecore_IMF_Context *ctx)
return;
}
show_req_ctx = NULL;
if (ctx->klass->hide) ctx->klass->hide(ctx);
}
@ -792,7 +797,6 @@ ecore_imf_context_input_panel_hide(Ecore_IMF_Context *ctx)
return;
}
show_req_ctx = NULL;
if (ctx->klass->hide) ctx->klass->hide(ctx);
}
@ -1060,6 +1064,8 @@ ecore_imf_context_input_panel_event_callback_add(Ecore_IMF_Context *ctx,
void (*func) (void *data, Ecore_IMF_Context *ctx, int value),
const void *data)
{
Ecore_IMF_Input_Panel_Callback_Node *fn = NULL;
if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
{
ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
@ -1067,8 +1073,16 @@ ecore_imf_context_input_panel_event_callback_add(Ecore_IMF_Context *ctx,
return;
}
if (ctx->klass->input_panel_event_callback_add)
ctx->klass->input_panel_event_callback_add(ctx, type, func, (void *)data);
if (!func) return;
fn = calloc(1, sizeof (Ecore_IMF_Input_Panel_Callback_Node));
if (!fn) return;
fn->func = func;
fn->data = data;
fn->type = type;
ctx->input_panel_callbacks = eina_list_append(ctx->input_panel_callbacks, fn);
}
EAPI void
@ -1076,6 +1090,10 @@ 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 = NULL;
Eina_List *l_next = NULL;
Ecore_IMF_Input_Panel_Callback_Node *fn = NULL;
if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
{
ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
@ -1083,8 +1101,70 @@ ecore_imf_context_input_panel_event_callback_del(Ecore_IMF_Context *ctx,
return;
}
if (ctx->klass->input_panel_event_callback_del)
ctx->klass->input_panel_event_callback_del(ctx, type, func);
if (!func) return;
if (!ctx->input_panel_callbacks) return;
EINA_LIST_FOREACH_SAFE(ctx->input_panel_callbacks, l, l_next, fn)
{
if ((fn) && (fn->func == func) && (fn->type == type))
{
free(fn);
ctx->input_panel_callbacks = eina_list_remove_list(ctx->input_panel_callbacks, l);
return;
}
}
}
EAPI void
ecore_imf_context_input_panel_event_callback_call(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, int value)
{
Ecore_IMF_Input_Panel_Callback_Node *fn = NULL;
Eina_List *l = NULL;
if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
{
ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
"ecore_imf_context_input_panel_event_callback_call");
return;
}
EINA_LIST_FOREACH(ctx->input_panel_callbacks, l, fn)
{
if ((fn) && (fn->type == type) && (fn->func))
{
fn->func(fn->data, ctx, value);
if (type == ECORE_IMF_INPUT_PANEL_STATE_EVENT &&
value == ECORE_IMF_INPUT_PANEL_STATE_HIDE &&
show_req_ctx == ctx)
show_req_ctx = NULL;
}
}
}
EAPI void
ecore_imf_context_input_panel_event_callback_clear(Ecore_IMF_Context *ctx)
{
Ecore_IMF_Input_Panel_Callback_Node *fn = NULL;
Eina_List *l = NULL;
if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
{
ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
"ecore_imf_context_input_panel_event_callback_clear");
return;
}
for (l = ctx->input_panel_callbacks; l;)
{
fn = (Ecore_IMF_Input_Panel_Callback_Node *)l->data;
if (fn)
{
ctx->input_panel_callbacks = eina_list_remove(ctx->input_panel_callbacks, fn);
free (fn);
}
l = l->next;
}
}
EAPI void

View File

@ -36,6 +36,7 @@ extern int _ecore_imf_log_dom;
typedef struct _Ecore_IMF_Module Ecore_IMF_Module;
typedef struct _Ecore_IMF_Func_Node Ecore_IMF_Func_Node;
typedef struct _Ecore_IMF_Input_Panel_Callback_Node Ecore_IMF_Input_Panel_Callback_Node;
struct _Ecore_IMF_Context
{
@ -49,6 +50,7 @@ struct _Ecore_IMF_Context
Eina_Bool (*retrieve_surrounding_func)(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos);
void *retrieve_surrounding_data;
Eina_List *callbacks;
Eina_List *input_panel_callbacks;
Ecore_IMF_Autocapital_Type autocapital_type;
Ecore_IMF_Input_Panel_Layout input_panel_layout;
Ecore_IMF_Input_Panel_Lang input_panel_lang;
@ -74,6 +76,13 @@ struct _Ecore_IMF_Func_Node
Ecore_IMF_Callback_Type type;
};
struct _Ecore_IMF_Input_Panel_Callback_Node
{
void (*func) ();
const void *data;
Ecore_IMF_Input_Panel_Event type;
};
void ecore_imf_module_init(void);
void ecore_imf_module_shutdown(void);
Eina_List *ecore_imf_module_available_get(void);