aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/ecore_imf
diff options
context:
space:
mode:
authorJihoon Kim <jihoon48.kim@samsung.com>2013-04-13 17:11:32 +0900
committerJihoon Kim <jihoon48.kim@samsung.com>2013-04-13 17:11:32 +0900
commitaf31393a09251e7a42897fdaca893600d5221e03 (patch)
tree6286609ac753263407dbe08f3680f30d146b4639 /src/lib/ecore_imf
parentecore_imf: Add ecore_imf_input_panel_hide() API (diff)
downloadefl-af31393a09251e7a42897fdaca893600d5221e03.tar.gz
ecore_imf: Add ecore_imf_context_input_panel_event_callback_call, clear API
Diffstat (limited to 'src/lib/ecore_imf')
-rw-r--r--src/lib/ecore_imf/Ecore_IMF.h22
-rw-r--r--src/lib/ecore_imf/ecore_imf_context.c92
-rw-r--r--src/lib/ecore_imf/ecore_imf_private.h9
3 files changed, 117 insertions, 6 deletions
diff --git a/src/lib/ecore_imf/Ecore_IMF.h b/src/lib/ecore_imf/Ecore_IMF.h
index 2eb81fdfbd..7e740c7d60 100644
--- a/src/lib/ecore_imf/Ecore_IMF.h
+++ b/src/lib/ecore_imf/Ecore_IMF.h
@@ -1475,6 +1475,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.
*
* ex) fr_FR
diff --git a/src/lib/ecore_imf/ecore_imf_context.c b/src/lib/ecore_imf/ecore_imf_context.c
index 7c8318e547..f1e88211c7 100644
--- a/src/lib/ecore_imf/ecore_imf_context.c
+++ b/src/lib/ecore_imf/ecore_imf_context.c
@@ -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
diff --git a/src/lib/ecore_imf/ecore_imf_private.h b/src/lib/ecore_imf/ecore_imf_private.h
index 7452bd784f..b63500afec 100644
--- a/src/lib/ecore_imf/ecore_imf_private.h
+++ b/src/lib/ecore_imf/ecore_imf_private.h
@@ -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);