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.
23 #include <efl_assist.h>
25 #include "mobileprint.h"
26 #include "pts_common.h"
27 #include "pts_main_view.h"
28 #include "pts_setting_view.h"
30 static Elm_Genlist_Item_Class itc_normal_options;
31 static Elm_Genlist_Item_Class itc_tree_options;
32 static Elm_Genlist_Item_Class itc_printer;
33 static Elm_Genlist_Item_Class itc_separator;
35 static Elm_Genlist_Item_Class itc_paper_size;
36 static Elm_Genlist_Item_Class itc_paper_quality;
37 static Elm_Genlist_Item_Class itc_paper_type;
38 static Elm_Genlist_Item_Class itc_grayscale;
39 static Elm_Genlist_Item_Class itc_page_range;
40 static Elm_Genlist_Item_Class itc_duplex;
42 static Evas_Coord touch_x;
43 static Evas_Coord touch_y;
44 static Evas_Object *copies_popup = NULL;
46 static void __pts_setting_view_leave_view(pts_appdata_t *ad)
48 PTS_IF_DEL_OBJ(ad->setting_info.radio_group_paper_size);
49 PTS_IF_DEL_OBJ(ad->setting_info.radio_group_paper_quality);
50 PTS_IF_DEL_OBJ(ad->setting_info.radio_group_paper_type);
51 PTS_IF_DEL_OBJ(ad->setting_info.radio_group_page_range);
52 PTS_IF_DEL_OBJ(ad->setting_info.radio_group_grayscale);
53 PTS_IF_DEL_OBJ(ad->setting_info.radio_group_duplex);
54 elm_naviframe_item_pop_to(ad->main_info.navi_it);
58 * the response callback when click back button
60 static Eina_Bool __pts_setting_view_btn_back_cb(void *data, Elm_Object_Item *it)
64 pts_appdata_t *ad = (pts_appdata_t *)data;
66 PTS_RETV_IF(ad == NULL, EINA_TRUE, "ad is NULL");
68 __pts_setting_view_leave_view(ad);
70 if (ad->list_info.active_printer == NULL) {
71 PTS_DEBUG("No active printer. So just exit mobileprint");
78 pts_main_view_update_printer_label(ad);
79 pts_main_view_rotate_image(ad, app_get_device_orientation());
84 static void _dismissed_cb(void *data, Evas_Object *obj, void *event_info)
86 PTS_IF_DEL_OBJ(copies_popup);
89 static void _copies_picker_cb(void *data, Evas_Object *obj, void *event_info)
93 pts_appdata_t *ad = (pts_appdata_t *)data;
94 Elm_Object_Item *item = event_info;
96 const char *label = elm_object_item_text_get(item);
98 PTS_RET_IF(label == NULL, "label is NULL");
100 copies = atoi(label);
101 if (copies == ad->list_info.active_printer->copies) {
102 PTS_DEBUG("Not changed\n");
106 PTS_DEBUG("text(%s) is clicked!\n", label);
107 ad->list_info.active_printer->copies = copies;
108 elm_genlist_item_selected_set(ad->setting_info.item_paper_copies, EINA_FALSE);
109 elm_genlist_item_update(ad->setting_info.item_paper_copies);
111 PTS_IF_DEL_OBJ(copies_popup);
116 static void _move_copies_popup(Evas_Object *copies_popup, Evas_Object *win)
121 evas_object_geometry_get(win, &x, &y, &w, &h);
122 evas_object_move(copies_popup, x+(w*0.06), touch_y);
125 static void __on_show(void *data, Evas *e, Evas_Object *obj, void *event_info)
127 PTS_DEBUG("copies popup show\n");
130 static void __on_hide(void *data, Evas *e, Evas_Object *obj, void *event_info)
132 PTS_DEBUG("copies popup hide\n");
136 * Copies picker create
138 static void _create_copies_popup_timepicker(void *data, Evas_Object *obj, void *event_info)
143 Evas_Object *diskselector;
146 char current_selection[4];
148 pts_appdata_t *ad = (pts_appdata_t *)data;
149 elm_genlist_item_selected_set(ad->setting_info.item_paper_copies, EINA_TRUE);
151 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
153 elm_genlist_item_selected_set(event_info, EINA_FALSE);
156 PTS_IF_DEL_OBJ(copies_popup);
158 evas_object_geometry_get(ad->main_info.root_win, NULL, NULL, &w, NULL);
159 copies_popup = elm_ctxpopup_add(ad->main_info.navi);
160 //elm_object_style_set(copies_popup, "timepicker");
161 elm_object_style_set(copies_popup, "datetime/default");
162 evas_object_size_hint_min_set(copies_popup, w, -1);
163 evas_object_size_hint_weight_set(copies_popup, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
164 evas_object_smart_callback_add(copies_popup, "dismissed", _dismissed_cb, copies_popup);
165 evas_object_event_callback_add(copies_popup, EVAS_CALLBACK_SHOW, __on_show, ad);
166 evas_object_event_callback_add(copies_popup, EVAS_CALLBACK_HIDE, __on_hide, ad);
168 diskselector = elm_diskselector_add(ad->main_info.navi);
169 elm_diskselector_display_item_num_set(diskselector, 8);
170 //elm_object_style_set(diskselector, "timepicker");
171 elm_object_style_set(diskselector, "datetime/default");
173 snprintf(current_selection, 4, "%d", ad->list_info.active_printer->copies);
175 for (idx = 1; idx < COPIES_MAX+1; idx++) {
176 snprintf(buffer, 4, "%d", idx);
178 if (strcmp(current_selection, buffer) == 0) {
179 item = elm_diskselector_item_append(diskselector, buffer, NULL, _copies_picker_cb, ad);
181 elm_diskselector_item_append(diskselector, buffer, NULL, _copies_picker_cb, ad);
186 elm_diskselector_item_selected_set(item, EINA_TRUE);
189 elm_diskselector_round_enabled_set(diskselector, EINA_TRUE);
190 evas_object_size_hint_weight_set(diskselector, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
191 evas_object_size_hint_align_set(diskselector, EVAS_HINT_FILL, EVAS_HINT_FILL);
193 evas_object_show(diskselector);
194 elm_object_content_set(copies_popup, diskselector);
196 elm_ctxpopup_direction_priority_set(copies_popup, ELM_CTXPOPUP_DIRECTION_DOWN,
197 ELM_CTXPOPUP_DIRECTION_UP,
198 ELM_CTXPOPUP_DIRECTION_LEFT,
199 ELM_CTXPOPUP_DIRECTION_RIGHT);
201 _move_copies_popup(copies_popup, ad->main_info.root_win);
202 evas_object_show(copies_popup);
208 * Callback for expandable genlist selection
210 static void __pts_setting_view_gl_sel(void *data, Evas_Object *obj, void *event_info)
214 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
215 Eina_Bool expand_state = EINA_FALSE;
217 elm_genlist_item_selected_set(event_info, EINA_FALSE);
220 expand_state = elm_genlist_item_expanded_get(item);
221 elm_genlist_item_expanded_set(item, !expand_state);
222 PTS_DEBUG("expanded : %d", expand_state);
227 void pts_setting_view_printer_select_done_cb(void *userdata)
230 struct appdata *ad = pts_get_appdata();
232 Elm_Object_Item *item = (Elm_Object_Item *)userdata;
233 elm_genlist_item_update(item);
235 if (ad->list_info.active_printer) {
236 pts_create_setting_view(ad);
244 * Callback for expandable genlist selection
246 static void __pts_setting_view_printer_sel(void *data, Evas_Object *obj, void *event_info)
250 pts_appdata_t *ad = (pts_appdata_t *)data;
252 elm_genlist_item_selected_set(event_info, EINA_FALSE);
255 if (ad->search_info.popup != NULL
256 || ad->list_info.no_found_popup != NULL
257 || ad->list_info.printer_list_popup != NULL) {
258 PTS_WARN("event was called duplicated, it is ignored");
262 // Launch Print searching module
263 ad->search_info.print_search_mode = PTS_SEARCH_IN_SETTING;
264 ad->search_info.selection_done_cb = pts_setting_view_printer_select_done_cb;
265 ad->search_info.print_search_popup_parent = ad->main_info.navi;
266 ad->search_info.printer_search_user_data = (void *)event_info;
267 pts_search_printer(ad);
273 * Callback for expandable genlist contract
275 static void __pts_setting_view_gl_con(void *data, Evas_Object *obj, void *event_info)
277 Elm_Object_Item *item = event_info;
278 elm_genlist_item_subitems_clear(item);
282 * get the label of the printer information
284 static char *__pts_setting_view_printer_label_get(void *data, Evas_Object *obj, const char *part)
287 struct appdata *ad = pts_get_appdata();
288 if (strcmp(part, "elm.text.1") == 0) {
289 //if (printer != NULL) {
290 //return strdup(printer->name);
292 return strdup(_("IDS_PRT_BODY_PRINTER"));
294 } else if (strcmp(part, "elm.text.2") == 0) {
295 //if (printer != NULL) {
296 if (ad->list_info.active_printer != NULL) {
297 char *printer_label = strdup(ad->list_info.active_printer->name);
298 pts_unstandardization(printer_label);
299 //return strdup(printer->address);
301 return printer_label;
304 return strdup(PTS_18);
312 * get the label of the option setting
314 #define MAX_TMP_BUF 64
315 static char *__pts_setting_view_option_label_get(void *data, Evas_Object *obj, const char *part)
318 struct appdata *ad = pts_get_appdata();
319 pt_printer_mgr_t *active_printer = ad->list_info.active_printer;
320 pt_print_option_e option_type = (pt_print_option_e)data;
322 char buf[MAX_TMP_BUF];
324 if (strcmp(part, "elm.text.1") == 0) {
325 switch (option_type) {
326 case PT_OPTION_ID_COPIES:
327 return strdup(_("IDS_PRT_BODY_NUMBEROFCOPIES"));
328 case PT_OPTION_ID_PAPERSIZE:
329 return strdup(_("IDS_PRT_BODY_PAPERSIZE"));
330 case PT_OPTION_ID_RANGE:
331 return strdup(_("IDS_PRT_BODY_PRINT_RANGE_ABB"));
332 case PT_OPTION_ID_GRAYSCALE:
333 return strdup(_("IDS_PRT_BODY_COLOUR"));
334 case PT_OPTION_ID_QUALITY:
335 return strdup(_("IDS_PRT_BODY_PRINTSETTINGS_PRINT_QUALITY"));
336 case PT_OPTION_ID_PAPER:
337 return strdup(_("IDS_IMGE_BUTTON_PAPER_M_STICKER"));
338 case PT_OPTION_ID_DUPLEX:
339 return strdup(IDS_PRINT_SETTINGS_DUPLEX);
341 return strdup(PTS_17);
343 } else if (strcmp(part, "elm.text.2") == 0) {
345 switch (option_type) {
346 case PT_OPTION_ID_COPIES: {
347 snprintf(buf, MAX_TMP_BUF, "%d", active_printer->copies);
348 PTS_DEBUG("Selected copies[%d, %s]",active_printer->copies, buf);
351 case PT_OPTION_ID_PAPERSIZE: {
352 active_printer->size = pt_get_selected(PT_OPTION_ID_PAPERSIZE);
353 strncpy(buf, pt_get_print_option_papersize(active_printer->size), MAX_TMP_BUF-1);
354 PTS_DEBUG("Selected paper size[%d, %s]", active_printer->size, buf);
357 case PT_OPTION_ID_RANGE: {
358 pt_range_e p_range = active_printer->range;
359 if (PT_RANGE_ALL == p_range) {
360 strcpy(buf, _("IDS_DIC_BODY_ALL"));
362 strcpy(buf, _("IDS_BR_BODY_CURRENT_PAGE"));
364 PTS_DEBUG("Selected range[%d, %s]", p_range, buf);
367 case PT_OPTION_ID_GRAYSCALE: {
368 int p_grayscale = pt_get_selected(PT_OPTION_ID_GRAYSCALE);
370 if (PT_GRAYSCALE_COLOUR == p_grayscale) {
371 strcpy(buf, _("IDS_PRT_BODY_COLOUR"));
372 } else if (PT_GRAYSCALE_GRAYSCALE == p_grayscale) {
373 strcpy(buf, _("IDS_IMGE_HEADER_GREY"));
374 } /* else if (PT_GRAYSCALE_BLACKNWHITE == *p_value) {
375 strcpy(buf, _("IDS_BR_OPT_BLACKNWHITE"));
378 PTS_DEBUG("Selected color [%d, %s]", p_grayscale, buf);
381 case PT_OPTION_ID_QUALITY: {
382 int p_quality = pt_get_selected(PT_OPTION_ID_QUALITY);
383 if (PT_QUALITY_DRAFT == p_quality) {
384 strcpy(buf, _("IDS_PRT_OPT_PRINTSETTINGS_DRAFT"));
385 } else if (PT_QUALITY_STANDARD == p_quality) {
386 strcpy(buf, _("IDS_PRT_OPT_PRINTSETTINGS_STANDARD"));
387 } else if (PT_QUALITY_HIGH == p_quality) {
388 strcpy(buf, _("IDS_COM_BODY_HIGH"));
390 PTS_DEBUG("Selected quality [%d, %s]", p_quality, buf);
393 case PT_OPTION_ID_PAPER: {
394 int p_type = pt_get_selected(PT_OPTION_ID_PAPER);
395 if (PT_PAPER_NORMAL == p_type) {
396 strcpy(buf, _("IDS_ST_BODY_NORMAL"));
397 } else if (PT_PAPER_GLOSSY == p_type) {
398 strcpy(buf, _("IDS_ST_BODY_GLOSSY"));
399 } else if (PT_PAPER_PHOTO == p_type) {
400 strcpy(buf, _("IDS_PRT_BODY_PHOTOGRAPHIC_ABB"));
402 PTS_DEBUG("Selected paper type [%d, %s]", p_type, buf);
405 case PT_OPTION_ID_DUPLEX: {
406 int p_dup = pt_get_selected(PT_OPTION_ID_DUPLEX);
407 if (PT_DUPLEX_OFF == p_dup) {
408 strcpy(buf, IDS_PRINT_SETTINGS_DUPLEX_OFF);
409 } else if (PT_DUPLEX_NO_TUMBLE == p_dup || PT_DUPLEX_TUMBLE == p_dup) {
410 strcpy(buf, IDS_PRINT_SETTINGS_DUPLEX_ON);
412 PTS_DEBUG("Selected duplex mode [%d, %s]", p_dup, buf);
416 return strdup(PTS_17);
429 __pts_setting_view_gl_content_get(void *data, Evas_Object *obj, const char *part)
432 pts_appdata_t *ad = pts_get_appdata();
433 Evas_Object *radio_button = NULL;
434 Item_data *core = (Item_data *)data;
437 if (!strcmp(part, "elm.icon")) {
438 switch (core->option) {
439 case PT_OPTION_ID_PAPERSIZE:
440 selected = pt_get_selected(PT_OPTION_ID_PAPERSIZE);
442 case PT_OPTION_ID_RANGE:
443 selected = ad->list_info.active_printer->range;
445 case PT_OPTION_ID_QUALITY:
446 selected = pt_get_selected(PT_OPTION_ID_QUALITY);
448 case PT_OPTION_ID_PAPER:
449 selected = pt_get_selected(PT_OPTION_ID_PAPER);
451 case PT_OPTION_ID_GRAYSCALE:
452 selected = pt_get_selected(PT_OPTION_ID_GRAYSCALE);
454 case PT_OPTION_ID_DUPLEX:
455 selected = pt_get_selected(PT_OPTION_ID_DUPLEX);
457 /* case PT_OPTION_ID_COPIES: */
462 PTS_DEBUG("Create Radio button[%d] (%d,%d) , r_group= [0x%x] selected: %d",
463 core->radio_index, core->option, core->sub_item, core->radio_group, selected);
465 radio_button = elm_radio_add(obj);
466 core->radio_btn = radio_button;
467 evas_object_propagate_events_set(radio_button, EINA_TRUE);
468 elm_radio_state_value_set(radio_button, core->radio_index);
469 elm_radio_group_add(radio_button, core->radio_group);
470 elm_radio_value_set(core->radio_group, selected);
471 evas_object_show(radio_button);
472 evas_object_size_hint_weight_set(radio_button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
473 evas_object_size_hint_align_set(radio_button, EVAS_HINT_FILL, EVAS_HINT_FILL);
476 return radio_button ;
485 __pts_setting_view_gl_state_item_delete(void *data, Evas_Object *obj)
488 PTS_RET_IF(data == NULL, "data is NULL");
489 Item_data *core = (Item_data *)data;
490 pts_appdata_t *ad = pts_get_appdata();
491 PTS_RET_IF(ad == NULL, "ad is NULL");
493 switch (core->option) {
494 case PT_OPTION_ID_QUALITY:
495 ad->setting_info.quality[core->sub_item] = NULL;
497 case PT_OPTION_ID_PAPER:
498 ad->setting_info.paper_type[core->sub_item] = NULL;
500 case PT_OPTION_ID_GRAYSCALE:
501 ad->setting_info.color[core->sub_item] = NULL;
503 case PT_OPTION_ID_PAPERSIZE:
504 ad->setting_info.paper_size[core->sub_item] = NULL;
506 case PT_OPTION_ID_DUPLEX:
507 ad->setting_info.duplex[core->sub_item] = NULL;
512 PTS_DEBUG("Free core memory");
513 PTS_IF_FREE_MEM(core);
519 * get the papersize value of the key
521 static char *__pts_setting_view_papersize_key_label_get(void *data, Evas_Object *obj, const char *part)
524 Item_data *core = (Item_data *)data;
525 pt_paper_size_e p_size = (pt_paper_size_e)core->sub_item;
527 if (p_size < (pt_paper_size_e)0 || p_size >= pt_get_print_option_papersize_num()) {
528 PTS_DEBUG("wrong paper size: %d", p_size);
532 return strdup(pt_get_print_option_papersize(p_size));
536 * get the grayscale value of the key
538 static char *__pts_setting_view_grayscale_key_label_get(void *data, Evas_Object *obj, const char *part)
541 Item_data *core = (Item_data *)data;
542 pt_grayscale_e p_grayscale = (pt_grayscale_e)core->sub_item;
545 //PTS_RETV_IF(p_grayscale < 0 ||p_grayscale >= PT_GRAYSCALE_ANY, NULL, "wrong gray scale: %d", p_grayscale);
547 if (strcmp(part, "elm.text") == 0) {
548 switch (p_grayscale) {
549 case PT_GRAYSCALE_COLOUR:
550 ret = strdup(_("IDS_PRT_BODY_COLOUR"));
552 case PT_GRAYSCALE_GRAYSCALE:
553 ret = strdup(_("IDS_IMGE_HEADER_GREY"));
564 * get the quality value of the key
566 static char *__pts_setting_view_quality_key_label_get(void *data, Evas_Object *obj, const char *part)
569 Item_data *core = (Item_data *)data;
570 pt_quality_e p_quality = (pt_quality_e)core->sub_item;
573 //PTS_RETV_IF(p_quality < 0 || p_quality >= PT_QUALITY_ANY, NULL, "wrong paper quality: %d", p_quality);
575 if (strcmp(part, "elm.text") == 0) {
578 ret = strdup(_("IDS_PRT_OPT_PRINTSETTINGS_DRAFT"));
581 ret = strdup(_("IDS_PRT_OPT_PRINTSETTINGS_STANDARD"));
584 ret = strdup(_("IDS_COM_BODY_HIGH"));
595 * get the paper type value of the key
597 static char *__pts_setting_view_paper_key_label_get(void *data, Evas_Object *obj, const char *part)
600 Item_data *core = (Item_data *)data;
601 pt_papertype_e p_type = (pt_papertype_e) core->sub_item;
604 //PTS_RETV_IF(p_type < 0 || p_type >= PT_PAPER_ANY, NULL, "wrong paper type: %d", p_type);
606 if (strcmp(part, "elm.text") == 0) {
609 ret = strdup(_("IDS_ST_BODY_NORMAL"));
612 ret = strdup(_("IDS_ST_BODY_GLOSSY"));
615 ret = strdup(_("IDS_PRT_BODY_PHOTOGRAPHIC_ABB"));
626 * get the range label of the key
628 static char *__pts_setting_view_range_key_label_get(void *data, Evas_Object *obj, const char *part)
631 Item_data *core = (Item_data *)data;
632 pt_range_e p_range = (pt_range_e)core->sub_item;
635 //PTS_RETV_IF(p_range < PT_RANGE_ALL || p_range > PT_RANGE_CURRENT, NULL, "wrong paper range: %d", p_range);
639 ret = strdup(_("IDS_DIC_BODY_ALL"));
641 case PT_RANGE_CURRENT:
642 ret = strdup(_("IDS_BR_BODY_CURRENT_PAGE"));
653 * get the duplex value of the key
655 static char *__pts_setting_view_duplex_key_label_get(void *data, Evas_Object *obj, const char *part)
658 Item_data *core = (Item_data *)data;
659 pt_duplex_e p_duplex = (pt_duplex_e)core->sub_item;
662 if (strcmp(part, "elm.text") == 0) {
665 ret = strdup(IDS_PRINT_SETTINGS_DUPLEX_OFF);
667 case PT_DUPLEX_NO_TUMBLE:
668 case PT_DUPLEX_TUMBLE:
669 ret = strdup(IDS_PRINT_SETTINGS_DUPLEX_ON);
679 static void __pts_setting_view_enable_disable(pts_appdata_t *ad)
682 for (i=0; i<PT_QUALITY_ANY; i++) {
683 if (ad->setting_info.quality[i]) {
684 if (pt_is_enabled(PT_OPTION_ID_QUALITY, i)) {
685 elm_object_item_disabled_set(ad->setting_info.quality[i], EINA_FALSE);
687 elm_object_item_disabled_set(ad->setting_info.quality[i], EINA_TRUE);
691 for (i=0; i<PT_PAPER_ANY; i++) {
692 if (ad->setting_info.paper_type[i]) {
693 if (pt_is_enabled(PT_OPTION_ID_PAPER, i)) {
694 elm_object_item_disabled_set(ad->setting_info.paper_type[i], EINA_FALSE);
696 elm_object_item_disabled_set(ad->setting_info.paper_type[i], EINA_TRUE);
700 for (i=0; i<PT_GRAYSCALE_ANY; i++) {
701 if (ad->setting_info.color[i]) {
702 if (pt_is_enabled(PT_OPTION_ID_GRAYSCALE, i)) {
703 elm_object_item_disabled_set(ad->setting_info.color[i], EINA_FALSE);
705 elm_object_item_disabled_set(ad->setting_info.color[i], EINA_TRUE);
709 for (i=0; i<PT_DUPLEX_ANY-1; i++) {
710 if (ad->setting_info.duplex[i]) {
711 if (pt_is_enabled(PT_OPTION_ID_DUPLEX, i)) {
712 elm_object_item_disabled_set(ad->setting_info.duplex[i], EINA_FALSE);
714 elm_object_item_disabled_set(ad->setting_info.duplex[i], EINA_TRUE);
718 for (i=0; i<pt_get_print_option_papersize_num(); i++) {
719 if (ad->setting_info.paper_size[i]) {
720 if (pt_is_enabled(PT_OPTION_ID_PAPERSIZE, i)) {
721 elm_object_item_disabled_set(ad->setting_info.paper_size[i], EINA_FALSE);
723 elm_object_item_disabled_set(ad->setting_info.paper_size[i], EINA_TRUE);
730 * Select the option from list
732 static void __pts_setting_view_key_value_sel(void *user_data, Evas_Object *obj, void *event_info)
736 Item_data *core = (Item_data *) user_data;
737 struct appdata *ad = pts_get_appdata();
738 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
739 Elm_Object_Item *parent_item = NULL;
741 elm_genlist_item_selected_set(item, EINA_FALSE);
743 if (NULL != core && NULL != core->item) {
745 switch (core->option) {
746 case PT_OPTION_ID_PAPERSIZE:
747 ad->list_info.active_printer->size = core->sub_item;
748 parent_item = ad->setting_info.item_paper_size;
749 pt_set_choice(PT_OPTION_ID_PAPERSIZE, core->sub_item);
750 PTS_DEBUG("Paper size select: %d", ad->list_info.active_printer->size);
752 case PT_OPTION_ID_COPIES:
753 ad->list_info.active_printer->copies = core->sub_item;
754 parent_item = ad->setting_info.item_paper_copies;
755 PTS_DEBUG("Print copy select: %d", ad->list_info.active_printer->copies);
757 case PT_OPTION_ID_RANGE:
758 ad->list_info.active_printer->range = core->sub_item;
759 parent_item = ad->setting_info.item_page_range;
760 PTS_DEBUG("Print range select: %d", ad->list_info.active_printer->range);
762 case PT_OPTION_ID_QUALITY:
763 pt_set_choice(PT_OPTION_ID_QUALITY, core->sub_item);
764 parent_item = ad->setting_info.item_paper_quality;
765 PTS_DEBUG("Print quality select: %d", pt_get_selected(PT_OPTION_ID_QUALITY));
767 case PT_OPTION_ID_PAPER:
768 pt_set_choice(PT_OPTION_ID_PAPER, core->sub_item);
769 parent_item = ad->setting_info.item_paper_type;
770 PTS_DEBUG("Paper type select: %d", pt_get_selected(PT_OPTION_ID_PAPER));
772 case PT_OPTION_ID_GRAYSCALE:
773 pt_set_choice(PT_OPTION_ID_GRAYSCALE, core->sub_item);
774 parent_item = ad->setting_info.item_grayscale;
775 PTS_DEBUG("Print color select: %d", pt_get_selected(PT_OPTION_ID_GRAYSCALE));
777 case PT_OPTION_ID_DUPLEX:
778 pt_set_choice(PT_OPTION_ID_DUPLEX, core->sub_item);
779 parent_item = ad->setting_info.item_duplex;
780 PTS_DEBUG("Duplex select: %d", pt_get_selected(PT_OPTION_ID_DUPLEX));
783 PTS_DEBUG("Unknown option: %d", core->option);
788 elm_radio_value_set(core->radio_group, core->radio_index);
789 __pts_setting_view_enable_disable(ad);
791 elm_genlist_item_update(parent_item);
793 PTS_DEBUG("Update radio group: r_group=[0x%x <-- %d]", core->radio_group, core->radio_index);
796 PTS_DEBUG("data or data->item are NULL");
802 static Item_data *__pts_setting_view_add_genlist_item(
803 Evas_Object *genlist,
804 Elm_Object_Item *parent,
805 pt_print_option_e option,
807 int *radio_btn_index,
808 Evas_Object *radio_group,
812 PTS_RETV_IF(genlist == NULL, NULL, "genlist is NULL");
814 Elm_Genlist_Item_Class *itc = NULL;
816 if (PT_OPTION_ID_PAPERSIZE == option) {
817 itc_paper_size.item_style = "dialogue/1text.1icon/expandable2";
818 itc_paper_size.func.text_get = __pts_setting_view_papersize_key_label_get;
819 itc_paper_size.func.content_get = __pts_setting_view_gl_content_get;
820 itc_paper_size.func.state_get = NULL; //__pts_setting_view_gl_state_get;
821 itc_paper_size.func.del = __pts_setting_view_gl_state_item_delete;
822 itc = &itc_paper_size;
823 } else if (PT_OPTION_ID_GRAYSCALE == option) {
824 itc_grayscale.item_style = "dialogue/1text.1icon/expandable2";
825 itc_grayscale.func.text_get = __pts_setting_view_grayscale_key_label_get;
826 itc_grayscale.func.content_get = __pts_setting_view_gl_content_get;
827 itc_grayscale.func.state_get = NULL; //__pts_setting_view_gl_state_get;
828 itc_grayscale.func.del = __pts_setting_view_gl_state_item_delete;
829 itc = &itc_grayscale;
830 } else if (PT_OPTION_ID_QUALITY == option) {
831 itc_paper_quality.item_style = "dialogue/1text.1icon/expandable2";
832 itc_paper_quality.func.text_get = __pts_setting_view_quality_key_label_get;
833 itc_paper_quality.func.content_get = __pts_setting_view_gl_content_get;
834 itc_paper_quality.func.state_get = NULL; //__pts_setting_view_gl_state_get;
835 itc_paper_quality.func.del = __pts_setting_view_gl_state_item_delete;
836 itc = &itc_paper_quality;
837 } else if (PT_OPTION_ID_PAPER == option) {
838 itc_paper_type.item_style = "dialogue/1text.1icon/expandable2";
839 itc_paper_type.func.text_get = __pts_setting_view_paper_key_label_get;
840 itc_paper_type.func.content_get = __pts_setting_view_gl_content_get;
841 itc_paper_type.func.state_get = NULL; //__pts_setting_view_gl_state_get;
842 itc_paper_type.func.del = __pts_setting_view_gl_state_item_delete;
843 itc = &itc_paper_type;
844 } else if (PT_OPTION_ID_RANGE == option) {
845 itc_page_range.item_style = "dialogue/1text.1icon/expandable2";
846 itc_page_range.func.text_get = __pts_setting_view_range_key_label_get;
847 itc_page_range.func.content_get = __pts_setting_view_gl_content_get;
848 itc_page_range.func.state_get = NULL; //__pts_setting_view_gl_state_get;
849 itc_page_range.func.del = __pts_setting_view_gl_state_item_delete;
850 itc = &itc_page_range;
851 } else if (PT_OPTION_ID_DUPLEX == option) {
852 itc_duplex.item_style = "dialogue/1text.1icon/expandable2";
853 itc_duplex.func.text_get = __pts_setting_view_duplex_key_label_get;
854 itc_duplex.func.content_get = __pts_setting_view_gl_content_get;
855 itc_duplex.func.state_get = NULL;
856 itc_duplex.func.del = __pts_setting_view_gl_state_item_delete;
859 PTS_DEBUG("Unknown option: %d", option);
864 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
865 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
867 Item_data *core = calloc(1, sizeof(Item_data));
868 core->option = option;
869 core->sub_item = sub_item;
870 core->radio_index = *radio_btn_index;
871 core->radio_group = radio_group;
873 core->item = elm_genlist_item_append(
878 ELM_GENLIST_ITEM_NONE,
879 __pts_setting_view_key_value_sel,
882 if (!pt_is_enabled(option, sub_item)) {
883 elm_object_item_disabled_set(core->item, EINA_TRUE);
886 ++(*radio_btn_index);
893 static Evas_Object *__pts_create_radio_group(Evas_Object *genlist)
895 Evas_Object *radio = elm_radio_add(genlist);
896 elm_radio_state_value_set(radio, 0);
897 elm_radio_value_set(radio, 0);
903 * Callback for expandable genlist expand
905 static void __pts_setting_view_gl_exp(void *data, Evas_Object *obj, void *event_info)
908 PTS_RET_IF(NULL == event_info, "item object is NULL");
910 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
911 Evas_Object *genlist = elm_object_item_widget_get(item);
912 pts_appdata_t *ad = (pts_appdata_t *)data;
916 elm_genlist_item_selected_set(item, EINA_FALSE);
918 if (ad->setting_info.radio_group_paper_size == NULL) {
919 ad->setting_info.radio_group_paper_size = __pts_create_radio_group(genlist);
921 if (ad->setting_info.radio_group_paper_quality == NULL) {
922 ad->setting_info.radio_group_paper_quality = __pts_create_radio_group(genlist);
924 if (ad->setting_info.radio_group_paper_type == NULL) {
925 ad->setting_info.radio_group_paper_type = __pts_create_radio_group(genlist);
927 if (ad->setting_info.radio_group_page_range == NULL) {
928 ad->setting_info.radio_group_page_range = __pts_create_radio_group(genlist);
930 if (ad->setting_info.radio_group_grayscale == NULL) {
931 ad->setting_info.radio_group_grayscale = __pts_create_radio_group(genlist);
933 if (ad->setting_info.radio_group_duplex == NULL) {
934 ad->setting_info.radio_group_duplex = __pts_create_radio_group(genlist);
937 if (item == ad->setting_info.item_paper_size) {
940 for (i = 0; i < pt_get_print_option_papersize_num(); i++) {
941 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);
943 ad->setting_info.paper_size[i] = i_d->item;
946 } else if (item == ad->setting_info.item_paper_quality) {
948 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;
949 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;
950 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;
951 } else if (item == ad->setting_info.item_paper_type) {
953 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;
954 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;
955 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;
956 } else if (item == ad->setting_info.item_page_range) {
958 __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);
959 __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);
960 } else if (item == ad->setting_info.item_grayscale) {
962 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;
963 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;
964 } else if (item == ad->setting_info.item_duplex) {
966 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;
967 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;
969 PTS_DEBUG("Unknown item");
976 * Accessability info for items from list
978 static void __pts_setting_view_gl_realized(void *data, Evas_Object *obj, void *event_info)
981 PTS_RET_IF(NULL == event_info, "item object is NULL");
982 PTS_RET_IF(NULL == data, "ad is NULL");
984 Elm_Object_Item *item = (Elm_Object_Item *)event_info;
985 pts_appdata_t *ad = (pts_appdata_t *)data;
986 void *item_data = elm_object_item_data_get(item);
987 //PTS_RET_IF(NULL == item_data, "item data is NULL"); //FIXME: related to Jira issue #
989 pt_print_option_e option = (pt_print_option_e)item_data;
990 PTS_RET_IF(option >= PT_OPTION_ID_MAX, "UNKNOWN OPTION REALIZED - %d", option);
992 PTS_DEBUG("realized print option: [%d]\n", option);
994 if (PT_OPTION_ID_PAPERSIZE == option
995 || PT_OPTION_ID_RANGE == option
996 || PT_OPTION_ID_QUALITY == option
997 || PT_OPTION_ID_PAPER == option
998 || PT_OPTION_ID_GRAYSCALE == option
999 || PT_OPTION_ID_DUPLEX == option) {
1001 Evas_Object *ao = elm_object_item_access_object_get(item);
1002 PTS_RET_IF(NULL == ao, "Access object is NULL");
1003 elm_access_info_set(ao, ELM_ACCESS_TYPE, IDS_SCRREAD_EXPANDABLE_LIST_TYPE);
1004 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, IDS_SCRREAD_EXPANDABLE_LIST_CONTEXT);
1005 PTS_DEBUG("Item #%d access context info: [%s]", option, IDS_SCRREAD_EXPANDABLE_LIST_CONTEXT);
1006 } else if (PT_OPTION_ID_COPIES == option) {
1007 Evas_Object *ao = elm_object_item_access_object_get(item);
1008 PTS_RET_IF(NULL == ao, "Access object is NULL");
1009 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, IDS_SCRREAD_SETTINS_ITEM_CONTEXT);
1010 PTS_DEBUG("Item #%d access context info: [%s]", option, IDS_SCRREAD_SETTINS_ITEM_CONTEXT);
1011 } else if (PT_OPTION_ID_PRINTER == option) {
1012 Evas_Object *ao = elm_object_item_access_object_get(item);
1013 PTS_RET_IF(NULL == ao, "Access object is NULL");
1014 elm_access_info_set(ao, ELM_ACCESS_CONTEXT_INFO, IDS_SCRREAD_PRINTER_ITEM_CONTEXT);
1015 PTS_DEBUG("Item #printer access context info: [%s]", IDS_SCRREAD_PRINTER_ITEM_CONTEXT);
1022 * create the content of setting view
1024 static Evas_Object *__pts_setting_view_create_content(Evas_Object *parent, pts_appdata_t *ad)
1027 PTS_RETV_IF(ad == NULL, NULL, "ad is NULL");
1028 PTS_RETV_IF(parent == NULL, NULL, "parent is NULL");
1030 Evas_Object *genlist = NULL;
1031 Elm_Object_Item *separator_item;
1033 //itc_separator.item_style = "dialogue/separator/21/with_line";
1034 itc_separator.item_style = "dialogue/separator";
1035 itc_separator.func.text_get = NULL;
1036 itc_separator.func.content_get = NULL;
1037 itc_separator.func.state_get = NULL;
1038 itc_separator.func.del = NULL;
1040 itc_printer.item_style = "dialogue/2text";
1041 itc_printer.func.text_get = __pts_setting_view_printer_label_get;
1042 itc_printer.func.content_get = NULL;
1043 itc_printer.func.state_get = NULL;
1044 itc_printer.func.del = NULL;
1046 //itc_tree_options.item_style = "dialogue/2text/expandable";
1047 itc_tree_options.item_style = "dialogue/2text.3/expandable";
1048 itc_tree_options.func.text_get = __pts_setting_view_option_label_get;
1049 itc_tree_options.func.content_get = NULL;
1050 itc_tree_options.func.state_get = NULL;
1051 itc_tree_options.func.del = NULL;
1053 itc_normal_options.item_style = "dialogue/2text";
1054 itc_normal_options.func.text_get = __pts_setting_view_option_label_get;
1055 itc_normal_options.func.content_get = NULL;
1056 itc_normal_options.func.state_get = NULL;
1057 itc_normal_options.func.del = NULL;
1059 genlist = elm_genlist_add(parent);
1061 elm_object_style_set(genlist, "dialogue");
1062 elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
1064 separator_item= elm_genlist_item_append(
1069 ELM_GENLIST_ITEM_NONE,
1072 elm_genlist_item_select_mode_set(separator_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1074 ad->setting_info.printer_item = elm_genlist_item_append(
1077 (void *)PT_OPTION_ID_PRINTER,
1079 ELM_GENLIST_ITEM_NONE,
1080 __pts_setting_view_printer_sel, ad);
1082 ad->setting_info.header_separator_item = elm_genlist_item_append(
1087 ELM_GENLIST_ITEM_NONE,
1089 elm_genlist_item_select_mode_set(ad->setting_info.header_separator_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1091 ad->setting_info.item_paper_size = elm_genlist_item_append(
1094 (void *)PT_OPTION_ID_PAPERSIZE,
1096 ELM_GENLIST_ITEM_TREE,
1097 __pts_setting_view_gl_sel,
1100 ad->setting_info.item_paper_copies = elm_genlist_item_append(
1102 &itc_normal_options,
1103 (void *)PT_OPTION_ID_COPIES,
1105 ELM_GENLIST_ITEM_NONE,
1106 _create_copies_popup_timepicker,
1109 ad->setting_info.item_page_range = elm_genlist_item_append(
1112 (void *)PT_OPTION_ID_RANGE,
1114 ELM_GENLIST_ITEM_TREE,
1115 __pts_setting_view_gl_sel,
1118 ad->setting_info.item_paper_quality = elm_genlist_item_append(
1121 (void *)PT_OPTION_ID_QUALITY,
1123 ELM_GENLIST_ITEM_TREE,
1124 __pts_setting_view_gl_sel,
1127 ad->setting_info.item_paper_type = elm_genlist_item_append(
1130 (void *)PT_OPTION_ID_PAPER,
1132 ELM_GENLIST_ITEM_TREE,
1133 __pts_setting_view_gl_sel,
1136 ad->setting_info.item_grayscale = elm_genlist_item_append(
1139 (void *)PT_OPTION_ID_GRAYSCALE,
1141 ELM_GENLIST_ITEM_TREE,
1142 __pts_setting_view_gl_sel,
1145 ad->setting_info.item_duplex = elm_genlist_item_append(
1148 (void *)PT_OPTION_ID_DUPLEX,
1150 ELM_GENLIST_ITEM_TREE,
1151 __pts_setting_view_gl_sel,
1155 ad->setting_info.footer_separator_item = elm_genlist_item_append(
1160 ELM_GENLIST_ITEM_NONE,
1162 elm_genlist_item_select_mode_set(ad->setting_info.footer_separator_item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
1164 evas_object_smart_callback_add(genlist, "expanded", __pts_setting_view_gl_exp, ad);
1165 evas_object_smart_callback_add(genlist, "contracted", __pts_setting_view_gl_con, ad);
1167 /* Accessability information callback */
1168 evas_object_smart_callback_add(genlist, "realized", __pts_setting_view_gl_realized, ad);
1170 /* Add touch coordinates handler */
1171 //Ecore_Event_Handler *event;
1172 //event = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_DOWN, _mousedown_cb, NULL);
1173 //evas_object_smart_callback_add(genlist, "clicked", _back_cb, event);
1180 * This function let the app create setting view
1182 * @param[in] sd the pointer to the printer setting structure
1184 void pts_create_setting_view(pts_appdata_t *ad)
1187 PTS_RET_IF(ad == NULL, "ad is NULL");
1189 Evas_Object *back_btn = NULL;
1190 //Evas_Object *layout = NULL;
1191 Evas_Object *genlist = NULL;
1192 Elm_Object_Item *navi_item = NULL;
1194 //layout = pts_utils_create_layout(ugd->navi);
1195 //evas_object_show(layout);
1197 genlist = __pts_setting_view_create_content(ad->main_info.navi, ad);
1198 //elm_object_content_set(layout, genlist);
1199 evas_object_size_hint_weight_set(genlist, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
1200 evas_object_size_hint_align_set(genlist, EVAS_HINT_FILL, EVAS_HINT_FILL);
1202 back_btn = elm_button_add(ad->main_info.navi);
1203 elm_object_style_set(back_btn, "naviframe/end_btn/default");
1205 navi_item = elm_naviframe_item_push(ad->main_info.navi, _("IDS_SMPOS_HEADER_PRINTER_SETTINGS"), back_btn, NULL, genlist, NULL);
1206 elm_naviframe_item_pop_cb_set(navi_item, __pts_setting_view_btn_back_cb, ad);