4 * Copyright (c) 2000 - 2012 Samsung Electronics Co., Ltd All Rights Reserved
6 * This file is part of org.tizen.setting
7 * Written by Hyejin Kim <hyejin0906.kim@samsung.com>
9 * PROPRIETARY/CONFIDENTIAL
11 * This software is the confidential and proprietary information of
12 * SAMSUNG ELECTRONICS ("Confidential Information"). You shall not
13 * disclose such Confidential Information and shall use it only in
14 * accordance with the terms of the license agreement you entered
15 * into with SAMSUNG ELECTRONICS.
17 * SAMSUNG make no representations or warranties about the suitability
18 * of the software, either express or implied, including but not limited
19 * to the implied warranties of merchantability, fitness for a particular
20 * purpose, or non-infringement. SAMSUNG shall not be liable for any
21 * damages suffered by licensee as a result of using, modifying or
22 * distributing this software or its derivatives.
25 #include <setting-phone-language-region.h>
27 static int setting_phone_language_region_create(void *cb);
28 static int setting_phone_language_region_destroy(void *cb);
29 static int setting_phone_language_region_update(void *cb);
30 static int setting_phone_language_region_cleanup(void *cb);
32 setting_view setting_view_phone_language_region = {
33 .create = setting_phone_language_region_create,
34 .destroy = setting_phone_language_region_destroy,
35 .update = setting_phone_language_region_update,
36 .cleanup = setting_phone_language_region_cleanup,
39 static void setting_phone_lang_click_softkey_cancel_cb(void *data,
42 static void setting_phone_lang_item_Gendial_mouse_up_cb(void *data,
47 /* ***************************************************
51 ***************************************************/
53 static int setting_phone_language_region_create(void *cb)
57 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
59 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
60 Evas_Object *scroller = NULL;
62 char *title = _(KeyStr_LanguageRegion);
64 setting_create_layout_navi_bar_genlist(ad->win_main_layout,
66 _("IDS_COM_BODY_BACK"),
68 setting_phone_lang_click_softkey_cancel_cb,
71 retv_if(ad->ly_language == NULL, SETTING_RETURN_FAIL);
72 ad->gl_lang_region = scroller;
74 Elm_Object_Item *item = NULL;
76 elm_genlist_item_append(scroller, &(ad->itc_seperator),
77 NULL, NULL, ELM_GENLIST_ITEM_NONE,
79 elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
81 char* pa_display_lang = get_pa_display_language_str();
82 ad->data_display_language =
83 setting_create_Gendial_field_def(scroller,
85 setting_phone_lang_item_Gendial_mouse_up_cb,
86 ad, SWALLOW_Type_INVALID,
88 "IDS_ST_HEADER_DISPLAY_LANGUAGE",
91 if (ad->data_display_language) {
92 ad->data_display_language->userdata = ad;
94 SETTING_TRACE_ERROR("ad->data_display_language is NULL");
96 G_FREE(pa_display_lang);
98 char *pa_region = vconf_get_str(VCONFKEY_REGIONFORMAT);
99 if (pa_region == NULL) {
101 ("[Error] get value of VCONFKEY_REGIONFORMAT fail.");
103 ad->prev_locale = (char *)g_strdup(pa_region);
104 ad->data_region_fmt =
105 setting_create_Gendial_field_def(scroller,
107 setting_phone_lang_item_Gendial_mouse_up_cb,
108 ad, SWALLOW_Type_INVALID,
110 "IDS_ST_BODY_REGION",
111 setting_phone_lang_get_region_str
113 if (ad->data_region_fmt) {
114 ad->data_region_fmt->userdata = ad;
116 SETTING_TRACE_ERROR("ad->data_region_fmt is NULL");
120 setting_phone_lang_get_example_desc(pa_region, ad);
121 ad->data_region_fmt_example =
122 setting_create_Gendial_field_def(scroller,
123 &(ad->itc_bg_1icon), NULL,
125 SWALLOW_Type_LAYOUT_SPECIALIZTION,
127 example_desc, NULL, NULL);
135 setting_view_phone_language_region.is_create = 1;
136 return SETTING_RETURN_SUCCESS;
139 static int setting_phone_language_region_destroy(void *cb)
143 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
145 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
147 if (ad->ly_language != NULL) {
148 evas_object_del(ad->ly_language);
149 ad->ly_language = NULL;
151 if (ad->pattern_generator) {
152 udatpg_close(ad->pattern_generator);
153 ad->pattern_generator = NULL;
155 setting_view_phone_language_region.is_create = 0;
158 return SETTING_RETURN_SUCCESS;
161 static int setting_phone_language_region_update(void *cb)
165 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
167 SettingPhoneUG *ad = (SettingPhoneUG *) cb;
169 if (ad->ly_language != NULL) {
170 evas_object_show(ad->ly_language);
173 return SETTING_RETURN_SUCCESS;
176 static int setting_phone_language_region_cleanup(void *cb)
179 return SETTING_RETURN_SUCCESS;
182 /* ***************************************************
186 ***************************************************/
188 /* ***************************************************
192 ***************************************************/
195 setting_phone_lang_click_softkey_cancel_cb(void *data, Evas_Object *obj,
200 retm_if(data == NULL, "Data parameter is NULL");
202 SettingPhoneUG *ad = (SettingPhoneUG *) data;
204 ug_destroy_me(ad->ug);
208 void setting_phone_lang_change_lang_value(int cur_chk_lang)
213 /** @todo ASSERT ( SCOPE CHECK ) */
214 setting_lang_entry* table = setting_get_language_table();
215 char* locale = table[cur_chk_lang].locale;
216 SETTING_TRACE("table . locale >>>>>> :: %s ", locale);
218 //if (cur_chk_lang > 0) {
220 ret = setting_set_int_slp_key(INT_SLP_SETTING_LANG, cur_chk_lang, &err);
221 ret = vconf_set_str(VCONFKEY_LANGSET, locale);
223 // do nothing on 'auto'
226 static void setting_phone_lang_item_Gendial_mouse_up_cb(void *data,
232 setting_retm_if(data == NULL, "Data parameter is NULL");
233 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
234 elm_genlist_item_selected_set(item, 0);
235 Setting_GenGroupItem_Data *list_item =
236 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
237 SETTING_TRACE("clicking item[%s]", _(list_item->keyStr));
239 SettingPhoneUG *ad = (SettingPhoneUG *) data;
241 int ret = SETTING_RETURN_SUCCESS;
242 if (!safeStrCmp("IDS_ST_HEADER_DISPLAY_LANGUAGE", list_item->keyStr)) {
244 setting_view_change(&setting_view_phone_language_region,
245 &setting_view_phone_display_language,
247 } else if (!safeStrCmp("IDS_ST_BODY_REGION", list_item->keyStr)) {
249 setting_view_change(&setting_view_phone_language_region,
250 &setting_view_phone_region_format, ad);