4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
6 * Contact: MyoungJune Park <mj2004.park@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
21 #include <setting-display-screen-mode.h>
24 static int setting_display_screen_mode_create(void *cb);
25 static int setting_display_screen_mode_destroy(void *cb);
26 static int setting_display_screen_mode_update(void *cb);
27 static int setting_display_screen_mode_cleanup(void *cb);
29 static char* str_in_arr[] = {"Dynamic", "Standard", "Natural", "Movie"};
30 static char* str_out_arr[] = {Keystr_Dynamic, Keystr_Standard, Keystr_Natural, Keystr_Movie};
32 static void setting_display_screen_mode_mouse_up_Gendial_list_radio_cb(void *data, Evas_Object *obj, void *event_info);
34 setting_view setting_view_display_screen_mode = {
35 .create = setting_display_screen_mode_create,
36 .destroy = setting_display_screen_mode_destroy,
37 .update = setting_display_screen_mode_update,
38 .cleanup = setting_display_screen_mode_cleanup,
42 static Evas_Object *__gl_content_get(void *data, Evas_Object *obj, const char *part)
44 if (!strcmp(part, "elm.icon")) {
45 Evas_Object *sub_layout = elm_layout_add(obj);
46 elm_layout_file_set(sub_layout, SETTING_THEME_EDJ_NAME, "screen_mode");
47 evas_object_size_hint_weight_set(sub_layout, EVAS_HINT_EXPAND, 0.0);
48 evas_object_show(sub_layout);
50 Evas_Object *image = elm_image_add(obj);
51 elm_image_file_set(image, IMG_SCREEN_MODE, NULL);
52 elm_image_resizable_set(image, EINA_TRUE, EINA_TRUE);
53 evas_object_show(image);
57 elm_image_object_size_get(image, &w, &h);
58 setting_resize_object(image, w * WIDGET_SCALE_FACTOR, h * WIDGET_SCALE_FACTOR);
60 elm_object_part_content_set(sub_layout, "content", image);
67 static void __gl_item_del(void *data, Evas_Object *obj)
69 setting_retm_if(data == NULL, "Data parameter is NULL");
70 Setting_GenGroupItem_Data *item_data = (Setting_GenGroupItem_Data *) data;
72 G_FREE(item_data->keyStr);
73 G_FREE(item_data->sub_desc);
78 /* ***************************************************
82 ***************************************************/
83 static int setting_display_screen_mode_create(void *cb)
87 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
89 SettingDisplayUG *ad = (SettingDisplayUG *) cb;
91 setting_call_back_func gl_sel_cb = NULL;
92 Evas_Object *genlist = NULL;
93 Setting_GenGroupItem_Data *item_data = NULL;
95 genlist = elm_genlist_add(ad->navi_bar);
96 retvm_if(genlist == NULL, SETTING_RETURN_FAIL, "scroller == NULL");
97 elm_object_style_set(genlist, "dialogue");
98 elm_genlist_clear(genlist); /* first to clear list */
100 setting_push_layout_navi_bar(_(Keystr_ScreenMode), _("IDS_COM_BODY_BACK"),
102 setting_display_screen_mode_click_softkey_back_cb,
103 NULL, NULL, ad, genlist, ad->navi_bar, NULL);
105 Elm_Object_Item *item = elm_genlist_item_append(genlist,
108 ELM_GENLIST_ITEM_NONE,
110 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
112 ad->itc_screen_mode.item_style = "1icon";
113 ad->itc_screen_mode.func.text_get = NULL;
114 ad->itc_screen_mode.func.content_get = __gl_content_get;
115 ad->itc_screen_mode.func.state_get = NULL;
116 ad->itc_screen_mode.func.del = __gl_item_del;
118 Setting_GenGroupItem_Data *screen_mode = (Setting_GenGroupItem_Data *) calloc(1, sizeof(Setting_GenGroupItem_Data));
119 setting_retvm_if(!screen_mode, SETTING_RETURN_FAIL, "calloc failed");
122 screen_mode->userdata = ad;
123 screen_mode->item = elm_genlist_item_append(genlist, &(ad->itc_screen_mode), screen_mode, NULL,
124 ELM_GENLIST_ITEM_NONE, NULL, NULL);
125 elm_genlist_item_select_mode_set(screen_mode->item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
127 SETTING_TRACE_ERROR("screen_mode is NULL");
128 return SETTING_RETURN_FAIL;
131 gl_sel_cb = setting_display_screen_mode_mouse_up_Gendial_list_radio_cb;
133 Evas_Object *radio = elm_radio_add(genlist);
134 elm_radio_state_value_set(radio, -1);
136 char* curmode = vconf_get_str(VCONFKEY_SETAPPL_SCREENMODE_SELNAME);
137 SETTING_TRACE(">>> CUR SCREEN MODE : %s ", curmode);
141 for (i=0; i< sizeof(str_in_arr)/sizeof(str_in_arr[0]) ;i++)
143 item_data = setting_create_Gendial_field_1radio(genlist,
144 &(itc_1text_1icon_2),
146 radio, /* sel data */
149 str_out_arr[i], NULL);
151 item_data->userdata = ad;
153 SETTING_TRACE_ERROR("item_data is NULL");
159 for (j=0; j< sizeof(str_in_arr)/sizeof(str_in_arr[0]) ;j++) {
160 if (0 == strcmp(str_in_arr[j], curmode)) {
161 elm_radio_value_set(radio, j);
166 item = elm_genlist_item_append(genlist, &itc_bottom_seperator, NULL, NULL,
167 ELM_GENLIST_ITEM_NONE, NULL, NULL);
168 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
170 setting_view_display_screen_mode.is_create = 1;
171 return SETTING_RETURN_SUCCESS;
174 static int setting_display_screen_mode_destroy(void *cb)
178 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
180 SettingDisplayUG *ad = (SettingDisplayUG *) cb;
182 elm_naviframe_item_pop(ad->navi_bar);
184 setting_view_display_screen_mode.is_create = 0;
186 return SETTING_RETURN_SUCCESS;
189 static int setting_display_screen_mode_update(void *cb)
193 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
195 return SETTING_RETURN_SUCCESS;
198 static int setting_display_screen_mode_cleanup(void *cb)
201 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
203 SettingDisplayUG *ad = (SettingDisplayUG *) cb;
205 setting_display_screen_mode_destroy(ad);
207 return SETTING_RETURN_SUCCESS;
210 /* ***************************************************
214 ***************************************************/
217 setting_display_screen_mode_click_softkey_back_cb(void *data, Evas_Object *obj, void *event_info)
221 setting_retm_if(data == NULL,
222 "[Setting > Display] Data parameter is NULL");
224 SettingDisplayUG *ad = (SettingDisplayUG *) data;
226 setting_view_change(&setting_view_display_screen_mode, &setting_view_display_main, ad);
232 setting_display_screen_mode_mouse_up_Gendial_list_radio_cb(void *data, Evas_Object *obj, void *event_info)
236 setting_retm_if(data == NULL, "Data parameter is NULL");
237 setting_retm_if(event_info == NULL,
238 "Invalid argument: event info is NULL");
240 Evas_Object *radio = (Evas_Object *) data;
241 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
242 elm_genlist_item_selected_set(item, 0);
244 Setting_GenGroupItem_Data *list_item =
245 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
246 //SettingDisplayUG *ad = (SettingDisplayUG *) list_item->userdata;
248 elm_radio_value_set(radio, list_item->chk_status);
249 vconf_set_str(VCONFKEY_SETAPPL_SCREENMODE_SELNAME, str_in_arr[list_item->chk_status]);
250 /* Set status to device manager */
251 device_set_image_enhance_mode(list_item->chk_status);
252 SETTING_TRACE(">>> AFTER VCONF SET : %s ", str_in_arr[list_item->chk_status]);