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>
23 #include <setting-cfg.h>
26 #define UG_MODULE_API __attribute__ ((visibility("default")))
29 setting_view *__default_view_state(void *data, app_control_h service)
32 setting_retvm_if((!data), NULL, "data is NULL");
33 SettingFontUG *fontUG = (SettingFontUG *)data;
35 /* argument processing */
36 char *category = NULL;
37 app_control_get_extra_data(service, "category", &category);
39 if (0 == safeStrCmp(category, "FontType")) {
40 SETTING_TRACE("LAUNCHED BY APP-CONTROL MODE");
41 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);
45 return &setting_view_font_main;
46 } else if (0 == safeStrCmp(category, "FontSize")) {
47 SETTING_TRACE("category = %s", category);
48 fontUG->viewmode = FONT_SIZE_VIEW_APPCONTROL;
49 setting_view_node_table_register(&setting_view_font_font_size, NULL);
51 return &setting_view_font_font_size;
53 SETTING_TRACE("HERE ?? <<<<< ");
54 char *viewtype = NULL;
55 app_control_get_extra_data(service, "viewtype", &viewtype);
56 if (!safeStrCmp(viewtype, "FontType_expand")) {
57 fontUG->font_expand_state = FONT_EXPAND_STATE_FONT_TYPE;
58 } else if (!safeStrCmp(viewtype, "FontSize_expand")) {
59 fontUG->font_expand_state = FONT_EXPAND_STATE_FONT_SIZE;
61 fontUG->font_expand_state = FONT_EXPAND_STATE_NONE;
63 fontUG->viewmode = FONT_SIZE_AND_FONT_SEL_UG; /* set default */
64 setting_view_node_table_register(&setting_view_font_font_size, &setting_view_font_main);
65 setting_view_node_table_register(&setting_view_font_main, NULL);
68 return &setting_view_font_main;
72 /*------------------------------------------------------------- */
73 /* http://tizen.org/appcontrol/operation/configure/font/type */
74 /* http://tizen.org/appcontrol/operation/configure/font/size */
75 /*------------------------------------------------------------- */
76 setting_view *__app_control_get_operation_handler(void *data, app_control_h service)
79 setting_retvm_if((!data), NULL, "data is NULL");
80 setting_retvm_if((!service), NULL, "service is NULL");
81 SettingFontUG *fontUG = (SettingFontUG *)data;
82 char *output_url = NULL;
84 int ret = app_control_get_operation(service, &output_url);
86 if (ret == APP_CONTROL_ERROR_NONE) {
87 /*SETTING_TRACE(" >>>>>>>>>>>>>>>>>>> (%s) ", output_url); */
88 if (0 == safeStrCmp(output_url, "http://tizen.org/appcontrol/operation/configure/font/type")) {
89 fontUG->viewmode = FONT_SEL_VIEW_APPCONTROL;
90 setting_view_node_table_register(&setting_view_font_font_size, &setting_view_font_main);
91 setting_view_node_table_register(&setting_view_font_main, NULL);
94 return &setting_view_font_main;
95 } else if (0 == safeStrCmp(output_url, "http://tizen.org/appcontrol/operation/configure/font/size")) {
96 fontUG->viewmode = FONT_SIZE_VIEW_APPCONTROL;
97 setting_view_node_table_register(&setting_view_font_font_size, NULL);
100 return &setting_view_font_font_size;
102 SETTING_TRACE("No URL, default action - argument parsing");
104 return __default_view_state(fontUG, service);
107 SETTING_TRACE("failed to call app_control_get_operation with error code %d", ret);
115 setting_view *__get_font_view_to_load(void *data, app_control_h service)
118 setting_retvm_if((!data), NULL, "data is NULL");
119 SettingFontUG *fontUG = (SettingFontUG *)data;
121 /*if ug is called by accessibility, view node table should not be initialized */
123 app_control_get_extra_data(service, "caller", &caller);
124 if (0 != safeStrCmp(caller, "accessibility")) {
125 /*need to initialize the node table when UG is re-created and it is NOT loaded by another UG*/
126 setting_view_node_table_intialize();
130 /* if argument is there, process it first */
131 char *output_url = NULL;
132 int ret = app_control_get_operation(service, &output_url);
134 /* service OK, but there's no argument */
135 if ((ret == APP_CONTROL_ERROR_NONE)
136 && (0 == safeStrCmp(output_url, "http://tizen.org/appcontrol/operation/default"))) {
138 return __default_view_state(fontUG, service);
140 } else if (ret == APP_CONTROL_ERROR_NONE) {
142 return __app_control_get_operation_handler(fontUG, service);
148 /* service is not OK, but need to handle default action */
149 return __default_view_state(fontUG, service);
153 static void setting_font_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
156 SettingFontUG *ad = (SettingFontUG *) data;
157 setting_view_update(&setting_view_font_main, ad);
160 static void *setting_font_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
161 app_control_h service, void *priv)
163 setting_retvm_if((!priv), NULL, "!priv");
164 SettingFontUG *fontUG = priv;
166 setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
169 fontUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
170 fontUG->win_get = (Evas_Object *) ug_get_window();
171 evas_object_show(fontUG->win_main_layout);
172 fontUG->evas = evas_object_evas_get(fontUG->win_main_layout);
174 setting_retvm_if(fontUG->win_main_layout == NULL, NULL,
175 "cannot get main window ");
177 setting_create_Gendial_itc(SETTING_GENLIST_2LINE_STYLE, &(fontUG->itc_2text_3_parent));
178 setting_create_Gendial_itc(SETTING_GENLIST_2LINE_STYLE, &(fontUG->itc_1icon_1text_sub));
179 /*setting_create_Gendial_itc("dialogue/2text.3", &(fontUG->itc_2text_2)); */
180 setting_create_Gendial_itc(SETTING_GENLIST_2LINE_STYLE, &(fontUG->itc_2text_2));
181 setting_create_Gendial_itc(SETTING_GENLIST_GROUP_INDEX_STYLE, &(fontUG->itc_group_item));
182 setting_create_Gendial_itc("1icon", &(fontUG->itc_1icon));
184 /* view type checking */
185 fontUG->view_to_load = __get_font_view_to_load(fontUG, service);
186 setting_retvm_if(NULL == fontUG->view_to_load, NULL, "NULL == fontUG->view_to_load");
188 setting_view_node_set_cur_view(fontUG->view_to_load);
189 setting_view_create(fontUG->view_to_load, (void *)fontUG);
191 elm_theme_extension_add(NULL, SETTING_5STEP_SLIDER_EDJ_NAME);
193 /* creating a view. */
194 /*setting_view_create(&setting_view_font_main, (void *)fontUG); */
195 evas_object_event_callback_add(fontUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_font_ug_cb_resize, fontUG);
196 return fontUG->ly_main;
199 static void setting_font_ug_on_start(ui_gadget_h ug, app_control_h service,
204 static void setting_font_ug_on_pause(ui_gadget_h ug, app_control_h service,
209 static void setting_font_ug_on_resume(ui_gadget_h ug, app_control_h service,
214 static void setting_font_ug_on_destroy(ui_gadget_h ug, app_control_h service,
218 setting_retm_if((!priv), "!priv");
219 SettingFontUG *fontUG = priv;
221 evas_object_event_callback_del(fontUG->win_main_layout, EVAS_CALLBACK_RESIZE, setting_font_ug_cb_resize); /* fix flash issue for gallery */
224 setting_view_destroy(&setting_view_font_font_size, fontUG);
225 setting_view_destroy(&setting_view_font_main, fontUG);
227 if (NULL != ug_get_layout(fontUG->ug)) {
228 evas_object_hide((Evas_Object *) ug_get_layout(fontUG->ug));
229 evas_object_del((Evas_Object *) ug_get_layout(fontUG->ug));
235 static void setting_font_ug_on_message(ui_gadget_h ug, app_control_h msg,
236 app_control_h service, void *priv)
242 static void setting_font_ug_on_event(ui_gadget_h ug, enum ug_event event,
243 app_control_h service, void *priv)
246 SettingFontUG *ad = (SettingFontUG *)priv;
247 setting_retm_if(NULL == ad, "ad is NULL");
249 case UG_EVENT_LOW_MEMORY:
251 case UG_EVENT_LOW_BATTERY:
253 case UG_EVENT_LANG_CHANGE:
254 setting_navi_items_update(ad->navibar);
256 case UG_EVENT_ROTATE_PORTRAIT:
258 case UG_EVENT_ROTATE_PORTRAIT_UPSIDEDOWN:
260 case UG_EVENT_ROTATE_LANDSCAPE:
262 case UG_EVENT_ROTATE_LANDSCAPE_UPSIDEDOWN:
264 case UG_EVENT_REGION_CHANGE:
271 static void setting_font_ug_on_key_event(ui_gadget_h ug,
272 enum ug_key_event event, app_control_h service,
281 case UG_KEY_EVENT_END:
289 UG_MODULE_API int UG_MODULE_INIT(struct ug_module_ops *ops)
292 SettingFontUG *fontUG = calloc(1, sizeof(SettingFontUG));
293 setting_retvm_if(!fontUG, -1, "Create SettingFontUG obj failed");
295 ops->create = setting_font_ug_on_create;
296 ops->start = setting_font_ug_on_start;
297 ops->pause = setting_font_ug_on_pause;
298 ops->resume = setting_font_ug_on_resume;
299 ops->destroy = setting_font_ug_on_destroy;
300 ops->message = setting_font_ug_on_message;
301 ops->event = setting_font_ug_on_event;
302 ops->key_event = setting_font_ug_on_key_event;
304 ops->opt = UG_OPT_INDICATOR_ENABLE;
306 memset(fontUG, 0x00, sizeof(SettingFontUG));
311 UG_MODULE_API void UG_MODULE_EXIT(struct ug_module_ops *ops)
314 struct SettingFontUG *fontUG;
315 setting_retm_if(!ops, "ops == NULL");
323 /* ***************************************************
327 ***************************************************/
330 * Reset function to 'reset' the settings of the UG, it will be invoked by 'Reset' UG
332 UG_MODULE_API int setting_plugin_reset(app_control_h service, void *priv)
337 /* reset font type, default is HelveticaNeue */
338 /*font_config_set("HelveticaNeue"); */
339 char *default_font_name = NULL;
340 default_font_name = _get_default_font();
341 if (NULL != default_font_name) {
342 ret += system_settings_set_value_string(SYSTEM_SETTINGS_KEY_FONT_TYPE, default_font_name);
344 SETTING_TRACE_ERROR("Failed to get default font type");
346 ret += vconf_set_int(VCONFKEY_SETAPPL_ACCESSIBILITY_FONT_SIZE, SYSTEM_SETTINGS_FONT_SIZE_NORMAL);
347 setting_retvm_if(ret == -1, ret, "Failed to set vconf");
352 static Setting_Cfg_Node_T s_cfg_node_array[] = {
353 {"IDS_ST_BODY_FONT_TYPE", NULL, "viewtype:FontType_expand;tab:first;keyword:IDS_ST_BODY_FONT_TYPE", 0, 0, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
354 {"IDS_ST_MBODY_FONT_SIZE", NULL, "viewtype:FontSize_expand;tab:first;keyword:IDS_ST_MBODY_FONT_SIZE", 0, 0, 0, Cfg_Item_View_Node, NULL, NULL, NULL, NULL},
357 UG_MODULE_API int setting_plugin_search_init(app_control_h service, void *priv, char **applocale)
360 SETTING_TRACE(">> setting-font-efl DB search code");
361 setting_retvm_if(!priv || !applocale, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "pplist/applocale is NULL");
363 *applocale = strdup("setting:/usr/apps/org.tizen.setting/res/locale");
365 Eina_List **pplist = (Eina_List **)priv;
367 int size = sizeof(s_cfg_node_array) / sizeof(s_cfg_node_array[0]);
368 for (i = 0; i < size; i++) {
369 Setting_Cfg_Node_T *node = setting_plugin_search_item_subindex_add(s_cfg_node_array[i].key_name, s_cfg_node_array[i].ug_args, IMG_Font, s_cfg_node_array[i].item_type, s_cfg_node_array[i].data, "Font");
370 *pplist = eina_list_append(*pplist, node);