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