2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.tizenopensource.org/license
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
18 #include <setting-phone-display-language.h>
20 static int setting_phone_display_language_create(void *cb);
21 static int setting_phone_display_language_destroy(void *cb);
22 static int setting_phone_display_language_cleanup(void *cb);
25 setting_view setting_view_phone_display_language = {
26 .create = setting_phone_display_language_create,
27 .destroy = setting_phone_display_language_destroy,
29 .cleanup = setting_phone_display_language_cleanup,
32 static void setting_phone_display_language_caller_exist_left_cb(void *data,
37 setting_retm_if(data == NULL, "Data parameter is NULL");
38 SettingPhoneUG *ad = (SettingPhoneUG *) data;
40 /* Create Bundle and send message */
43 setting_retm_if(b == NULL, "bundle_create failed");
45 bundle_add(b, "result", "lbutton_click");
46 ug_send_result(ad->ug, b);
49 ug_destroy_me(ad->ug);
55 static void setting_phone_display_language_caller_exist_right_cb(void *data,
60 setting_retm_if(data == NULL, "Data parameter is NULL");
61 SettingPhoneUG *ad = (SettingPhoneUG *) data;
64 int cur_chk_lang = (int)elm_radio_value_get(ad->chk_lang);
66 setting_phone_lang_change_lang_value(cur_chk_lang);
68 SETTING_TRACE("---> cur_chk_lang : %d", cur_chk_lang);
69 ret = setting_set_int_slp_key(INT_SLP_SETTING_LANG, cur_chk_lang, &err);
71 if (0 == cur_chk_lang) {
72 (void)vconf_set_str(VCONFKEY_LANGSET, ad->sim_lang);
75 /* Just filter out Setting App, other Apps stil need to be terminated
76 until they implement updating language or region automatically */
77 if (aul_app_get_running_app_info(app_terminate_func, NULL) < 0) {
78 /* tet_infoline("aul_app_get_running_app_info() failed in positive test case"); */
81 const char *pa_lang = vconf_get_str(VCONFKEY_LANGSET);
83 char *q = strchr(pa_lang, '.');
87 SETTING_TRACE("pa_lang:%s", pa_lang);
89 uloc_setDefault(pa_lang, &err);
90 free((void *)pa_lang);
93 SETTING_TRACE_ERROR("get vconf failed");
96 /* Create Bundle and send message */
99 setting_retm_if(b == NULL, "bundle_create failed");
101 bundle_add(b, "result", "rbutton_click");
102 ug_send_result(ad->ug, b);
105 ug_destroy_me(ad->ug);
109 /* ***************************************************
113 ***************************************************/
115 static int setting_phone_display_language_create(void *cb)
119 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
121 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
122 char *title = _("IDS_ST_HEADER_DISPLAY_LANGUAGE");
124 Evas_Object *scroller = NULL;
125 setting_call_back_func gl_sel_cb = NULL;
127 if (&setting_view_phone_display_language == ad->view_to_load) {
132 setting_call_back_func l_button_cb = NULL;
133 setting_call_back_func r_button_cb = NULL;
135 bundle *data = ad->bundle_data;
136 if (NULL != (temp = (char *)bundle_get_val(data, "lbutton"))) {
139 setting_phone_display_language_caller_exist_left_cb;
142 if (NULL != (temp = (char *)bundle_get_val(data, "title"))) {
146 if (NULL != (temp = (char *)bundle_get_val(data, "rbutton"))) {
149 setting_phone_display_language_caller_exist_right_cb;
153 setting_create_layout_navi_bar_genlist(ad->win_main_layout,
161 gl_sel_cb = setting_mouse_up_Gendial_list_radio_cb;
163 /* add basic layout */
164 setting_push_layout_navi_bar_genlist(ad->win_main_layout, ad->win_get,
165 title, _("IDS_COM_BODY_BACK"),
167 setting_phone_display_language_click_softkey_cancel_cb,
168 NULL, ad, &scroller, ad->navi_bar);
169 gl_sel_cb = setting_phone_display_language_mouse_up_Gendial_list_radio_cb;
172 ad->gl_lang = scroller;
174 Elm_Object_Item *item = NULL;
176 elm_genlist_item_append(scroller, &(ad->itc_seperator), NULL, NULL,
177 ELM_GENLIST_ITEM_NONE, NULL, NULL);
178 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
180 /* scroller is a genlist */
181 ad->chk_lang = elm_radio_add(scroller);
182 elm_radio_state_value_set(ad->chk_lang, -1);
186 setting_lang_entry* table = setting_get_language_table();
189 Setting_GenGroupItem_Data *item_data = NULL;
191 setting_create_Gendial_field_1radio(scroller,
192 &(ad->itc_1text_1icon_2),
197 "IDS_COM_BODY_AUTOMATIC", NULL);
199 item_data->userdata = ad;
201 SETTING_TRACE_ERROR("item_data is NULL");
205 setting_create_Gendial_field_1radio(scroller,
206 &(ad->itc_1text_1icon_2),
212 table[SETTING_LANG_KOREA].title, NULL);
214 item_data->userdata = ad;
216 SETTING_TRACE_ERROR("item_data is NULL");
220 setting_create_Gendial_field_1radio(scroller,
221 &(ad->itc_1text_1icon_2),
226 SETTING_LANG_ENGLISH,
227 table[SETTING_LANG_ENGLISH].title, NULL);
229 item_data->userdata = ad;
231 SETTING_TRACE_ERROR("item_data is NULL");
235 setting_create_Gendial_field_1radio(scroller,
236 &(ad->itc_1text_1icon_2),
242 table[SETTING_LANG_GERMAN].title, NULL);
244 item_data->userdata = ad;
246 SETTING_TRACE_ERROR("item_data is NULL");
250 setting_create_Gendial_field_1radio(scroller,
251 &(ad->itc_1text_1icon_2),
257 table[SETTING_LANG_DUTCH].title, NULL);
259 item_data->userdata = ad;
261 SETTING_TRACE_ERROR("item_data is NULL");
265 setting_create_Gendial_field_1radio(scroller,
266 &(ad->itc_1text_1icon_2),
271 SETTING_LANG_SPAINISH,
272 table[SETTING_LANG_SPAINISH].title, NULL);
274 item_data->userdata = ad;
276 SETTING_TRACE_ERROR("item_data is NULL");
280 setting_create_Gendial_field_1radio(scroller,
281 &(ad->itc_1text_1icon_2),
286 SETTING_LANG_PORTUGUESE,
287 table[SETTING_LANG_PORTUGUESE].title, NULL);
289 item_data->userdata = ad;
291 SETTING_TRACE_ERROR("item_data is NULL");
295 setting_create_Gendial_field_1radio(scroller,
296 &(ad->itc_1text_1icon_2),
302 table[SETTING_LANG_GREEK].title, NULL);
304 item_data->userdata = ad;
306 SETTING_TRACE_ERROR("item_data is NULL");
310 setting_create_Gendial_field_1radio(scroller,
311 &(ad->itc_1text_1icon_2),
316 SETTING_LANG_ITALIAN,
317 table[SETTING_LANG_ITALIAN].title, NULL);
319 item_data->userdata = ad;
321 SETTING_TRACE_ERROR("item_data is NULL");
325 setting_create_Gendial_field_1radio(scroller,
326 &(ad->itc_1text_1icon_2),
332 table[SETTING_LANG_FRENCH].title, NULL);
334 item_data->userdata = ad;
336 SETTING_TRACE_ERROR("item_data is NULL");
340 setting_create_Gendial_field_1radio(scroller,
341 &(ad->itc_1text_1icon_2),
346 SETTING_LANG_TURKISH,
347 table[SETTING_LANG_TURKISH].title, NULL);
349 item_data->userdata = ad;
351 SETTING_TRACE_ERROR("item_data is NULL");
355 setting_create_Gendial_field_1radio(scroller,
356 &(ad->itc_1text_1icon_2),
361 SETTING_LANG_RUSSIAN,
362 table[SETTING_LANG_RUSSIAN].title, NULL);
364 item_data->userdata = ad;
366 SETTING_TRACE_ERROR("item_data is NULL");
369 // set radio button to the selected state.
372 ret = setting_get_int_slp_key(INT_SLP_SETTING_LANG, &index, &err);
373 elm_radio_value_set(ad->chk_lang, index);
375 ad->prev_lang = (int)elm_radio_value_get(ad->chk_lang);
376 setting_view_phone_display_language.is_create = 1;
378 return SETTING_RETURN_SUCCESS;
381 static int setting_phone_display_language_destroy(void *cb)
385 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
386 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
388 /* FIXED : destroy only if it was created. */
389 if (setting_view_phone_display_language.is_create) {
391 evas_object_del(ad->popup);
395 if (ad->pop_progress) {
396 evas_object_del(ad->pop_progress);
397 ad->pop_progress = NULL;
399 if (ad->killed_pid_list) {
400 eina_list_free(ad->killed_pid_list);
401 ad->killed_pid_list = NULL;
403 elm_naviframe_item_pop(ad->navi_bar);
404 setting_view_phone_display_language.is_create = 0;
407 return SETTING_RETURN_SUCCESS;
410 static int setting_phone_display_language_cleanup(void *cb)
414 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
415 setting_phone_display_language_destroy(cb);
417 return SETTING_RETURN_SUCCESS;
421 setting_phone_display_language_click_softkey_cancel_cb(void *data,
427 retm_if(data == NULL, "Data parameter is NULL");
428 SettingPhoneUG *ad = (SettingPhoneUG *) data;
429 setting_view_change(&setting_view_phone_display_language,
430 &setting_view_phone_language_region, ad);
434 setting_phone_display_language_mouse_up_Gendial_list_radio_cb(void *data,
440 setting_retm_if(data == NULL, "Data parameter is NULL");
441 setting_retm_if(event_info == NULL,
442 "Invalid argument: event info is NULL");
444 Evas_Object *radio = (Evas_Object *) data;
445 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
446 elm_genlist_item_selected_set(item, 0);
447 Setting_GenGroupItem_Data *list_item =
448 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
449 SettingPhoneUG *ad = (SettingPhoneUG *) list_item->userdata;
455 /* if not change, return */
456 if (ad->prev_lang == list_item->chk_status) {
457 SETTING_TRACE("NOT CHANGED ");
461 elm_radio_value_set(radio, list_item->chk_status);
462 setting_phone_display_language_close_popup_ex(ad);
465 static void setting_phone_display_language_close_popup_ex(void *data)
468 setting_retm_if(data == NULL, "Data parameter is NULL");
469 SettingPhoneUG *ad = (SettingPhoneUG *) data;
471 ad->popup_cb = setting_phone_display_language_exit_cb_ex;
472 ad->popup = setting_create_popup_with_btn(ad, ad->win_get,
474 ("IDS_ST_POP_CHANGING_LANGUAGE_WILL_CLOSE_ALL_APPLICATIONS_AND_UNSAVED_DATA_WILL_BE_LOST_CONTINUE_Q"),
475 NULL, ad->popup_cb, 0,
476 2, _("IDS_COM_SK_YES"),_("IDS_COM_SK_NO"));
480 setting_phone_display_language_exit_cb_ex(void *data, Evas_Object *obj,
484 setting_retm_if(data == NULL, "Data parameter is NULL");
485 SettingPhoneUG *ad = (SettingPhoneUG *) data;
487 switch (btn_type(obj)) {
488 case POPUP_RESPONSE_OK:
490 ad->prev_lang = elm_radio_value_get(ad->chk_lang);
491 SETTING_TRACE("cur_chk_lang = %d", ad->prev_lang);
493 /////////////////////////////////////////////////////////////////
494 // 0. change VCONFKEY_LANGSET
495 /////////////////////////////////////////////////////////////////
496 setting_phone_lang_change_lang_value(ad->prev_lang);
498 if (ad->killed_pid_list) {
499 eina_list_free(ad->killed_pid_list);
500 ad->killed_pid_list = NULL;
503 /////////////////////////////////////////////////////////////////
505 /////////////////////////////////////////////////////////////////
506 /* just filter out Setting App, other Apps stil need to be terminated untill they implement updating language or region automatically */
507 if (aul_app_get_running_app_info (app_terminate_func, ad) < 0) {
508 /* tet_infoline("aul_app_get_running_app_info() failed in positive test case"); */
511 SETTING_TRACE("eina_list_count(ad->killed_pid_list):%d", eina_list_count(ad->killed_pid_list));
512 if (0 != eina_list_count(ad->killed_pid_list)) {
513 if (ad->pop_progress) {
514 evas_object_del(ad->pop_progress);
515 ad->pop_progress = NULL;
517 ad->pop_progress = setting_create_popup_with_progressbar(ad, ad->win_get,
519 NULL, NULL, NULL, 10);
522 /* if set automatic */
523 if (0 == ad->prev_lang) {
524 vconf_set_str(VCONFKEY_LANGSET, ad->sim_lang);
527 /////////////////////////////////////////////////////////////////
528 // 2. GET SELECTED LANG
529 /////////////////////////////////////////////////////////////////
530 const char *pa_lang = vconf_get_str(VCONFKEY_LANGSET);
531 if (pa_lang) { /* remove the */
532 char *q = strchr(pa_lang, '.');
536 SETTING_TRACE("pa_lang:%s", pa_lang);
538 /////////////////////////////////////////////////////////////////
540 /////////////////////////////////////////////////////////////////
541 // default UI language
542 uloc_setDefault(pa_lang, &err);
545 /* after lang-change, go back to the previous page*/
546 elm_naviframe_item_pop(ad->navi_bar);
547 setting_view_phone_display_language.is_create = 0;
551 case POPUP_RESPONSE_CANCEL:
553 elm_radio_value_set(ad->chk_lang, ad->prev_lang);
555 evas_object_del(ad->popup);
563 evas_object_del(ad->popup);
571 evas_object_del(ad->popup);