4 * Copyright 2012 Samsung Electronics Co., Ltd
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
10 * http://floralicense.org/license/
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.
24 #include "mobileprint.h"
25 #include "pts_common.h"
26 #include "pts_main_view.h"
27 #include "pts_setting_view.h"
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;
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;
41 static Evas_Coord touch_x;
42 static Evas_Coord touch_y;
43 static Evas_Object *copies_popup = NULL;
45 static void __pts_setting_view_leave_view(pts_appdata_t *ad)
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);
57 * the response callback when click back button
59 static void __pts_setting_view_btn_back_cb(void *data, Evas_Object *obj, void *event_info)
63 pts_appdata_t *ad = (pts_appdata_t *)data;
65 PTS_RET_IF(ad == NULL, "ad is NULL");
67 __pts_setting_view_leave_view(ad);
69 if (ad->list_info.active_printer == NULL) {
70 PTS_DEBUG("No active printer. So just exit mobileprint");
77 pts_main_view_update_printer_label(ad);
78 pts_main_view_rotate_image(ad, app_get_device_orientation());
82 static void _back_cb(void *data, Evas_Object *obj, void *event_info)
84 ecore_event_handler_del(data);
87 static void _dismissed_cb(void *data, Evas_Object *obj, void *event_info)
89 PTS_IF_DEL_OBJ(copies_popup);
92 static void _copies_picker_cb(void *data, Evas_Object *obj, void *event_info)
96 pts_appdata_t *ad = (pts_appdata_t *)data;
97 Elm_Object_Item *item = event_info;
99 const char *label = elm_object_item_text_get(item);
101 PTS_RET_IF(label == NULL, "label is NULL");
103 copies = atoi(label);
104 if (copies == ad->list_info.active_printer->copies) {
105 PTS_DEBUG("Not changed\n");
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);
114 PTS_IF_DEL_OBJ(copies_popup);
119 static void _move_copies_popup(Evas_Object *copies_popup, Evas_Object *win)
124 evas_object_geometry_get(win, &x, &y, &w, &h);
125 evas_object_move(copies_popup, x+(w*0.06), touch_y);
128 static Eina_Bool _mousedown_cb(void *data, int type, void *event)
130 Ecore_Event_Mouse_Button *ev = event;
133 return ECORE_CALLBACK_CANCEL;
136 static void __on_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
138 PTS_DEBUG("copies popup show\n");
141 static void __on_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
143 PTS_DEBUG("copies popup hide\n");
147 * Copies picker create
149 static void _create_copies_popup_timepicker(void *data, Evas_Object *obj, void *event_info)
154 Evas_Object *diskselector;
157 char current_selection[4];
159 pts_appdata_t *ad = (pts_appdata_t *)data;
160 elm_genlist_item_selected_set(ad->setting_info.item_paper_copies, EINA_TRUE);
162 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
164 elm_genlist_item_selected_set(event_info, EINA_FALSE);
167 PTS_IF_DEL_OBJ(copies_popup);
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);
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");
184 snprintf(current_selection, 4, "%d", ad->list_info.active_printer->copies);
186 for (idx = 1; idx < COPIES_MAX+1; idx++) {
187 snprintf(buffer, 4, "%d", idx);
189 if (strcmp(current_selection, buffer) == 0) {
190 item = elm_diskselector_item_append(diskselector, buffer, NULL, _copies_picker_cb, ad);
192 elm_diskselector_item_append(diskselector, buffer, NULL, _copies_picker_cb, ad);
197 elm_diskselector_item_selected_set(item, EINA_TRUE);
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);
204 evas_object_show(diskselector);
205 elm_object_content_set(copies_popup, diskselector);
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);
212 _move_copies_popup(copies_popup, ad->main_info.root_win);
213 evas_object_show(copies_popup);
219 * Callback for expandable genlist selection
221 static void __pts_setting_view_gl_sel(void *data, Evas_Object *obj, void *event_info)
225 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
226 Eina_Bool expand_state = EINA_FALSE;
228 elm_genlist_item_selected_set(event_info, EINA_FALSE);
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);
238 void pts_setting_view_printer_select_done_cb(void *userdata)
241 struct appdata *ad = pts_get_appdata();
243 Elm_Object_Item *item = (Elm_Object_Item *)userdata;
244 elm_genlist_item_update(item);
246 if (ad->list_info.active_printer) {
247 pts_create_setting_view(ad);
255 * Callback for expandable genlist selection
257 static void __pts_setting_view_printer_sel(void *data, Evas_Object *obj, void *event_info)
261 pts_appdata_t *ad = (pts_appdata_t *)data;
263 elm_genlist_item_selected_set(event_info, EINA_FALSE);
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);
277 * Callback for expandable genlist contract
279 static void __pts_setting_view_gl_con(void *data, Evas_Object *obj, void *event_info)
281 Elm_Object_Item *item = event_info;
282 elm_genlist_item_subitems_clear(item);
286 * get the label of the printer information
288 static char *__pts_setting_view_printer_label_get(void *data, Evas_Object *obj, const char *part)
291 struct appdata *ad = pts_get_appdata();
292 if (strcmp(part, "elm.text.1") == 0) {
293 //if (printer != NULL) {
294 //return strdup(printer->name);
296 return strdup(_("IDS_PRT_BODY_PRINTER"));
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);
305 return printer_label;
308 return strdup(PTS_18);
316 * get the label of the option setting
318 #define MAX_TMP_BUF 64
319 static char *__pts_setting_view_option_label_get(void *data, Evas_Object *obj, const char *part)
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;
326 char buf[MAX_TMP_BUF];
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);
345 return strdup(PTS_17);
347 } else if (strcmp(part, "elm.text.2") == 0) {
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);
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);
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"));
366 strcpy(buf, _("IDS_BR_BODY_CURRENT_PAGE"));
368 PTS_DEBUG("Selected range[%d, %s]", p_range, buf);
371 case PT_OPTION_ID_GRAYSCALE: {
372 int p_grayscale = pt_get_selected(PT_OPTION_ID_GRAYSCALE);
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"));
382 PTS_DEBUG("Selected color [%d, %s]", p_grayscale, buf);
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"));
394 PTS_DEBUG("Selected quality [%d, %s]", p_quality, buf);
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"));
406 PTS_DEBUG("Selected paper type [%d, %s]", p_type, buf);
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);
416 PTS_DEBUG("Selected duplex mode [%d, %s]", p_dup, buf);
420 return strdup(PTS_17);
433 __pts_setting_view_gl_content_get(void *data, Evas_Object *obj, const char *part)
436 pts_appdata_t *ad = pts_get_appdata();
437 Evas_Object *radio_button = NULL;
438 Item_data *core = (Item_data *)data;
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);
446 case PT_OPTION_ID_RANGE:
447 selected = ad->list_info.active_printer->range;
449 case PT_OPTION_ID_QUALITY:
450 selected = pt_get_selected(PT_OPTION_ID_QUALITY);
452 case PT_OPTION_ID_PAPER:
453 selected = pt_get_selected(PT_OPTION_ID_PAPER);
455 case PT_OPTION_ID_GRAYSCALE:
456 selected = pt_get_selected(PT_OPTION_ID_GRAYSCALE);
458 case PT_OPTION_ID_DUPLEX:
459 selected = pt_get_selected(PT_OPTION_ID_DUPLEX);
461 /* case PT_OPTION_ID_COPIES: */
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);
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);
480 return radio_button ;
489 __pts_setting_view_gl_state_item_delete(void *data, Evas_Object *obj)
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");
497 switch (core->option) {
498 case PT_OPTION_ID_QUALITY:
499 ad->setting_info.quality[core->sub_item] = NULL;
501 case PT_OPTION_ID_PAPER:
502 ad->setting_info.paper_type[core->sub_item] = NULL;
504 case PT_OPTION_ID_GRAYSCALE:
505 ad->setting_info.color[core->sub_item] = NULL;
507 case PT_OPTION_ID_PAPERSIZE:
508 ad->setting_info.paper_size[core->sub_item] = NULL;
510 case PT_OPTION_ID_DUPLEX:
511 ad->setting_info.duplex[core->sub_item] = NULL;
516 PTS_DEBUG("Free core memory");
517 PTS_IF_FREE_MEM(core);
523 * get the papersize value of the key
525 static char *__pts_setting_view_papersize_key_label_get(void *data, Evas_Object *obj, const char *part)
528 Item_data *core = (Item_data *)data;
529 pt_paper_size_e p_size = (pt_paper_size_e)core->sub_item;
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);
536 return strdup(pt_get_print_option_papersize(p_size));
540 * get the grayscale value of the key
542 static char *__pts_setting_view_grayscale_key_label_get(void *data, Evas_Object *obj, const char *part)
545 Item_data *core = (Item_data *)data;
546 pt_grayscale_e p_grayscale = (pt_grayscale_e)core->sub_item;
549 //PTS_RETV_IF(p_grayscale < 0 ||p_grayscale >= PT_GRAYSCALE_ANY, NULL, "wrong gray scale: %d", p_grayscale);
551 if (strcmp(part, "elm.text") == 0) {
552 switch (p_grayscale) {
553 case PT_GRAYSCALE_COLOUR:
554 ret = strdup(_("IDS_PRT_BODY_COLOUR"));
556 case PT_GRAYSCALE_GRAYSCALE:
557 ret = strdup(_("IDS_IMGE_HEADER_GREY"));
568 * get the quality value of the key
570 static char *__pts_setting_view_quality_key_label_get(void *data, Evas_Object *obj, const char *part)
573 Item_data *core = (Item_data *)data;
574 pt_quality_e p_quality = (pt_quality_e)core->sub_item;
577 //PTS_RETV_IF(p_quality < 0 || p_quality >= PT_QUALITY_ANY, NULL, "wrong paper quality: %d", p_quality);
579 if (strcmp(part, "elm.text") == 0) {
582 ret = strdup(_("IDS_PRT_OPT_PRINTSETTINGS_DRAFT"));
585 ret = strdup(_("IDS_PRT_OPT_PRINTSETTINGS_STANDARD"));
588 ret = strdup(_("IDS_COM_BODY_HIGH"));
599 * get the paper type value of the key
601 static char *__pts_setting_view_paper_key_label_get(void *data, Evas_Object *obj, const char *part)
604 Item_data *core = (Item_data *)data;
605 pt_papertype_e p_type = (pt_papertype_e) core->sub_item;
608 //PTS_RETV_IF(p_type < 0 || p_type >= PT_PAPER_ANY, NULL, "wrong paper type: %d", p_type);
610 if (strcmp(part, "elm.text") == 0) {
613 ret = strdup(_("IDS_ST_BODY_NORMAL"));
616 ret = strdup(_("IDS_ST_BODY_GLOSSY"));
619 ret = strdup(_("IDS_PRT_BODY_PHOTOGRAPHIC_ABB"));
630 * get the range label of the key
632 static char *__pts_setting_view_range_key_label_get(void *data, Evas_Object *obj, const char *part)
635 Item_data *core = (Item_data *)data;
636 pt_range_e p_range = (pt_range_e)core->sub_item;
639 //PTS_RETV_IF(p_range < PT_RANGE_ALL || p_range > PT_RANGE_CURRENT, NULL, "wrong paper range: %d", p_range);
643 ret = strdup(_("IDS_DIC_BODY_ALL"));
645 case PT_RANGE_CURRENT:
646 ret = strdup(_("IDS_BR_BODY_CURRENT_PAGE"));
657 * get the duplex value of the key
659 static char *__pts_setting_view_duplex_key_label_get(void *data, Evas_Object *obj, const char *part)
662 Item_data *core = (Item_data *)data;
663 pt_duplex_e p_duplex = (pt_duplex_e)core->sub_item;
666 if (strcmp(part, "elm.text") == 0) {
669 ret = strdup(IDS_PRINT_SETTINGS_DUPLEX_OFF);
671 case PT_DUPLEX_NO_TUMBLE:
672 case PT_DUPLEX_TUMBLE:
673 ret = strdup(IDS_PRINT_SETTINGS_DUPLEX_ON);
683 static void __pts_setting_view_enable_disable(pts_appdata_t *ad)
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);
691 elm_object_item_disabled_set(ad->setting_info.quality[i], EINA_TRUE);
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);
700 elm_object_item_disabled_set(ad->setting_info.paper_type[i], EINA_TRUE);
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);
709 elm_object_item_disabled_set(ad->setting_info.color[i], EINA_TRUE);
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);
718 elm_object_item_disabled_set(ad->setting_info.duplex[i], EINA_TRUE);
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);
727 elm_object_item_disabled_set(ad->setting_info.paper_size[i], EINA_TRUE);
734 * Select the option from list
736 static void __pts_setting_view_key_value_sel(void *user_data, Evas_Object *obj, void *event_info)
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;
745 elm_genlist_item_selected_set(item, EINA_FALSE);
747 if (NULL != core && NULL != core->item) {
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);
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);
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);
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));
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));
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));
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));
787 PTS_DEBUG("Unknown option: %d", core->option);
792 elm_radio_value_set(core->radio_group, core->radio_index);
793 __pts_setting_view_enable_disable(ad);
795 elm_genlist_item_update(parent_item);
797 PTS_DEBUG("Update radio group: r_group=[0x%x <-- %d]", core->radio_group, core->radio_index);
800 PTS_DEBUG("data or data->item are NULL");
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,
811 int *radio_btn_index,
812 Evas_Object *radio_group,
816 PTS_RETV_IF(genlist == NULL, NULL, "genlist is NULL");
818 Elm_Genlist_Item_Class *itc = NULL;
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;
863 PTS_DEBUG("Unknown option: %d", option);
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);
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;
877 core->item = elm_genlist_item_append(
882 ELM_GENLIST_ITEM_NONE,
883 __pts_setting_view_key_value_sel,
886 if (!pt_is_enabled(option, sub_item)) {
887 elm_object_item_disabled_set(core->item, EINA_TRUE);
890 ++(*radio_btn_index);
897 static Evas_Object *__pts_create_radio_group(Evas_Object *genlist)
899 Evas_Object *radio = elm_radio_add(genlist);
900 elm_radio_state_value_set(radio, 0);
901 elm_radio_value_set(radio, 0);
907 * Callback for expandable genlist expand
909 static void __pts_setting_view_gl_exp(void *data, Evas_Object *obj, void *event_info)
912 PTS_RET_IF(NULL == event_info, "item object is NULL");
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;
920 elm_genlist_item_selected_set(item, EINA_FALSE);
922 if (ad->setting_info.radio_group_paper_size == NULL) {
923 ad->setting_info.radio_group_paper_size = __pts_create_radio_group(genlist);
925 if (ad->setting_info.radio_group_paper_quality == NULL) {
926 ad->setting_info.radio_group_paper_quality = __pts_create_radio_group(genlist);
928 if (ad->setting_info.radio_group_paper_type == NULL) {
929 ad->setting_info.radio_group_paper_type = __pts_create_radio_group(genlist);
931 if (ad->setting_info.radio_group_page_range == NULL) {
932 ad->setting_info.radio_group_page_range = __pts_create_radio_group(genlist);
934 if (ad->setting_info.radio_group_grayscale == NULL) {
935 ad->setting_info.radio_group_grayscale = __pts_create_radio_group(genlist);
937 if (ad->setting_info.radio_group_duplex == NULL) {
938 ad->setting_info.radio_group_duplex = __pts_create_radio_group(genlist);
941 if (item == ad->setting_info.item_paper_size) {
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);
947 ad->setting_info.paper_size[i] = i_d->item;
950 } else if (item == ad->setting_info.item_paper_quality) {
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) {
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) {
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) {
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) {
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;
973 PTS_DEBUG("Unknown item");
980 * Accessability info for items from list
982 static void __pts_setting_view_gl_realized(void *data, Evas_Object *obj, void *event_info)
985 PTS_RET_IF(NULL == event_info, "item object is NULL");
986 PTS_RET_IF(NULL == data, "ad is NULL");
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 #
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);
996 PTS_DEBUG("realized print option: [%d]\n", option);
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) {
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);
1026 * create the content of setting view
1028 static Evas_Object *__pts_setting_view_create_content(Evas_Object *parent, pts_appdata_t *ad)
1031 PTS_RETV_IF(ad == NULL, NULL, "ad is NULL");
1032 PTS_RETV_IF(parent == NULL, NULL, "parent is NULL");
1034 Evas_Object *genlist = NULL;
1035 Elm_Object_Item *separator_item;
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;
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;
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;
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;
1063 genlist = elm_genlist_add(parent);
1065 elm_object_style_set(genlist, "dialogue");
1066 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1068 separator_item= elm_genlist_item_append(
1073 ELM_GENLIST_ITEM_NONE,
1076 elm_genlist_item_select_mode_set(separator_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1078 ad->setting_info.printer_item = elm_genlist_item_append(
1081 (void *)PT_OPTION_ID_PRINTER,
1083 ELM_GENLIST_ITEM_NONE,
1084 __pts_setting_view_printer_sel, ad);
1086 ad->setting_info.header_separator_item = elm_genlist_item_append(
1091 ELM_GENLIST_ITEM_NONE,
1093 elm_genlist_item_select_mode_set(ad->setting_info.header_separator_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1095 ad->setting_info.item_paper_size = elm_genlist_item_append(
1098 (void *)PT_OPTION_ID_PAPERSIZE,
1100 ELM_GENLIST_ITEM_TREE,
1101 __pts_setting_view_gl_sel,
1104 ad->setting_info.item_paper_copies = elm_genlist_item_append(
1106 &itc_normal_options,
1107 (void *)PT_OPTION_ID_COPIES,
1109 ELM_GENLIST_ITEM_NONE,
1110 _create_copies_popup_timepicker,
1113 ad->setting_info.item_page_range = elm_genlist_item_append(
1116 (void *)PT_OPTION_ID_RANGE,
1118 ELM_GENLIST_ITEM_TREE,
1119 __pts_setting_view_gl_sel,
1122 ad->setting_info.item_paper_quality = elm_genlist_item_append(
1125 (void *)PT_OPTION_ID_QUALITY,
1127 ELM_GENLIST_ITEM_TREE,
1128 __pts_setting_view_gl_sel,
1131 ad->setting_info.item_paper_type = elm_genlist_item_append(
1134 (void *)PT_OPTION_ID_PAPER,
1136 ELM_GENLIST_ITEM_TREE,
1137 __pts_setting_view_gl_sel,
1140 ad->setting_info.item_grayscale = elm_genlist_item_append(
1143 (void *)PT_OPTION_ID_GRAYSCALE,
1145 ELM_GENLIST_ITEM_TREE,
1146 __pts_setting_view_gl_sel,
1149 ad->setting_info.item_duplex = elm_genlist_item_append(
1152 (void *)PT_OPTION_ID_DUPLEX,
1154 ELM_GENLIST_ITEM_TREE,
1155 __pts_setting_view_gl_sel,
1159 ad->setting_info.footer_separator_item = elm_genlist_item_append(
1164 ELM_GENLIST_ITEM_NONE,
1166 elm_genlist_item_select_mode_set(ad->setting_info.footer_separator_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
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);
1171 /* Accessability information callback */
1172 evas_object_smart_callback_add(genlist, "realized", __pts_setting_view_gl_realized, ad);
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);
1184 Evas_Object *pt_util_add_bg(Evas_Object *obj, Eina_Bool is_window)
1189 bg = elm_bg_add(obj);
1190 PTS_RETV_IF(bg == NULL, NULL, "bg is NULL");
1192 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1195 elm_win_resize_object_add(obj, bg);
1197 elm_object_style_set(bg, "group_list");
1200 evas_object_show(bg);
1208 * This function let the app create setting view
1210 * @param[in] sd the pointer to the printer setting structure
1212 void pts_create_setting_view(pts_appdata_t *ad)
1215 PTS_RET_IF(ad == NULL, "ad is NULL");
1217 Evas_Object *back_btn = NULL;
1218 //Evas_Object *layout = NULL;
1219 Evas_Object *genlist = NULL;
1220 //Elm_Object_Item *navi_item = NULL;
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");
1226 genlist = __pts_setting_view_create_content(ad->main_info.navi, ad);
1227 //elm_object_content_set(layout, genlist);
1229 back_btn = elm_button_add(ad->main_info.navi);
1230 elm_object_style_set(back_btn, "naviframe/end_btn/default");
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);