3e042fcae676065206e2564b3485bbea05a180ef
[apps/core/preloaded/settings.git] / setting-shortcut / src / setting-shortcut-main.c
1 /*
2  * setting
3  *
4  * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd.
5  *
6  * Contact: MyoungJune Park <mj2004.park@samsung.com>
7  *
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
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
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.
19  *
20  */
21 #include <setting-shortcut-main.h>
22 #include <setting-common-data-slp-setting.h>
23 #include <setting-debug.h>
24
25 static int setting_shortcut_main_create(void *cb);
26 static int setting_shortcut_main_destroy(void *cb);
27 static int setting_shortcut_main_update(void *cb);
28 static int setting_shortcut_main_cleanup(void *cb);
29
30 setting_view setting_view_shortcut_main = {
31         .create = setting_shortcut_main_create,
32         .destroy = setting_shortcut_main_destroy,
33         .update = setting_shortcut_main_update,
34         .cleanup = setting_shortcut_main_cleanup,
35 };
36
37 /* ***************************************************
38  *
39  *basic func
40  *
41  ***************************************************/
42
43 static void setting_shortcut_main_sk_cancel_cb(void *data, Evas_Object *obj, void *event_info)
44 {
45         SETTING_TRACE_BEGIN;
46         /* error check */
47         ret_if(data == NULL);
48
49         SettingShortcutUG *ad = (SettingShortcutUG *)data;
50         /* Send destroy request */
51         ug_destroy_me(ad->ug);
52 }
53
54 static void
55 setting_shortcut_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info)
56 {
57         SETTING_TRACE_BEGIN;
58
59         if(data == NULL)
60                 return;
61         retm_if(event_info == NULL, "Invalid argument: event info is NULL");
62
63         //SettingShortcutUG *ad = (SettingShortcutUG*)data;
64         Elm_Object_Item *item = (Elm_Object_Item *) event_info;
65         elm_genlist_item_selected_set(item, 0);
66
67         Setting_GenGroupItem_Data *list_item =
68             (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
69
70         SETTING_TRACE_DEBUG("%s selected", list_item->keyStr);
71
72 }
73
74 void setting_shortcut_add_genlist_items(void *data)
75 {
76         SETTING_TRACE_BEGIN;
77         if(data == NULL)
78                 return;
79
80         SettingShortcutUG *ad = (SettingShortcutUG*)data;
81
82         /* separator */
83         Elm_Object_Item *item = elm_genlist_item_append(ad->scroller, &itc_seperator, NULL, NULL, ELM_GENLIST_ITEM_NONE, NULL, NULL);
84         elm_genlist_item_select_mode_set(item, ELM_OBJECT_SELECT_MODE_DISPLAY_ONLY);
85
86         /* To do : Add 6 items */
87         ad->acc_assistive_light = setting_create_Gendial_field_def(ad->scroller, &itc_1text,
88                                                                 setting_shortcut_main_mouse_up_Gendial_list_cb,ad,
89                                                                 SWALLOW_Type_INVALID,
90                                                                 NULL, NULL,
91                                                                 0, _("IDS_ST_MBODY_ASSISTIVE_LIGHT"), NULL, NULL);
92
93         ad->acc_led_notification = setting_create_Gendial_field_def(ad->scroller, &itc_1text,
94                                                                 setting_shortcut_main_mouse_up_Gendial_list_cb,ad,
95                                                                 SWALLOW_Type_INVALID,
96                                                                 NULL, NULL,
97                                                                 0, _("LED notification"), NULL, NULL);
98
99         ad->acc_mono_audio = setting_create_Gendial_field_def(ad->scroller, &itc_1text,
100                                                                 setting_shortcut_main_mouse_up_Gendial_list_cb,ad,
101                                                                 SWALLOW_Type_INVALID,
102                                                                 NULL, NULL,
103                                                                 0, _("IDS_ST_MBODY_MONO_AUDIO"), NULL, NULL);
104
105         ad->acc_negative_color = setting_create_Gendial_field_def(ad->scroller, &itc_1text,
106                                                                 setting_shortcut_main_mouse_up_Gendial_list_cb,ad,
107                                                                 SWALLOW_Type_INVALID,
108                                                                 NULL, NULL,
109                                                                 0, _("IDS_ST_BODY_NEGATIVE_COLOURS"), NULL, NULL);
110
111         ad->acc_screen_reader = setting_create_Gendial_field_def(ad->scroller, &itc_1text,
112                                                                 setting_shortcut_main_mouse_up_Gendial_list_cb,ad,
113                                                                 SWALLOW_Type_INVALID,
114                                                                 NULL, NULL,
115                                                                 0, _("IDS_ST_MBODY_SCREEN_READER_HTTS"), NULL, NULL);
116
117         ad->acc_zoom = setting_create_Gendial_field_def(ad->scroller, &itc_1text,
118                                                                 setting_shortcut_main_mouse_up_Gendial_list_cb,ad,
119                                                                 SWALLOW_Type_INVALID,
120                                                                 NULL, NULL,
121                                                                 0, _("IDS_ST_MBODY_ZOOM"), NULL, NULL);
122 }
123
124 static int
125 setting_shortcut_main_create(void *cb)
126 {
127         SETTING_TRACE_BEGIN;
128         /* error check */
129         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
130
131         SettingShortcutUG *ad = (SettingShortcutUG *) cb;
132
133         char setBtnStr[MAX_DISPLAY_NAME_LEN_ON_UI];
134         snprintf(setBtnStr, sizeof(setBtnStr), "%s",
135                  (char *)dgettext("sys_string", "IDS_COM_BODY_BACK"));
136
137         ad->ly_main = 
138             setting_create_layout_navi_bar_genlist(ad->win_main_layout,
139                                                    ad->win_get,
140                                                    "Accessibility shortcut list",
141                                                    setBtnStr, NULL,
142                                                    setting_shortcut_main_sk_cancel_cb,
143                                                    NULL, ad, &(ad->scroller),
144                                                    &(ad->navi_bar));
145
146         if(ad->ly_main == NULL)
147                 return SETTING_RETURN_FAIL;
148
149         setting_shortcut_add_genlist_items(ad);
150
151         setting_view_shortcut_main.is_create = 1;
152         SETTING_TRACE_END;
153         return SETTING_RETURN_SUCCESS;
154 }
155
156 static int setting_shortcut_main_destroy(void *cb)
157 {
158         /* error check */
159         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
160
161         SettingShortcutUG *ad = (SettingShortcutUG *) cb;
162
163         if (ad->ly_main != NULL) {
164                 evas_object_del(ad->ly_main);
165                 ad->ly_main = NULL;
166                 setting_view_shortcut_main.is_create = 0;
167         }
168         return SETTING_RETURN_SUCCESS;
169 }
170
171 static int setting_shortcut_main_update(void *cb)
172 {
173         /* error check */
174         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
175
176         SettingShortcutUG *ad = (SettingShortcutUG *) cb;
177
178         if (ad->ly_main != NULL) {
179                 evas_object_show(ad->ly_main);
180         }
181
182         return SETTING_RETURN_SUCCESS;
183 }
184
185 static int setting_shortcut_main_cleanup(void *cb)
186 {
187         /* error check */
188         retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
189
190         SettingShortcutUG *ad = (SettingShortcutUG *) cb;
191
192         if (ad->ly_main != NULL) {
193                 evas_object_hide(ad->ly_main);
194         }
195
196         return SETTING_RETURN_SUCCESS;
197 }