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);
67 return &setting_view_font_main;
71 /*------------------------------------------------------------- */
72 /* http://tizen.org/appcontrol/operation/configure/font/type */
73 /* http://tizen.org/appcontrol/operation/configure/font/size */
74 /*------------------------------------------------------------- */
75 setting_view *__app_control_get_operation_handler(void *data, app_control_h service)
78 setting_retvm_if((!data), NULL, "data is NULL");
79 setting_retvm_if((!service), NULL, "service is NULL");
80 SettingFontUG *fontUG = (SettingFontUG *)data;
81 char *output_url = NULL;
83 int ret = app_control_get_operation(service, &output_url);
85 if (ret == APP_CONTROL_ERROR_NONE) {
86 /*SETTING_TRACE(" >>>>>>>>>>>>>>>>>>> (%s) ", output_url); */
87 if (0 == safeStrCmp(output_url, "http://tizen.org/appcontrol/operation/configure/font/type")
88 || 0 == safeStrCmp(output_url, "http://samsung.com/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 || 0 == safeStrCmp(output_url, "http://tizen.org/appcontrol/operation/configure/font/size")) {
97 fontUG->viewmode = FONT_SIZE_VIEW_APPCONTROL;
98 setting_view_node_table_register(&setting_view_font_font_size, NULL);
101 return &setting_view_font_font_size;
103 SETTING_TRACE("No URL, default action - argument parsing");
105 return __default_view_state(fontUG, service);
108 SETTING_TRACE("failed to call app_control_get_operation with error code %d", ret);
116 setting_view *__get_font_view_to_load(void *data, app_control_h service)
119 setting_retvm_if((!data), NULL, "data is NULL");
120 SettingFontUG *fontUG = (SettingFontUG *)data;
122 /*if ug is called by accessibility, view node table should not be initialized */
124 app_control_get_extra_data(service, "caller", &caller);
125 if (0 != safeStrCmp(caller, "accessibility")) {
126 /*need to initialize the node table when UG is re-created and it is NOT loaded by another UG*/
127 setting_view_node_table_intialize();
131 /* if argument is there, process it first */
132 char *output_url = NULL;
133 int ret = app_control_get_operation(service, &output_url);
135 /* service OK, but there's no argument */
136 if ((ret == APP_CONTROL_ERROR_NONE)
137 && (0 == safeStrCmp(output_url, "http://tizen.org/appcontrol/operation/default")
138 || 0 == safeStrCmp(output_url, "http://samsung.com/appcontrol/operation/default"))) {
140 return __default_view_state(fontUG, service);
142 } else if (ret == APP_CONTROL_ERROR_NONE) {
144 return __app_control_get_operation_handler(fontUG, service);
150 /* service is not OK, but need to handle default action */
151 return __default_view_state(fontUG, service);
155 static void setting_font_ug_cb_resize(void *data, Evas *e, Evas_Object *obj,
158 SettingFontUG *ad = (SettingFontUG *) data;
159 setting_view_update(&setting_view_font_main, ad);
162 static void *setting_font_ug_on_create(ui_gadget_h ug, enum ug_mode mode,
163 app_control_h service, void *priv)
165 setting_retvm_if((!priv), NULL, "!priv");
166 SettingFontUG *fontUG = priv;
168 setting_set_i18n(SETTING_PACKAGE, SETTING_LOCALEDIR);
171 fontUG->win_main_layout = (Evas_Object *) ug_get_parent_layout(ug);
172 fontUG->win_get = (Evas_Object *) ug_get_window();
173 evas_object_show(fontUG->win_main_layout);
174 fontUG->evas = evas_object_evas_get(fontUG->win_main_layout);
176 setting_retvm_if(fontUG->win_main_layout == NULL, NULL,
177 "cannot get main window ");
179 setting_create_Gendial_itc("2line.top", &(fontUG->itc_2text_3_parent));
180 setting_create_Gendial_itc("2line.top", &(fontUG->itc_1icon_1text_sub));
181 /*setting_create_Gendial_itc("dialogue/2text.3", &(fontUG->itc_2text_2)); */
182 setting_create_Gendial_itc("2line.top", &(fontUG->itc_2text_2));
183 setting_create_Gendial_itc("groupindex", &(fontUG->itc_group_item));
184 setting_create_Gendial_itc("multiline", &(fontUG->itc_bg_1icon));
186 /* view type checking */
187 fontUG->view_to_load = __get_font_view_to_load(fontUG, service);
188 setting_retvm_if(NULL == fontUG->view_to_load, NULL, "NULL == fontUG->view_to_load");
190 setting_view_node_set_cur_view(fontUG->view_to_load);
191 setting_view_create(fontUG->view_to_load, (void *)fontUG);
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 ***************************************************/
329 static Setting_Cfg_Node_T s_cfg_node_array[] = {
330 {"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},
331 {"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},
334 UG_MODULE_API int setting_plugin_search_init(app_control_h service, void *priv, char **applocale)
337 SETTING_TRACE(">> setting-font-efl DB search code");
338 setting_retvm_if(!priv || !applocale, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER, "pplist/applocale is NULL");
340 *applocale = strdup("setting:/usr/apps/org.tizen.setting/res/locale");
342 Eina_List **pplist = (Eina_List **)priv;
344 int size = sizeof(s_cfg_node_array) / sizeof(s_cfg_node_array[0]);
345 for (i = 0; i < size; i++) {
346 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");
347 *pplist = eina_list_append(*pplist, node);