summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJihoon Kim <jihoon48.kim@samsung.com>2014-01-23 11:26:52 +0900
committerJihoon Kim <jihoon48.kim@samsung.com>2014-01-23 11:26:52 +0900
commit1d7d554348f76645734772b48d83ae63d8ca6de8 (patch)
tree281a93d248d364857dcf21fd602bbfaa67b38553 /src
parent4fb04c3cd0f4c8f678666d8b92368d66798aed5d (diff)
edje: Support to set or retrieve selection of ecore_imf
Diffstat (limited to 'src')
-rw-r--r--src/lib/edje/edje_entry.c57
1 files changed, 57 insertions, 0 deletions
diff --git a/src/lib/edje/edje_entry.c b/src/lib/edje/edje_entry.c
index 53494a3858..8a7b741eca 100644
--- a/src/lib/edje/edje_entry.c
+++ b/src/lib/edje/edje_entry.c
@@ -5,6 +5,8 @@ static Eina_Bool _edje_entry_imf_retrieve_surrounding_cb(void *data, Ecore_IMF_C
5static void _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx, void *event_info); 5static void _edje_entry_imf_event_commit_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
6static void _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx, void *event_info); 6static void _edje_entry_imf_event_preedit_changed_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
7static void _edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx, void *event); 7static void _edje_entry_imf_event_delete_surrounding_cb(void *data, Ecore_IMF_Context *ctx, void *event);
8static void _edje_entry_imf_event_selection_set_cb(void *data, Ecore_IMF_Context *ctx, void *event_info);
9static Eina_Bool _edje_entry_imf_retrieve_selection_cb(void *data, Ecore_IMF_Context *ctx, char **text);
8#endif 10#endif
9 11
10typedef struct _Entry Entry; 12typedef struct _Entry Entry;
@@ -2495,9 +2497,11 @@ _edje_entry_real_part_init(Edje *ed, Edje_Real_Part *rp)
2495 2497
2496 ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context, 2498 ecore_imf_context_retrieve_surrounding_callback_set(en->imf_context,
2497 _edje_entry_imf_retrieve_surrounding_cb, ed); 2499 _edje_entry_imf_retrieve_surrounding_cb, ed);
2500 ecore_imf_context_retrieve_selection_callback_set(en->imf_context, _edje_entry_imf_retrieve_selection_cb, ed);
2498 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb, ed); 2501 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb, ed);
2499 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, ed); 2502 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb, ed);
2500 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb, ed); 2503 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb, ed);
2504 ecore_imf_context_event_callback_add(en->imf_context, ECORE_IMF_CALLBACK_SELECTION_SET, _edje_entry_imf_event_selection_set_cb, ed);
2501 ecore_imf_context_input_mode_set(en->imf_context, 2505 ecore_imf_context_input_mode_set(en->imf_context,
2502 rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD ? 2506 rp->part->entry_mode == EDJE_ENTRY_EDIT_MODE_PASSWORD ?
2503 ECORE_IMF_INPUT_MODE_INVISIBLE : ECORE_IMF_INPUT_MODE_FULL); 2507 ECORE_IMF_INPUT_MODE_INVISIBLE : ECORE_IMF_INPUT_MODE_FULL);
@@ -2545,6 +2549,7 @@ _edje_entry_real_part_shutdown(Edje *ed, Edje_Real_Part *rp)
2545 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb); 2549 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_COMMIT, _edje_entry_imf_event_commit_cb);
2546 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb); 2550 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_DELETE_SURROUNDING, _edje_entry_imf_event_delete_surrounding_cb);
2547 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb); 2551 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_PREEDIT_CHANGED, _edje_entry_imf_event_preedit_changed_cb);
2552 ecore_imf_context_event_callback_del(en->imf_context, ECORE_IMF_CALLBACK_SELECTION_SET, _edje_entry_imf_event_selection_set_cb);
2548 2553
2549 ecore_imf_context_del(en->imf_context); 2554 ecore_imf_context_del(en->imf_context);
2550 en->imf_context = NULL; 2555 en->imf_context = NULL;
@@ -4189,6 +4194,58 @@ end:
4189 evas_textblock_cursor_free(del_start); 4194 evas_textblock_cursor_free(del_start);
4190 evas_textblock_cursor_free(del_end); 4195 evas_textblock_cursor_free(del_end);
4191} 4196}
4197
4198static void
4199_edje_entry_imf_event_selection_set_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, void *event_info)
4200{
4201 Edje *ed = data;
4202 Edje_Real_Part *rp = ed->focused_part;
4203 Entry *en = NULL;
4204 Ecore_IMF_Event_Selection *ev = event_info;
4205
4206 if ((!rp) || (!ev)) return;
4207 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4208 (!rp->typedata.text)) return;
4209 else
4210 en = rp->typedata.text->entry_data;
4211 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
4212 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
4213 return;
4214
4215 evas_textblock_cursor_pos_set(en->cursor, ev->start);
4216
4217 _sel_start(en->cursor, rp->object, en);
4218
4219 evas_textblock_cursor_pos_set(en->cursor, ev->end);
4220
4221 _sel_extend(ed, en->cursor, rp->object, en);
4222}
4223
4224static Eina_Bool
4225_edje_entry_imf_retrieve_selection_cb(void *data, Ecore_IMF_Context *ctx EINA_UNUSED, char **text)
4226{
4227 Edje *ed = data;
4228 Edje_Real_Part *rp = ed->focused_part;
4229 Entry *en = NULL;
4230
4231 if (!rp) return EINA_FALSE;
4232 if ((rp->type != EDJE_RP_TYPE_TEXT) ||
4233 (!rp->typedata.text)) return EINA_FALSE;
4234 else
4235 en = rp->typedata.text->entry_data;
4236 if ((!en) || (rp->part->type != EDJE_PART_TYPE_TEXTBLOCK) ||
4237 (rp->part->entry_mode < EDJE_ENTRY_EDIT_MODE_SELECTABLE))
4238 return EINA_FALSE;
4239
4240 if (en->have_selection)
4241 {
4242 if (text)
4243 *text = strdup(_edje_entry_selection_get(rp));
4244 return EINA_TRUE;
4245 }
4246 else
4247 return EINA_FALSE;
4248}
4192#endif 4249#endif
4193 4250
4194/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/ 4251/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/