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-phone-display-language.h>
24 static int setting_phone_display_language_create(void *cb);
25 static int setting_phone_display_language_destroy(void *cb);
26 static int setting_phone_display_language_cleanup(void *cb);
29 setting_view setting_view_phone_display_language = {
30 .create = setting_phone_display_language_create,
31 .destroy = setting_phone_display_language_destroy,
33 .cleanup = setting_phone_display_language_cleanup,
39 static void setting_phone_display_language_caller_exist_right_cb(void *data,
44 setting_retm_if(data == NULL, "Data parameter is NULL");
46 SettingPhoneUG *ad = (SettingPhoneUG *) data;
50 int cur_chk_lang = (int)elm_radio_value_get(ad->chk_lang);
52 setting_phone_lang_change_lang_value(cur_chk_lang);
54 //ret = setting_get_int_slp_key(INT_SLP_SETTING_LANG, &chr_chk_lang, &err);
55 SETTING_TRACE("---> cur_chk_lang : %d", cur_chk_lang);
56 ret = setting_set_int_slp_key(INT_SLP_SETTING_LANG, cur_chk_lang, &err);
58 if (0 == cur_chk_lang) {
59 (void)vconf_set_str(VCONFKEY_LANGSET, ad->sim_lang);
62 /* Just filter out Setting App, other Apps stil need to be terminated
63 until they implement updating language or region automatically */
65 const char *pa_lang = vconf_get_str(VCONFKEY_LANGSET);
67 char *q = strchr(pa_lang, '.');
71 SETTING_TRACE("pa_lang:%s", pa_lang);
73 uloc_setDefault(pa_lang, &err);
74 free((void *)pa_lang);
77 SETTING_TRACE_ERROR("get vconf failed");
81 /* Create Bundle and send message */
83 if(service_create(&svc))
86 service_add_extra_data(svc, "result", "rbutton_click");
87 ug_send_result(ad->ug, svc);
91 ug_destroy_me(ad->ug);
95 /* ***************************************************
99 ***************************************************/
101 static int setting_phone_display_language_create(void *cb)
105 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
107 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
108 char *title = _("IDS_ST_HEADER_DISPLAY_LANGUAGE");
110 Evas_Object *scroller = NULL;
111 setting_call_back_func gl_sel_cb = NULL;
113 if (&setting_view_phone_display_language == ad->view_to_load) {
116 service_h service = ad->bundle_data;
118 service_get_extra_data(service, "caller", &caller);
122 ad->ly_language = setting_create_layout_navi_bar_genlist(ad->win_main_layout,
125 _("IDS_COM_BODY_BACK"), NULL,
126 setting_phone_display_language_caller_exist_right_cb, NULL,
127 ad, &scroller, &ad->navi_bar);
128 gl_sel_cb = setting_phone_display_language_mouse_up_Gendial_list_radio_cb;
132 SETTING_TRACE_ERROR("[ERROR] caller is empty");
133 return SETTING_RETURN_FAIL;
136 /* add basic layout */
137 setting_push_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get,
138 title, _("IDS_COM_BODY_BACK"),
140 setting_phone_display_language_click_softkey_cancel_cb,
141 NULL, ad, &scroller, ad->navi_bar);
142 gl_sel_cb = setting_phone_display_language_mouse_up_Gendial_list_radio_cb;
145 ad->gl_lang = scroller;
147 Elm_Object_Item *item = NULL;
149 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
150 ELM_GENLIST_ITEM_NONE, NULL, NULL);
151 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
153 /* scroller is a genlist */
154 ad->chk_lang = elm_radio_add(scroller);
155 elm_radio_state_value_set(ad->chk_lang, -1);
160 Setting_GenGroupItem_Data *item_data = NULL;
162 setting_create_Gendial_field_1radio(scroller,
163 &(ad->itc_1text_1icon_2),
168 "IDS_COM_BODY_AUTOMATIC", NULL);
170 item_data->userdata = ad;
172 SETTING_TRACE_ERROR("item_data is NULL");
175 // create loop operation here
176 Eina_List* elist = NULL;
177 setting_lang_entry* pnode = NULL;
178 int idx = SETTING_LANG_KOREA; // 2
180 // load language table from XML file
181 Eina_List* langlist = setting_get_language_list();
183 EINA_LIST_FOREACH( langlist, elist, pnode)
186 setting_create_Gendial_field_1radio(scroller,
187 &(ad->itc_1text_1icon_2),
192 //idx, // <<< WARNING
196 item_data->userdata = ad;
198 SETTING_TRACE_ERROR("item_data is NULL");
203 item = elm_genlist_item_append(scroller, &itc_bottom_seperator, NULL, NULL,
204 ELM_GENLIST_ITEM_NONE, NULL, NULL);
205 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
207 // set radio button to the selected state.
210 ret = setting_get_int_slp_key(INT_SLP_SETTING_LANG, &index, &err);
211 elm_radio_value_set(ad->chk_lang, index);
213 ad->prev_lang = (int)elm_radio_value_get(ad->chk_lang);
214 setting_view_phone_display_language.is_create = 1;
216 return SETTING_RETURN_SUCCESS;
219 static int setting_phone_display_language_destroy(void *cb)
223 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
224 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
226 /* FIXED : destroy only if it was created. */
227 if (setting_view_phone_display_language.is_create) {
229 evas_object_del(ad->popup);
233 if (ad->pop_progress) {
234 evas_object_del(ad->pop_progress);
235 ad->pop_progress = NULL;
237 elm_naviframe_item_pop(ad->navi_bar);
238 setting_view_phone_display_language.is_create = 0;
240 setting_get_language_list_destroy();
243 return SETTING_RETURN_SUCCESS;
246 static int setting_phone_display_language_cleanup(void *cb)
250 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
251 setting_phone_display_language_destroy(cb);
253 return SETTING_RETURN_SUCCESS;
257 setting_phone_display_language_click_softkey_cancel_cb(void *data,
263 retm_if(data == NULL, "Data parameter is NULL");
264 SettingPhoneUG *ad = (SettingPhoneUG *) data;
265 setting_view_change(&setting_view_phone_display_language,
266 &setting_view_phone_language_region, ad);
270 setting_phone_display_language_mouse_up_Gendial_list_radio_cb(void *data,
276 setting_retm_if(data == NULL, "Data parameter is NULL");
277 setting_retm_if(event_info == NULL,
278 "Invalid argument: event info is NULL");
280 Evas_Object *radio = (Evas_Object *) data;
281 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
282 elm_genlist_item_selected_set(item, 0);
283 Setting_GenGroupItem_Data *list_item =
284 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
285 SettingPhoneUG *ad = (SettingPhoneUG *) list_item->userdata;
290 //SETTING_TRACE("---------------------------------------------");
291 //SETTING_TRACE("ad->prev_lang = %d ", ad->prev_lang);
292 //SETTING_TRACE("chk_status = %d ", list_item->chk_status);
293 //SETTING_TRACE("---------------------------------------------");
294 /* if not change, return */
295 if (ad->prev_lang == list_item->chk_status) {
296 SETTING_TRACE("NOT CHANGED ");
300 elm_radio_value_set(radio, list_item->chk_status);
301 setting_phone_display_language_close_popup_ex(ad);
304 static void setting_phone_display_language_close_popup_ex(void *data)
307 setting_retm_if(data == NULL, "Data parameter is NULL");
308 SettingPhoneUG *ad = (SettingPhoneUG *) data;
310 ad->prev_lang = elm_radio_value_get(ad->chk_lang);
311 SETTING_TRACE("cur_chk_lang = %d", ad->prev_lang);
313 // 0. change VCONFKEY_LANGSET
314 setting_phone_lang_change_lang_value(ad->prev_lang);
316 /* if set automatic */
317 if (0 == ad->prev_lang) {
318 vconf_set_str(VCONFKEY_LANGSET, ad->sim_lang);
321 // 2. GET SELECTED LANG
322 const char *pa_lang = vconf_get_str(VCONFKEY_LANGSET);
323 if (pa_lang) { /* remove the */
324 char *q = strchr(pa_lang, '.');
328 SETTING_TRACE("pa_lang:%s", pa_lang);
331 // default UI language
332 uloc_setDefault(pa_lang, &err);
333 if (U_FAILURE(err)) {
334 SETTING_TRACE("FAILED : uloc_setDefault error code : %d", err);
336 SETTING_TRACE("SUCCESS : uloc_setDefault error code : %d", err);
341 service_h service = ad->bundle_data;
343 service_get_extra_data(service, "caller", &caller);
346 /* Create Bundle and send message */
348 if(service_create(&svc))
351 service_add_extra_data(svc, "result", "rbutton_click");
352 ug_send_result(ad->ug, svc);
354 service_destroy(svc);
356 ug_destroy_me(ad->ug);
359 /* after lang-change, go back to the previous page*/
360 elm_naviframe_item_pop(ad->navi_bar);
361 setting_view_phone_display_language.is_create = 0;