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-font.h>
22 #include <system_settings.h>
24 #define UG_MODULE_API __attribute__ ((visibility("default")))
27 setting_view *__get_font_view_to_load(void *data,service_h service)
30 setting_retvm_if((!data), NULL, "data is NULL");
31 SettingFontUG *fontUG = (SettingFontUG *)data;
33 setting_view_node_table_intialize();
35 char *category = NULL;
36 service_get_extra_data(service, "category", &category);
38 if (0 == safeStrCmp(category, "FontType")) {
39 SETTING_TRACE("LAUNCHED BY APP-CONTROL MODE");
40 fontUG->viewmode = FONT_SEL_VIEW_APPCONTROL;
42 setting_view_node_table_register(&setting_view_font_font_size, &setting_view_font_main);
43 setting_view_node_table_register(&setting_view_font_main, NULL);
44 return &setting_view_font_main;
45 } else if (0 == safeStrCmp(category, "FontSize")) {
46 SETTING_TRACE("category = %s", category);
47 fontUG->viewmode = FONT_SIZE_VIEW_APPCONTROL;
48 setting_view_node_table_register(&setting_view_font_font_size, NULL);
49 return &setting_view_font_font_size;
51 SETTING_TRACE("HERE ?? <<<<< ");
52 fontUG->viewmode = FONT_SIZE_AND_FONT_SEL_UG; // set default
53 setting_view_node_table_register(&setting_view_font_font_size, &setting_view_font_main);
54 setting_view_node_table_register(&setting_view_font_main, NULL);
55 return &setting_view_font_main;
59 static void setting_font_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
62 SettingFontUG *ad = (SettingFontUG *) data;
63 setting_view_update(&setting_view_font_main, ad);
66 static void *setting_font_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
67 service_h service, void *priv)
69 setting_retvm_if((!priv), NULL, "!priv");
70 SettingFontUG *fontUG = priv;
72 appcore_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
75 fontUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
76 fontUG->win_get = (Evas_Object *) ug_get_window();
77 evas_object_show(fontUG->win_main_layout);
78 fontUG->evas = evas_object_evas_get(fontUG->win_main_layout);
80 setting_retvm_if(fontUG->win_main_layout == NULL, NULL,
81 "cannot get main window ");
83 fontUG->itc_seperator.item_style = "dialogue/separator/21/with_line";
84 fontUG->itc_seperator.func.text_get = NULL;
85 fontUG->itc_seperator.func.content_get = NULL;
86 fontUG->itc_seperator.func.state_get = NULL;
87 fontUG->itc_seperator.func.del = NULL;
89 setting_create_Gendial_itc("dialogue/2text.3/expandable", &(fontUG->itc_2text_3_parent));
90 setting_create_Gendial_itc("dialogue/1text.1icon/expandable2", &(fontUG->itc_1icon_1text_sub));
91 setting_create_Gendial_itc("dialogue/2text.3", &(fontUG->itc_2text_2));
92 setting_create_Gendial_itc("dialogue/1text.1icon.6", &(fontUG->itc_1text_1icon_2));
93 setting_create_Gendial_itc("dialogue/title", &(fontUG->itc_group_item));
94 setting_create_Gendial_itc("multiline/1text", &(fontUG->itc_bg_1icon));
97 fontUG->view_to_load = __get_font_view_to_load(fontUG, service);
98 setting_retvm_if(NULL == fontUG->view_to_load, NULL, "NULL == fontUG->view_to_load");
100 setting_view_node_set_cur_view(fontUG->view_to_load);
101 setting_view_create(fontUG->view_to_load, (void *)fontUG);
103 /* creating a view. */
104 //setting_view_create(&setting_view_font_main, (void *)fontUG);
105 evas_object_event_callback_add(fontUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_font_ug_cb_resize, fontUG);
106 return fontUG->ly_main;
109 static void setting_font_ug_on_start(ui_gadget_h ug, service_h service,
114 static void setting_font_ug_on_pause(ui_gadget_h ug, service_h service,
119 static void setting_font_ug_on_resume(ui_gadget_h ug, service_h service,
124 static void setting_font_ug_on_destroy(ui_gadget_h ug, service_h service,
128 setting_retm_if((!priv), "!priv");
129 SettingFontUG *fontUG = priv;
131 evas_object_event_callback_del(fontUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_font_ug_cb_resize); /* fix flash issue for gallery */
134 /* delete the allocated objects. */
135 if (fontUG->view_to_load == &setting_view_font_font_size) {
136 setting_view_destroy(&setting_view_font_font_size, fontUG);
138 setting_view_destroy(&setting_view_font_font_size, fontUG);
139 setting_view_destroy(&setting_view_font_main, fontUG);
142 if (NULL != ug_get_layout(fontUG->ug)) {
143 evas_object_hide((Evas_Object *) ug_get_layout(fontUG->ug));
144 evas_object_del((Evas_Object *) ug_get_layout(fontUG->ug));
150 static void setting_font_ug_on_message(ui_gadget_h ug, service_h msg,
151 service_h service, void *priv)
156 static void setting_font_ug_on_event(ui_gadget_h ug, enum ug_event event,
157 service_h service, void *priv)
161 case UG_EVENT_LOW_MEMORY:
163 case UG_EVENT_LOW_BATTERY:
165 case UG_EVENT_LANG_CHANGE:
167 case UG_EVENT_ROTATE_PORTRAIT:
169 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
171 case UG_EVENT_ROTATE_LANDSCAPE:
173 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
175 case UG_EVENT_REGION_CHANGE:
182 static void setting_font_ug_on_key_event(ui_gadget_h ug,
183 enum ug_key_event event, service_h service,
191 case UG_KEY_EVENT_END:
199 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
202 SettingFontUG *fontUG = calloc(1, sizeof(SettingFontUG));
203 setting_retvm_if(!fontUG, -1, "Create SettingFontUG obj failed");
205 ops->create = setting_font_ug_on_create;
206 ops->start = setting_font_ug_on_start;
207 ops->pause = setting_font_ug_on_pause;
208 ops->resume = setting_font_ug_on_resume;
209 ops->destroy = setting_font_ug_on_destroy;
210 ops->message = setting_font_ug_on_message;
211 ops->event = setting_font_ug_on_event;
212 ops->key_event = setting_font_ug_on_key_event;
214 ops->opt = UG_OPT_INDICATOR_ENABLE;
219 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
222 struct SettingFontUG *fontUG;
223 setting_retm_if(!ops, "ops == NULL");
231 /* ***************************************************
235 ***************************************************/
237 int setting_font_update_vconf_key_int_type(void *data,
238 setting_int_slp_list slp_key)
243 return SETTING_GENERAL_ERR_NULL_DATA_PARAMETER;
246 int ret = SETTING_RETURN_FAIL;
249 /* SettingFontUG *ad = (SettingFontUG *)data; */
251 ret = setting_get_int_slp_key(slp_key, &value, &err);
255 case INT_SLP_SETTING_LCD_TIMEOUT_NORMAL:
257 if (ret == SETTING_RETURN_FAIL) value = SETTING_BACKLIGHT_TIME_15SEC;
261 case SETTING_BACKLIGHT_TIME_8SEC: edje_object_part_text_set(_EDJ(ad->eo_DC_backlight), DC_ITEM_SUB_STR_BACKLIGHT, _(STR_SETTING_8SEC)); break;
262 case SETTING_BACKLIGHT_TIME_15SEC: edje_object_part_text_set(_EDJ(ad->eo_DC_backlight), DC_ITEM_SUB_STR_BACKLIGHT, _(STR_SETTING_15SEC)); break;
263 case SETTING_BACKLIGHT_TIME_30SEC: edje_object_part_text_set(_EDJ(ad->eo_DC_backlight), DC_ITEM_SUB_STR_BACKLIGHT, _(STR_SETTING_30SEC)); break;
264 case SETTING_BACKLIGHT_TIME_1MIN: edje_object_part_text_set(_EDJ(ad->eo_DC_backlight), DC_ITEM_SUB_STR_BACKLIGHT, _(STR_SETTING_1MIN)); break;
265 case SETTING_BACKLIGHT_TIME_3MIN: edje_object_part_text_set(_EDJ(ad->eo_DC_backlight), DC_ITEM_SUB_STR_BACKLIGHT, _(STR_SETTING_3MIN)); break;
266 case SETTING_BACKLIGHT_TIME_10MIN: edje_object_part_text_set(_EDJ(ad->eo_DC_backlight), DC_ITEM_SUB_STR_BACKLIGHT, _(STR_SETTING_10MIN)); break;
267 default: ret = SETTING_GENERAL_ERR_NOT_FIND_VALUE_SWITCH;
274 ret = SETTING_GENERAL_ERR_NOT_FIND_VALUE_SWITCH;
281 int setting_font_update_vconf_key(void *data, setting_vconf_type type,
287 return SETTING_GENERAL_ERR_NULL_DATA_PARAMETER;
290 int ret = SETTING_RETURN_FAIL;
291 SettingFontUG *ad = (SettingFontUG *) data;
294 case SETTING_VCONF_INT_TYPE:
295 ret = setting_font_update_vconf_key_int_type(ad, slp_key);
298 case SETTING_VCONF_BOOL_TYPE:
301 case SETTING_VCONF_STR_TYPE:
311 * Reset function to 'reset' the settings of the UG, it will be invoked by 'Reset' UG
313 UG_MODULE_API int setting_plugin_reset(service_h service, void *priv)
316 //int ret = vconf_set_str(VCONFKEY_SETAPPL_DEVICE_NAME_STR, "Fraser");
318 #if SUPPORT_RUN_SYSTEM_COMMAND
319 ret += excuteCmd(SETTING_POSTINST_FILE, 1, "font");
321 /* reset font type, default is HelveticaNeue */
322 font_config_set("HelveticaNeue");
324 /* reset font size */
325 ret += vconf_set_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_FONT_SIZE_NORMAL); // 3 is normal size
326 setting_retvm_if(ret == -1, -1, "Failed to set vconf");