2 * Copyright (c) 2014 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.
17 #define Uses_SCIM_PANEL_AGENT
18 #define Uses_SCIM_CONFIG_PATH
19 #define Uses_SCIM_HELPER_MODULE
20 #define Uses_SCIM_IMENGINE_MODULE
21 #define Uses_SCIM_COMPOSE_KEY
23 #include "input_method_setting_list.h"
26 #include <efl_extension.h>
28 #include "isf_control.h"
30 #include <scim_setup_module_efl.h>
32 #define IM_SETTING_LIST_PACKAGE PACKAGE
33 #define IM_SETTING_LIST_LOCALE_DIR ("/usr/apps/"PACKAGE_NAME"/res/locale")
34 #define IM_SETTING_LIST_TITLE dgettext(PACKAGE, "IDS_IME_BODY_KEYBOARD")
35 #define IM_SETTING_LIST_KEYBOARD_HEADER dgettext(PACKAGE, "IDS_ST_HEADER_KEYBOARDS")
36 #define IM_SETTING_LIST_POPUP_TITLE dgettext(PACKAGE, "IDS_ST_BODY_ATTENTION")
37 #define IM_SETTING_LIST_POPUP_CANCEL dgettext(PACKAGE, "IDS_COM_SK_CANCEL_ABB")
38 #define IM_SETTING_LIST_POPUP_ENABLE dgettext(PACKAGE, "IDS_ST_BUTTON_ENABLE")
39 #define IM_SETTING_LIST_VIRTUAL_KEYBOARD dgettext(PACKAGE, "IDS_ST_HEADER_VIRTUAL_KEYBOARD")
40 #define IM_SETTING_LIST_DEFAULT_KEYBOARD dgettext(PACKAGE, "IDS_ST_HEADER_DEFAULT_KEYBOARD_ABB")
41 #define IM_SETTING_LIST_KEYBOARD_SETTING dgettext(PACKAGE, "IDS_IME_HEADER_KEYBOARD_SETTINGS_ABB")
42 #define IM_SETTING_LIST_POPUP_TEXT dgettext(PACKAGE, "IDS_ST_POP_THIS_INPUT_METHOD_MAY_BE_ABLE_TO_COLLECT_ALL_THE"\
43 "_TEXT_YOU_TYPE_INCLUDING_PERSONAL_DATA_LIKE_PASSWORDS_AND"\
44 "_CREDIT_CARD_NUMBERS_MSG")
47 typedef struct list_item_text_s
53 typedef struct popup_cb_data_s
59 typedef struct gen_item_data_s
61 Elm_Object_Item *gen_item;
66 ISE_OPTION_MODULE_EXIST_SO = 0,
67 ISE_OPTION_MODULE_NO_EXIST
68 } ISE_OPTION_MODULE_STATE;
70 typedef void (*popup_ok_cb)(void *data, Evas_Object *obj, void *event_info);
71 typedef void (*popup_cancel_cb)(void *data, Evas_Object *obj, void *event_info);
73 static std::vector<ime_info_s> g_ime_info_list;
74 static Elm_Genlist_Item_Class *itc_im_list_keyboard_list = NULL;
75 static Elm_Genlist_Item_Class *itc_im_list_group = NULL;
76 static Elm_Genlist_Item_Class *itc_im_list_item = NULL;
77 static Elm_Genlist_Item_Class *itc_im_list_item_one_line = NULL;
78 static int g_active_ime_index = -1;
79 static list_item_text item_text[2];
80 static std::vector<gen_item_data> g_gen_item_data;
82 static std::vector<String> _setup_modules;
83 static String _mdl_name;
84 static SetupModule *_mdl = NULL;
85 static ConfigPointer _config;
86 static Connection _reload_signal_connection;
87 static ISE_OPTION_MODULE_STATE _ise_option_module_stat = ISE_OPTION_MODULE_NO_EXIST;
89 static Ecore_Fd_Handler *_read_handler = 0;
90 static HelperAgent _helper_agent;
91 static HelperInfo _helper_info ("fd491a70-22f5-11e2-89f3-eb5999be869e", "ISF Setting", "", "", SCIM_HELPER_STAND_ALONE);
93 void im_setting_list_update_window(void *data);
95 static void helper_ise_reload_config (void)
97 if (_helper_agent.is_connected ())
98 _helper_agent.reload_config ();
101 static Eina_Bool ise_option_view_set_cb (void *data, Elm_Object_Item *it)
106 _mdl->save_config (_config);
107 helper_ise_reload_config ();
112 static ISE_OPTION_MODULE_STATE find_ise_option_module (char *active_ime_appid)
114 LOGD ("%s", active_ime_appid);
116 _ise_option_module_stat = ISE_OPTION_MODULE_NO_EXIST;
118 _mdl_name = active_ime_appid + String ("-setup");
119 for (unsigned int i = 0; i < _setup_modules.size (); i++) {
120 if (_mdl_name == _setup_modules[i]) {
121 _ise_option_module_stat = ISE_OPTION_MODULE_EXIST_SO;
125 return _ise_option_module_stat;
128 static void im_setting_list_text_domain_set(void)
130 bindtextdomain(IM_SETTING_LIST_PACKAGE, IM_SETTING_LIST_LOCALE_DIR);
131 textdomain(IM_SETTING_LIST_PACKAGE);
135 im_setting_list_main_window_create(const char *name)
137 Evas_Object *eo = NULL;
139 eo = elm_win_add(NULL, name, ELM_WIN_BASIC);
141 elm_win_title_set(eo, name);
142 elm_win_borderless_set(eo, EINA_TRUE);
143 elm_win_alpha_set(eo, EINA_FALSE);
144 elm_win_conformant_set(eo, EINA_TRUE);
145 elm_win_autodel_set(eo, EINA_TRUE);
146 elm_win_screen_size_get(eo, NULL, NULL, &w, &h);
147 if(w == -1 || h == -1){
148 LOGD("elm_win_screen_size_get() is failed\n");
151 evas_object_resize(eo, w, h);
152 int rots[4] = {0, 90, 180, 270};
153 elm_win_wm_rotation_available_rotations_set(eo, rots, 4);
158 static Evas_Object* im_setting_list_bg_create(Evas_Object *parent)
161 if (parent == NULL) return NULL;
162 bg = elm_bg_add(parent);
163 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
164 elm_win_resize_object_add(parent, bg);
165 evas_object_show(bg);
169 static void im_setting_list_load_ime_info(void)
171 ime_info_s *info = NULL;
172 g_ime_info_list.clear();
173 int cnt = isf_control_get_all_ime_info(&info);
176 for(int i=0; i<cnt; ++i)
178 SECURE_LOGD("%s %s %d %d %d", info[i].appid, info[i].label, info[i].is_enabled, info[i].is_preinstalled, info[i].has_option);
179 g_ime_info_list.push_back(info[i]);
185 LOGD("isf_control_get_all_ime_info failed\n");
189 static int im_setting_list_get_active_ime_index(void)
191 char *active_ime_appid = NULL;
192 isf_control_get_active_ime(&active_ime_appid);
193 std::vector<ime_info_s>::iterator iter = g_ime_info_list.begin();
194 std::vector<ime_info_s>::iterator end = g_ime_info_list.end();
195 for (; iter != end; ++iter)
197 if(active_ime_appid && (!strcmp(active_ime_appid, iter->appid)))
204 free(active_ime_appid);
206 return (iter-g_ime_info_list.begin());
210 im_setting_list_app_control_reply_cb(app_control_h request, app_control_h reply, app_control_result_e result, void *user_data)
212 if (!request || !reply) {
213 LOGD("app_control handle is null");
216 if (result == APP_CONTROL_RESULT_SUCCEEDED) {
218 int res = app_control_get_extra_data(reply, "result", &value);
219 if (APP_CONTROL_ERROR_NONE == res && NULL != value) {
220 im_setting_list_update_window(user_data);
228 static void im_setting_list_show_ime_selector(void *data)
231 app_control_h app_control;
232 const char *app_id = "org.tizen.inputmethod-setting-selector"; // This is temporary. AppId can be got using pkgmgr-info later.
233 ret = app_control_create (&app_control);
234 if (ret != APP_CONTROL_ERROR_NONE) {
235 LOGD("app_control_create returned %d", ret);
239 ret = app_control_set_operation (app_control, APP_CONTROL_OPERATION_DEFAULT);
240 if (ret != APP_CONTROL_ERROR_NONE) {
241 LOGD("app_control_set_operation returned %d", ret);
242 app_control_destroy(app_control);
246 ret = app_control_set_app_id (app_control, app_id);
247 if (ret != APP_CONTROL_ERROR_NONE) {
248 LOGD("app_control_set_app_id returned %d", ret);
249 app_control_destroy(app_control);
253 app_control_add_extra_data(app_control, "caller", "settings");
254 ret = app_control_send_launch_request(app_control, im_setting_list_app_control_reply_cb, data);
255 if (ret != APP_CONTROL_ERROR_NONE) {
256 LOGD("app_control_send_launch_request returned %d, %s\n", ret, get_error_message(ret));
257 app_control_destroy(app_control);
260 app_control_destroy(app_control);
264 im_setting_list_check_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
266 popup_cb_data *cb_data = (popup_cb_data *)data;
267 int index = (int)reinterpret_cast<long>(cb_data->data);
268 Eina_Bool state = EINA_FALSE;
269 state = g_gen_item_data[index].chk_status;
270 isf_control_set_enable_ime(g_ime_info_list[index].appid, state);
271 evas_object_del(cb_data->popup);
276 im_setting_list_check_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
278 popup_cb_data *cb_data = (popup_cb_data *)data;
279 int index = (int)reinterpret_cast<long>(cb_data->data);
280 Eina_Bool state = g_gen_item_data[index].chk_status;
281 isf_control_set_enable_ime(g_ime_info_list[index].appid, !state);
282 g_gen_item_data[index].chk_status = !state;
283 elm_genlist_item_update(g_gen_item_data[index].gen_item);
284 evas_object_del(cb_data->popup);
288 static void im_setting_list_show_popup(void *data, Evas_Object *obj, popup_ok_cb ime_setting_list_ok_callback, popup_cancel_cb ime_setting_list_cancel_callback)
290 int index = (int)reinterpret_cast<long>(data);
291 Evas_Object *top_widget = elm_object_top_widget_get(obj);
292 Evas_Object *popup = elm_popup_add(top_widget);
293 elm_popup_align_set (popup, ELM_NOTIFY_ALIGN_FILL, 0.5);
294 eext_object_event_callback_add (popup, EEXT_CALLBACK_BACK, eext_popup_back_cb, NULL);
295 elm_object_part_text_set(popup, "title,text", IM_SETTING_LIST_POPUP_TITLE);
297 char chFormatMsg[255] = {'\0'};
298 char chPopupMsg[255] = {'\0'};
299 snprintf(chFormatMsg, sizeof(chFormatMsg), "%s", IM_SETTING_LIST_POPUP_TEXT);
300 snprintf(chPopupMsg, sizeof(chPopupMsg), chFormatMsg, g_ime_info_list[index].label);
301 elm_object_text_set(popup, chPopupMsg);
303 popup_cb_data *cb_data = new popup_cb_data;
304 cb_data->popup = popup;
305 cb_data->data = data;
307 Evas_Object *btn_cancel = elm_button_add(popup);
308 elm_object_text_set(btn_cancel, IM_SETTING_LIST_POPUP_CANCEL);
309 elm_object_part_content_set(popup, "button1", btn_cancel);
310 evas_object_smart_callback_add(btn_cancel, "clicked", ime_setting_list_cancel_callback, cb_data);
312 Evas_Object *btn_ok = elm_button_add(popup);
313 elm_object_text_set(btn_ok, IM_SETTING_LIST_POPUP_ENABLE);
314 elm_object_part_content_set(popup, "button2", btn_ok);
315 evas_object_smart_callback_add(btn_ok, "clicked", ime_setting_list_ok_callback, cb_data);
317 evas_object_show(popup);
321 static void im_setting_list_check_button_change_cb(void *data, Evas_Object *obj, void *event_info)
323 /*save the checked ime*/
324 int index = (int)reinterpret_cast<long>(data);
325 Eina_Bool state = g_gen_item_data[index].chk_status;
329 isf_control_set_enable_ime(g_ime_info_list[index].appid, state);
333 im_setting_list_show_popup(data, obj, im_setting_list_check_popup_ok_cb, im_setting_list_check_popup_cancel_cb);
338 im_setting_list_popup_ok_cb(void *data, Evas_Object *obj, void *event_info)
340 popup_cb_data *cb_data = (popup_cb_data *)data;
341 int index = (int)reinterpret_cast<long>(cb_data->data);
342 Eina_Bool state = g_gen_item_data[index].chk_status;
343 g_gen_item_data[index].chk_status = !state;
344 isf_control_set_enable_ime(g_ime_info_list[index].appid, !state);
345 elm_genlist_item_update(g_gen_item_data[index].gen_item);
346 evas_object_del(cb_data->popup);
351 im_setting_list_popup_cancel_cb(void *data, Evas_Object *obj, void *event_info)
353 popup_cb_data *cb_data = (popup_cb_data *)data;
354 evas_object_del(cb_data->popup);
358 static void im_setting_list_item_sel_cb(void *data, Evas_Object *obj, void *event_info)
360 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
361 elm_genlist_item_selected_set (item, EINA_FALSE);
363 int index = (int)reinterpret_cast<long>(data);
364 if(g_ime_info_list[index].is_preinstalled || (index == g_active_ime_index))
369 Evas_Object *ck = elm_object_item_part_content_get (item, "elm.icon.right");
371 ck = elm_object_item_part_content_get (item, "elm.icon");
373 Eina_Bool state = g_gen_item_data[index].chk_status;
377 g_gen_item_data[index].chk_status = !state;
378 isf_control_set_enable_ime(g_ime_info_list[index].appid, !state);
379 elm_genlist_item_update(item);
383 im_setting_list_show_popup(data, obj, im_setting_list_popup_ok_cb, im_setting_list_popup_cancel_cb);
387 static void im_setting_list_set_default_keyboard_item_sel_cb(void *data, Evas_Object *obj, void *event_info)
389 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
390 elm_genlist_item_selected_set (item, EINA_FALSE);
391 im_setting_list_show_ime_selector(data);
394 static void im_setting_list_keyboard_setting_item_sel_cb(void *data, Evas_Object *obj, void *event_info)
396 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
397 elm_genlist_item_selected_set (item, EINA_FALSE);
398 Evas_Object *option_content;
399 appdata *ad = (appdata *)data;
400 char *active_ime_appid = NULL;
401 isf_control_get_active_ime(&active_ime_appid);
403 if (ad && active_ime_appid && ISE_OPTION_MODULE_EXIST_SO == find_ise_option_module (active_ime_appid)) {
409 if (_mdl_name.length () > 0)
410 _mdl = new SetupModule (String (_mdl_name));
412 if (_mdl == NULL || !_mdl->valid ()) {
413 free(active_ime_appid);
416 LOGD("keyboard option window is showing");
417 _mdl->load_config (_config);
418 option_content = _mdl->create_ui (ad->conform, ad->naviframe);
420 Elm_Object_Item *it = elm_naviframe_item_push (ad->naviframe, IM_SETTING_LIST_KEYBOARD_SETTING, NULL, NULL, option_content, NULL);
421 elm_naviframe_item_pop_cb_set (it, ise_option_view_set_cb, ad);
425 isf_control_open_ime_option_window();
427 if (active_ime_appid)
428 free(active_ime_appid);
431 static Evas_Object *im_setting_list_conform_create(Evas_Object *parentWin)
433 Evas_Object *conform = elm_conformant_add(parentWin);
434 elm_win_indicator_mode_set(parentWin, ELM_WIN_INDICATOR_SHOW);
435 elm_win_indicator_opacity_set(parentWin, ELM_WIN_INDICATOR_OPAQUE);
436 evas_object_size_hint_weight_set(conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
437 evas_object_size_hint_align_set(conform, EVAS_HINT_FILL, EVAS_HINT_FILL);
438 elm_win_resize_object_add(parentWin, conform);
439 evas_object_show(conform);
443 static Evas_Object *im_setting_list_naviframe_create(Evas_Object* parent)
445 Evas_Object *naviframe = elm_naviframe_add(parent);
446 elm_naviframe_prev_btn_auto_pushed_set(naviframe, EINA_FALSE);
447 eext_object_event_callback_add(naviframe, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
448 evas_object_size_hint_weight_set(naviframe, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
449 evas_object_size_hint_align_set(naviframe, EVAS_HINT_FILL, EVAS_HINT_FILL);
450 elm_object_part_content_set(parent, "elm.swallow.content", naviframe);
451 evas_object_show(naviframe);
455 static Evas_Object *im_setting_list_genlist_create(Evas_Object* parent)
457 Evas_Object *genlist = elm_genlist_add(parent);
458 evas_object_show(genlist);
462 static char *im_setting_list_genlist_group_label_get(void *data, Evas_Object *obj, const char *part)
464 char *text = (char *)data;
466 if (!strcmp(part, "elm.text.main")) {
468 if (!strcmp(part, "elm.text")) {
475 static char *im_setting_list_genlist_keyboard_list_item_label_get(void *data, Evas_Object *obj, const char *part)
477 int index = (int)reinterpret_cast<long>(data);
478 if (!strcmp(part, "elm.text.main.left.top") ||
479 !strcmp(part, "elm.text.main.left") ||
480 !strcmp(part, "elm.text.main") ||
481 !strcmp(part, "elm.text") ||
482 !strcmp(part, "elm.text.1")) {
483 return strdup(g_ime_info_list[index].label);
488 static Evas_Object *im_setting_list_genlist_keyboard_list_item_icon_get(void *data, Evas_Object *obj, const char *part)
490 int index = (int)reinterpret_cast<long>(data);
491 if (!strcmp(part, "elm.icon.right") || !strcmp(part, "elm.icon")) {
492 Evas_Object *ck = elm_check_add(obj);
493 elm_object_style_set (ck, "on&off");
494 elm_object_disabled_set(ck, g_ime_info_list[index].is_preinstalled || (index == g_active_ime_index));
495 elm_check_state_set(ck, g_gen_item_data[index].chk_status);
496 evas_object_propagate_events_set (ck, EINA_FALSE);
497 evas_object_size_hint_align_set(ck, EVAS_HINT_FILL, EVAS_HINT_FILL);
498 evas_object_size_hint_weight_set(ck, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
499 elm_check_state_pointer_set(ck, (Eina_Bool *)(&(g_gen_item_data[index].chk_status)));
500 evas_object_pass_events_set(ck, 1);
501 evas_object_smart_callback_add(ck, "changed", im_setting_list_check_button_change_cb, (void *)(index));
502 evas_object_show(ck);
508 static char *im_setting_list_genlist_item_label_get(void *data, Evas_Object *obj, const char *part)
510 list_item_text *item_text = (list_item_text *)data;
511 if (!strcmp(part, "elm.text.main.left.top") ||
512 !strcmp(part, "elm.text.main.left") ||
513 !strcmp(part, "elm.text.main") ||
514 !strcmp(part, "elm.text") ||
515 !strcmp(part, "elm.text.1")) {
516 return strdup(item_text->main_text);
519 if (!strcmp(part, "elm.text.sub.left.bottom") ||
520 !strcmp(part, "elm.text.multiline") ||
521 !strcmp(part, "elm.text.2")) {
522 return strdup(item_text->sub_text);
527 static char *im_setting_list_genlist_item_one_line_label_get(void *data, Evas_Object *obj, const char *part)
529 list_item_text *item_text = (list_item_text *)data;
530 if (!strcmp(part, "elm.text.main.left.top") ||
531 !strcmp(part, "elm.text.main.left") ||
532 !strcmp(part, "elm.text.main") ||
533 !strcmp(part, "elm.text") ||
534 !strcmp(part, "elm.text.1")) {
535 return strdup(item_text->main_text);
540 static void im_setting_list_genlist_item_class_create(int app_type)
542 if(NULL == itc_im_list_group)
544 itc_im_list_group = elm_genlist_item_class_new();
545 if(itc_im_list_group)
547 itc_im_list_group->item_style = "groupindex";
548 itc_im_list_group->func.text_get = im_setting_list_genlist_group_label_get;
549 itc_im_list_group->func.content_get = NULL;
550 itc_im_list_group->func.state_get = NULL;
551 itc_im_list_group->func.del = NULL;
555 if(NULL == itc_im_list_keyboard_list)
557 itc_im_list_keyboard_list = elm_genlist_item_class_new();
558 if (itc_im_list_keyboard_list)
561 itc_im_list_keyboard_list->item_style = "1line";
563 itc_im_list_keyboard_list->item_style = "1text.1icon.1";
565 itc_im_list_keyboard_list->func.text_get = im_setting_list_genlist_keyboard_list_item_label_get;
566 itc_im_list_keyboard_list->func.content_get = im_setting_list_genlist_keyboard_list_item_icon_get;
567 itc_im_list_keyboard_list->func.state_get = NULL;
568 itc_im_list_keyboard_list->func.del = NULL;
572 if(app_type == APP_TYPE_SETTING)
574 if(NULL == itc_im_list_item)
576 itc_im_list_item = elm_genlist_item_class_new();
577 if (itc_im_list_item)
580 itc_im_list_item->item_style = "2line.top";
582 itc_im_list_item->item_style = "2text";
584 itc_im_list_item->func.text_get = im_setting_list_genlist_item_label_get;
585 itc_im_list_item->func.content_get = NULL;
586 itc_im_list_item->func.state_get = NULL;
587 itc_im_list_item->func.del = NULL;
591 if(NULL == itc_im_list_item_one_line)
593 itc_im_list_item_one_line = elm_genlist_item_class_new();
594 if (itc_im_list_item_one_line)
597 itc_im_list_item_one_line->item_style = "1line";
599 itc_im_list_item_one_line->item_style = "1text";
601 itc_im_list_item_one_line->func.text_get = im_setting_list_genlist_item_one_line_label_get;
602 itc_im_list_item_one_line->func.content_get = NULL;
603 itc_im_list_item_one_line->func.state_get = NULL;
604 itc_im_list_item_one_line->func.del = NULL;
610 static void im_setting_list_add_ime(void *data) {
611 appdata *ad = (appdata *)data;
613 im_setting_list_genlist_item_class_create(ad->app_type);
615 if(NULL != ad->genlist)
617 elm_genlist_clear(ad->genlist);
620 g_active_ime_index = im_setting_list_get_active_ime_index();
621 // list_item_text item_text;
622 memset(&item_text, 0, sizeof(item_text));
623 if(ad->app_type == APP_TYPE_SETTING)
625 elm_genlist_item_append(ad->genlist,
627 IM_SETTING_LIST_VIRTUAL_KEYBOARD,
629 ELM_GENLIST_ITEM_NONE,
633 snprintf(item_text[0].main_text, sizeof(item_text[0].main_text), "%s", IM_SETTING_LIST_DEFAULT_KEYBOARD);
634 snprintf(item_text[0].sub_text, sizeof(item_text[0].sub_text), "%s", g_ime_info_list[g_active_ime_index].label);
635 elm_genlist_item_append(ad->genlist,
637 (void *)&item_text[0],
639 ELM_GENLIST_ITEM_NONE,
640 im_setting_list_set_default_keyboard_item_sel_cb,
643 snprintf(item_text[1].main_text, sizeof(item_text[1].main_text), "%s", IM_SETTING_LIST_KEYBOARD_SETTING);
644 Elm_Object_Item *item = elm_genlist_item_append(ad->genlist,
645 itc_im_list_item_one_line,
646 (void *)&item_text[1],
648 ELM_GENLIST_ITEM_NONE,
649 im_setting_list_keyboard_setting_item_sel_cb,
652 elm_object_item_disabled_set(item, !(g_ime_info_list[g_active_ime_index].has_option));
655 elm_genlist_item_append(ad->genlist,
657 IM_SETTING_LIST_KEYBOARD_HEADER,
659 ELM_GENLIST_ITEM_NONE,
664 int info_list_size = g_ime_info_list.size();
665 for (i = 0; i < info_list_size; i++) {
666 gen_item_data item_data;
668 if(g_ime_info_list[i].is_preinstalled || (i == g_active_ime_index)){
669 item_data.chk_status = EINA_TRUE;
672 item_data.chk_status = g_ime_info_list[i].is_enabled;
674 g_gen_item_data.push_back(item_data);
676 Elm_Object_Item *item = elm_genlist_item_append(ad->genlist,
677 itc_im_list_keyboard_list,
680 ELM_GENLIST_ITEM_NONE,
681 im_setting_list_item_sel_cb,
684 g_gen_item_data[i].gen_item = item;
688 static Eina_Bool im_setting_list_navi_item_pop_cb(void *data, Elm_Object_Item *it)
690 static bool in_exit = false;
700 static void im_setting_list_navi_back_btn_call_cb(void *data, Evas_Object *obj, void *event_info)
702 evas_object_smart_callback_del(obj, "clicked", im_setting_list_navi_back_btn_call_cb);
706 Evas_Object *im_setting_list_list_create(void *data)
708 appdata *ad = (appdata *)data;
709 ad->conform = im_setting_list_conform_create(ad->win);
710 ad->naviframe = im_setting_list_naviframe_create(ad->conform);
711 ad->genlist = im_setting_list_genlist_create(ad->naviframe);
712 im_setting_list_add_ime(ad);
714 /* Add genlist to naviframe */
715 Evas_Object *back_btn = elm_button_add (ad->naviframe);
716 elm_object_style_set (back_btn, "naviframe/back_btn/default");
717 evas_object_smart_callback_add(back_btn, "clicked", im_setting_list_navi_back_btn_call_cb, NULL);
718 Elm_Object_Item *nf_main_item = elm_naviframe_item_push(ad->naviframe,
719 IM_SETTING_LIST_TITLE,
724 elm_naviframe_item_title_enabled_set(nf_main_item, EINA_TRUE, EINA_TRUE);
725 elm_naviframe_item_pop_cb_set(nf_main_item, im_setting_list_navi_item_pop_cb, ad);
726 elm_object_content_set(ad->conform, ad->naviframe);
731 void im_setting_list_app_terminate(void *data)
733 g_ime_info_list.clear();
734 g_gen_item_data.clear();
735 if(NULL != itc_im_list_keyboard_list)
737 elm_genlist_item_class_free(itc_im_list_keyboard_list);
738 itc_im_list_keyboard_list = NULL;
741 if(NULL != itc_im_list_group)
743 elm_genlist_item_class_free(itc_im_list_group);
744 itc_im_list_group = NULL;
747 if(NULL != itc_im_list_item)
749 elm_genlist_item_class_free(itc_im_list_item);
750 itc_im_list_item = NULL;
754 void im_setting_list_update_window(void *data)
756 appdata *ad = (appdata *)data;
757 im_setting_list_load_ime_info();
758 im_setting_list_add_ime(ad);
761 static void load_config_module (void)
763 _config = ConfigBase::get (true, "socket");
764 if (_config.null ()) {
765 std::cerr << "Create dummy config!!!\n";
766 _config = new DummyConfig ();
769 if (_config.null ()) {
770 std::cerr << "Can not create Config Object!\n";
775 * @brief Reload config slot function for HelperAgent.
777 * @param ic The context of application.
778 * @param ise_uuid The ISE uuid.
782 static void slot_reload_config (const HelperAgent *, int ic, const String &ise_uuid)
788 * @brief Handler function for HelperAgent input.
790 * @param user_data Data to pass when it is called.
791 * @param fd_handler The Ecore Fd handler.
793 * @return ECORE_CALLBACK_RENEW
795 static Eina_Bool helper_agent_input_handler (void *user_data, Ecore_Fd_Handler *fd_handler)
797 if (fd_handler == _read_handler && _helper_agent.has_pending_event ()) {
798 if (!_helper_agent.filter_event ()) {
799 LOGD ("helper_agent.filter_event () failed!!!\n");
802 LOGD ("helper_agent.has_pending_event () failed!!!\n");
805 return ECORE_CALLBACK_RENEW;
809 im_setting_list_app_create(void *data)
811 appdata *ad = (appdata *)data;
812 im_setting_list_text_domain_set();
813 ad->win = im_setting_list_main_window_create(PACKAGE);
814 im_setting_list_bg_create(ad->win);
815 im_setting_list_load_ime_info();
817 load_config_module ();
818 scim_get_setup_module_list (_setup_modules);
820 /* Connect PanelAgent by HelperAgent */
821 String display_name = String (":13");
822 const char *p = getenv ("DISPLAY");
824 display_name = String (p);
826 _reload_signal_connection = _helper_agent.signal_connect_reload_config (slot (slot_reload_config));
827 int id = _helper_agent.open_connection (_helper_info, display_name);
829 LOGD("open_connection failed!!!!!!\n");
831 int fd = _helper_agent.get_connection_number ();
833 _read_handler = ecore_main_fd_handler_add (fd, ECORE_FD_READ, helper_agent_input_handler, NULL, NULL, NULL);
836 im_setting_list_list_create(ad);
837 evas_object_show(ad->win);