summaryrefslogtreecommitdiff
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
parent58d7c5c1dcef38ab671b6066aa779e725b693022 (diff)
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_
1475EAPI 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)); 1475EAPI 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));
1476 1476
1477/** 1477/**
1478 * Call a given input panel callback on the context @p ctx.
1479 *
1480 * @param ctx Ecore_IMF_Context.
1481 * @param type The type of event that will trigger the callback
1482 * @param value the event value
1483 * @ingroup Ecore_IMF_Context_Group
1484 * @since 1.8.0
1485 */
1486EAPI void ecore_imf_context_input_panel_event_callback_call(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, int value);
1487
1488/**
1489 * Delete all input panel callback on the context @p ctx.
1490 *
1491 * Delete all input panel callback to be registered by ecore_imf_context_input_panel_event_callback_add()
1492 *
1493 * @param ctx Ecore_IMF_Context.
1494 * @ingroup Ecore_IMF_Context_Group
1495 * @since 1.8.0
1496 */
1497EAPI void ecore_imf_context_input_panel_event_callback_clear(Ecore_IMF_Context *ctx);
1498
1499/**
1478 * Get the current language locale of the input panel. 1500 * Get the current language locale of the input panel.
1479 * 1501 *
1480 * ex) fr_FR 1502 * 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)
190 free(fn); 190 free(fn);
191 } 191 }
192 192
193 if (ctx->input_panel_callbacks)
194 {
195 EINA_LIST_FREE(ctx->input_panel_callbacks, fn)
196 free(fn);
197 }
198
193 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE); 199 ECORE_MAGIC_SET(ctx, ECORE_MAGIC_NONE);
194 free(ctx); 200 free(ctx);
195} 201}
@@ -268,7 +274,6 @@ ecore_imf_context_hide(Ecore_IMF_Context *ctx)
268 return; 274 return;
269 } 275 }
270 276
271 show_req_ctx = NULL;
272 if (ctx->klass->hide) ctx->klass->hide(ctx); 277 if (ctx->klass->hide) ctx->klass->hide(ctx);
273} 278}
274 279
@@ -792,7 +797,6 @@ ecore_imf_context_input_panel_hide(Ecore_IMF_Context *ctx)
792 return; 797 return;
793 } 798 }
794 799
795 show_req_ctx = NULL;
796 if (ctx->klass->hide) ctx->klass->hide(ctx); 800 if (ctx->klass->hide) ctx->klass->hide(ctx);
797} 801}
798 802
@@ -1060,6 +1064,8 @@ ecore_imf_context_input_panel_event_callback_add(Ecore_IMF_Context *ctx,
1060 void (*func) (void *data, Ecore_IMF_Context *ctx, int value), 1064 void (*func) (void *data, Ecore_IMF_Context *ctx, int value),
1061 const void *data) 1065 const void *data)
1062{ 1066{
1067 Ecore_IMF_Input_Panel_Callback_Node *fn = NULL;
1068
1063 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) 1069 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1064 { 1070 {
1065 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, 1071 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
@@ -1067,8 +1073,16 @@ ecore_imf_context_input_panel_event_callback_add(Ecore_IMF_Context *ctx,
1067 return; 1073 return;
1068 } 1074 }
1069 1075
1070 if (ctx->klass->input_panel_event_callback_add) 1076 if (!func) return;
1071 ctx->klass->input_panel_event_callback_add(ctx, type, func, (void *)data); 1077
1078 fn = calloc(1, sizeof (Ecore_IMF_Input_Panel_Callback_Node));
1079 if (!fn) return;
1080
1081 fn->func = func;
1082 fn->data = data;
1083 fn->type = type;
1084
1085 ctx->input_panel_callbacks = eina_list_append(ctx->input_panel_callbacks, fn);
1072} 1086}
1073 1087
1074EAPI void 1088EAPI void
@@ -1076,6 +1090,10 @@ ecore_imf_context_input_panel_event_callback_del(Ecore_IMF_Context *ctx,
1076 Ecore_IMF_Input_Panel_Event type, 1090 Ecore_IMF_Input_Panel_Event type,
1077 void (*func) (void *data, Ecore_IMF_Context *ctx, int value)) 1091 void (*func) (void *data, Ecore_IMF_Context *ctx, int value))
1078{ 1092{
1093 Eina_List *l = NULL;
1094 Eina_List *l_next = NULL;
1095 Ecore_IMF_Input_Panel_Callback_Node *fn = NULL;
1096
1079 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT)) 1097 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1080 { 1098 {
1081 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT, 1099 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
@@ -1083,8 +1101,70 @@ ecore_imf_context_input_panel_event_callback_del(Ecore_IMF_Context *ctx,
1083 return; 1101 return;
1084 } 1102 }
1085 1103
1086 if (ctx->klass->input_panel_event_callback_del) 1104 if (!func) return;
1087 ctx->klass->input_panel_event_callback_del(ctx, type, func); 1105 if (!ctx->input_panel_callbacks) return;
1106
1107 EINA_LIST_FOREACH_SAFE(ctx->input_panel_callbacks, l, l_next, fn)
1108 {
1109 if ((fn) && (fn->func == func) && (fn->type == type))
1110 {
1111 free(fn);
1112 ctx->input_panel_callbacks = eina_list_remove_list(ctx->input_panel_callbacks, l);
1113 return;
1114 }
1115 }
1116}
1117
1118EAPI void
1119ecore_imf_context_input_panel_event_callback_call(Ecore_IMF_Context *ctx, Ecore_IMF_Input_Panel_Event type, int value)
1120{
1121 Ecore_IMF_Input_Panel_Callback_Node *fn = NULL;
1122 Eina_List *l = NULL;
1123
1124 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1125 {
1126 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
1127 "ecore_imf_context_input_panel_event_callback_call");
1128 return;
1129 }
1130
1131 EINA_LIST_FOREACH(ctx->input_panel_callbacks, l, fn)
1132 {
1133 if ((fn) && (fn->type == type) && (fn->func))
1134 {
1135 fn->func(fn->data, ctx, value);
1136 if (type == ECORE_IMF_INPUT_PANEL_STATE_EVENT &&
1137 value == ECORE_IMF_INPUT_PANEL_STATE_HIDE &&
1138 show_req_ctx == ctx)
1139 show_req_ctx = NULL;
1140 }
1141 }
1142}
1143
1144EAPI void
1145ecore_imf_context_input_panel_event_callback_clear(Ecore_IMF_Context *ctx)
1146{
1147 Ecore_IMF_Input_Panel_Callback_Node *fn = NULL;
1148 Eina_List *l = NULL;
1149
1150 if (!ECORE_MAGIC_CHECK(ctx, ECORE_MAGIC_CONTEXT))
1151 {
1152 ECORE_MAGIC_FAIL(ctx, ECORE_MAGIC_CONTEXT,
1153 "ecore_imf_context_input_panel_event_callback_clear");
1154 return;
1155 }
1156
1157 for (l = ctx->input_panel_callbacks; l;)
1158 {
1159 fn = (Ecore_IMF_Input_Panel_Callback_Node *)l->data;
1160
1161 if (fn)
1162 {
1163 ctx->input_panel_callbacks = eina_list_remove(ctx->input_panel_callbacks, fn);
1164 free (fn);
1165 }
1166 l = l->next;
1167 }
1088} 1168}
1089 1169
1090EAPI void 1170EAPI 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;
36 36
37typedef struct _Ecore_IMF_Module Ecore_IMF_Module; 37typedef struct _Ecore_IMF_Module Ecore_IMF_Module;
38typedef struct _Ecore_IMF_Func_Node Ecore_IMF_Func_Node; 38typedef struct _Ecore_IMF_Func_Node Ecore_IMF_Func_Node;
39typedef struct _Ecore_IMF_Input_Panel_Callback_Node Ecore_IMF_Input_Panel_Callback_Node;
39 40
40struct _Ecore_IMF_Context 41struct _Ecore_IMF_Context
41{ 42{
@@ -49,6 +50,7 @@ struct _Ecore_IMF_Context
49 Eina_Bool (*retrieve_surrounding_func)(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos); 50 Eina_Bool (*retrieve_surrounding_func)(void *data, Ecore_IMF_Context *ctx, char **text, int *cursor_pos);
50 void *retrieve_surrounding_data; 51 void *retrieve_surrounding_data;
51 Eina_List *callbacks; 52 Eina_List *callbacks;
53 Eina_List *input_panel_callbacks;
52 Ecore_IMF_Autocapital_Type autocapital_type; 54 Ecore_IMF_Autocapital_Type autocapital_type;
53 Ecore_IMF_Input_Panel_Layout input_panel_layout; 55 Ecore_IMF_Input_Panel_Layout input_panel_layout;
54 Ecore_IMF_Input_Panel_Lang input_panel_lang; 56 Ecore_IMF_Input_Panel_Lang input_panel_lang;
@@ -74,6 +76,13 @@ struct _Ecore_IMF_Func_Node
74 Ecore_IMF_Callback_Type type; 76 Ecore_IMF_Callback_Type type;
75}; 77};
76 78
79struct _Ecore_IMF_Input_Panel_Callback_Node
80{
81 void (*func) ();
82 const void *data;
83 Ecore_IMF_Input_Panel_Event type;
84};
85
77void ecore_imf_module_init(void); 86void ecore_imf_module_init(void);
78void ecore_imf_module_shutdown(void); 87void ecore_imf_module_shutdown(void);
79Eina_List *ecore_imf_module_available_get(void); 88Eina_List *ecore_imf_module_available_get(void);