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