1. Changed license year
[apps/home/mobileprint.git] / mobileprint / app / pts_setting_view.c
1 /*
2 *  Mobileprint
3 *
4 * Copyright 2012  Samsung Electronics Co., Ltd
5
6 * Licensed under the Flora License, Version 1.1 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9
10 * http://floralicense.org/license/
11
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20 #define _GNU_SOURCE
21 #include <stdio.h>
22 #include <string.h>
23 #include "pt_api.h"
24 #include "mobileprint.h"
25 #include "pts_common.h"
26 #include "pts_main_view.h"
27 #include "pts_setting_view.h"
28
29 static Elm_Genlist_Item_Class itc_normal_options;
30 static Elm_Genlist_Item_Class itc_tree_options;
31 static Elm_Genlist_Item_Class itc_printer;
32 static Elm_Genlist_Item_Class itc_separator;
33
34 static Elm_Genlist_Item_Class itc_paper_size;
35 static Elm_Genlist_Item_Class itc_paper_quality;
36 static Elm_Genlist_Item_Class itc_paper_type;
37 static Elm_Genlist_Item_Class itc_grayscale;
38 static Elm_Genlist_Item_Class itc_page_range;
39 static Elm_Genlist_Item_Class itc_duplex;
40
41 static Evas_Coord touch_x;
42 static Evas_Coord touch_y;
43 static Evas_Object *copies_popup = NULL;
44
45 static void __pts_setting_view_leave_view(pts_appdata_t *ad)
46 {
47         PTS_IF_DEL_OBJ(ad->setting_info.radio_group_paper_size);
48         PTS_IF_DEL_OBJ(ad->setting_info.radio_group_paper_quality);
49         PTS_IF_DEL_OBJ(ad->setting_info.radio_group_paper_type);
50         PTS_IF_DEL_OBJ(ad->setting_info.radio_group_page_range);
51         PTS_IF_DEL_OBJ(ad->setting_info.radio_group_grayscale);
52         PTS_IF_DEL_OBJ(ad->setting_info.radio_group_duplex);
53         elm_naviframe_item_pop_to(ad->main_info.navi_it);
54 }
55
56 /*
57 *  the response callback when click back button
58 */
59 static void __pts_setting_view_btn_back_cb(void *data, Evas_Object *obj, void *event_info)
60 {
61         PTS_TRACE_BEGIN;
62
63         pts_appdata_t *ad = (pts_appdata_t *)data;
64
65         PTS_RET_IF(ad == NULL, "ad is NULL");
66
67         __pts_setting_view_leave_view(ad);
68
69         if (ad->list_info.active_printer == NULL) {
70                 PTS_DEBUG("No active printer. So just exit mobileprint");
71                 pt_deinit();
72                 elm_exit();
73                 PTS_TRACE_END;
74                 return;
75         }
76
77         pts_main_view_update_printer_label(ad);
78         pts_main_view_rotate_image(ad, app_get_device_orientation());
79         PTS_TRACE_END;
80 }
81
82 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
83 {
84         ecore_event_handler_del(data);
85 }
86
87 static void _dismissed_cb(void *data, Evas_Object *obj, void *event_info)
88 {
89         PTS_IF_DEL_OBJ(copies_popup);
90 }
91
92 static void _copies_picker_cb(void *data, Evas_Object *obj, void *event_info)
93 {
94         PTS_TRACE_BEGIN;
95         int copies = 1;
96         pts_appdata_t *ad  = (pts_appdata_t *)data;
97         Elm_Object_Item *item = event_info;
98
99         const char *label = elm_object_item_text_get(item);
100
101         PTS_RET_IF(label == NULL, "label is NULL");
102
103         copies = atoi(label);
104         if (copies == ad->list_info.active_printer->copies) {
105                 PTS_DEBUG("Not changed\n");
106                 PTS_TRACE_END;
107                 return;
108         } else {
109                 PTS_DEBUG("text(%s) is clicked!\n", label);
110                 ad->list_info.active_printer->copies = copies;
111                 elm_genlist_item_selected_set(ad->setting_info.item_paper_copies, EINA_FALSE);
112                 elm_genlist_item_update(ad->setting_info.item_paper_copies);
113
114                 PTS_IF_DEL_OBJ(copies_popup);
115         }
116         PTS_TRACE_END;
117 }
118
119 static void _move_copies_popup(Evas_Object *copies_popup, Evas_Object *win)
120 {
121         Evas_Coord w, h;
122         Evas_Coord x, y;
123
124         evas_object_geometry_get(win, &x, &y, &w, &h);
125         evas_object_move(copies_popup, x+(w*0.06), touch_y);
126 }
127
128 static Eina_Bool _mousedown_cb(void *data, int type, void *event)
129 {
130         Ecore_Event_Mouse_Button *ev = event;
131         touch_x = ev->x;
132         touch_y = ev->y;
133         return ECORE_CALLBACK_CANCEL;
134 }
135
136 static void __on_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
137 {
138         PTS_DEBUG("copies popup show\n");
139 }
140
141 static void __on_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
142 {
143         PTS_DEBUG("copies popup hide\n");
144 }
145
146 /**
147  * Copies picker create
148  */
149 static void _create_copies_popup_timepicker(void *data, Evas_Object *obj, void *event_info)
150 {
151         PTS_TRACE_BEGIN;
152
153         int idx;
154         Evas_Object *diskselector;
155         Evas_Coord w;
156         char buffer[4];
157         char current_selection[4];
158
159         pts_appdata_t *ad  = (pts_appdata_t *)data;
160         elm_genlist_item_selected_set(ad->setting_info.item_paper_copies, EINA_TRUE);
161
162         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
163         if (event_info) {
164                 elm_genlist_item_selected_set(event_info, EINA_FALSE);
165         }
166
167         PTS_IF_DEL_OBJ(copies_popup);
168
169         evas_object_geometry_get(ad->main_info.root_win, NULL, NULL, &w, NULL);
170         copies_popup = elm_ctxpopup_add(ad->main_info.navi);
171         //elm_object_style_set(copies_popup, "timepicker");
172         elm_object_style_set(copies_popup, "datetime/default");
173         evas_object_size_hint_min_set(copies_popup, w, -1);
174         evas_object_size_hint_weight_set(copies_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
175         evas_object_smart_callback_add(copies_popup, "dismissed", _dismissed_cb, copies_popup);
176         evas_object_event_callback_add(copies_popup, EVAS_CALLBACK_SHOW, __on_show, ad);
177         evas_object_event_callback_add(copies_popup, EVAS_CALLBACK_HIDE, __on_hide, ad);
178
179         diskselector = elm_diskselector_add(ad->main_info.navi);
180         elm_diskselector_display_item_num_set(diskselector, 8);
181         //elm_object_style_set(diskselector, "timepicker");
182         elm_object_style_set(diskselector, "datetime/default");
183
184         snprintf(current_selection, 4, "%d", ad->list_info.active_printer->copies);
185
186         for (idx = 1; idx < COPIES_MAX+1; idx++) {
187                 snprintf(buffer, 4, "%d", idx);
188
189                 if (strcmp(current_selection, buffer) == 0) {
190                         item = elm_diskselector_item_append(diskselector, buffer, NULL, _copies_picker_cb, ad);
191                 } else {
192                         elm_diskselector_item_append(diskselector, buffer, NULL, _copies_picker_cb, ad);
193                 }
194         }
195
196         if (item != NULL) {
197                 elm_diskselector_item_selected_set(item, EINA_TRUE);
198         }
199
200         elm_diskselector_round_enabled_set(diskselector, EINA_TRUE);
201         evas_object_size_hint_weight_set(diskselector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
202         evas_object_size_hint_align_set(diskselector, EVAS_HINT_FILL, EVAS_HINT_FILL);
203
204         evas_object_show(diskselector);
205         elm_object_content_set(copies_popup, diskselector);
206
207         elm_ctxpopup_direction_priority_set(copies_popup, ELM_CTXPOPUP_DIRECTION_DOWN,
208                                                                                 ELM_CTXPOPUP_DIRECTION_UP,
209                                                                                 ELM_CTXPOPUP_DIRECTION_LEFT,
210                                                                                 ELM_CTXPOPUP_DIRECTION_RIGHT);
211
212         _move_copies_popup(copies_popup, ad->main_info.root_win);
213         evas_object_show(copies_popup);
214
215         PTS_TRACE_END;
216 }
217
218 /**
219 *  Callback for expandable genlist selection
220 */
221 static void __pts_setting_view_gl_sel(void *data, Evas_Object *obj, void *event_info)
222 {
223         PTS_TRACE_BEGIN;
224
225         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
226         Eina_Bool expand_state = EINA_FALSE;
227         if (event_info) {
228                 elm_genlist_item_selected_set(event_info, EINA_FALSE);
229         }
230
231         expand_state = elm_genlist_item_expanded_get(item);
232         elm_genlist_item_expanded_set(item, !expand_state);
233         PTS_DEBUG("expanded : %d", expand_state);
234
235         PTS_TRACE_END;
236 }
237
238 void pts_setting_view_printer_select_done_cb(void *userdata)
239 {
240         PTS_TRACE_BEGIN;
241         struct appdata *ad = pts_get_appdata();
242
243         Elm_Object_Item *item = (Elm_Object_Item *)userdata;
244         elm_genlist_item_update(item);
245
246         if (ad->list_info.active_printer) {
247                 pts_create_setting_view(ad);
248         }
249
250         PTS_TRACE_END;
251         return;
252 }
253
254 /**
255 *  Callback for expandable genlist selection
256 */
257 static void __pts_setting_view_printer_sel(void *data, Evas_Object *obj, void *event_info)
258 {
259         PTS_TRACE_BEGIN;
260
261         pts_appdata_t *ad = (pts_appdata_t *)data;
262         if (event_info) {
263                 elm_genlist_item_selected_set(event_info, EINA_FALSE);
264         }
265
266         // Launch Print searching module
267         ad->search_info.print_search_mode = PTS_SEARCH_IN_SETTING;
268         ad->search_info.selection_done_cb = pts_setting_view_printer_select_done_cb;
269         ad->search_info.print_search_popup_parent = ad->main_info.navi;
270         ad->search_info.printer_search_user_data = (void *)event_info;
271         pts_search_printer(ad);
272
273         PTS_TRACE_END;
274 }
275
276 /**
277 *  Callback for expandable genlist contract
278 */
279 static void __pts_setting_view_gl_con(void *data, Evas_Object *obj, void *event_info)
280 {
281         Elm_Object_Item *item = event_info;
282         elm_genlist_item_subitems_clear(item);
283 }
284
285 /*
286 *  get the label of the printer information
287 */
288 static char *__pts_setting_view_printer_label_get(void *data, Evas_Object *obj, const char *part)
289 {
290         PTS_TRACE_BEGIN;
291         struct appdata *ad = pts_get_appdata();
292         if (strcmp(part, "elm.text.1") == 0) {
293                 //if (printer != NULL) {
294                 //return strdup(printer->name);
295                 PTS_TRACE_END;
296                 return strdup(_("IDS_PRT_BODY_PRINTER"));
297                 //}
298         } else if (strcmp(part, "elm.text.2") == 0) {
299                 //if (printer != NULL) {
300                 if (ad->list_info.active_printer != NULL) {
301                         char *printer_label = strdup(ad->list_info.active_printer->name);
302                         pts_unstandardization(printer_label);
303                         //return strdup(printer->address);
304                         PTS_TRACE_END;
305                         return printer_label;
306                 } else {
307                         PTS_TRACE_END;
308                         return strdup(PTS_18);
309                 }
310         }
311         PTS_TRACE_END;
312         return NULL;
313 }
314
315 /*
316 *  get the label of the option setting
317 */
318 #define MAX_TMP_BUF 64
319 static char *__pts_setting_view_option_label_get(void *data, Evas_Object *obj, const char *part)
320 {
321         PTS_TRACE_BEGIN;
322         struct appdata *ad = pts_get_appdata();
323         pt_printer_mgr_t *active_printer = ad->list_info.active_printer;
324         pt_print_option_e option_type = (pt_print_option_e)data;
325
326         char buf[MAX_TMP_BUF];
327
328         if (strcmp(part, "elm.text.1") == 0) {
329                 switch (option_type) {
330                 case PT_OPTION_ID_COPIES:
331                         return strdup(_("IDS_PRT_BODY_NUMBEROFCOPIES"));
332                 case PT_OPTION_ID_PAPERSIZE:
333                         return strdup(_("IDS_PRT_BODY_PAPERSIZE"));
334                 case PT_OPTION_ID_RANGE:
335                         return strdup(_("IDS_PRT_BODY_PRINT_RANGE_ABB"));
336                 case PT_OPTION_ID_GRAYSCALE:
337                         return strdup(_("IDS_PRT_BODY_COLOUR"));
338                 case PT_OPTION_ID_QUALITY:
339                         return strdup(_("IDS_PRT_BODY_PRINTSETTINGS_PRINT_QUALITY"));
340                 case PT_OPTION_ID_PAPER:
341                         return strdup(_("IDS_IMGE_BUTTON_PAPER_M_STICKER"));
342                 case PT_OPTION_ID_DUPLEX:
343                         return strdup(IDS_PRINT_SETTINGS_DUPLEX);
344                 default:
345                         return strdup(PTS_17);
346                 }
347         } else if (strcmp(part, "elm.text.2") == 0) {
348
349                 switch (option_type) {
350                 case PT_OPTION_ID_COPIES: {
351                         snprintf(buf, MAX_TMP_BUF, "%d", active_printer->copies);
352                         PTS_DEBUG("Selected copies[%d, %s]",active_printer->copies, buf);
353                 }
354                 break;
355                 case PT_OPTION_ID_PAPERSIZE: {
356                         active_printer->size = pt_get_selected(PT_OPTION_ID_PAPERSIZE);
357                         strncpy(buf, pt_get_print_option_papersize(active_printer->size), MAX_TMP_BUF-1);
358                         PTS_DEBUG("Selected paper size[%d, %s]", active_printer->size, buf);
359                 }
360                 break;
361                 case PT_OPTION_ID_RANGE: {
362                         pt_range_e p_range = active_printer->range;
363                         if (PT_RANGE_ALL == p_range) {
364                                 strcpy(buf, _("IDS_DIC_BODY_ALL"));
365                         } else {
366                                 strcpy(buf, _("IDS_BR_BODY_CURRENT_PAGE"));
367                         }
368                         PTS_DEBUG("Selected range[%d, %s]", p_range, buf);
369                 }
370                 break;
371                 case PT_OPTION_ID_GRAYSCALE: {
372                         int p_grayscale = pt_get_selected(PT_OPTION_ID_GRAYSCALE);
373
374                         if (PT_GRAYSCALE_COLOUR == p_grayscale) {
375                                 strcpy(buf, _("IDS_PRT_BODY_COLOUR"));
376                         } else if (PT_GRAYSCALE_GRAYSCALE == p_grayscale) {
377                                 strcpy(buf, _("IDS_IMGE_HEADER_GREY"));
378                         } /* else if (PT_GRAYSCALE_BLACKNWHITE == *p_value) {
379 strcpy(buf, _("IDS_BR_OPT_BLACKNWHITE"));
380 } */
381
382                         PTS_DEBUG("Selected color [%d, %s]", p_grayscale, buf);
383                 }
384                 break;
385                 case PT_OPTION_ID_QUALITY: {
386                         int p_quality = pt_get_selected(PT_OPTION_ID_QUALITY);
387                         if (PT_QUALITY_DRAFT == p_quality) {
388                                 strcpy(buf, _("IDS_PRT_OPT_PRINTSETTINGS_DRAFT"));
389                         } else if (PT_QUALITY_STANDARD == p_quality) {
390                                 strcpy(buf, _("IDS_PRT_OPT_PRINTSETTINGS_STANDARD"));
391                         } else if (PT_QUALITY_HIGH == p_quality) {
392                                 strcpy(buf, _("IDS_COM_BODY_HIGH"));
393                         }
394                         PTS_DEBUG("Selected quality [%d, %s]", p_quality, buf);
395                 }
396                 break;
397                 case PT_OPTION_ID_PAPER: {
398                         int p_type = pt_get_selected(PT_OPTION_ID_PAPER);
399                         if (PT_PAPER_NORMAL == p_type) {
400                                 strcpy(buf, _("IDS_ST_BODY_NORMAL"));
401                         } else if (PT_PAPER_GLOSSY == p_type) {
402                                 strcpy(buf, _("IDS_ST_BODY_GLOSSY"));
403                         } else if (PT_PAPER_PHOTO == p_type) {
404                                 strcpy(buf, _("IDS_PRT_BODY_PHOTOGRAPHIC_ABB"));
405                         }
406                         PTS_DEBUG("Selected paper type [%d, %s]", p_type, buf);
407                 }
408                 break;
409                 case PT_OPTION_ID_DUPLEX: {
410                         int p_dup = pt_get_selected(PT_OPTION_ID_DUPLEX);
411                         if (PT_DUPLEX_OFF == p_dup) {
412                                 strcpy(buf, IDS_PRINT_SETTINGS_DUPLEX_OFF);
413                         } else if (PT_DUPLEX_NO_TUMBLE == p_dup || PT_DUPLEX_TUMBLE == p_dup) {
414                                 strcpy(buf, IDS_PRINT_SETTINGS_DUPLEX_ON);
415                         }
416                         PTS_DEBUG("Selected duplex mode [%d, %s]", p_dup, buf);
417                 }
418                 break;
419                 default: {
420                         return strdup(PTS_17);
421                 }
422                 }
423
424                 return strdup(buf);
425         }
426         PTS_TRACE_END;
427         return NULL;
428 }
429
430
431
432 static Evas_Object *
433 __pts_setting_view_gl_content_get(void *data, Evas_Object *obj, const char *part)
434 {
435         PTS_TRACE_BEGIN;
436         pts_appdata_t *ad = pts_get_appdata();
437         Evas_Object *radio_button = NULL;
438         Item_data *core = (Item_data *)data;
439         int selected = 0;
440
441         if (!strcmp(part, "elm.icon")) {
442                 switch (core->option) {
443                 case PT_OPTION_ID_PAPERSIZE:
444                         selected = pt_get_selected(PT_OPTION_ID_PAPERSIZE);
445                         break;
446                 case    PT_OPTION_ID_RANGE:
447                         selected = ad->list_info.active_printer->range;
448                         break;
449                 case    PT_OPTION_ID_QUALITY:
450                         selected = pt_get_selected(PT_OPTION_ID_QUALITY);
451                         break;
452                 case    PT_OPTION_ID_PAPER:
453                         selected = pt_get_selected(PT_OPTION_ID_PAPER);
454                         break;
455                 case    PT_OPTION_ID_GRAYSCALE:
456                         selected = pt_get_selected(PT_OPTION_ID_GRAYSCALE);
457                         break;
458                 case PT_OPTION_ID_DUPLEX:
459                         selected = pt_get_selected(PT_OPTION_ID_DUPLEX);
460                         break;
461                         /* case    PT_OPTION_ID_COPIES: */
462                 default:
463                         break;
464                 }
465
466                 PTS_DEBUG("Create Radio button[%d] (%d,%d) , r_group= [0x%x] selected: %d",
467                         core->radio_index, core->option, core->sub_item, core->radio_group, selected);
468
469                 radio_button  = elm_radio_add(obj);
470                 core->radio_btn = radio_button;
471                 evas_object_propagate_events_set(radio_button, EINA_TRUE);
472                 elm_radio_state_value_set(radio_button, core->radio_index);
473                 elm_radio_group_add(radio_button, core->radio_group);
474                 elm_radio_value_set(core->radio_group, selected);
475                 evas_object_show(radio_button);
476                 evas_object_size_hint_weight_set(radio_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
477                 evas_object_size_hint_align_set(radio_button, EVAS_HINT_FILL, EVAS_HINT_FILL);
478
479                 PTS_TRACE_END;
480                 return radio_button ;
481         }
482
483         PTS_TRACE_END;
484         return NULL;
485 }
486
487
488 static void
489 __pts_setting_view_gl_state_item_delete(void *data, Evas_Object *obj)
490 {
491         PTS_TRACE_BEGIN;
492         PTS_RET_IF(data == NULL, "data is NULL");
493         Item_data *core = (Item_data *)data;
494         pts_appdata_t *ad = pts_get_appdata();
495         PTS_RET_IF(ad == NULL, "ad is NULL");
496
497         switch (core->option) {
498         case    PT_OPTION_ID_QUALITY:
499                 ad->setting_info.quality[core->sub_item] = NULL;
500                 break;
501         case    PT_OPTION_ID_PAPER:
502                 ad->setting_info.paper_type[core->sub_item] = NULL;
503                 break;
504         case    PT_OPTION_ID_GRAYSCALE:
505                 ad->setting_info.color[core->sub_item] = NULL;
506                 break;
507         case PT_OPTION_ID_PAPERSIZE:
508                 ad->setting_info.paper_size[core->sub_item] = NULL;
509                 break;
510         case PT_OPTION_ID_DUPLEX:
511                 ad->setting_info.duplex[core->sub_item] = NULL;
512                 break;
513         default:
514                 break;
515         }
516         PTS_DEBUG("Free core memory");
517         PTS_IF_FREE_MEM(core);
518
519         return;
520 }
521
522 /*
523 * get the papersize value of the key
524 */
525 static char *__pts_setting_view_papersize_key_label_get(void *data, Evas_Object *obj, const char *part)
526 {
527         PTS_TRACE_BEGIN;
528         Item_data *core = (Item_data *)data;
529         pt_paper_size_e p_size = (pt_paper_size_e)core->sub_item;
530
531         if (p_size < (pt_paper_size_e)0 || p_size >=  pt_get_print_option_papersize_num()) {
532                 PTS_DEBUG("wrong paper size: %d", p_size);
533                 return NULL;
534         }
535         PTS_TRACE_END;
536         return strdup(pt_get_print_option_papersize(p_size));
537 }
538
539 /*
540 * get the grayscale value of the key
541 */
542 static char *__pts_setting_view_grayscale_key_label_get(void *data, Evas_Object *obj, const char *part)
543 {
544         PTS_TRACE_BEGIN;
545         Item_data *core = (Item_data *)data;
546         pt_grayscale_e p_grayscale = (pt_grayscale_e)core->sub_item;
547         char *ret = NULL;
548
549         //PTS_RETV_IF(p_grayscale < 0 ||p_grayscale >= PT_GRAYSCALE_ANY, NULL, "wrong gray scale: %d", p_grayscale);
550
551         if (strcmp(part, "elm.text") == 0) {
552                 switch (p_grayscale) {
553                 case PT_GRAYSCALE_COLOUR:
554                         ret = strdup(_("IDS_PRT_BODY_COLOUR"));
555                         break;
556                 case PT_GRAYSCALE_GRAYSCALE:
557                         ret = strdup(_("IDS_IMGE_HEADER_GREY"));
558                         break;
559                 default:
560                         ret =  NULL;
561                 }
562         }
563         PTS_TRACE_END;
564         return ret;
565 }
566
567 /*
568 * get the quality value of the key
569 */
570 static char *__pts_setting_view_quality_key_label_get(void *data, Evas_Object *obj, const char *part)
571 {
572         PTS_TRACE_BEGIN;
573         Item_data *core = (Item_data *)data;
574         pt_quality_e p_quality = (pt_quality_e)core->sub_item;
575         char *ret = NULL;
576
577         //PTS_RETV_IF(p_quality < 0 || p_quality >= PT_QUALITY_ANY, NULL, "wrong paper quality: %d", p_quality);
578
579         if (strcmp(part, "elm.text") == 0) {
580                 switch (p_quality) {
581                 case 0:
582                         ret = strdup(_("IDS_PRT_OPT_PRINTSETTINGS_DRAFT"));
583                         break;
584                 case 1:
585                         ret = strdup(_("IDS_PRT_OPT_PRINTSETTINGS_STANDARD"));
586                         break;
587                 case 2:
588                         ret = strdup(_("IDS_COM_BODY_HIGH"));
589                         break;
590                 default:
591                         ret = NULL;
592                 }
593         }
594         PTS_TRACE_END;
595         return ret;
596 }
597
598 /**
599 * get the paper type value of the key
600 */
601 static char *__pts_setting_view_paper_key_label_get(void *data, Evas_Object *obj, const char *part)
602 {
603         PTS_TRACE_BEGIN;
604         Item_data *core = (Item_data *)data;
605         pt_papertype_e p_type = (pt_papertype_e) core->sub_item;
606         char *ret = NULL;
607
608         //PTS_RETV_IF(p_type < 0 || p_type >= PT_PAPER_ANY, NULL, "wrong paper type: %d", p_type);
609
610         if (strcmp(part, "elm.text") == 0) {
611                 switch (p_type) {
612                 case 0:
613                         ret = strdup(_("IDS_ST_BODY_NORMAL"));
614                         break;
615                 case 1:
616                         ret = strdup(_("IDS_ST_BODY_GLOSSY"));
617                         break;
618                 case 2:
619                         ret = strdup(_("IDS_PRT_BODY_PHOTOGRAPHIC_ABB"));
620                         break;
621                 default:
622                         ret = NULL;
623                 }
624         }
625         PTS_TRACE_END;
626         return ret;
627 }
628
629 /*
630 * get the range label of the key
631 */
632 static char *__pts_setting_view_range_key_label_get(void *data, Evas_Object *obj, const char *part)
633 {
634         PTS_TRACE_BEGIN;
635         Item_data *core = (Item_data *)data;
636         pt_range_e p_range = (pt_range_e)core->sub_item;
637         char *ret = NULL;
638
639         //PTS_RETV_IF(p_range < PT_RANGE_ALL || p_range > PT_RANGE_CURRENT, NULL, "wrong paper range: %d", p_range);
640
641         switch (p_range) {
642         case PT_RANGE_ALL:
643                 ret = strdup(_("IDS_DIC_BODY_ALL"));
644                 break;
645         case PT_RANGE_CURRENT:
646                 ret = strdup(_("IDS_BR_BODY_CURRENT_PAGE"));
647                 break;
648         default:
649                 ret = NULL;
650         }
651
652         PTS_TRACE_END;
653         return ret;
654 }
655
656 /*
657 * get the duplex value of the key
658 */
659 static char *__pts_setting_view_duplex_key_label_get(void *data, Evas_Object *obj, const char *part)
660 {
661         PTS_TRACE_BEGIN;
662         Item_data *core = (Item_data *)data;
663         pt_duplex_e p_duplex = (pt_duplex_e)core->sub_item;
664         char *ret = NULL;
665
666         if (strcmp(part, "elm.text") == 0) {
667                 switch (p_duplex) {
668                 case PT_DUPLEX_OFF:
669                         ret = strdup(IDS_PRINT_SETTINGS_DUPLEX_OFF);
670                         break;
671                 case PT_DUPLEX_NO_TUMBLE:
672                 case PT_DUPLEX_TUMBLE:
673                         ret = strdup(IDS_PRINT_SETTINGS_DUPLEX_ON);
674                         break;
675                 default:
676                         ret =  NULL;
677                 }
678         }
679         PTS_TRACE_END;
680         return ret;
681 }
682
683 static void __pts_setting_view_enable_disable(pts_appdata_t *ad)
684 {
685         int i;
686         for (i=0; i<PT_QUALITY_ANY; i++) {
687                 if (ad->setting_info.quality[i]) {
688                         if (pt_is_enabled(PT_OPTION_ID_QUALITY, i)) {
689                                 elm_object_item_disabled_set(ad->setting_info.quality[i], EINA_FALSE);
690                         } else {
691                                 elm_object_item_disabled_set(ad->setting_info.quality[i], EINA_TRUE);
692                         }
693                 }
694         }
695         for (i=0; i<PT_PAPER_ANY; i++) {
696                 if (ad->setting_info.paper_type[i]) {
697                         if (pt_is_enabled(PT_OPTION_ID_PAPER, i)) {
698                                 elm_object_item_disabled_set(ad->setting_info.paper_type[i], EINA_FALSE);
699                         } else {
700                                 elm_object_item_disabled_set(ad->setting_info.paper_type[i], EINA_TRUE);
701                         }
702                 }
703         }
704         for (i=0; i<PT_GRAYSCALE_ANY; i++) {
705                 if (ad->setting_info.color[i]) {
706                         if (pt_is_enabled(PT_OPTION_ID_GRAYSCALE, i)) {
707                                 elm_object_item_disabled_set(ad->setting_info.color[i], EINA_FALSE);
708                         } else {
709                                 elm_object_item_disabled_set(ad->setting_info.color[i], EINA_TRUE);
710                         }
711                 }
712         }
713         for (i=0; i<PT_DUPLEX_ANY-1; i++) {
714                 if (ad->setting_info.duplex[i]) {
715                         if (pt_is_enabled(PT_OPTION_ID_DUPLEX, i)) {
716                                 elm_object_item_disabled_set(ad->setting_info.duplex[i], EINA_FALSE);
717                         } else {
718                                 elm_object_item_disabled_set(ad->setting_info.duplex[i], EINA_TRUE);
719                         }
720                 }
721         }
722         for (i=0; i<pt_get_print_option_papersize_num(); i++) {
723                 if (ad->setting_info.paper_size[i]) {
724                         if (pt_is_enabled(PT_OPTION_ID_PAPERSIZE, i)) {
725                                 elm_object_item_disabled_set(ad->setting_info.paper_size[i], EINA_FALSE);
726                         } else {
727                                 elm_object_item_disabled_set(ad->setting_info.paper_size[i], EINA_TRUE);
728                         }
729                 }
730         }
731 }
732
733 /**
734 * Select the option from list
735 */
736 static void __pts_setting_view_key_value_sel(void *user_data, Evas_Object *obj, void *event_info)
737 {
738         PTS_TRACE_BEGIN;
739
740         Item_data *core = (Item_data *) user_data;
741         struct appdata *ad = pts_get_appdata();
742         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
743         Elm_Object_Item *parent_item = NULL;
744
745         elm_genlist_item_selected_set(item, EINA_FALSE);
746
747         if (NULL != core && NULL != core->item) {
748
749                 switch (core->option) {
750                 case PT_OPTION_ID_PAPERSIZE:
751                         ad->list_info.active_printer->size = core->sub_item;
752                         parent_item  = ad->setting_info.item_paper_size;
753                         pt_set_choice(PT_OPTION_ID_PAPERSIZE, core->sub_item);
754                         PTS_DEBUG("Paper size select: %d", ad->list_info.active_printer->size);
755                         break;
756                 case PT_OPTION_ID_COPIES:
757                         ad->list_info.active_printer->copies = core->sub_item;
758                         parent_item  = ad->setting_info.item_paper_copies;
759                         PTS_DEBUG("Print copy select: %d", ad->list_info.active_printer->copies);
760                         break;
761                 case PT_OPTION_ID_RANGE:
762                         ad->list_info.active_printer->range = core->sub_item;
763                         parent_item  = ad->setting_info.item_page_range;
764                         PTS_DEBUG("Print range select: %d", ad->list_info.active_printer->range);
765                         break;
766                 case PT_OPTION_ID_QUALITY:
767                         pt_set_choice(PT_OPTION_ID_QUALITY, core->sub_item);
768                         parent_item  = ad->setting_info.item_paper_quality;
769                         PTS_DEBUG("Print quality select: %d", pt_get_selected(PT_OPTION_ID_QUALITY));
770                         break;
771                 case PT_OPTION_ID_PAPER:
772                         pt_set_choice(PT_OPTION_ID_PAPER, core->sub_item);
773                         parent_item  = ad->setting_info.item_paper_type;
774                         PTS_DEBUG("Paper type select: %d", pt_get_selected(PT_OPTION_ID_PAPER));
775                         break;
776                 case PT_OPTION_ID_GRAYSCALE:
777                         pt_set_choice(PT_OPTION_ID_GRAYSCALE, core->sub_item);
778                         parent_item  = ad->setting_info.item_grayscale;
779                         PTS_DEBUG("Print color select: %d", pt_get_selected(PT_OPTION_ID_GRAYSCALE));
780                         break;
781                 case PT_OPTION_ID_DUPLEX:
782                         pt_set_choice(PT_OPTION_ID_DUPLEX, core->sub_item);
783                         parent_item = ad->setting_info.item_duplex;
784                         PTS_DEBUG("Duplex select: %d", pt_get_selected(PT_OPTION_ID_DUPLEX));
785                         break;
786                 default:
787                         PTS_DEBUG("Unknown option: %d", core->option);
788                         parent_item = NULL;
789                         break;
790                 }
791
792                 elm_radio_value_set(core->radio_group, core->radio_index);
793                 __pts_setting_view_enable_disable(ad);
794                 if(parent_item) {
795                         elm_genlist_item_update(parent_item);
796                 }
797                 PTS_DEBUG("Update radio group: r_group=[0x%x  <-- %d]", core->radio_group, core->radio_index);
798
799         } else {
800                 PTS_DEBUG("data or data->item are NULL");
801         }
802
803         PTS_TRACE_END;
804 }
805
806 static Item_data *__pts_setting_view_add_genlist_item(
807         Evas_Object *genlist,
808         Elm_Object_Item *parent,
809         pt_print_option_e option,
810         int sub_item,
811         int *radio_btn_index,
812         Evas_Object *radio_group,
813         pts_appdata_t *ad)
814 {
815         PTS_TRACE_BEGIN;
816         PTS_RETV_IF(genlist == NULL, NULL, "genlist is NULL");
817
818         Elm_Genlist_Item_Class *itc = NULL;
819
820         if (PT_OPTION_ID_PAPERSIZE == option) {
821                 itc_paper_size.item_style = "dialogue/1text.1icon/expandable2";
822                 itc_paper_size.func.text_get = __pts_setting_view_papersize_key_label_get;
823                 itc_paper_size.func.content_get = __pts_setting_view_gl_content_get;
824                 itc_paper_size.func.state_get = NULL; //__pts_setting_view_gl_state_get;
825                 itc_paper_size.func.del = __pts_setting_view_gl_state_item_delete;
826                 itc = &itc_paper_size;
827         } else if (PT_OPTION_ID_GRAYSCALE == option) {
828                 itc_grayscale.item_style = "dialogue/1text.1icon/expandable2";
829                 itc_grayscale.func.text_get = __pts_setting_view_grayscale_key_label_get;
830                 itc_grayscale.func.content_get = __pts_setting_view_gl_content_get;
831                 itc_grayscale.func.state_get = NULL; //__pts_setting_view_gl_state_get;
832                 itc_grayscale.func.del = __pts_setting_view_gl_state_item_delete;
833                 itc = &itc_grayscale;
834         } else if (PT_OPTION_ID_QUALITY == option) {
835                 itc_paper_quality.item_style = "dialogue/1text.1icon/expandable2";
836                 itc_paper_quality.func.text_get = __pts_setting_view_quality_key_label_get;
837                 itc_paper_quality.func.content_get = __pts_setting_view_gl_content_get;
838                 itc_paper_quality.func.state_get = NULL; //__pts_setting_view_gl_state_get;
839                 itc_paper_quality.func.del = __pts_setting_view_gl_state_item_delete;
840                 itc = &itc_paper_quality;
841         } else if (PT_OPTION_ID_PAPER == option) {
842                 itc_paper_type.item_style = "dialogue/1text.1icon/expandable2";
843                 itc_paper_type.func.text_get = __pts_setting_view_paper_key_label_get;
844                 itc_paper_type.func.content_get = __pts_setting_view_gl_content_get;
845                 itc_paper_type.func.state_get = NULL; //__pts_setting_view_gl_state_get;
846                 itc_paper_type.func.del = __pts_setting_view_gl_state_item_delete;
847                 itc = &itc_paper_type;
848         } else if (PT_OPTION_ID_RANGE == option) {
849                 itc_page_range.item_style = "dialogue/1text.1icon/expandable2";
850                 itc_page_range.func.text_get = __pts_setting_view_range_key_label_get;
851                 itc_page_range.func.content_get = __pts_setting_view_gl_content_get;
852                 itc_page_range.func.state_get = NULL; //__pts_setting_view_gl_state_get;
853                 itc_page_range.func.del = __pts_setting_view_gl_state_item_delete;
854                 itc = &itc_page_range;
855         } else if (PT_OPTION_ID_DUPLEX == option) {
856                 itc_duplex.item_style = "dialogue/1text.1icon/expandable2";
857                 itc_duplex.func.text_get = __pts_setting_view_duplex_key_label_get;
858                 itc_duplex.func.content_get = __pts_setting_view_gl_content_get;
859                 itc_duplex.func.state_get = NULL;
860                 itc_duplex.func.del = __pts_setting_view_gl_state_item_delete;
861                 itc = &itc_duplex;
862         } else {
863                 PTS_DEBUG("Unknown option: %d", option);
864                 PTS_TRACE_END;
865                 return NULL;
866         }
867
868         evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND,     EVAS_HINT_EXPAND);
869         evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
870
871         Item_data *core = calloc(1, sizeof(Item_data));
872         core->option = option;
873         core->sub_item = sub_item;
874         core->radio_index = *radio_btn_index;
875         core->radio_group = radio_group;
876
877         core->item = elm_genlist_item_append(
878                                          genlist,
879                                          itc,
880                                          (void *)core,
881                                          parent,
882                                          ELM_GENLIST_ITEM_NONE,
883                                          __pts_setting_view_key_value_sel,
884                                          core);
885
886         if (!pt_is_enabled(option, sub_item)) {
887                 elm_object_item_disabled_set(core->item, EINA_TRUE);
888         }
889
890         ++(*radio_btn_index);
891
892         PTS_TRACE_END;
893         return core;
894 }
895
896
897 static Evas_Object *__pts_create_radio_group(Evas_Object *genlist)
898 {
899         Evas_Object *radio = elm_radio_add(genlist);
900         elm_radio_state_value_set(radio, 0);
901         elm_radio_value_set(radio, 0);
902
903         return radio;
904 }
905
906 /**
907 *  Callback for expandable genlist expand
908 */
909 static void __pts_setting_view_gl_exp(void *data, Evas_Object *obj, void *event_info)
910 {
911         PTS_TRACE_BEGIN;
912         PTS_RET_IF(NULL == event_info, "item object is NULL");
913
914         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
915         Evas_Object *genlist = elm_object_item_widget_get(item);
916         pts_appdata_t *ad = (pts_appdata_t *)data;
917         int radio_index = 0;
918         int i = 0;
919
920         elm_genlist_item_selected_set(item, EINA_FALSE);
921
922         if (ad->setting_info.radio_group_paper_size == NULL) {
923                 ad->setting_info.radio_group_paper_size = __pts_create_radio_group(genlist);
924         }
925         if (ad->setting_info.radio_group_paper_quality == NULL) {
926                 ad->setting_info.radio_group_paper_quality = __pts_create_radio_group(genlist);
927         }
928         if (ad->setting_info.radio_group_paper_type == NULL) {
929                 ad->setting_info.radio_group_paper_type = __pts_create_radio_group(genlist);
930         }
931         if (ad->setting_info.radio_group_page_range == NULL) {
932                 ad->setting_info.radio_group_page_range = __pts_create_radio_group(genlist);
933         }
934         if (ad->setting_info.radio_group_grayscale == NULL) {
935                 ad->setting_info.radio_group_grayscale = __pts_create_radio_group(genlist);
936         }
937         if (ad->setting_info.radio_group_duplex == NULL) {
938                 ad->setting_info.radio_group_duplex = __pts_create_radio_group(genlist);
939         }
940
941         if (item == ad->setting_info.item_paper_size) {
942                 radio_index = 0;
943                 Item_data *i_d;
944                 for (i = 0; i < pt_get_print_option_papersize_num(); i++) {
945                         i_d = __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_PAPERSIZE, i, &radio_index, ad->setting_info.radio_group_paper_size, ad);
946                         if (i_d != NULL) {
947                                 ad->setting_info.paper_size[i] = i_d->item;
948                         }
949                 }
950         } else if (item == ad->setting_info.item_paper_quality) {
951                 radio_index = 0;
952                 ad->setting_info.quality[PT_QUALITY_DRAFT] = __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_QUALITY, PT_QUALITY_DRAFT, &radio_index, ad->setting_info.radio_group_paper_quality, ad)->item;
953                 ad->setting_info.quality[PT_QUALITY_STANDARD] = __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_QUALITY, PT_QUALITY_STANDARD, &radio_index, ad->setting_info.radio_group_paper_quality, ad)->item;
954                 ad->setting_info.quality[PT_QUALITY_HIGH] = __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_QUALITY, PT_QUALITY_HIGH, &radio_index, ad->setting_info.radio_group_paper_quality, ad)->item;
955         } else if (item == ad->setting_info.item_paper_type) {
956                 radio_index = 0;
957                 ad->setting_info.paper_type[PT_PAPER_NORMAL] = __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_PAPER, PT_PAPER_NORMAL, &radio_index, ad->setting_info.radio_group_paper_type, ad)->item;
958                 ad->setting_info.paper_type[PT_PAPER_GLOSSY] = __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_PAPER, PT_PAPER_GLOSSY, &radio_index, ad->setting_info.radio_group_paper_type, ad)->item;
959                 ad->setting_info.paper_type[PT_PAPER_PHOTO] = __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_PAPER, PT_PAPER_PHOTO, &radio_index, ad->setting_info.radio_group_paper_type, ad)->item;
960         } else if (item == ad->setting_info.item_page_range) {
961                 radio_index = 0;
962                 __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_RANGE, PT_RANGE_ALL, &radio_index, ad->setting_info.radio_group_page_range, ad);
963                 __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_RANGE, PT_RANGE_CURRENT, &radio_index, ad->setting_info.radio_group_page_range, ad);
964         } else if (item == ad->setting_info.item_grayscale) {
965                 radio_index = 0;
966                 ad->setting_info.color[PT_GRAYSCALE_GRAYSCALE] = __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_GRAYSCALE, PT_GRAYSCALE_GRAYSCALE, &radio_index, ad->setting_info.radio_group_grayscale, ad)->item;
967                 ad->setting_info.color[PT_GRAYSCALE_COLOUR] = __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_GRAYSCALE, PT_GRAYSCALE_COLOUR, &radio_index, ad->setting_info.radio_group_grayscale, ad)->item;
968         } else if (item == ad->setting_info.item_duplex) {
969                 radio_index = 0;
970                 ad->setting_info.duplex[PT_DUPLEX_OFF] = __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_DUPLEX, PT_DUPLEX_OFF, &radio_index, ad->setting_info.radio_group_duplex, ad)->item;
971                 ad->setting_info.duplex[PT_DUPLEX_NO_TUMBLE] = __pts_setting_view_add_genlist_item(genlist, item, PT_OPTION_ID_DUPLEX, PT_DUPLEX_NO_TUMBLE, &radio_index, ad->setting_info.radio_group_duplex, ad)->item;
972         } else {
973                 PTS_DEBUG("Unknown item");
974         }
975
976         PTS_TRACE_END;
977 }
978
979 /*
980  * Accessability info for items from list
981  */
982 static void __pts_setting_view_gl_realized(void *data, Evas_Object *obj, void *event_info)
983 {
984         PTS_TRACE_BEGIN;
985         PTS_RET_IF(NULL == event_info, "item object is NULL");
986         PTS_RET_IF(NULL == data, "ad is NULL");
987
988         Elm_Object_Item *item = (Elm_Object_Item *)event_info;
989         pts_appdata_t *ad = (pts_appdata_t *)data;
990         void *item_data = elm_object_item_data_get(item);
991         //PTS_RET_IF(NULL == item_data, "item data is NULL"); //FIXME: related to Jira issue #
992
993         pt_print_option_e option = (pt_print_option_e)item_data;
994         PTS_RET_IF(option >= PT_OPTION_ID_MAX, "UNKNOWN OPTION REALIZED - %d", option);
995
996         PTS_DEBUG("realized print option: [%d]\n", option);
997
998         if (PT_OPTION_ID_PAPERSIZE == option
999                         || PT_OPTION_ID_RANGE == option
1000                         || PT_OPTION_ID_QUALITY == option
1001                         || PT_OPTION_ID_PAPER == option
1002                         || PT_OPTION_ID_GRAYSCALE == option
1003                         || PT_OPTION_ID_DUPLEX == option) {
1004
1005                 Evas_Object *ao = elm_object_item_access_object_get(item);
1006                 PTS_RET_IF(NULL == ao, "Access object is NULL");
1007                 elm_access_info_set(ao, ELM_ACCESS_TYPE, IDS_SCRREAD_EXPANDABLE_LIST_TYPE);
1008                 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, IDS_SCRREAD_EXPANDABLE_LIST_CONTEXT);
1009                 PTS_DEBUG("Item #%d access context info: [%s]", option, IDS_SCRREAD_EXPANDABLE_LIST_CONTEXT);
1010         } else if (PT_OPTION_ID_COPIES == option) {
1011                 Evas_Object *ao = elm_object_item_access_object_get(item);
1012                 PTS_RET_IF(NULL == ao, "Access object is NULL");
1013                 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, IDS_SCRREAD_SETTINS_ITEM_CONTEXT);
1014                 PTS_DEBUG("Item #%d access context info: [%s]", option, IDS_SCRREAD_SETTINS_ITEM_CONTEXT);
1015         } else if (PT_OPTION_ID_PRINTER == option) {
1016                 Evas_Object *ao = elm_object_item_access_object_get(item);
1017                 PTS_RET_IF(NULL == ao, "Access object is NULL");
1018                 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, IDS_SCRREAD_PRINTER_ITEM_CONTEXT);
1019                 PTS_DEBUG("Item #printer access context info: [%s]", IDS_SCRREAD_PRINTER_ITEM_CONTEXT);
1020         }
1021
1022         PTS_TRACE_END;
1023 }
1024
1025 /*
1026 * create the content of setting view
1027 */
1028 static Evas_Object *__pts_setting_view_create_content(Evas_Object *parent, pts_appdata_t *ad)
1029 {
1030         PTS_TRACE_BEGIN;
1031         PTS_RETV_IF(ad == NULL, NULL, "ad is NULL");
1032         PTS_RETV_IF(parent == NULL, NULL, "parent is NULL");
1033
1034         Evas_Object *genlist = NULL;
1035         Elm_Object_Item *separator_item;
1036
1037         //itc_separator.item_style =  "dialogue/separator/21/with_line";
1038         itc_separator.item_style =  "dialogue/separator";
1039         itc_separator.func.text_get = NULL;
1040         itc_separator.func.content_get = NULL;
1041         itc_separator.func.state_get = NULL;
1042         itc_separator.func.del = NULL;
1043
1044         itc_printer.item_style = "dialogue/2text";
1045         itc_printer.func.text_get = __pts_setting_view_printer_label_get;
1046         itc_printer.func.content_get = NULL;
1047         itc_printer.func.state_get = NULL;
1048         itc_printer.func.del = NULL;
1049
1050         //itc_tree_options.item_style = "dialogue/2text/expandable";
1051         itc_tree_options.item_style = "dialogue/2text.3/expandable";
1052         itc_tree_options.func.text_get = __pts_setting_view_option_label_get;
1053         itc_tree_options.func.content_get = NULL;
1054         itc_tree_options.func.state_get = NULL;
1055         itc_tree_options.func.del = NULL;
1056
1057         itc_normal_options.item_style = "dialogue/2text";
1058         itc_normal_options.func.text_get = __pts_setting_view_option_label_get;
1059         itc_normal_options.func.content_get = NULL;
1060         itc_normal_options.func.state_get = NULL;
1061         itc_normal_options.func.del = NULL;
1062
1063         genlist = elm_genlist_add(parent);
1064
1065         elm_object_style_set(genlist, "dialogue");
1066         elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1067
1068         separator_item= elm_genlist_item_append(
1069                                                 genlist,
1070                                                 &itc_separator,
1071                                                 NULL,
1072                                                 NULL,
1073                                                 ELM_GENLIST_ITEM_NONE,
1074                                                 NULL, NULL);
1075
1076         elm_genlist_item_select_mode_set(separator_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1077
1078         ad->setting_info.printer_item = elm_genlist_item_append(
1079                                                         genlist,
1080                                                         &itc_printer,
1081                                                         (void *)PT_OPTION_ID_PRINTER,
1082                                                         NULL,
1083                                                         ELM_GENLIST_ITEM_NONE,
1084                                                         __pts_setting_view_printer_sel, ad);
1085
1086         ad->setting_info.header_separator_item = elm_genlist_item_append(
1087                                                                          genlist,
1088                                                                          &itc_separator,
1089                                                                          NULL,
1090                                                                          NULL,
1091                                                                          ELM_GENLIST_ITEM_NONE,
1092                                                                          NULL, NULL);
1093         elm_genlist_item_select_mode_set(ad->setting_info.header_separator_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1094
1095         ad->setting_info.item_paper_size = elm_genlist_item_append(
1096                                                            genlist,
1097                                                            &itc_tree_options,
1098                                                            (void *)PT_OPTION_ID_PAPERSIZE,
1099                                                            NULL,
1100                                                            ELM_GENLIST_ITEM_TREE,
1101                                                            __pts_setting_view_gl_sel,
1102                                                            ad);
1103
1104         ad->setting_info.item_paper_copies = elm_genlist_item_append(
1105                                                                  genlist,
1106                                                                  &itc_normal_options,
1107                                                                  (void *)PT_OPTION_ID_COPIES,
1108                                                                  NULL,
1109                                                                  ELM_GENLIST_ITEM_NONE,
1110                                                                  _create_copies_popup_timepicker,
1111                                                                  ad);
1112
1113         ad->setting_info.item_page_range = elm_genlist_item_append(
1114                                                            genlist,
1115                                                            &itc_tree_options,
1116                                                            (void *)PT_OPTION_ID_RANGE,
1117                                                            NULL,
1118                                                            ELM_GENLIST_ITEM_TREE,
1119                                                            __pts_setting_view_gl_sel,
1120                                                            ad);
1121
1122         ad->setting_info.item_paper_quality = elm_genlist_item_append(
1123                                                                   genlist,
1124                                                                   &itc_tree_options,
1125                                                                   (void *)PT_OPTION_ID_QUALITY,
1126                                                                   NULL,
1127                                                                   ELM_GENLIST_ITEM_TREE,
1128                                                                   __pts_setting_view_gl_sel,
1129                                                                   ad);
1130
1131         ad->setting_info.item_paper_type = elm_genlist_item_append(
1132                                                            genlist,
1133                                                            &itc_tree_options,
1134                                                            (void *)PT_OPTION_ID_PAPER,
1135                                                            NULL,
1136                                                            ELM_GENLIST_ITEM_TREE,
1137                                                            __pts_setting_view_gl_sel,
1138                                                            ad);
1139
1140         ad->setting_info.item_grayscale = elm_genlist_item_append(
1141                                                           genlist,
1142                                                           &itc_tree_options,
1143                                                           (void *)PT_OPTION_ID_GRAYSCALE,
1144                                                           NULL,
1145                                                           ELM_GENLIST_ITEM_TREE,
1146                                                           __pts_setting_view_gl_sel,
1147                                                           ad);
1148
1149         ad->setting_info.item_duplex = elm_genlist_item_append(
1150                                                           genlist,
1151                                                           &itc_tree_options,
1152                                                           (void *)PT_OPTION_ID_DUPLEX,
1153                                                           NULL,
1154                                                           ELM_GENLIST_ITEM_TREE,
1155                                                           __pts_setting_view_gl_sel,
1156                                                           ad);
1157
1158         // Footer space
1159         ad->setting_info.footer_separator_item = elm_genlist_item_append(
1160                                                                          genlist,
1161                                                                          &itc_separator,
1162                                                                          NULL,
1163                                                                          NULL,
1164                                                                          ELM_GENLIST_ITEM_NONE,
1165                                                                          NULL, NULL);
1166         elm_genlist_item_select_mode_set(ad->setting_info.footer_separator_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1167
1168         evas_object_smart_callback_add(genlist, "expanded", __pts_setting_view_gl_exp, ad);
1169         evas_object_smart_callback_add(genlist, "contracted", __pts_setting_view_gl_con, ad);
1170
1171         /* Accessability information callback */
1172         evas_object_smart_callback_add(genlist, "realized", __pts_setting_view_gl_realized, ad);
1173
1174         /* Add touch coordinates handler */
1175         Ecore_Event_Handler *event;
1176         event = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _mousedown_cb, NULL);
1177         evas_object_smart_callback_add(genlist, "clicked", _back_cb, event);
1178
1179         PTS_TRACE_END;
1180         return genlist;
1181 }
1182
1183 #if 0
1184 Evas_Object *pt_util_add_bg(Evas_Object *obj, Eina_Bool is_window)
1185 {
1186         PTS_TRACE_BEGIN;
1187
1188         Evas_Object *bg;
1189         bg = elm_bg_add(obj);
1190         PTS_RETV_IF(bg == NULL, NULL, "bg is NULL");
1191
1192         evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1193
1194         if (is_window) {
1195                 elm_win_resize_object_add(obj, bg);
1196         } else {
1197                 elm_object_style_set(bg, "group_list");
1198         }
1199
1200         evas_object_show(bg);
1201
1202         PTS_TRACE_END;
1203         return bg;
1204 }
1205 #endif
1206
1207 /**
1208  *      This function let the app create setting view
1209  *      @return  void
1210  *      @param[in] sd the pointer to the printer setting structure
1211  */
1212 void pts_create_setting_view(pts_appdata_t *ad)
1213 {
1214         PTS_TRACE_BEGIN;
1215         PTS_RET_IF(ad == NULL, "ad is NULL");
1216
1217         Evas_Object *back_btn = NULL;
1218         //Evas_Object *layout = NULL;
1219         Evas_Object *genlist = NULL;
1220         //Elm_Object_Item *navi_item = NULL;
1221
1222         //layout = pts_utils_create_layout(ugd->navi);
1223         //evas_object_show(layout);
1224         //Evas_Object *conform = elm_object_part_content_get(layout, "elm.swallow.content");
1225
1226         genlist = __pts_setting_view_create_content(ad->main_info.navi, ad);
1227         //elm_object_content_set(layout, genlist);
1228
1229         back_btn = elm_button_add(ad->main_info.navi);
1230         elm_object_style_set(back_btn, "naviframe/end_btn/default");
1231
1232         evas_object_smart_callback_add(back_btn, "clicked", __pts_setting_view_btn_back_cb, ad);
1233         elm_naviframe_item_push(ad->main_info.navi, _("IDS_SMPOS_HEADER_PRINTER_SETTINGS"), back_btn, NULL, genlist, NULL);
1234         //navi_item = elm_naviframe_item_push(ugd->navi, _("IDS_SMPOS_HEADER_PRINTER_SETTINGS"), back_btn, NULL, genlist, NULL);
1235
1236         PTS_TRACE_END;
1237 }