fixed N_SE-47240
[apps/home/settings.git] / setting-common / src / setting-common-draw-genlist.c
1 /*
2  * setting
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Flora License, Version 1.1 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://floralicense.org/license/
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 #include <setting-common-draw-widget.h>
18 #include <glib.h>
19 #include <utilX.h>
20 #include <Ecore_X.h>
21 #include <system_settings.h>
22 #include <efl_assist.h>
23
24 static Evas_Object *_gl_Gendial_content_get(void *data, Evas_Object *obj, const char *part);
25 static char *_gl_Gendial_text_get(void *data, Evas_Object *obj, const char *part);
26 static void _gl_Gendial_del(void *data, Evas_Object *obj);
27 const Elm_Genlist_Item_Class itc_seperator = {
28         .item_style = "dialogue/separator",
29         .func.text_get = NULL,
30         .func.content_get = NULL,
31         .func.state_get = NULL,
32         .func.del = NULL,
33 };
34
35 const Elm_Genlist_Item_Class itc_bottom_seperator = {
36         .item_style = "dialogue/separator",
37         .func.text_get = NULL,
38         .func.content_get = NULL,
39         .func.state_get = NULL,
40         .func.del = NULL,
41 };
42
43 const Elm_Genlist_Item_Class itc_sep_line = {
44         .item_style = "dialogue/separator",
45         .func.text_get = _gl_Gendial_text_get,
46         .func.content_get = NULL,
47         .func.state_get = NULL,
48         .func.del = NULL,
49 };
50
51 #define DEFINE_ITC1(style, name) \
52 const Elm_Genlist_Item_Class name = {\
53         .item_style = style,\
54         .func.text_get = _gl_Gendial_text_get,\
55         .func.content_get = _gl_Gendial_content_get,\
56         .func.state_get = NULL,\
57         .func.del = _gl_Gendial_del,\
58 };
59
60 DEFINE_ITC1("dialogue/1text", itc_1text);
61 DEFINE_ITC1("dialogue/1text.1icon.2", itc_1text_1icon_2);
62
63 DEFINE_ITC1("dialogue/editfield/title", itc_dialogue_editfield_title);
64 DEFINE_ITC1("dialogue/1icon", itc_1icon);
65 DEFINE_ITC1("dialogue/1text.1icon/expandable2", itc_1icon_1text_sub);
66 DEFINE_ITC1("dialogue/1text.1icon", itc_1text_1icon);
67 DEFINE_ITC1("dialogue/1text.2icon", itc_1text_2icon);
68 DEFINE_ITC1("dialogue/1text.2icon.2", itc_1text_2icon_2);
69
70 DEFINE_ITC1("dialogue/2text.2", itc_2text_2);
71 DEFINE_ITC1("dialogue/2text", itc_2text);
72 DEFINE_ITC1("multiline/2text.1icon", itc_multiline_2text_1icon);
73 DEFINE_ITC1("dialogue/2text.1icon.3", itc_2text_1icon_3);
74 DEFINE_ITC1("dialogue/2text.1icon.6", itc_2text_1icon_6);
75 DEFINE_ITC1("dialogue/2text.1icon.10.tb", itc_2text_1icon_7);
76
77 DEFINE_ITC1("dialogue/2text.3/expandable", itc_2text_3_parent);
78 DEFINE_ITC1("dialogue/2text.3", itc_2text_3);
79 DEFINE_ITC1("dialogue/2text.2icon.3", itc_2text_2icon_3);
80
81 DEFINE_ITC1("multiline/1text", itc_multiline_text);
82 DEFINE_ITC1("1text.1icon.3", itc_1text_1icon_3_tb);
83 DEFINE_ITC1("1text.1icon.2", itc_cm_1text_1icon_2);
84 DEFINE_ITC1("select_all", itc_sel_all);
85 //DEFINE_ITC1("dialogue/bg/1icon", itc_bg_1icon);
86 DEFINE_ITC1("1icon", itc_bg_1icon);
87 DEFINE_ITC1("dialogue/title", itc_group_item);
88
89 /**
90  * Do process when clicking on a common genlist item
91  */
92 void setting_mouse_up_Gendial_list_radio_cb(void *data, Evas_Object *obj,
93                                             void *event_info)
94 {
95         /* error check */
96         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
97         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
98         elm_genlist_item_selected_set(item, 0);
99         Setting_GenGroupItem_Data *list_item =
100             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
101
102         setting_retm_if(data == NULL, "Data parameter is NULL");
103         Evas_Object *radio = data;
104         elm_radio_value_set(radio, list_item->chk_status);
105 }
106
107 static void __radio_changed(void *data, Evas_Object *obj, void *event_info)
108 {
109         retm_if(data == NULL, "Data parameter is NULL");
110         Setting_GenGroupItem_Data *list_item =
111             (Setting_GenGroupItem_Data *) data;
112         list_item->chk_status = elm_radio_value_get(obj);       /*  for update */
113 }
114
115 static void __entry_changed(void *data, Evas_Object *obj, void *event_info)
116 {
117         retm_if(data == NULL, "Data parameter is NULL");
118         SETTING_TRACE_BEGIN;
119         Setting_GenGroupItem_Data *list_item =
120             (Setting_GenGroupItem_Data *) data;
121         list_item->sub_desc = (char *)g_strdup(elm_entry_entry_get(obj));
122         Evas_Object *entry_container = elm_object_parent_widget_get(obj);
123         if (entry_container)
124         {
125                 if (elm_entry_is_empty(obj))
126                 {
127                         elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
128                         elm_object_signal_emit(entry_container, "elm,state,eraser,hide", "elm");
129                 }
130                 else
131                 {
132                         elm_object_signal_emit(entry_container, "elm,state,guidetext,hide", "elm");
133                         if (elm_object_focus_get(obj)) //only do when entry is focused
134                         {
135                                 elm_object_signal_emit(entry_container, "elm,state,eraser,show", "elm");
136                         }
137                 }
138         }
139 }
140
141 static void __entry_unfocused(void *data, Evas_Object *obj, void *event_info) // Unfocused callback will show guidetext and hide X marked button.
142 {
143         ret_if(!data);
144         SETTING_TRACE_BEGIN;
145         #if 0
146         Evas_Object *entry_container = data;
147         //whe entry unfocused, its guidetext will becomes "Input here"
148         elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
149         if (elm_entry_is_empty(obj))
150                 elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
151         elm_object_signal_emit(entry_container, "elm,state,eraser,hide", "elm");
152         #endif
153 }
154
155 static void __entry_focused(void *data, Evas_Object *obj, void *event_info) // Focused callback will show X marked button and hide guidetext.
156 {
157         ret_if(!data);
158         SETTING_TRACE_BEGIN;
159         #if 0
160         Evas_Object *entry_container = data;
161         //whe entry focused, its guidetext will becomes "Input here"
162         elm_object_part_text_set(entry_container, "elm.guidetext", _("IDS_ST_BODY_TAP_TO_INSERT"));
163         if (!elm_entry_is_empty(obj))
164                 elm_object_signal_emit(entry_container, "elm,state,eraser,show", "elm");
165         elm_object_signal_emit(entry_container, "elm,state,guidetext,hide", "elm");
166
167         Ecore_IMF_Context *imf_context = (Ecore_IMF_Context *)elm_entry_imf_context_get(obj);
168         if (imf_context) ecore_imf_context_input_panel_show(imf_context);
169         #endif
170 }
171 static void __eraser_clicked(void *data, Evas_Object *obj, const char *emission, const char *source) // When X marked button is clicked, empty entry's contents.
172 {
173         ret_if(!data);
174         SETTING_TRACE_BEGIN;
175         Evas_Object *entry = data;
176         elm_entry_entry_set(entry, "");
177         elm_object_focus_set(entry, EINA_TRUE);
178 }
179
180 static void __chk_changed(void *data, Evas_Object *obj, void *event_info)
181 {
182         retm_if(data == NULL, "Data parameter is NULL");
183         SETTING_TRACE_BEGIN;
184         Setting_GenGroupItem_Data *list_item =
185             (Setting_GenGroupItem_Data *) data;
186         list_item->chk_status = elm_check_state_get(obj);       /*  for update */
187 }
188
189 void __error_popup_response_cb(void *data, Evas_Object *obj,
190                                      void *event_info)
191 {
192         SETTING_TRACE_BEGIN;
193         retm_if(data == NULL, "Data parameter is NULL");
194         Setting_GenGroupItem_Data *list_item = data;
195         if (list_item->notify) {
196                 evas_object_del(list_item->notify);
197                 list_item->notify = NULL;
198         }
199 }
200
201 static void __max_len_reached(void *data, Evas_Object *obj, void *event_info)
202 {
203         SETTING_TRACE_BEGIN;
204         retm_if(data == NULL, "Data parameter is NULL");
205         retm_if(!elm_object_focus_get(obj), "Entry is not focused");//notify only when entry is being focused on.
206
207         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
208         if (!list_item->notify)
209         {
210                 list_item->notify = setting_create_popup_without_btn(list_item, list_item->win_main,
211                                                          NULL, _(EXCEED_LIMITATION_STR),
212                                                          __error_popup_response_cb,
213                                                          POPUP_INTERVAL, FALSE, FALSE);
214                 // elm_object_focus_set(list_item->eo_check, EINA_FALSE);
215         } else {
216                 //postpone 2 seconds again
217
218                 elm_popup_timeout_set(list_item->notify, POPUP_INTERVAL);
219         }
220 }
221
222 static void __entry_keydown(void *data, Evas *e, Evas_Object *obj, void *event_info)
223 {
224         retm_if(data == NULL, "Data parameter is NULL");
225         retm_if(event_info == NULL, "event_info is NULL");
226         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
227         Evas_Event_Key_Down *ev = (Evas_Event_Key_Down *)event_info;
228         SETTING_TRACE_BEGIN;
229         if(safeStrCmp(ev->key, "KP_Enter") == 0 //it is for Japanese keyboard to fix N_SE-10719
230            || safeStrCmp(ev->key, "Return") == 0) //to disable the 'Enter' orginal function
231         {
232                 SETTING_TRACE("ENTER %s ev->key:%s", __FUNCTION__, ev->key);
233                 list_item->enterKeyPressFlag = true;
234                 //hide the eraser button
235                 //format like:xx<br/>
236                 if (list_item->isSinglelineFlag == FALSE) {
237                         const char *entry_str = remove_first_substring(elm_entry_entry_get(obj), "<br/>");
238                         elm_entry_entry_set(obj, entry_str);
239                         FREE(entry_str);
240                         elm_entry_cursor_end_set(obj);
241                 }
242                 setting_hide_input_pannel_cb(obj);
243         } else {
244                 list_item->enterKeyPressFlag = false;
245                 Evas_Object *entry_container = elm_object_parent_widget_get(obj);
246                 if(safeStrLen(elm_entry_entry_get(obj)) > 0) {
247                         elm_object_signal_emit(entry_container, "elm,state,guidetext,hide", "elm");
248                 } else {
249                         elm_object_signal_emit(entry_container, "elm,state,guidetext,show", "elm");
250                 }
251         }
252 }
253
254 /**
255  * Do process when clicking radio in subitem of expandable item
256  */
257 void setting_sub_list_rd_change(void *data, Evas_Object *obj, void *event_info)
258 {
259         SETTING_TRACE_BEGIN;
260         retm_if(data == NULL, "Data parameter is NULL");
261         Setting_GenGroupItem_Data *list_item =
262             (Setting_GenGroupItem_Data *) data;
263         list_item->chk_status = elm_radio_value_get(obj);       /*  for update */
264
265         Elm_Object_Item *subItem = list_item->item;
266         Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subItem);
267
268         Setting_GenGroupItem_Data *data_subItem = elm_object_item_data_get(subItem);    /* subItem data */
269         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
270
271         ret_if(NULL == data_subItem || NULL == data_parentItem);
272         int err;
273         setting_set_int_slp_key(data_parentItem->int_slp_setting_binded,
274                                 list_item->chk_status, &err);
275         ret_if(0 != err);
276         data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
277         elm_object_item_data_set(data_parentItem->item, data_parentItem);
278         elm_genlist_item_update(data_parentItem->item);
279 }
280
281 /**
282  * Do process when clicking on subitem of expandable item
283  */
284 void setting_sub_list_sel_cb(void *data, Evas_Object *obj, void *event_info)
285 {
286         SETTING_TRACE_BEGIN;
287         /* error check */
288         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
289         Elm_Object_Item *subitem = (Elm_Object_Item *) event_info;
290         Elm_Object_Item *parentItem = elm_genlist_item_parent_get(subitem);
291         elm_genlist_item_selected_set(subitem, 0);
292         Setting_GenGroupItem_Data *data_subItem =
293             elm_object_item_data_get(subitem);
294         Setting_GenGroupItem_Data *data_parentItem = elm_object_item_data_get(parentItem);      /* parent data */
295         ret_if(NULL == data_subItem || NULL == data_parentItem);
296
297         elm_radio_value_set(data_subItem->rgd, data_subItem->chk_status);
298         int err;
299         setting_set_int_slp_key(data_parentItem->int_slp_setting_binded,
300                                 data_subItem->chk_status, &err);
301         setting_retm_if(0 != err, "Set vconf error[%d]",data_parentItem->int_slp_setting_binded);
302
303         data_parentItem->sub_desc = (char *)g_strdup(_(data_subItem->keyStr));
304         elm_object_item_data_set(data_parentItem->item, data_parentItem);
305         elm_genlist_item_update(data_parentItem->item);
306 }
307
308 static void __exp_list_smart_cb(void *data, Evas_Object *obj, void *event_info)
309 {
310         ret_if(data == NULL || event_info == NULL);
311         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
312         char *cb_type = data;
313
314         if (0 == safeStrCmp(cb_type, "drag")
315             || 0 == safeStrCmp(cb_type, "longpressed")) {
316                 //Evas_Object *base_view = (Evas_Object *) elm_genlist_item_object_get(item);
317                 //edje_object_signal_emit(base_view, "mouse,out", "touch_arrow");
318         } else if (0 == safeStrCmp(cb_type, "contracted")) {
319                 elm_genlist_item_subitems_clear(item);
320         }
321 }
322
323 static void _gl_Gendial_sel(void *data, Evas_Object *obj, void *event_info)
324 {
325         /* SETTING_TRACE_BEGIN; */
326         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
327         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
328         elm_genlist_item_selected_set(item, 0);
329 }
330
331 static void _gl_Gendial_sel_expand(void *data, Evas_Object *obj,
332                                    void *event_info)
333 {
334         /* SETTING_TRACE_BEGIN; */
335         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
336         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
337         elm_genlist_item_selected_set(item, 0);
338         bool status = !elm_genlist_item_expanded_get(item);
339         elm_genlist_item_expanded_set(item, status);
340 }
341
342 static char *_gl_Gendial_text_get(void *data, Evas_Object *obj,
343                                    const char *part)
344 {
345         /* SETTING_TRACE_BEGIN; */
346         Setting_GenGroupItem_Data *item_data =
347             (Setting_GenGroupItem_Data *) data;
348
349         /* for font size view */
350         if (SWALLOW_Type_1RADIO_1LABLE == item_data->swallow_type) {
351                 char speciliztion[MAX_SPECIALIZITION_LEN] = {0,};
352                 int font_size = -1;
353                 SETTING_TRACE("item_data->chk_status:%d", item_data->chk_status);
354                 if (SYSTEM_SETTINGS_FONT_SIZE_SMALL == item_data->chk_status) {
355                         font_size = LABEL_FONT_SIZE_SMALL;
356                 } else if (SYSTEM_SETTINGS_FONT_SIZE_LARGE == item_data->chk_status) {
357                         font_size = LABEL_FONT_SIZE_LARGE;
358                 } else if (SYSTEM_SETTINGS_FONT_SIZE_HUGE == item_data->chk_status) {
359                         font_size = LABEL_FONT_SIZE_HUGE;
360                 } else if (SYSTEM_SETTINGS_FONT_SIZE_GIANT == item_data->chk_status) {
361                         font_size = LABEL_FONT_SIZE_GIANT;
362                 } else {
363                         font_size = LABEL_FONT_SIZE_NORMAL;
364                 }
365                 SETTING_TRACE("font_size:%d", font_size);
366                 snprintf(speciliztion, sizeof(speciliztion), "<font_size=%d>%s</font_size>",
367                         font_size, _(item_data->keyStr));
368                 return (char *)g_strdup(speciliztion);
369         }
370
371         if (!safeStrCmp(part, "elm.text") || !safeStrCmp(part, "elm.text.1")) { /* title */
372                         return (char *)g_strdup(_(item_data->keyStr));
373
374         } else if (!safeStrCmp(part, "elm.text.2")) {   /* bottom or right */
375                 if (item_data->sub_desc) {
376                         return (char *)g_strdup(item_data->sub_desc);
377                 }
378         }
379
380         return NULL;
381 }
382
383 static Evas_Object *__add_check(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
384 {
385         retv_if(!item_data || !parent, NULL);
386         Evas_Object *check = elm_check_add(parent);
387         elm_check_state_set(check, item_data->chk_status);
388         evas_object_show(check);
389         evas_object_pass_events_set(check, 1);
390         evas_object_propagate_events_set(check, 0);
391
392         item_data->eo_check = check;
393
394         if (item_data->chk_change_cb) {
395                 evas_object_smart_callback_add(check,"changed",item_data->chk_change_cb,item_data);
396         } else {
397                 evas_object_smart_callback_add(check,"changed", __chk_changed, item_data);
398         }
399         return check;
400 }
401 static Evas_Object *__add_check_icon(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
402 {
403         retv_if(!item_data || !parent, NULL);
404         Evas_Object *check = __add_check(item_data, parent);
405
406         Evas_Object *thumb = NULL;
407         if (item_data->r_swallow_path) {
408                 thumb = elm_icon_add(parent);
409                 elm_icon_file_set(thumb,
410                                   item_data->r_swallow_path,
411                                   NULL);
412                 evas_object_size_hint_aspect_set(thumb,
413                                                  EVAS_ASPECT_CONTROL_VERTICAL,
414                                                  1, 1);
415         }
416
417         Evas_Object *layout = elm_layout_add(parent);
418         elm_layout_file_set(layout, SETTING_THEME_EDJ_NAME,
419                             "thumbnail_icon2");
420         evas_object_size_hint_weight_set(layout,
421                                          EVAS_HINT_EXPAND,
422                                          EVAS_HINT_EXPAND);
423         elm_object_part_content_set(layout, "checkbox", check);
424         elm_object_part_content_set(layout, "thumbnail", thumb);
425         evas_object_show(layout);
426         return layout;
427 }
428 static Evas_Object *__add_toggle(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
429 {
430         retv_if(!item_data || !parent, NULL);
431         Evas_Object *check = __add_check(item_data, parent);
432         elm_object_style_set(check, "on&off");
433         return check;
434 }
435 static Evas_Object *__add_multiline_toggle(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
436 {
437         retv_if(!item_data || !parent, NULL);
438         Evas_Object *chk = __add_toggle(item_data, parent);
439         elm_object_style_set(chk, "on&off");
440         return chk;
441 }
442
443 static Evas_Object *__add_radio(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
444 {
445         retv_if(!item_data || !parent, NULL);
446         if (!item_data->rgd) {  /* exceptional handling */
447                 item_data->rgd = elm_radio_add(parent);
448                 elm_radio_state_value_set(item_data->rgd, -1);
449         }
450         Evas_Object *radio = elm_radio_add(parent);
451         elm_radio_state_value_set(radio,
452                                   item_data->chk_status);
453         elm_radio_group_add(radio, item_data->rgd);
454         evas_object_show(radio);
455         item_data->eo_check = radio;
456         if (item_data->chk_change_cb) {
457                 evas_object_smart_callback_add(radio,
458                                                "changed",
459                                                item_data->chk_change_cb,
460                                                item_data);
461         } else {
462                 evas_object_smart_callback_add(radio,
463                                                "changed",
464                                                __radio_changed,
465                                                item_data);
466         }
467         return radio;
468 }
469 static Evas_Object *__add_button(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
470 {
471         retv_if(!item_data || !parent, NULL);
472         Evas_Object *btn = elm_button_add(parent);
473         evas_object_show(btn);
474         if (item_data->r_swallow_path)
475         {
476                 elm_object_style_set(btn, item_data->r_swallow_path);
477         }
478         if (item_data->keyStr)
479         {
480                 elm_object_text_set(btn, _(item_data->keyStr));
481         }
482         evas_object_propagate_events_set(btn, EINA_FALSE);
483         if (item_data->chk_change_cb)
484                 evas_object_smart_callback_add(btn,
485                                                "clicked",
486                                                item_data->chk_change_cb,
487                                                item_data);
488         return btn;
489 }
490
491 static Evas_Object *__add_entry(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
492 {
493         retv_if(!item_data || !parent, NULL);
494         elm_genlist_mode_set(parent, ELM_LIST_COMPRESS);        /* resolve abnormal height issue */
495         Evas_Object *entry = NULL;
496         entry = ea_editfield_add(parent, EA_EDITFIELD_SINGLELINE);
497
498         char* def_str = NULL;
499         def_str = item_data->sub_desc;
500
501         if (def_str && safeStrLen(def_str) > 0) {
502                 elm_entry_entry_set(entry, def_str);
503         } else {
504                 elm_object_part_text_set(entry , "elm.guide", _("IDS_ST_BODY_TAP_TO_INSERT"));
505         }
506
507         evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, 0);
508         evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, 0);
509
510         item_data->eo_check = entry;
511         elm_entry_input_panel_layout_set(entry, item_data->input_type);
512
513         if (item_data->isSinglelineFlag) {
514                 elm_entry_scrollable_set(entry, EINA_TRUE);
515                 elm_entry_single_line_set(entry, EINA_TRUE);
516         }
517
518         if (item_data->isPasswordFlag) {
519                 elm_entry_single_line_set(entry, EINA_TRUE);
520                 elm_entry_password_set(entry, EINA_TRUE);
521         }
522
523         if (item_data->limit_filter_data) {
524                 elm_entry_markup_filter_append (entry,
525                      elm_entry_filter_limit_size,
526                      item_data->limit_filter_data);
527
528                 if (item_data->maxlength_reached_cb) {
529                         evas_object_smart_callback_add(entry, "maxlength,reached", item_data->maxlength_reached_cb, item_data);
530                 } else {
531                         evas_object_smart_callback_add(entry, "maxlength,reached", __max_len_reached, item_data);
532                 }
533         }
534         if (item_data->stop_change_cb) {//invoked when stop focusing on
535                 evas_object_smart_callback_add(entry, "unfocused", item_data->stop_change_cb, item_data);
536         } else {
537                 evas_object_smart_callback_add(entry, "unfocused", __entry_unfocused, item_data);
538         }
539
540         if (item_data->digits_filter_data) {
541                 elm_entry_markup_filter_append ( entry, elm_entry_filter_accept_set, item_data->digits_filter_data);
542         }
543
544         /* for Setting App, All the entrys's context popup shouldn't be able */
545         /* to insert images, text is the only one can be inserted. */
546         elm_entry_cnp_mode_set(entry, ELM_CNP_MODE_PLAINTEXT);
547
548         if (item_data->chk_change_cb) {
549                 evas_object_smart_callback_add (entry, "changed", item_data->chk_change_cb, item_data);
550         }
551         //default handle
552         evas_object_smart_callback_add(entry, "changed", __entry_changed, item_data);
553         evas_object_smart_callback_add(entry, "focused", __entry_focused, entry);
554         elm_object_signal_callback_add(entry, "elm,eraser,clicked", "elm", __eraser_clicked, entry);
555
556         if (item_data->start_change_cb) {
557                 evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN, (Evas_Object_Event_Cb)(item_data->start_change_cb), item_data->userdata);
558         }
559         evas_object_event_callback_add(entry, EVAS_CALLBACK_KEY_DOWN, __entry_keydown, item_data);
560
561         if (item_data->input_panel_disable_flag) {
562                 elm_entry_input_panel_enabled_set(entry, EINA_FALSE);
563         }
564         return entry;
565
566         // ??? 
567         //elm_entry_prediction_allow_set(entry, FALSE);
568 }
569 static Evas_Object *__add_slider(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
570 {
571         retv_if(!item_data || !parent, NULL);
572         Evas_Object *li_slider =
573             setting_create_slider(parent, item_data->evas,
574                                   item_data->l_swallow_path,
575                                   item_data->r_swallow_path,
576                                   item_data->chk_status,
577                                   item_data->isIndicatorVisible,
578                                   item_data->slider_min,
579                                   item_data->slider_max,
580                                   item_data->chk_change_cb,
581                                   item_data->start_change_cb,
582                                   item_data->stop_change_cb,
583                                   item_data);
584         evas_object_pass_events_set(li_slider, 1);
585         evas_object_propagate_events_set(li_slider, 0);
586         item_data->eo_check = li_slider;
587         return li_slider;
588 }
589
590 static inline void _datefield_back_cb(void *data, Evas_Object *obj, const char *emission, const char *source)
591 {
592         elm_object_signal_emit(obj, "picker,hide", "");
593 }
594 static void _datefield_edit_start_cb(void *data, Evas_Object *obj, void *event_info)
595 {
596         ea_object_event_callback_add(obj, EA_CALLBACK_BACK, _datefield_back_cb, NULL);
597 }
598
599 static void _datefield_edit_end_cb(void *data, Evas_Object *obj, void *event_info)
600 {
601         ea_object_event_callback_del(obj, EA_CALLBACK_BACK, _datefield_back_cb);
602 }
603
604 static Evas_Object *__add_datefield(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
605 {
606         retv_if(!item_data || !parent, NULL);
607         /* **********create time/date field */
608         Evas_Object *datetimefield = item_data->eo_check = elm_datetime_add(parent);
609         evas_object_size_hint_weight_set(datetimefield, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
610         evas_object_size_hint_align_set(datetimefield, EVAS_HINT_FILL, 0.5);
611         evas_object_show(datetimefield);
612
613         evas_object_pass_events_set(datetimefield, 1);
614         evas_object_propagate_events_set(datetimefield, 0);
615
616         evas_object_smart_callback_add(datetimefield, "edit,start", _datefield_edit_start_cb, NULL);
617         evas_object_smart_callback_add(datetimefield, "edit,end", _datefield_edit_end_cb, NULL);
618
619         char date_format[MAX_DATETIME_FORMAT_LEN + 1] = {0, };
620         const char *time_format = NULL;
621         if (item_data->chk_status)//12 hours
622         {
623                 time_format = "%I : %M %p";
624         } else { //24 hours
625                 time_format = "%H : %M";
626         }
627
628 #if SUPPORT_DATEFIELD_DATE_FORMAT_AUTOSET //Get date-format from datefiled itself, if elm_datetime_add() supports set date-format via ICU.
629         char *old_format = elm_datetime_format_get(datetimefield);
630         snprintf(date_format, MAX_DATE_FORMAT_LEN + 1, //add one space " "
631                  "%s", old_format);
632         safeStrNCat(date_format, time_format, MAX_DATETIME_FORMAT_LEN);
633         FREE(old_format);
634         SETTING_TRACE("datefield_format:%s", date_format);
635 #else
636         snprintf(date_format, MAX_DATETIME_FORMAT_LEN,
637                  "%s %s", item_data->sub_desc, time_format);
638 #endif
639         elm_datetime_format_set(datetimefield, date_format);
640
641         // min : 1970 1, 01, Thursday 00:00:00
642         // max : 2038 1, 19, Thursday 03:14:07
643         struct tm ts_ret;
644         memset(&ts_ret, 0, sizeof(struct tm));
645         ts_ret.tm_year = 138;
646         ts_ret.tm_mon = 1;
647         ts_ret.tm_mday = 19;
648         elm_datetime_value_max_set(datetimefield, &ts_ret);
649
650         ts_ret.tm_year = 70;
651         ts_ret.tm_mon = 0;
652         ts_ret.tm_mday = 1;
653         elm_datetime_value_min_set(datetimefield, &ts_ret);
654
655
656         time_t ctime = time(NULL);
657         //struct tm ts_ret;
658         struct tm *ts = localtime_r(&ctime, &ts_ret);
659         retv_if(!ts, NULL);
660
661         elm_datetime_value_set(datetimefield, &ts_ret);
662
663         if (item_data->chk_change_cb) {
664                 evas_object_smart_callback_add(datetimefield,
665                                                "changed",
666                                                item_data->chk_change_cb,
667                                                item_data);
668         }
669
670         if (item_data->isItemDisableFlag) {
671                 setting_disable_evas_object(datetimefield);
672         }
673         return datetimefield;
674 }
675 static Evas_Object *__add_radio_search(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
676 {
677         retv_if(!item_data || !parent, NULL);
678         Evas_Object *box = elm_box_add(parent);
679         elm_box_horizontal_set(box, 1);
680
681         //a.radio..
682         Evas_Object *radio = __add_radio(item_data, parent);
683         setting_disable_evas_object(radio);
684         elm_box_pack_end(box, radio);
685
686         //b.separator..
687         Evas_Object *separator =
688                 setting_create_blank_rect_customize(box,
689                                 SETTING_HALF_SCREEN_WIDTH,
690                                 SETTING_PADDING_HEIGHT);
691         elm_box_pack_end(box, separator);
692
693         //c.progressbar..
694         Evas_Object *progressbar = elm_progressbar_add(parent);
695         elm_object_style_set(progressbar, "list_process");
696         evas_object_size_hint_align_set(progressbar,
697                                         EVAS_HINT_FILL, 0.5);
698         evas_object_size_hint_weight_set(progressbar,
699                                          EVAS_HINT_EXPAND,
700                                          EVAS_HINT_EXPAND);
701         elm_progressbar_pulse(progressbar, EINA_TRUE);
702         evas_object_show(progressbar);
703         elm_box_pack_end(box, progressbar);
704
705         evas_object_show(box);
706         return box;
707 }
708 static Evas_Object *__add_search(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
709 {
710         retv_if(!item_data || !parent, NULL);
711         // added by JTS: CQ H0100135171
712         Evas_Object *box = elm_box_add(parent);
713         elm_box_horizontal_set(box, 1);
714
715         //b.separator..
716         Evas_Object *separator =
717                 setting_create_blank_rect_customize(box,
718                 SETTING_HALF_SCREEN_WIDTH, SETTING_PADDING_HEIGHT);
719         elm_box_pack_end(box, separator);
720
721         //c.progressbar..
722         Evas_Object *progressbar = elm_progressbar_add(parent);
723         elm_object_style_set(progressbar, "list_process");
724         evas_object_size_hint_align_set(progressbar, EVAS_HINT_FILL, 0.5);
725         evas_object_size_hint_weight_set(progressbar,
726                                         EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
727         elm_progressbar_pulse(progressbar, EINA_TRUE);
728         evas_object_show(progressbar);
729         elm_box_pack_end(box, progressbar);
730
731         evas_object_show(box);
732         return box;
733
734 }
735 static Evas_Object *__add_process(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
736 {
737         retv_if(!item_data || !parent, NULL);
738         Evas_Object *progressbar = elm_progressbar_add(parent);
739         elm_object_style_set(progressbar, "list_process");
740         evas_object_size_hint_align_set(progressbar,
741                                         EVAS_HINT_FILL, 0.5);
742         evas_object_size_hint_weight_set(progressbar,
743                                          EVAS_HINT_EXPAND,
744                                          EVAS_HINT_EXPAND);
745         elm_progressbar_pulse(progressbar, EINA_TRUE);
746         evas_object_show(progressbar);
747         return progressbar;
748 }
749
750 static Evas_Object *__add_radio_lable(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
751 {
752         retv_if(!item_data || !parent, NULL);
753
754         //a.radio..
755         Evas_Object *radio = __add_radio(item_data, parent);
756
757         return radio;
758 }
759
760 static Evas_Object *__add_left_default(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
761 {
762         retv_if(!item_data || !parent || !item_data->l_swallow_path, NULL);
763         Evas_Object *icon = elm_icon_add(parent);
764         elm_icon_file_set(icon, item_data->l_swallow_path,NULL);
765         evas_object_size_hint_aspect_set(icon,EVAS_ASPECT_CONTROL_VERTICAL,1, 1);
766         return icon;
767 }
768 static Evas_Object *__add_right_default(Setting_GenGroupItem_Data *item_data, Evas_Object *parent)
769 {
770         retv_if(!item_data || !parent || !item_data->r_swallow_path, NULL);
771         Evas_Object *icon = elm_icon_add(parent);
772         elm_icon_file_set(icon, item_data->r_swallow_path,NULL);
773         evas_object_size_hint_aspect_set(icon,EVAS_ASPECT_CONTROL_VERTICAL,1, 1);
774         return icon;
775 }
776
777 // draw handler
778 typedef Evas_Object * (*__drawer_fp)(Setting_GenGroupItem_Data *item_data, Evas_Object *parent);
779 typedef struct
780 {
781         SWALLOW_Type type;                      // ui type
782         __drawer_fp draw;
783 } __Content_Drawer;
784 static __Content_Drawer __cd_left[SWALLOW_Type_MAX] = {
785         //base objects
786         {SWALLOW_Type_1CHECK, __add_check},
787         {SWALLOW_Type_1TOGGLE, __add_toggle},
788         {SWALLOW_Type_1RADIO, __add_radio},
789         {SWALLOW_Type_1BUTTON, __add_button},
790
791         //base objects in an layout
792         {SWALLOW_Type_LAYOUT_ENTRY, __add_entry},
793         {SWALLOW_Type_LAYOUT_SLIDER, __add_slider},
794         {SWALLOW_Type_LAYOUT_DATEFIELD, __add_datefield},
795
796         //other compelx objects
797         {SWALLOW_Type_1SEARCH, __add_search},
798         {SWALLOW_Type_1PROCESS, __add_process},
799         {SWALLOW_Type_MULTILINE_1TOGGLE, __add_multiline_toggle},
800         {SWALLOW_Type_1CHECKICON, __add_check_icon},
801         {SWALLOW_Type_1RADIO_1SEARCH, __add_radio_search},
802         {SWALLOW_Type_1RADIO_1LABLE, __add_radio_lable},
803
804         //left part object of the type
805         {SWALLOW_Type_1ICON_1RADIO, __add_left_default},
806         {SWALLOW_Type_1ICON_1PROCESS, __add_left_default},
807         {SWALLOW_Type_1RADIO_1PROCESS, __add_radio},
808 };
809 static __Content_Drawer __cd_right[SWALLOW_Type_MAX] = {
810         //right part object of the type
811         {SWALLOW_Type_1ICON_1RADIO, __add_toggle},
812         {SWALLOW_Type_1ICON_1PROCESS, __add_process},
813         {SWALLOW_Type_1RADIO_1PROCESS, __add_process},
814 };
815
816 static __Content_Drawer __cd_end[SWALLOW_Type_MAX] = {
817         //end part object of the type
818         {SWALLOW_Type_1RADIO, __add_radio},
819 };
820 /*static __Part_Drawer __pd[__MAX_PART_NUM] = {
821         {"elm.icon", __cd_left},
822         {"elm.icon.1", __cd_left},
823         {"elm.icon.2", __cd_right},
824         {"elm.swallow.end", __cd_end},
825 };*/
826
827 static Evas_Object *_gl_Gendial_content_get(void *data, Evas_Object *obj,
828                                          const char *part)
829 {
830 //      SETTING_TRACE_BEGIN;
831         retv_if(!data, NULL);
832         Setting_GenGroupItem_Data *item_data = data;
833         retv_if(!data, NULL);
834         __Content_Drawer *cd_list = NULL;
835         __drawer_fp fp = NULL;
836         //SETTING_TRACE(" ----> part : %s", part);
837
838         if (!safeStrCmp(part, "elm.icon")
839                 || !safeStrCmp(part, "elm.icon.1")
840                 || !safeStrCmp(part, "elm.icon.entry")
841                 )
842         {
843                 fp = __add_left_default; //hold default drawer
844                 cd_list = __cd_left;
845         }
846         else if (!safeStrCmp(part, "elm.icon.2"))
847         {
848                 fp = __add_right_default; //hold default drawer
849                 cd_list = __cd_right;
850         }
851         else if (!safeStrCmp(part, "elm.swallow.end"))
852         {
853                 //the default value of fp is NULL here
854                 cd_list = __cd_end;
855         }
856         if (!cd_list) return NULL;//invalid part
857
858         int idx = 0;
859         for (; idx < SWALLOW_Type_MAX; idx++)
860         {
861                 if (item_data->swallow_type == cd_list[idx].type)//match using swallow type
862                 {
863                         fp = cd_list[idx].draw;
864                         break;
865                 }
866         }
867         return fp ? fp(item_data, obj) : NULL;
868 }
869
870 static void _gl_Gendial_del(void *data, Evas_Object *obj)
871 {
872         /* SETTING_TRACE_BEGIN; */
873         Setting_GenGroupItem_Data *item_data =
874             (Setting_GenGroupItem_Data *) data;
875         if (item_data) {
876                 G_FREE(item_data->keyStr);
877                 G_FREE(item_data->sub_desc);
878                 G_FREE((item_data->l_swallow_path));
879                 G_FREE((item_data->r_swallow_path));
880                 G_FREE(item_data->item_style);
881
882 #if 1
883                 if (item_data->stop_change_cb)
884                 {
885                         SETTING_TRACE("remove unfocused handler callback");
886                         evas_object_smart_callback_del(item_data->eo_check,
887                                         "unfocused", item_data->stop_change_cb);
888                         item_data->stop_change_cb = NULL;
889                 }
890 #endif
891
892
893                 if (item_data->digits_filter_data)
894                 {
895                         G_FREE(item_data->digits_filter_data->accepted);
896                         G_FREE(item_data->digits_filter_data->rejected);
897                         FREE(item_data->digits_filter_data);
898
899                 }
900
901                 if (item_data->notify) {
902                         evas_object_del(item_data->notify);
903                         item_data->notify = NULL;
904                 }
905
906                 FREE(item_data->limit_filter_data);
907                 __BACK_POINTER_UNSET(item_data);
908                 FREE(item_data);
909         }
910         /* SETTING_TRACE_END; */
911 }
912
913 /**
914  * To intialize an Elm_Genlist_Item_Class, according to item style
915  *
916  * @param[in] item_style
917  * @param[in/out] itc
918  */
919 bool setting_create_Gendial_itc(const char *item_style,
920                                 Elm_Genlist_Item_Class *itc)
921 {
922         itc->item_style = item_style;
923         itc->func.text_get = _gl_Gendial_text_get;
924         itc->func.content_get = _gl_Gendial_content_get;
925         itc->func.state_get = NULL;
926         itc->func.del = _gl_Gendial_del;        /* _gl_Gendial_del; */
927         return TRUE;
928 }
929
930 /**
931  * Create group style item
932  *
933  * @return a pointer to Setting_GenGroupItem_Data
934  */
935 Setting_GenGroupItem_Data *setting_create_Gendial_field_group_titleItem(Evas_Object *genlist,
936                                                 const Elm_Genlist_Item_Class *itc,
937                                                 Elm_Object_Item *parent,
938                                                 Elm_Genlist_Item_Type flag,     /* ELM_GENLIST_ITEM_GROUP or ELM_GENLIST_ITEM_NONE */
939                                                 const char *keyStr,
940                                                 setting_call_back_func gl_sel)
941 {
942         /* SETTING_TRACE_BEGIN; */
943         Setting_GenGroupItem_Data *item_data =
944             (Setting_GenGroupItem_Data *) calloc(1,
945                                                  sizeof
946                                                  (Setting_GenGroupItem_Data));
947         setting_retvm_if(!item_data, NULL, "calloc failed");
948         item_data->keyStr = (char *)g_strdup(keyStr);
949         if (gl_sel) {
950                 item_data->item =
951                     elm_genlist_item_append(genlist, itc, item_data, parent,
952                                             flag, gl_sel, NULL);
953         } else {
954                 item_data->item =
955                     elm_genlist_item_append(genlist, itc, item_data, parent,
956                                             flag, _gl_Gendial_sel, NULL);
957         }
958         return item_data;
959 }
960
961 /**
962  * Create separator style item with title
963  *
964  * @return a pointer to Setting_GenGroupItem_Data
965  */
966 Setting_GenGroupItem_Data *setting_create_Gendial_field_titleItem(
967                                                 Evas_Object *genlist,
968                                                 const Elm_Genlist_Item_Class *itc,
969                                                 const char *keyStr,
970                                                 setting_call_back_func gl_sel)
971 {
972         /* SETTING_TRACE_BEGIN; */
973         Setting_GenGroupItem_Data *item_data =
974             (Setting_GenGroupItem_Data *) calloc(1,
975                                                  sizeof
976                                                  (Setting_GenGroupItem_Data));
977         setting_retvm_if(!item_data, NULL, "calloc failed");
978         item_data->keyStr = (char *)g_strdup(keyStr);
979         if (gl_sel) {
980                 item_data->item =
981                     elm_genlist_item_append(genlist, itc, item_data, NULL,
982                                             ELM_GENLIST_ITEM_NONE, gl_sel,
983                                             NULL);
984         } else {
985                 item_data->item =
986                     elm_genlist_item_append(genlist, itc, item_data, NULL,
987                                             ELM_GENLIST_ITEM_NONE,
988                                             _gl_Gendial_sel, NULL);
989         }
990         return item_data;
991 }
992
993 /**
994  * Create 1radio-1text style item
995  *
996  * @return a pointer to Setting_GenGroupItem_Data
997  */
998
999 Setting_GenGroupItem_Data *setting_create_Gendial_field_1radio(
1000                                         Evas_Object *genlist,
1001                                         const Elm_Genlist_Item_Class *itc,
1002                                         setting_call_back_func gl_sel,
1003                                         void *sel_data,
1004                                         SWALLOW_Type swallow_type,
1005                                         Evas_Object *rgd, int chk_status,
1006                                         const char *keyStr,
1007                                         setting_call_back_func chk_change_cb)
1008 {
1009         /* SETTING_TRACE_BEGIN; */
1010         Setting_GenGroupItem_Data *item_data =
1011             (Setting_GenGroupItem_Data *) calloc(1,
1012                                                  sizeof
1013                                                  (Setting_GenGroupItem_Data));
1014         setting_retvm_if(!item_data, NULL, "calloc failed");
1015         item_data->keyStr = (char *)g_strdup(keyStr);
1016         item_data->swallow_type = swallow_type;
1017         item_data->chk_status = chk_status;
1018         item_data->chk_change_cb = chk_change_cb;
1019         item_data->rgd = rgd;
1020
1021         if (gl_sel) {
1022                 item_data->item =
1023                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1024                                             ELM_GENLIST_ITEM_NONE, gl_sel,
1025                                             sel_data);
1026         } else {
1027                 item_data->item =
1028                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1029                                             ELM_GENLIST_ITEM_NONE,
1030                                             _gl_Gendial_sel, sel_data);
1031         }
1032         return item_data;
1033 }
1034
1035 Setting_GenGroupItem_Data *setting_create_Gendial_field_2radio(
1036                                         Evas_Object *genlist,
1037                                         const Elm_Genlist_Item_Class *itc,
1038                                         setting_call_back_func gl_sel,
1039                                         void *sel_data,
1040                                         SWALLOW_Type swallow_type,
1041                                         Evas_Object *rgd, int chk_status,
1042                                         const char *keyStr,
1043                                         const char *sub_desc,
1044                                         setting_call_back_func chk_change_cb)
1045 {
1046         /* SETTING_TRACE_BEGIN; */
1047         Setting_GenGroupItem_Data *item_data =
1048             (Setting_GenGroupItem_Data *) calloc(1,
1049                                                  sizeof
1050                                                  (Setting_GenGroupItem_Data));
1051         setting_retvm_if(!item_data, NULL, "calloc failed");
1052         item_data->keyStr = (char *)g_strdup(keyStr);
1053         item_data->sub_desc = (char *)g_strdup(sub_desc);
1054         item_data->swallow_type = swallow_type;
1055         item_data->chk_status = chk_status;
1056         item_data->chk_change_cb = chk_change_cb;
1057         item_data->rgd = rgd;
1058
1059         if (gl_sel) {
1060                 item_data->item =
1061                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1062                                             ELM_GENLIST_ITEM_NONE, gl_sel,
1063                                             sel_data);
1064         } else {
1065                 item_data->item =
1066                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1067                                             ELM_GENLIST_ITEM_NONE,
1068                                             _gl_Gendial_sel, sel_data);
1069         }
1070         return item_data;
1071 }
1072
1073 /**
1074  * Create common style item with menu icon
1075  *
1076  * @return a pointer to Setting_GenGroupItem_Data
1077  */
1078 Setting_GenGroupItem_Data *setting_create_Gendial_field_groupitem(
1079                                         Evas_Object *genlist,
1080                                         const Elm_Genlist_Item_Class *itc,
1081                                         Elm_Object_Item *parent,
1082                                         setting_call_back_func gl_sel,
1083                                         void *sel_data,
1084                                         SWALLOW_Type swallow_type,
1085                                         char *l_icon_path,
1086                                         char *r_icon_path, int chk_status,
1087                                         const char *keyStr, char *sub_desc,
1088                                         setting_call_back_func
1089                                         chk_change_cb)
1090 {
1091 //      SETTING_TRACE_BEGIN;
1092         Setting_GenGroupItem_Data *item_data = (
1093                 Setting_GenGroupItem_Data *) calloc(1, sizeof(Setting_GenGroupItem_Data));
1094         setting_retvm_if(!item_data, NULL, "calloc failed");
1095
1096         /* to do formatting customizition in one place */
1097         if (SWALLOW_Type_LAYOUT_SPECIALIZTION == swallow_type
1098             || SWALLOW_Type_LAYOUT_SPECIALIZTION_X == swallow_type) {
1099                 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1100
1101                 char speciliztion[MAX_SPECIALIZITION_LEN] = { 0, };
1102                 char* temp1 = (char *)keyStr;
1103                 char*temp2 = strchr(temp1, '&');
1104                 char* temp = NULL;
1105
1106                 while (NULL != temp2) {
1107                         if (0 == safeStrNCmp(temp2, "&amp;", strlen("&amp;")) ||//'&'
1108                             0 == safeStrNCmp(temp2, "&lt;", strlen("&lt;")) ||//'<'
1109                             0 == safeStrNCmp(temp2, "&gt;", strlen("&gt;")) ||//'>'
1110                             0 == safeStrNCmp(temp2, "&quot;", strlen("&quot;")) ||//double quotes
1111                             0 == safeStrNCmp(temp2, "&apos;", strlen("&apos;")) ||//single quotes
1112                             0 == safeStrNCmp(temp2, "&nbsp;", strlen("&nbsp;")) ||//space character
1113                             0 == safeStrNCmp(temp2, "&copy;", strlen("&copy;")) ||//copyright character
1114                             0 == safeStrNCmp(temp2, "&reg;", strlen("&reg;"))//registeration character
1115                            ) {//escape character,do nothing
1116                            temp = temp2 + 1;
1117                            if ('\0' == temp[0]) break;
1118                            temp2 = strchr(temp, '&');
1119                         }
1120                         else
1121                         {
1122                                 g_strlcat(speciliztion, temp1, temp2 - temp1 +1);
1123                                 g_strlcat(speciliztion, "&amp;", MAX_SPECIALIZITION_LEN);
1124                                 temp1 = temp2 + 1;
1125                                 if ('\0' == temp1[0]) break;
1126                                 temp2 = strchr(temp1, '&');
1127                         }
1128                 }
1129                 if ('\0' != temp1[0]) {
1130                         g_strlcat(speciliztion, temp1, MAX_SPECIALIZITION_LEN);
1131                 }
1132
1133
1134                 item_data->keyStr = (char *)g_strdup(speciliztion);
1135         } else {
1136                 item_data->keyStr = (char *)g_strdup(keyStr);
1137         }
1138
1139         item_data->sub_desc = (char *)g_strdup(sub_desc);
1140         item_data->swallow_type = swallow_type;
1141         item_data->l_swallow_path = (char *)g_strdup(l_icon_path);
1142         item_data->r_swallow_path = (char *)g_strdup(r_icon_path);
1143         item_data->chk_status = chk_status;
1144         item_data->chk_change_cb = chk_change_cb;
1145
1146         if (gl_sel) {
1147                 item_data->item =
1148                     elm_genlist_item_append(genlist, itc, item_data, parent,
1149                                             ELM_GENLIST_ITEM_NONE, gl_sel,
1150                                             sel_data);
1151         } else {
1152                 item_data->item =
1153                     elm_genlist_item_append(genlist, itc, item_data, parent,
1154                                             ELM_GENLIST_ITEM_NONE,
1155                                             _gl_Gendial_sel, sel_data);
1156
1157                 //help text clicking issue
1158                 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1159         }
1160         if (SWALLOW_Type_LAYOUT_SPECIALIZTION == swallow_type) {
1161                 Elm_Object_Item *item = elm_genlist_item_append(genlist,
1162                                                                 &(itc_sep_line),
1163                                                                 NULL, NULL,
1164                                                                 ELM_GENLIST_ITEM_NONE,
1165                                                                 NULL, NULL);
1166                 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1167                 //Fix the separator line disappear issue when clicking "SPECIALIZTION" words in new HD theme
1168                 elm_genlist_item_select_mode_set(item_data->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1169         }
1170
1171         return item_data;
1172 }
1173
1174 /**
1175  * Common function to create a genlist item
1176  * @return a pointer to Setting_GenGroupItem_Data
1177  */
1178 Setting_GenGroupItem_Data *setting_create_Gendial_field_def(Evas_Object *
1179                                                             genlist,
1180                                                             const Elm_Genlist_Item_Class *itc,
1181                                                             setting_call_back_func
1182                                                             gl_sel,
1183                                                             void *sel_data,
1184                                                             SWALLOW_Type
1185                                                             swallow_type,
1186                                                             char *l_icon_path,
1187                                                             char *r_icon_path,
1188                                                             int chk_status,
1189                                                             const char *keyStr,
1190                                                             char *sub_desc,
1191                                                             setting_call_back_func chk_change_cb)
1192 {
1193         return setting_create_Gendial_field_groupitem(genlist, itc, NULL,
1194                                                       gl_sel, sel_data,
1195                                                       swallow_type, l_icon_path,
1196                                                       r_icon_path, chk_status,
1197                                                       keyStr, sub_desc,
1198                                                       chk_change_cb);
1199 }
1200
1201 /**
1202  * Create 1entry style item
1203  * @return a pointer to Setting_GenGroupItem_Data
1204  */
1205 Setting_GenGroupItem_Data *setting_create_Gendial_field_entry(
1206                                                                   Evas_Object * genlist,
1207                                                               const Elm_Genlist_Item_Class *itc,
1208                                                               setting_call_back_func gl_sel,
1209                                                               void *sel_data,
1210                                                               SWALLOW_Type swallow_type,
1211                                                               char *l_icon_path,
1212                                                               char *r_icon_path,
1213                                                               int chk_status,
1214                                                               const char *keyStr,
1215                                                               char *sub_desc,
1216                                                               setting_call_back_func chk_change_cb,
1217                                                               Elm_Input_Panel_Layout input_type,
1218                                                               bool isPasswordFlag,
1219                                                               bool isFocusFlag,
1220                                                               int max_char_count,
1221                                                               int max_byte_count,
1222                                                               char *accepted,
1223                                                               char *rejected)
1224 {
1225         /* SETTING_TRACE_BEGIN; */
1226         Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *) calloc(1, sizeof (Setting_GenGroupItem_Data));
1227         setting_retvm_if(!item_data, NULL, "calloc failed");
1228         item_data->keyStr = (char *)g_strdup(keyStr);
1229         item_data->sub_desc = (char *)g_strdup(sub_desc);
1230         item_data->swallow_type = swallow_type;
1231         item_data->l_swallow_path = (char *)g_strdup(l_icon_path);
1232         item_data->r_swallow_path = (char *)g_strdup(r_icon_path);
1233         item_data->chk_status = chk_status;
1234         item_data->chk_change_cb = chk_change_cb;
1235
1236     //setting_call_back_func chk_focus_out_cb,
1237
1238
1239         item_data->input_type = input_type;
1240         item_data->isPasswordFlag = isPasswordFlag;
1241         item_data->isFocusFlag = isFocusFlag;
1242
1243         Elm_Entry_Filter_Accept_Set *digits_filter_data =
1244             (Elm_Entry_Filter_Accept_Set *) calloc(1, sizeof (Elm_Entry_Filter_Accept_Set));
1245         if(!digits_filter_data) {
1246                 SETTING_TRACE_ERROR("calloc Elm_Entry_Filter_Accept_Set failed");
1247                 // free allocated data
1248                 G_FREE(item_data->keyStr);
1249                 G_FREE(item_data->sub_desc);
1250                 G_FREE(item_data->l_swallow_path);
1251                 G_FREE(item_data->r_swallow_path);
1252                 FREE(item_data);
1253                 return NULL;
1254         }
1255
1256
1257         Elm_Entry_Filter_Limit_Size *limit_filter_data =
1258             (Elm_Entry_Filter_Limit_Size *) calloc(1, sizeof (Elm_Entry_Filter_Limit_Size));
1259         if(!limit_filter_data) {
1260                 SETTING_TRACE_ERROR("calloc Elm_Entry_Filter_Limit_Size failed");
1261
1262                 // free allocated data
1263                 G_FREE(item_data->keyStr);
1264                 G_FREE(item_data->sub_desc);
1265                 G_FREE(item_data->l_swallow_path);
1266                 G_FREE(item_data->r_swallow_path);
1267                 FREE(item_data);
1268                 FREE(digits_filter_data);
1269                 return NULL;
1270         }
1271
1272         limit_filter_data->max_char_count = max_char_count;
1273         limit_filter_data->max_byte_count = max_byte_count;
1274         digits_filter_data->accepted = (char *)g_strdup(accepted);
1275         digits_filter_data->rejected = (char *)g_strdup(rejected);
1276
1277         item_data->digits_filter_data = digits_filter_data;
1278         item_data->limit_filter_data = limit_filter_data;
1279         item_data->userdata = sel_data;
1280
1281         if (gl_sel) {
1282                 item_data->item =
1283                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1284                                             ELM_GENLIST_ITEM_NONE, gl_sel,
1285                                             sel_data);
1286         } else {
1287                 item_data->item =
1288                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1289                                             ELM_GENLIST_ITEM_NONE,
1290                                             _gl_Gendial_sel, sel_data);
1291         }
1292         return item_data;
1293 }
1294
1295 /**
1296  * Create 1entry style item
1297  * focus out
1298  * @return a pointer to Setting_GenGroupItem_Data
1299  */
1300 Setting_GenGroupItem_Data *setting_create_Gendial_field_entry_fo(
1301                                                                   Evas_Object * genlist,
1302                                                               const Elm_Genlist_Item_Class *itc,
1303                                                               setting_call_back_func gl_sel,
1304                                                               void *sel_data,
1305                                                               SWALLOW_Type swallow_type,
1306                                                               char *l_icon_path,
1307                                                               char *r_icon_path,
1308                                                               int chk_status,
1309                                                               const char *keyStr,
1310                                                               char *sub_desc,
1311                                                               setting_call_back_func chk_change_cb,
1312                                                               setting_call_back_func chk_focus_out_cb,
1313                                                               Elm_Input_Panel_Layout input_type,
1314                                                               bool isPasswordFlag,
1315                                                               bool isFocusFlag,
1316                                                               int min_char_count,
1317                                                               int max_char_count,
1318                                                               int max_byte_count,
1319                                                               char *accepted,
1320                                                               char *rejected)
1321 {
1322         /* SETTING_TRACE_BEGIN; */
1323         Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *) calloc(1, sizeof (Setting_GenGroupItem_Data));
1324         setting_retvm_if(!item_data, NULL, "calloc failed");
1325         item_data->keyStr = (char *)g_strdup(keyStr);
1326         item_data->sub_desc = (char *)g_strdup(sub_desc);
1327         item_data->swallow_type = swallow_type;
1328         item_data->l_swallow_path = (char *)g_strdup(l_icon_path);
1329         item_data->r_swallow_path = (char *)g_strdup(r_icon_path);
1330         item_data->chk_status = chk_status;
1331         item_data->chk_change_cb = chk_change_cb;
1332         item_data->stop_change_cb = chk_focus_out_cb;
1333         item_data->isSinglelineFlag = true;
1334
1335         item_data->input_type = input_type;
1336         item_data->isPasswordFlag = isPasswordFlag;
1337         item_data->isFocusFlag = isFocusFlag;
1338
1339         Elm_Entry_Filter_Accept_Set *digits_filter_data =
1340             (Elm_Entry_Filter_Accept_Set *) calloc(1, sizeof (Elm_Entry_Filter_Accept_Set));
1341         if(!digits_filter_data) {
1342                 SETTING_TRACE_ERROR("calloc Elm_Entry_Filter_Accept_Set failed");
1343                 // free allocated data
1344                 G_FREE(item_data->keyStr);
1345                 G_FREE(item_data->sub_desc);
1346                 G_FREE(item_data->l_swallow_path);
1347                 G_FREE(item_data->r_swallow_path);
1348                 FREE(item_data);
1349                 return NULL;
1350         }
1351
1352         Elm_Entry_Filter_Limit_Size *limit_filter_data =
1353             (Elm_Entry_Filter_Limit_Size *) calloc(1, sizeof (Elm_Entry_Filter_Limit_Size));
1354         if(!limit_filter_data) {
1355                 SETTING_TRACE_ERROR("calloc Elm_Entry_Filter_Limit_Size failed");
1356
1357                 // free allocated data
1358                 G_FREE(item_data->keyStr);
1359                 G_FREE(item_data->sub_desc);
1360                 G_FREE(item_data->l_swallow_path);
1361                 G_FREE(item_data->r_swallow_path);
1362                 FREE(item_data);
1363                 FREE(digits_filter_data);
1364                 return NULL;
1365         }
1366
1367         limit_filter_data->max_char_count = max_char_count;
1368         limit_filter_data->max_byte_count = max_byte_count;
1369         digits_filter_data->accepted = (char *)g_strdup(accepted);
1370         digits_filter_data->rejected = (char *)g_strdup(rejected);
1371
1372         item_data->digits_filter_data = digits_filter_data;
1373         item_data->limit_filter_data = limit_filter_data;
1374         item_data->userdata = sel_data;
1375
1376         item_data->minlength = min_char_count;
1377
1378         if (gl_sel) {
1379                 item_data->item =
1380                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1381                                             ELM_GENLIST_ITEM_NONE, gl_sel,
1382                                             sel_data);
1383         } else {
1384                 item_data->item =
1385                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1386                                             ELM_GENLIST_ITEM_NONE,
1387                                             _gl_Gendial_sel, sel_data);
1388         }
1389         return item_data;
1390 }
1391
1392 /**
1393  * General function to create a parent item of expandable item
1394  *
1395  * @return a pointer to Setting_GenGroupItem_Data
1396  */
1397 Setting_GenGroupItem_Data *setting_create_Gendial_exp_parent_field(
1398                                                 Evas_Object *genlist,
1399                                                 const Elm_Genlist_Item_Class *itc,
1400                                                 setting_call_back_func gl_sel,
1401                                                 void *sel_data,
1402                                                 SWALLOW_Type swallow_type,
1403                                                 const char *keyStr,
1404                                                 char *sub_desc)
1405 {
1406         /* SETTING_TRACE_BEGIN; */
1407         Setting_GenGroupItem_Data *item_data =
1408             (Setting_GenGroupItem_Data *) calloc(1,
1409                                                  sizeof
1410                                                  (Setting_GenGroupItem_Data));
1411         setting_retvm_if(!item_data, NULL, "calloc failed");
1412         item_data->keyStr = (char *)g_strdup(keyStr);
1413         item_data->sub_desc = (char *)g_strdup(sub_desc);
1414         item_data->swallow_type = swallow_type;
1415
1416         if (gl_sel) {
1417                 item_data->item =
1418                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1419                                             ELM_GENLIST_ITEM_TREE, gl_sel,
1420                                             sel_data);
1421         } else {
1422                 item_data->item =
1423                     elm_genlist_item_append(genlist, itc, item_data, NULL,
1424                                             ELM_GENLIST_ITEM_TREE,
1425                                             _gl_Gendial_sel_expand, sel_data);
1426         }
1427         return item_data;
1428 }
1429
1430 /**
1431  * General function to create a subitem of expandable item
1432  *
1433  * @return a pointer to Setting_GenGroupItem_Data
1434  */
1435 Setting_GenGroupItem_Data *setting_create_Gendial_exp_sub_field(
1436                                         Evas_Object *genlist,
1437                                         const Elm_Genlist_Item_Class *itc,
1438                                         setting_call_back_func gl_sel,
1439                                         void *sel_data,
1440                                         Elm_Object_Item *parent,
1441                                         SWALLOW_Type swallow_type,
1442                                         Evas_Object *rgd, int chk_status,
1443                                         const char *keyStr,
1444                                         setting_call_back_func
1445                                         chk_change_cb)
1446 {
1447         /* SETTING_TRACE_BEGIN; */
1448         Setting_GenGroupItem_Data *item_data =
1449             (Setting_GenGroupItem_Data *) calloc(1,
1450                                                  sizeof
1451                                                  (Setting_GenGroupItem_Data));
1452         setting_retvm_if(!item_data, NULL, "calloc failed");
1453         item_data->keyStr = (char *)g_strdup(keyStr);
1454         item_data->swallow_type = swallow_type;
1455         item_data->chk_status = chk_status;
1456         item_data->rgd = rgd;
1457
1458         if (!gl_sel) {
1459                 gl_sel = setting_sub_list_sel_cb;
1460         }
1461         if (!chk_change_cb) {
1462                 chk_change_cb = setting_sub_list_rd_change;
1463         }
1464
1465         item_data->chk_change_cb = chk_change_cb;
1466         item_data->item =
1467             elm_genlist_item_append(genlist, itc, item_data, parent,
1468                                     ELM_GENLIST_ITEM_NONE, gl_sel, sel_data);
1469         return item_data;
1470 }
1471
1472 /**
1473  * To make genlist support expandable style item
1474  */
1475 void setting_enable_expandable_genlist(Evas_Object *genlist, void *data,
1476                                        setting_call_back_func gl_exp_cb,
1477                                        setting_call_back_func gl_smart_cb)
1478 {
1479         ret_if(NULL == genlist);
1480         elm_genlist_tree_effect_enabled_set(genlist, TRUE);
1481         if (!gl_smart_cb) {
1482                 gl_smart_cb = __exp_list_smart_cb;
1483         }
1484
1485         if (gl_exp_cb)
1486                 evas_object_smart_callback_add(genlist, "expanded", gl_exp_cb, data);
1487         evas_object_smart_callback_add(genlist, "contracted", gl_smart_cb, "contracted");
1488
1489         evas_object_smart_callback_add(genlist, "drag", gl_smart_cb, "drag");
1490         evas_object_smart_callback_add(genlist, "longpressed", gl_smart_cb, "longpressed");
1491 }
1492
1493 /*
1494 example:
1495
1496 setting_create_Gendial_itc("dialogue/1text.2icon.2",
1497                                                         &(networkUG->itc_1text_2icon));
1498
1499 1. create a process genlist item : [intial state is 'PROCESS']
1500 ad->data_searching_net = setting_create_Gendial_field_1radio(scroller, &(ad->itc_1text_2icon),
1501                                                 setting_network_select_network_mouse_up_Gendial_list_radio_cb, ad,
1502                                                 SWALLOW_Type_1RADIO_1PROCESS,
1503                                                 ad->chk_sel, TAPI_NETWORK_SELECTIONMODE_MANUAL,
1504                                                 "Searching..", NULL);
1505 or [intial state is 'UNPROCESS']
1506 ad->data_searching_net = setting_create_Gendial_field_1radio(scroller, &(ad->itc_1text_2icon),
1507                                                 setting_network_select_network_mouse_up_Gendial_list_radio_cb, ad,
1508                                                 SWALLOW_Type_1RADIO,
1509                                                 ad->chk_sel, TAPI_NETWORK_SELECTIONMODE_MANUAL,
1510                                                 "Searching..", NULL);
1511
1512 2. to set the PROCESS state at any place as you like:
1513 setting_begin_progress_genlist_item(ad->data_searching_net); -- change from UNPROCESS->PROCESS
1514 setting_finish_progress_genlist_item(ad->data_searching_net);--change from PROCESS->UNPROCESS
1515 */
1516 void setting_begin_progress_genlist_item(Setting_GenGroupItem_Data *data_item)
1517 {
1518         if (data_item) {
1519                 if (SWALLOW_Type_1RADIO != data_item->swallow_type) {
1520                         return;
1521                 }
1522
1523                 data_item->swallow_type = SWALLOW_Type_1RADIO_1PROCESS;
1524                 elm_object_item_data_set(data_item->item, data_item);
1525                 elm_genlist_item_update(data_item->item);
1526         }
1527 }
1528
1529 void setting_finish_progress_genlist_item(Setting_GenGroupItem_Data *data_item)
1530 {
1531         if (data_item) {
1532                 if (SWALLOW_Type_1RADIO_1PROCESS != data_item->swallow_type) {
1533                         return;
1534                 }
1535                 data_item->swallow_type = SWALLOW_Type_1RADIO;
1536                 elm_object_item_data_set(data_item->item, data_item);
1537                 elm_genlist_item_update(data_item->item);
1538         }
1539 }
1540
1541 /**
1542 * Check if some item is selected in done-list
1543 */
1544
1545 bool setting_done_list_is_some_item_selected(Setting_Done_List_Data *list_data)
1546 {
1547         SETTING_TRACE_BEGIN;
1548         bool isFound = FALSE;   /* wether can found some item checked */
1549         int idx = 0;
1550         for (; idx < list_data->cur_item_num; idx++) {
1551                 if (list_data->chk_items[idx].data_GenItem->chk_status) {
1552                         isFound = TRUE;
1553                         break;
1554                 }
1555         }
1556         return isFound;
1557 }
1558
1559 static void __setting_done_list_item_sel(void *data)
1560 {
1561         SETTING_TRACE_BEGIN;
1562         retm_if(data == NULL, "data == NULL");
1563         Setting_Done_List_Data *list_data = (Setting_Done_List_Data *)data;
1564
1565         int sel_num = 0;
1566         int idx = 0;
1567
1568         setting_create_sel_info_popup(list_data->ly_parent,
1569                                       &(list_data->selInfoPop_layout),
1570                                       &(list_data->selInfoPop));
1571
1572         /* else for other checks, do rotinue checking */
1573         bool isFound = FALSE;   /* wether found the item not checked */
1574         for (idx = 0; idx < list_data->cur_item_num; idx++) {
1575                 if (!list_data->chk_items[idx].data_GenItem->chk_status) {
1576                         /* SETTING_TRACE("%s not select", _(list_data->chk_items[idx].item_name)); */
1577                         isFound = TRUE;
1578                         /* break; */
1579                 } else {
1580                         /* SETTING_TRACE("%s select", _(list_data->chk_items[idx].item_name)); */
1581                         sel_num++;
1582                 }
1583         }
1584
1585         if (isFound) {  /* reset state of chk_sel_all */
1586                 list_data->select_all_checked = 0;
1587                 elm_check_state_pointer_set(list_data->select_all_checkbox, &list_data->select_all_checked);
1588         } else {
1589                 list_data->select_all_checked = 1;
1590                 elm_check_state_pointer_set(list_data->select_all_checkbox, &list_data->select_all_checked);
1591         }
1592
1593         /* SETTING_TRACE("sel_num:%d", sel_num); */
1594         if (!sel_num) {
1595                 if (list_data->navi_it) {
1596                         Evas_Object  *button = elm_object_item_part_content_get(list_data->navi_it, "toolbar_button1");
1597                         elm_object_disabled_set(button, EINA_TRUE);
1598                 }
1599                 evas_object_hide(list_data->selInfoPop);
1600                 return;
1601         }
1602
1603         char text[MAX_DISPLAY_NAME_LEN_ON_UI +1] = {0, };
1604         snprintf(text, MAX_DISPLAY_NAME_LEN_ON_UI, "%s (%d)", _("IDS_ST_OPT_SELECTED"), sel_num);
1605
1606         /*  text set and timeout set */
1607         edje_object_part_text_set(_EDJ(list_data->selInfoPop_layout), "elm.text", text);
1608
1609         if (list_data->navi_it) {
1610                 Evas_Object  *button = elm_object_item_part_content_get(list_data->navi_it, "toolbar_button1");
1611                 elm_object_disabled_set(button, EINA_FALSE);
1612         }
1613 }
1614
1615 /**
1616 * Do process when clicking the check object in the done-list item
1617 */
1618 void setting_done_list_Gendial_chk_btn_cb(void *data, Evas_Object *obj,
1619                                           void *event_info)
1620 {
1621         SETTING_TRACE_BEGIN;
1622         /* error check */
1623         retm_if(data == NULL, "Data parameter is NULL");
1624         Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
1625
1626         /* new status */
1627         list_item->chk_status = elm_check_state_get(list_item->eo_check);
1628
1629         Setting_Done_List_Data *list_data = list_item->userdata;
1630         __setting_done_list_item_sel(list_data);
1631 }
1632
1633 static void setting_done_list_Gendial_mouse_up_cb(void *data, Evas_Object *obj,
1634                                                   void *event_info)
1635 {
1636         /* error check */
1637         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
1638         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
1639         elm_genlist_item_selected_set(item, 0);
1640         Setting_GenGroupItem_Data *list_item =
1641             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
1642
1643         int old_status = elm_check_state_get(list_item->eo_check);
1644         /* new status */
1645         list_item->chk_status = !old_status;
1646         elm_check_state_set(list_item->eo_check, list_item->chk_status);
1647
1648         /* other process.. */
1649         Setting_Done_List_Data *list_data = list_item->userdata;
1650         __setting_done_list_item_sel(list_data);
1651 }
1652
1653 static void __setting_select_all_done(void *data)
1654 {
1655         SETTING_TRACE_BEGIN;
1656         retm_if(data == NULL, "data == NULL");
1657         Setting_Done_List_Data *list_data = (Setting_Done_List_Data *)data;
1658
1659         int sel_num = 0;
1660         int idx = 0;
1661
1662         setting_create_sel_info_popup(list_data->ly_parent,
1663                                       &(list_data->selInfoPop_layout),
1664                                       &(list_data->selInfoPop));
1665
1666         if (list_data->select_all_checked) {
1667                 /* set all other checks state to be 1 */
1668                 SETTING_TRACE_DEBUG("Select All checked");
1669                 for (idx = 0; idx < list_data->cur_item_num; idx++) {
1670                         list_data->chk_items[idx].data_GenItem->chk_status = 1;
1671                         elm_object_item_data_set(list_data->chk_items[idx].data_GenItem->item, list_data->chk_items [idx].data_GenItem);
1672                         elm_genlist_item_update(list_data->chk_items [idx].data_GenItem->item);
1673                 }
1674                 sel_num = list_data->cur_item_num;
1675         } else {
1676                 SETTING_TRACE_DEBUG("Select All unchecked");
1677                 /* set all other checks state to be 0 */
1678                 for (idx = 0; idx < list_data->cur_item_num; idx++) {
1679                         list_data->chk_items[idx].data_GenItem->chk_status = 0;
1680                         elm_object_item_data_set(list_data->chk_items[idx].data_GenItem->item, list_data->chk_items[idx].data_GenItem);
1681                         elm_genlist_item_update(list_data->chk_items[idx].data_GenItem->item);
1682                 }
1683                 sel_num = 0;
1684         }
1685
1686         /* SETTING_TRACE("sel_num:%d", sel_num); */
1687         if (!sel_num) {
1688                 if (list_data->navi_it) {
1689                         Evas_Object *button = elm_object_item_part_content_get(list_data->navi_it, "toolbar_button1");
1690                         elm_object_disabled_set(button, EINA_TRUE);
1691                 }
1692
1693                 evas_object_hide(list_data->selInfoPop);
1694                 return;
1695         }
1696         char text[MAX_DISPLAY_NAME_LEN_ON_UI +1] = {0, };
1697         snprintf(text, MAX_DISPLAY_NAME_LEN_ON_UI, "%s (%d)", _("IDS_ST_OPT_SELECTED"), sel_num);
1698
1699         /*  text set and timeout set */
1700         edje_object_part_text_set(_EDJ(list_data->selInfoPop_layout), "elm.text", text);
1701
1702         if (list_data->navi_it) {
1703                 Evas_Object *button = elm_object_item_part_content_get(list_data->navi_it, "toolbar_button1");
1704                 elm_object_disabled_set(button, EINA_FALSE);
1705         }
1706 }
1707
1708 static void __setting_select_all_layout_mouse_down_cb(void *data, Evas *evas, Evas_Object *obj, void *event_info)
1709 {
1710         SETTING_TRACE_BEGIN;
1711         retm_if(data == NULL, "data == NULL");
1712         Setting_Done_List_Data *list_data = (Setting_Done_List_Data *)data;
1713
1714         list_data->select_all_checked = !list_data->select_all_checked;
1715         elm_check_state_pointer_set(list_data->select_all_checkbox, &list_data->select_all_checked);
1716
1717         __setting_select_all_done(list_data);
1718 }
1719
1720 static void __setting_select_all_check_changed_cb(void *data, Evas_Object *obj, void *event_info)
1721 {
1722         SETTING_TRACE_BEGIN;
1723         retm_if(data == NULL, "data == NULL");
1724         Setting_Done_List_Data *list_data = (Setting_Done_List_Data *)data;
1725
1726         list_data->select_all_checked = elm_check_state_get(list_data->select_all_checkbox);
1727         elm_check_state_pointer_set(list_data->select_all_checkbox, &list_data->select_all_checked);
1728         __setting_select_all_done(data);
1729 }
1730
1731 /**
1732 * The API to create done-list.
1733 *
1734 * @param[in] list_data
1735 * @return a done-list
1736 */
1737 Evas_Object *setting_create_done_list(Setting_Done_List_Data *list_data)
1738 {
1739         SETTING_TRACE_BEGIN;
1740         retvm_if(list_data == NULL, NULL, "list_data == NULL");
1741         Evas_Object *sub_layout = elm_layout_add(list_data->win_main);
1742         elm_layout_file_set(sub_layout, SETTING_THEME_EDJ_NAME, "search_layout");
1743         evas_object_size_hint_weight_set(sub_layout, EVAS_HINT_EXPAND, 0.0);
1744         evas_object_show(sub_layout);
1745
1746         setting_create_Gendial_itc("1text.1icon.3", &(list_data->itc_1text_1icon));
1747
1748         Evas_Object *select_all_layout = elm_layout_add(sub_layout);
1749         retvm_if(select_all_layout == NULL, NULL, "select_all_layout == NULL");
1750         elm_layout_theme_set(select_all_layout, "genlist", "item", "select_all/default"); //select_all/default
1751         evas_object_size_hint_weight_set(select_all_layout, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
1752         evas_object_size_hint_align_set(select_all_layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
1753         evas_object_event_callback_add(select_all_layout, EVAS_CALLBACK_MOUSE_DOWN, __setting_select_all_layout_mouse_down_cb, list_data);
1754
1755         Eina_Bool select_all_checked = list_data->select_all_checked;
1756         Evas_Object *select_all_checkbox = elm_check_add(select_all_layout);
1757         elm_check_state_pointer_set(select_all_checkbox, &select_all_checked);
1758         evas_object_smart_callback_add(select_all_checkbox, "changed", __setting_select_all_check_changed_cb, list_data);
1759         evas_object_propagate_events_set(select_all_checkbox, EINA_FALSE);
1760         elm_object_part_content_set(select_all_layout, "elm.icon", select_all_checkbox);
1761
1762         list_data->select_all_checkbox = select_all_checkbox;
1763         elm_object_part_text_set(select_all_layout, "elm.text", _(KeyStr_Select_All));
1764
1765         Evas_Object *scroller = elm_genlist_add(list_data->win_main);
1766         retvm_if(scroller == NULL, NULL, "scroller == NULL");
1767         elm_genlist_clear(scroller);    /* first to clear list */
1768
1769         elm_object_part_content_set(sub_layout, "search_list", scroller);
1770         elm_object_part_content_set(sub_layout, "search_bar", select_all_layout);
1771
1772         int index = 0;
1773         for (; index < list_data->cur_item_num; index++) {
1774                 list_data->chk_items[index].data_GenItem =
1775                     setting_create_Gendial_field_def(scroller,
1776                                                      &(list_data->itc_1text_1icon),
1777                                                      setting_done_list_Gendial_mouse_up_cb,
1778                                                      list_data,
1779                                                      SWALLOW_Type_1CHECK, NULL,
1780                                                      NULL, 0,
1781                                                      list_data->chk_items
1782                                                      [index].item_name, NULL,
1783                                                      setting_done_list_Gendial_chk_btn_cb);
1784                 if (list_data->chk_items[index].data_GenItem) {
1785                         list_data->chk_items[index].data_GenItem->userdata = list_data;
1786                 } else {
1787                         SETTING_TRACE_ERROR("list_data->chk_items[index].data_GenItem is NULL");
1788                 }
1789
1790         }
1791
1792         return sub_layout;
1793 }
1794
1795 /**
1796 * To disable a specialized genlist item
1797 *
1798 * @param[in] item
1799 */
1800 void setting_disable_genlist_item(Elm_Object_Item *item)
1801 {
1802         if (item) {
1803                 elm_object_item_disabled_set(item, EINA_TRUE); /* make it be dim displayed */
1804         }
1805 }
1806
1807 /**
1808 * To enable a specialized genlist item
1809 *
1810 * @param[in] item
1811 */
1812 void setting_enable_genlist_item(Elm_Object_Item *item)
1813 {
1814         if (item) {
1815                 elm_object_item_disabled_set(item, EINA_FALSE); /* make it be normally displayed */
1816         }
1817 }
1818