2 * Copyright (c) 2012 - 2015 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #ifdef SUPPORTS_EMOTICONS
25 #include <Elementary.h>
26 #include <app_preference.h>
28 #include <sclfeedback.h>
30 #include "ise-emoticon-mode.h"
33 #include "candidate-factory.h"
36 #define LOG_TAG "ISE_DEFAULT"
39 #define EVAS_CANDIDATE_LAYER 32000
42 #define ISE_HEIGHT_PORT 398
43 #define ISE_HEIGHT_LAND 398
45 #define ISE_HEIGHT_PORT 240
46 #define ISE_HEIGHT_LAND 240
48 #define ISE_HEIGHT_PORT 442
49 #define ISE_HEIGHT_LAND 318
52 #define EMOTICON_DIR LAYOUTDIR"/emoticons/"
53 #define EMOTICON_EDJ_FILE_PATH RESDIR"/edje/layout_keypad.edj"
54 #define CUSTOM_GENGRID_EDJ_FILE_PATH RESDIR"/edje/customised_gengrid.edj"
56 #define EMOTICON_EDJ_GROUP_PORT_CANDIDATE_ON "emoticon.main.portrait.candidate.on"
57 #define EMOTICON_EDJ_GROUP_LAND_CANDIDATE_ON "emoticon.main.landscape.candidate.on"
59 #define EMOTICON_EDJ_GROUP_PORT_CANDIDATE_OFF "emoticon.main.portrait.candidate.off"
60 #define EMOTICON_EDJ_GROUP_LAND_CANDIDATE_OFF "emoticon.main.landscape.candidate.off"
62 #define EMOTICON_GENGRID_ITEM_STYLE_PORT "ise/customized_default_style_port"
63 #define EMOTICON_GENGRID_ITEM_STYLE_LAND "ise/customized_default_style_land"
65 #define EMOTICON_GENGRID_ITEM_STYLE_PORT2 "ise/customized_default_style_port2"
66 #define EMOTICON_GENGRID_ITEM_STYLE_LAND2 "ise/customized_default_style_land2"
68 #define EMOTICON_GENGRID_ITEM_STYLE_WEARABLE "ise/customized_default_style_wearable"
73 #define EMOTICON_ICON_WIDTH_PORT 40
74 #define EMOTICON_ICON_HEIGHT_PORT 40
76 #define EMOTICON_ICON_GAP_WIDTH_PORT 24
77 #define EMOTICON_ICON_GAP_HEIGHT_PORT 3
79 #define EMOTICON_ICON_WIDTH_PORT 27
80 #define EMOTICON_ICON_HEIGHT_PORT 27
82 #define EMOTICON_ICON_GAP_WIDTH_PORT 10
83 #define EMOTICON_ICON_GAP_HEIGHT_PORT 2
85 #define EMOTICON_WIDTH_PORT (EMOTICON_ICON_WIDTH_PORT + EMOTICON_ICON_GAP_WIDTH_PORT)
86 #define EMOTICON_HEIGHT_PORT (EMOTICON_ICON_HEIGHT_PORT + EMOTICON_ICON_GAP_HEIGHT_PORT)
88 #define EMOTICON_ICON_WIDTH_LAND 27
89 #define EMOTICON_ICON_HEIGHT_LAND 27
91 #define EMOTICON_ICON_GAP_WIDTH_LAND 4
92 #define EMOTICON_ICON_GAP_HEIGHT_LAND 0
94 #define EMOTICON_WIDTH_LAND (EMOTICON_ICON_WIDTH_LAND + EMOTICON_ICON_GAP_WIDTH_LAND)
95 #define EMOTICON_HEIGHT_LAND (EMOTICON_ICON_HEIGHT_LAND + EMOTICON_ICON_GAP_HEIGHT_LAND)
97 #define MIN_RECENT_EMOTICON_NEEDED_IN_PORT 22 // (7*3 + 1)
98 #define MIN_RECENT_EMOTICON_NEEDED_IN_LAND 27 // (13*2 + 1)
100 #define MAX_SIZE_AMONG_FIRST_3_EMOTICON_GROUPS (EMOTICON_GROUP_1_NUM > EMOTICON_GROUP_2_NUM ? (EMOTICON_GROUP_1_NUM > EMOTICON_GROUP_3_NUM ? EMOTICON_GROUP_1_NUM : EMOTICON_GROUP_3_NUM) : (EMOTICON_GROUP_2_NUM > EMOTICON_GROUP_3_NUM ? EMOTICON_GROUP_2_NUM : EMOTICON_GROUP_3_NUM))
101 #define MAX_SIZE_AMONG_EMOTICON_GROUPS (EMOTICON_GROUP_4_NUM > EMOTICON_GROUP_5_NUM ? (EMOTICON_GROUP_4_NUM > MAX_SIZE_AMONG_FIRST_3_EMOTICON_GROUPS ? EMOTICON_GROUP_4_NUM : MAX_SIZE_AMONG_FIRST_3_EMOTICON_GROUPS) : (EMOTICON_GROUP_5_NUM > MAX_SIZE_AMONG_FIRST_3_EMOTICON_GROUPS ? EMOTICON_GROUP_5_NUM : MAX_SIZE_AMONG_FIRST_3_EMOTICON_GROUPS))
103 bool is_emoticon_mode = false;
104 emoticon_group_t current_emoticon_group = EMOTICON_GROUP_RECENTLY_USED;
105 std::vector <int> emoticon_list_recent;
106 bool is_recently_used_emoticon_mode_disabled = true;
109 extern int * emoticon_list[];
110 extern CONFIG_VALUES g_config_values;
111 extern Candidate *g_candidate;
114 unsigned short int emoticon_group_items[MAX_EMOTICON_GROUP] =
116 EMOTICON_GROUP_RECENTLY_USED_NUM,
117 EMOTICON_GROUP_1_NUM,
118 EMOTICON_GROUP_2_NUM,
122 unsigned short int emoticon_group_items[MAX_EMOTICON_GROUP] =
124 EMOTICON_GROUP_RECENTLY_USED_NUM,
125 EMOTICON_GROUP_1_NUM,
126 EMOTICON_GROUP_2_NUM,
127 EMOTICON_GROUP_3_NUM,
128 EMOTICON_GROUP_4_NUM,
132 const char *emoticon_group_icons_press[MAX_EMOTICON_GROUP] =
134 "emotion/icon_recent_press.png",
135 "emotion/icon_emotion_press.png",
136 "emotion/icon_crown_press.png",
137 "emotion/icon_dog_press.png",
138 "emotion/icon_house_press.png",
139 "emotion/icon_star_press.png"
143 struct emoticon_item_t
145 Elm_Object_Item *item;
148 Eina_Unicode keyevent;
151 emoticon_item_t emoticon_items[MAX_SIZE_AMONG_EMOTICON_GROUPS] = {{0, }, };
153 // Static variable declarations
154 static Evas_Object *layout = NULL;
155 static Evas_Object *gengrid = NULL;
156 static Elm_Theme *theme = NULL;
157 static Elm_Gengrid_Item_Class *gic = NULL;
159 // Static Function declarations
160 static void __ise_emoticon_create_gengrid(unsigned short int screen_degree);
161 static void __ise_emoticon_append_items_to_gengrid(emoticon_group_t emoticon_group);
162 static void __ise_emoticon_create_item_class(unsigned short int screen_degree);
163 #if SUPPORTS_EMOTICONS_BY_IMAGE
164 static Evas_Object * grid_content_get(void *data, Evas_Object *obj, const char *part);
165 static void grid_content_del(void *data, Evas_Object *obj);
167 static char * grid_text_get(void *data, Evas_Object *obj, const char *part);
169 static void _item_selected(void *data, Evas_Object *obj, void *event_info);
170 static Eina_Bool _focus_done(void *data);
171 static void _multi_down(void *data, Evas *e, Evas_Object *o, void *event_info);
172 static void _multi_up(void *data, Evas *e, Evas_Object *o, void *event_info);
174 void ise_read_recent_emoticon_list_from_scim(void)
177 std::string string_value;
178 read_ise_config_string(ISE_CONFIG_RECENT_EMOTICONS_LIST, string_value);
180 if (string_value.length() > 0) {
181 LOGD("read recent emoticon:%s\n", string_value.c_str());
182 std::stringstream ss(string_value);
183 std::istream_iterator<std::string> begin(ss);
184 std::istream_iterator<std::string> end;
185 std::vector<std::string> vstrings(begin, end);
187 emoticon_list_recent.clear();
188 std::vector<std::string>::iterator it;
189 for (it = vstrings.begin(); it != vstrings.end(); it++) {
190 emoticon_list_recent.push_back(atoi((*it).c_str()));
195 void ise_write_recent_emoticon_list_to_scim(void)
197 std::string string_value;
198 for (std::vector<int>::iterator it = emoticon_list_recent.begin();
199 it != emoticon_list_recent.end(); std::advance(it, 1)) {
201 snprintf (buf, sizeof(buf), "%d", *it);
202 string_value += std::string(buf);
205 if (string_value.length() > 0) {
206 preference_set_string(ISE_CONFIG_RECENT_EMOTICONS_LIST, string_value.c_str());
207 LOGD("write recent emoticon:%s\n", string_value.c_str());
211 void ise_show_emoticon_layout(emoticon_group_t emoticon_group, const int screen_degree, const bool is_candidate_on, void *main_window)
217 ise_init_emoticon_list();
218 ise_set_private_key_for_emoticon_mode(emoticon_group);
220 if (emoticon_group == EMOTICON_GROUP_RECENTLY_USED) {
221 //ise_read_recent_emoticon_list_from_scim();
222 if (emoticon_list_recent.size() == 0) {
223 //PRINTFUNC(DLOG_ERROR,"Cannot display recently used emoticons group. No recently used emoticons available");
228 ise_destroy_emoticon_layout();
230 layout = elm_layout_add((Evas_Object *)main_window);
231 evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
232 evas_object_size_hint_align_set(layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
235 if (g_candidate && g_candidate->get_visible())
236 y = g_candidate->get_height();
238 read_ise_config_values();
239 if (g_config_values.floating_mode)
240 evas_object_move(layout, 0, y + FLOATING_TITLE_BAR_HEIGHT);
242 evas_object_move(layout, 0, y);
244 if (is_candidate_on) {
245 if (screen_degree == 0 || screen_degree == 180)
246 elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH, EMOTICON_EDJ_GROUP_PORT_CANDIDATE_ON);
248 elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH, EMOTICON_EDJ_GROUP_LAND_CANDIDATE_ON);
252 g_ui->get_screen_resolution(&width, &height);
253 LOGD("screen width:%d, height:%d\n", width, height);
254 if (screen_degree == 0 || screen_degree == 180) {
255 elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH, EMOTICON_EDJ_GROUP_PORT_CANDIDATE_OFF);
256 if (g_config_values.floating_mode)
257 evas_object_resize(layout, width * FLOATING_SCALE_RATE, g_ui->get_scaled_y(ISE_HEIGHT_PORT) - ELM_SCALE_SIZE(EMOTICON_HEIGHT_PORT));
259 evas_object_resize(layout, width, g_ui->get_scaled_y(ISE_HEIGHT_PORT));
261 elm_layout_file_set(layout, EMOTICON_EDJ_FILE_PATH, EMOTICON_EDJ_GROUP_LAND_CANDIDATE_OFF);
262 if (g_config_values.floating_mode)
263 evas_object_resize(layout, width * FLOATING_SCALE_RATE, g_ui->get_scaled_y(ISE_HEIGHT_LAND) * FLOATING_SCALE_RATE);
265 evas_object_resize(layout, width, g_ui->get_scaled_y(ISE_HEIGHT_LAND));
268 if (g_config_values.floating_mode) {
269 evas_object_resize(layout, 260 * FLOATING_SCALE_RATE, 240 * FLOATING_SCALE_RATE);
270 evas_object_move(layout, 10, y + FLOATING_TITLE_BAR_HEIGHT);
272 evas_object_resize(layout, 260, 240);
273 evas_object_move(layout, 10, y);
276 if (screen_degree == 0 || screen_degree == 180) {
279 if (g_config_values.floating_mode) {
280 evas_object_resize(layout, (width - g_ui->get_scaled_y(88*2)) * FLOATING_SCALE_RATE, (g_ui->get_scaled_y(ISE_HEIGHT_LAND)) * FLOATING_SCALE_RATE);
281 evas_object_move(layout, g_ui->get_scaled_y(88), y + FLOATING_TITLE_BAR_HEIGHT);
283 evas_object_resize(layout, width - g_ui->get_scaled_y(88*2), g_ui->get_scaled_y(ISE_HEIGHT_LAND));
284 evas_object_move(layout, g_ui->get_scaled_y(88), y);
290 theme = elm_theme_new();
291 elm_theme_ref_set(theme, NULL); // refer to default theme
292 elm_theme_extension_add(theme, CUSTOM_GENGRID_EDJ_FILE_PATH);
294 __ise_emoticon_create_gengrid((unsigned short)screen_degree);
295 __ise_emoticon_create_item_class((unsigned short)screen_degree);
296 __ise_emoticon_append_items_to_gengrid(emoticon_group);
298 elm_object_part_content_set(layout, "emoticon.swallow.gengrid", gengrid);
299 //elm_win_resize_object_add(main_window, layout);
301 evas_object_show(gengrid);
302 evas_object_layer_set(layout, EVAS_CANDIDATE_LAYER-1);
303 evas_object_show(layout);
305 is_emoticon_mode = true;
306 current_emoticon_group = emoticon_group;
309 void ise_destroy_emoticon_layout(void)
311 /* According to UI FW team, when the a parent is deleted, all its child content will
312 * also be deleted. So no need to delete gengrid explicitly. Just setting the gendrid
313 * pointer to NULL should suffice here.
315 * We can first delete all the child elements and then we delete the parent.
316 * This approach is currently used below
320 elm_gengrid_clear(gengrid);
321 evas_object_del(gengrid);
326 evas_object_del(layout);
331 elm_theme_free(theme);
336 void ise_change_emoticon_mode(emoticon_group_t emoticon_group)
338 if (emoticon_group == EMOTICON_GROUP_RECENTLY_USED) {
339 //ise_read_recent_emoticon_list_from_scim();
340 if (emoticon_list_recent.size() == 0) {
341 //PRINTFUNC(DLOG_ERROR,"Cannot display recently used emoticons group. No recently used emoticons available");
347 elm_gengrid_clear(gengrid);
350 __ise_emoticon_append_items_to_gengrid(emoticon_group);
351 current_emoticon_group = emoticon_group;
354 static Eina_Bool _focus_done(void *data)
356 Elm_Object_Item *item = (Elm_Object_Item *)data;
358 elm_object_item_signal_emit(item, "mouse,up,1", "reorder_bg");
360 return ECORE_CALLBACK_CANCEL;
363 static void _multi_down(void *data, Evas *e, Evas_Object *o, void *event_info)
365 Evas_Event_Multi_Down *ev = (Evas_Event_Multi_Down*)event_info;
367 // PRINTFUNC(DLOG_DEBUG,"MULTI: down @ %4i %4i | dev: %i\n", ev->canvas.x, ev->canvas.y, ev->device);
368 if (ev->device >= IND_NUM)
371 Elm_Object_Item *item;
372 item = elm_gengrid_at_xy_item_get(o, ev->canvas.x, ev->canvas.y, NULL, NULL);
374 elm_object_item_signal_emit(item, "mouse,down,1", "reorder_bg");
376 ecore_timer_add(0.5, _focus_done, item);
379 static void _multi_up(void *data, Evas *e, Evas_Object *o, void *event_info)
381 Evas_Event_Multi_Up *ev = (Evas_Event_Multi_Up*)event_info;
382 // PRINTFUNC(DLOG_DEBUG,"MULTI: up @ %4i %4i | dev: %i\n", ev->canvas.x, ev->canvas.y, ev->device);
383 if (ev->device >= IND_NUM)
386 Elm_Object_Item *item = NULL;
387 item = elm_gengrid_at_xy_item_get(o, ev->canvas.x, ev->canvas.y, NULL, NULL);
389 elm_object_item_signal_emit(item, "mouse,up,1", "reorder_bg");
391 elm_gengrid_item_selected_set(item, EINA_TRUE);
394 static void __ise_emoticon_create_gengrid(unsigned short int screen_degree)
396 gengrid = elm_gengrid_add(layout);
397 elm_object_theme_set(gengrid, theme);
398 //elm_object_style_set(gengrid,"no_effect");
399 elm_gengrid_align_set(gengrid, 0.5, 0);
401 evas_object_size_hint_weight_set(gengrid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
402 evas_object_size_hint_align_set(gengrid, EVAS_HINT_FILL, EVAS_HINT_FILL);
404 if (screen_degree == 0 || screen_degree == 180)
405 elm_gengrid_item_size_set(gengrid, ELM_SCALE_SIZE(EMOTICON_WIDTH_PORT), ELM_SCALE_SIZE(EMOTICON_HEIGHT_PORT));
407 elm_gengrid_item_size_set(gengrid, ELM_SCALE_SIZE(EMOTICON_WIDTH_LAND), ELM_SCALE_SIZE(EMOTICON_HEIGHT_LAND));
409 elm_gengrid_highlight_mode_set(gengrid, EINA_TRUE);
410 elm_gengrid_select_mode_set(gengrid, ELM_OBJECT_SELECT_MODE_ALWAYS);
411 // elm_gengrid_cache_mode_set(gengrid, EINA_TRUE);
412 elm_gengrid_multi_select_set(gengrid, EINA_TRUE);
414 evas_object_event_callback_add(gengrid, EVAS_CALLBACK_MULTI_DOWN, _multi_down, NULL);
415 evas_object_event_callback_add(gengrid, EVAS_CALLBACK_MULTI_UP, _multi_up, NULL);
418 #if SUPPORTS_EMOTICONS_BY_IMAGE
419 static void __ise_emoticon_append_items_to_gengrid(emoticon_group_t emoticon_group)
423 std::string file_path = "";
425 if (emoticon_group == EMOTICON_GROUP_RECENTLY_USED) {
426 items = emoticon_list_recent.size();
428 for (int i = 0; i < items; i++) {
429 snprintf(img_name, 10, "%x", emoticon_list_recent[i]);
430 emoticon_items[i].code = emoticon_list_recent[i];
431 emoticon_items[i].keyevent = emoticon_list_recent[i];
432 emoticon_items[i].path = (std::string)EMOTICON_DIR + (std::string)"u" + (std::string)img_name + (std::string)".png";
433 emoticon_items[i].item = elm_gengrid_item_append(gengrid, gic, &(emoticon_items[i]), _item_selected, &(emoticon_items[i]));
436 if (emoticon_group != EMOTICON_GROUP_DESTROY) {
437 items = emoticon_group_items[emoticon_group];
439 for (int i = 0; i < items; i++) {
440 snprintf(img_name, 10, "%x", emoticon_list[emoticon_group-1][i]);
441 file_path = (std::string)EMOTICON_DIR + (std::string)"u" + (std::string)img_name + (std::string)".png";
442 if (ise_util_does_file_exists(file_path)) {
443 emoticon_items[i].code = emoticon_list[emoticon_group-1][i];
444 emoticon_items[i].keyevent = emoticon_list[emoticon_group-1][i];
445 emoticon_items[i].path = file_path;
446 emoticon_items[i].item = elm_gengrid_item_append(gengrid, gic, &(emoticon_items[i]), _item_selected, &(emoticon_items[i]));
447 // PRINTFUNC(SECURE_DEBUG,"file_path = %s\n",file_path.c_str());
451 Elm_Object_Item * it = elm_gengrid_first_item_get(gengrid);
452 elm_gengrid_item_show(it, ELM_GENGRID_ITEM_SCROLLTO_NONE);
456 static void __ise_emoticon_create_item_class(unsigned short int screen_degree)
459 gic = elm_gengrid_item_class_new();
461 if (screen_degree == 0 || screen_degree == 180)
462 gic->item_style = EMOTICON_GENGRID_ITEM_STYLE_PORT2;
464 gic->item_style = EMOTICON_GENGRID_ITEM_STYLE_LAND2;
466 gic->func.text_get = NULL;
467 gic->func.content_get = grid_content_get;
468 gic->func.state_get = NULL;
469 gic->func.del = grid_content_del;
472 static Evas_Object * grid_content_get(void *data, Evas_Object *obj, const char *part)
474 emoticon_item_t *ti = (emoticon_item_t *)data;
478 if (!strcmp(part, "elm.swallow.icon")) {
479 if (ti->path.c_str()) {
480 Eina_Bool is_image_file_set = false;
481 Evas_Object *icon = elm_image_add(obj);
482 is_image_file_set = elm_image_file_set(icon, ti->path.c_str(), NULL);
483 if (!is_image_file_set) {
484 //PRINTFUNC(SECURE_ERROR,"image \"%s\" not set",ti->path.c_str());
486 elm_image_aspect_fixed_set(icon, EINA_FALSE);
487 elm_image_preload_disabled_set(icon, EINA_FALSE);
488 evas_object_show(icon);
490 evas_object_data_set(icon, "code", (void *)ti->code);
498 static void grid_content_del(void *data, Evas_Object *obj)
500 emoticon_item_t *ti = (emoticon_item_t *)data;
504 Evas_Object *icon = elm_object_item_part_content_get(ti->item, "elm.swallow.icon");
506 evas_object_data_del(icon, "code");
510 #else //SUPPORTS_EMOTICONS_BY_IMAGE
511 static void __ise_emoticon_append_items_to_gengrid(emoticon_group_t emoticon_group)
515 std::string file_path = "";
517 if (emoticon_group == EMOTICON_GROUP_RECENTLY_USED) {
518 items = emoticon_list_recent.size();
520 for (int i = 0; i < items; i++) {
521 snprintf(img_name, 10, "%x", emoticon_list_recent[i]);
522 emoticon_items[i].keyevent = emoticon_list_recent[i];
523 emoticon_items[i].path = (std::string)img_name;
524 emoticon_items[i].item = elm_gengrid_item_append(gengrid, gic, &(emoticon_items[i]), _item_selected, &(emoticon_items[i]));
527 if (emoticon_group != EMOTICON_GROUP_DESTROY) {
528 items = emoticon_group_items[emoticon_group];
530 for (int i = 0; i < items; i++) {
531 snprintf(img_name, 10, "%x", emoticon_list[emoticon_group-1][i]);
532 file_path = (std::string)img_name;
533 emoticon_items[i].keyevent = emoticon_list[emoticon_group-1][i];
534 emoticon_items[i].path = file_path;
535 emoticon_items[i].item = elm_gengrid_item_append(gengrid, gic, &(emoticon_items[i]), _item_selected, &(emoticon_items[i]));
538 Elm_Object_Item * it = elm_gengrid_first_item_get(gengrid);
539 elm_gengrid_item_show(it, ELM_GENGRID_ITEM_SCROLLTO_NONE);
542 static void __ise_emoticon_create_item_class(unsigned short int screen_degree)
545 gic = elm_gengrid_item_class_new();
549 gic->item_style = EMOTICON_GENGRID_ITEM_STYLE_WEARABLE;
551 if (screen_degree == 0 || screen_degree == 180)
552 gic->item_style = EMOTICON_GENGRID_ITEM_STYLE_PORT2;
554 gic->item_style = EMOTICON_GENGRID_ITEM_STYLE_LAND2;
556 gic->func.text_get = grid_text_get;
557 gic->func.content_get = NULL;
558 gic->func.state_get = NULL;
559 gic->func.del = NULL;
563 static char * grid_text_get(void *data, Evas_Object *obj, const char *part)
565 emoticon_item_t *ti = (emoticon_item_t *)data;
570 if (!strcmp(part, "elm.text")) {
571 if (ti && !(ti->path.empty())) {
572 const Eina_Unicode unicode_event[2] = {ti->keyevent, 0};
573 utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length);
580 #endif //SUPPORTS_EMOTICONS_BY_IMAGE
582 static void _item_selected(void *data, Evas_Object *obj, void *event_info)
584 emoticon_item_t *ti = (emoticon_item_t *)data;
588 std::vector<int>::iterator it;
590 static CSCLUtils *utils = CSCLUtils::get_instance();
592 if (g_config_values.sound_on)
593 utils->play_sound(DEFAULT_SOUND_STYLE);
594 if (g_config_values.vibration_on)
595 utils->play_vibration(DEFAULT_VIBRATION_STYLE, DEFAULT_VIBRATION_DURATION);
599 elm_gengrid_item_selected_set((Elm_Object_Item *)event_info, EINA_FALSE);
600 if (ti && ti->keyevent) {
601 const Eina_Unicode unicode_event[2] = {ti->keyevent, 0};
602 // PRINTFUNC(DLOG_DEBUG,"unicode_event is %x",unicode_event);
603 utf_8 = eina_unicode_unicode_to_utf8(unicode_event, &length);
606 ise_send_string((sclchar *)utf_8);
610 if (current_emoticon_group != EMOTICON_GROUP_RECENTLY_USED) {
611 if (emoticon_list_recent.size() < EMOTICON_GROUP_RECENTLY_USED_NUM) {
612 it = find(emoticon_list_recent.begin(), emoticon_list_recent.end(), ti->keyevent);
613 if (it == emoticon_list_recent.end()) { // Item not found
614 emoticon_list_recent.insert(emoticon_list_recent.begin(), ti->keyevent);
616 emoticon_list_recent.erase(it);
617 emoticon_list_recent.insert(emoticon_list_recent.begin(), ti->keyevent);
620 it = find(emoticon_list_recent.begin(), emoticon_list_recent.end(), ti->keyevent);
621 if (it != emoticon_list_recent.end())
622 emoticon_list_recent.erase(it);
624 emoticon_list_recent.erase(emoticon_list_recent.end() - 1);
626 emoticon_list_recent.insert(emoticon_list_recent.begin(), ti->keyevent);
628 ise_write_recent_emoticon_list_to_scim();
630 if (is_recently_used_emoticon_mode_disabled)
631 ise_disable_recently_used_emoticon_key(false);
636 //PRINTFUNC(DLOG_DEBUG,"_item_selected() ends");
639 bool is_emoticon_show(void)
641 return is_emoticon_mode;
644 void ise_set_private_key_for_emoticon_mode(const emoticon_group_t emoticon_group)
647 const char *group_name = NULL;
648 for (int id = EMOTICON_GROUP_RECENTLY_USED; id < MAX_EMOTICON_GROUP; id++) {
649 group_name = ise_get_emoticon_group_name(id);
651 g_ui->unset_private_key(group_name);
654 group_name = ise_get_emoticon_group_name(emoticon_group);
657 sclchar* imagelabel[SCL_BUTTON_STATE_MAX] = {
658 const_cast<sclchar*>(emoticon_group_icons_press[emoticon_group]), const_cast<sclchar*>(""), const_cast<sclchar*>("")};
660 g_ui->set_private_key(group_name, const_cast<sclchar*>(""), imagelabel, NULL, 0, const_cast<sclchar*>(group_name), TRUE);