summaryrefslogtreecommitdiff
path: root/src/setting-accessibility.c
blob: c39d216c46a53afcd38a18e340d1cfda89ed7109 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
/*
 * Copyright (c) 2010 Samsung Electronics, Inc.
 * All rights reserved.
 *
 * This software is a confidential and proprietary information
 * of Samsung Electronics, Inc. ("Confidential Information").  You
 * shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement
 * you entered into with Samsung Electronics.
 */

#include "setting-accessibility.h"
#include "setting-accessibility-debug.h"

/*
 * Create common view
 */
static void
__setting_accessibility_create_common_view(void *data)
{
	DBG("API() entered.");

	SettingAccessibilityAppData *ad = (SettingAccessibilityAppData *)data;
	Evas_Object *pObj_bg = NULL;

	pObj_bg = elm_bg_add(ad->pObj_win_main);
	access_retm_if(!pObj_bg, "elm_bg_add() error.");

	elm_win_resize_object_add(ad->pObj_win_main, pObj_bg);
	evas_object_size_hint_weight_set(pObj_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);	// Sets the hints for an object's weight.
	evas_object_show(pObj_bg);

	ad->pObj_conform = elm_conformant_add(ad->pObj_win_main);
	access_retm_if(!ad->pObj_conform, "elm_conformant_add() error.");

	evas_object_size_hint_weight_set(ad->pObj_conform, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_win_resize_object_add(ad->pObj_win_main, ad->pObj_conform);
	evas_object_show(ad->pObj_conform);

	/* Add layout main */
	ad->pObj_layout_main = elm_layout_add(ad->pObj_conform);
	access_retm_if(!ad->pObj_layout_main, "elm_layout_add() error.");

	elm_layout_theme_set(ad->pObj_layout_main, "layout", "application", "default");
	evas_object_size_hint_weight_set(ad->pObj_layout_main, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	elm_object_part_content_set(ad->pObj_conform, "elm.swallow.content", ad->pObj_layout_main);
	evas_object_show(ad->pObj_layout_main);

	/* Add a navigation frame */
	ad->pObj_nf = elm_naviframe_add(ad->pObj_layout_main);
	access_retm_if(!ad->pObj_nf, "elm_naviframe_add() error.");
	elm_naviframe_prev_btn_auto_pushed_set(ad->pObj_nf, EINA_TRUE);
	elm_object_part_content_set(ad->pObj_layout_main, "elm.swallow.content", ad->pObj_nf);	// Set a content to an object
	evas_object_size_hint_weight_set(ad->pObj_nf, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
	evas_object_size_hint_align_set(ad->pObj_nf, EVAS_HINT_FILL, EVAS_HINT_FILL);
	evas_object_show(ad->pObj_nf);

	eext_object_event_callback_add(ad->pObj_nf, EEXT_CALLBACK_BACK, eext_naviframe_back_cb, NULL);
}

/*
 * Delete window
 */
static void
__setting_accessibility_win_del_cb(void *data, Evas_Object *obj, void *event_info)
{
	DBG("API() entered.");

	DBG("elm_exit() run(start).");
	elm_exit();
}

/*
 * Create window
 */
static Evas_Object*
__setting_accessibility_create_win(const char *name)
{
	DBG("API() entered.");

	Evas_Object *pObj = NULL;

	pObj = elm_win_add(NULL, name, ELM_WIN_BASIC);
	access_retv_if(!pObj, false);

	elm_win_title_set(pObj, name);
	elm_win_autodel_set(pObj, EINA_TRUE);
	elm_win_conformant_set(pObj, EINA_TRUE);

	if (elm_win_wm_rotation_supported_get(pObj)) {
		int rots[4] = { 0, 90, 180, 270 };
		elm_win_wm_rotation_available_rotations_set(pObj, (const int*)(&rots), 4);
	}

	elm_win_indicator_mode_set(pObj, ELM_WIN_INDICATOR_HIDE);

	evas_object_smart_callback_add(pObj, "delete,request", __setting_accessibility_win_del_cb, NULL);	// callback when window destroyed

	return pObj;
}

static bool
app_create(void *data)
{
	DBG("API() entered.");

	SettingAccessibilityAppData *ad = (SettingAccessibilityAppData *)data;
	ad->pObj_win_main = __setting_accessibility_create_win(SETTING_ACCESSIBILITY_PACKAGE_NAME);
	access_retv_if(!ad->pObj_win_main, false);

	double scale = elm_config_scale_get();
	if (scale < 1.0) elm_config_scale_set(1.0);

	char *pLocale = NULL;

	pLocale = vconf_get_str(VCONFKEY_LANGSET);
	if (pLocale) {
		elm_language_set(pLocale);
		free(pLocale);
		pLocale = NULL;
	}

	evas_object_show(ad->pObj_win_main);

	__setting_accessibility_create_common_view(ad);

	// Display accessibility menu
	setting_accessibility_menu_create_view(ad);

	return true;
}

static void
app_control(app_control_h app_control, void *data)
{
	/* Handle the launch request. */
	SettingAccessibilityAppData *ad = (SettingAccessibilityAppData *)data;
	access_ret_if(!ad);

	DBG("API() entered.");

	__setting_accessibility_create_common_view(ad);
	setting_accessibility_menu_create_view(ad);
	elm_win_activate(ad->pObj_win_main);
}

static void
app_pause(void *data)
{
	SettingAccessibilityAppData *ad = (SettingAccessibilityAppData *)data;
	DBG("");
	/* Take necessary actions when application becomes invisible. */
}

static void
app_resume(void *data)
{
	SettingAccessibilityAppData *ad = (SettingAccessibilityAppData *)data;
	DBG("");
	/* Take necessary actions when application becomes visible. */
}

static void
app_terminate(void *data)
{
	SettingAccessibilityAppData *ad = (SettingAccessibilityAppData *)data;
	DBG("");
	/* Release all resources. */

	if (!ad)
		return;
}

static void
ui_app_lang_changed(app_event_info_h event_info, void *user_data)
{
	DBG("");
	/*APP_EVENT_LANGUAGE_CHANGED*/
	char *pLocale = NULL;

	pLocale = vconf_get_str(VCONFKEY_LANGSET);
	if (pLocale) {
		elm_language_set(pLocale);

		free(pLocale);
		pLocale = NULL;
	}
}

static void
ui_app_orient_changed(app_event_info_h event_info, void *user_data)
{
	DBG("");
	/*APP_EVENT_DEVICE_ORIENTATION_CHANGED*/
}

static void
ui_app_region_changed(app_event_info_h event_info, void *user_data)
{
	DBG("");
	/*APP_EVENT_REGION_FORMAT_CHANGED*/
}

static void
ui_app_low_battery(app_event_info_h event_info, void *user_data)
{
	DBG("");
	/*APP_EVENT_LOW_BATTERY*/
}

static void
ui_app_low_memory(app_event_info_h event_info, void *user_data)
{
	DBG("");
	/*APP_EVENT_LOW_MEMORY*/
}

int
main(int argc, char *argv[])
{
	SettingAccessibilityAppData ad;
	int ret = 0;

	ui_app_lifecycle_callback_s event_callback = {0, };
	app_event_handler_h handlers[5] = {NULL, };

	event_callback.create = app_create;
	event_callback.terminate = app_terminate;
	event_callback.pause = app_pause;
	event_callback.resume = app_resume;
	event_callback.app_control = app_control;

	ui_app_add_event_handler(&handlers[APP_EVENT_LOW_BATTERY], APP_EVENT_LOW_BATTERY, ui_app_low_battery, &ad);
	ui_app_add_event_handler(&handlers[APP_EVENT_LOW_MEMORY], APP_EVENT_LOW_MEMORY, ui_app_low_memory, &ad);
	ui_app_add_event_handler(&handlers[APP_EVENT_DEVICE_ORIENTATION_CHANGED], APP_EVENT_DEVICE_ORIENTATION_CHANGED, ui_app_orient_changed, &ad);
	ui_app_add_event_handler(&handlers[APP_EVENT_LANGUAGE_CHANGED], APP_EVENT_LANGUAGE_CHANGED, ui_app_lang_changed, &ad);
	ui_app_add_event_handler(&handlers[APP_EVENT_REGION_FORMAT_CHANGED], APP_EVENT_REGION_FORMAT_CHANGED, ui_app_region_changed, &ad);

	memset(&ad, 0x0, sizeof(SettingAccessibilityAppData));
	ret = ui_app_main(argc, argv, &event_callback, &ad);
	if (ret != APP_ERROR_NONE) {
		LOGW("ui_app_main failed, Err=%d\n", ret);
	}

	return ret;
}