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-livebox.h>
22 #include <setting-livebox-main.h>
23 #include <setting-common-data-slp-setting.h>
24 #include <setting-debug.h>
26 static int setting_livebox_main_create(void *cb);
27 static int setting_livebox_main_destroy(void *cb);
28 static int setting_livebox_main_update(void *cb);
29 static int setting_livebox_main_cleanup(void *cb);
31 setting_view setting_view_livebox_main = {
32 .create = setting_livebox_main_create,
33 .destroy = setting_livebox_main_destroy,
34 .update = setting_livebox_main_update,
35 .cleanup = setting_livebox_main_cleanup,
38 /* ***************************************************
42 ***************************************************/
44 static void setting_livebox_main_sk_done_cb(void *data, Evas_Object *obj, void *event_info)
50 SettingLiveboxUG *ad = (SettingLiveboxUG *)data;
52 /* send information of selected items to live-setting */
53 if(ad->select_count > 0)
55 SETTING_TRACE_DEBUG("select_count : %u", ad->select_count);
58 char *result_array[MAX_SELECTION_NUM*2];
61 if (service_create(&svc)) {
65 for(; idx < ad->menu_count; idx++)
67 if(ad->item[idx]->chk_status)
69 if(check_count > ad->select_count)
71 SETTING_TRACE_DEBUG("exceed count: %u", check_count);
74 SETTING_TRACE_DEBUG("item[%u] is checked", idx);
75 result_array[check_count*2] = setting_gettext(ad->item[idx]->keyStr);
76 result_array[check_count*2+1] = (char *)ad->item[idx]->r_swallow_path;
77 SETTING_TRACE_DEBUG("app_name : %s, icon_path : %s", result_array[check_count*2], result_array[check_count*2+1]);
81 service_add_extra_data_array(svc, "result", (const char**)result_array, ad->select_count*2);
82 ug_send_result(ad->ug, svc);
86 /* Send destroy request */
87 ug_destroy_me(ad->ug);
90 static void setting_livebox_main_sk_cancel_cb(void *data, Evas_Object *obj, void *event_info)
96 SettingLiveboxUG *ad = (SettingLiveboxUG *)data;
97 /* Send destroy request */
98 ug_destroy_me(ad->ug);
101 static void __searchbar_changed_cb(void *data, Evas_Object *obj, void *event_info)
104 setting_retm_if(data == NULL, "Data parameter is NULL");
106 SettingLiveboxUG *ad = (SettingLiveboxUG *)data;
108 setting_searchbar_redraw(ad, ad->search_bar, NULL/*ad->search_text*/,
110 NULL); //__region_genlist_update);
114 static void __create_navibar(void *data, Evas_Object *content, Evas_Object *navibar, Evas_Object *controlbar)
117 ret_if(data == NULL || content == NULL || navibar == NULL);
119 SettingLiveboxUG *ad = (SettingLiveboxUG *)data;
121 setting_create_navi_bar_buttons("Customize setting Livebox",
122 "Done", "Cancel", NULL,
123 setting_livebox_main_sk_done_cb,
124 setting_livebox_main_sk_cancel_cb,
126 ad, content, navibar, controlbar);
129 static int __create_frame(void *data)
132 retv_if(data == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
134 SettingLiveboxUG *ad = (SettingLiveboxUG *)data;
135 Evas_Object *navi_bar = NULL;
136 Evas_Object *control_bar = NULL;
138 Evas_Object *content_list = elm_genlist_add(ad->win_main_layout);
139 elm_object_style_set(content_list, "dialogue");
140 if(content_list == NULL)
141 return SETTING_RETURN_FAIL;
143 elm_genlist_clear(content_list); /* first to clear list */
144 elm_genlist_mode_set(content_list, ELM_LIST_COMPRESS);
146 ad->ly_main = setting_create_win_layout(ad->win_main_layout, ad->win_get);
147 retv_if(!ad->ly_main, SETTING_RETURN_FAIL);
149 navi_bar = setting_create_navi_bar(ad->ly_main);
150 retv_if(!navi_bar, SETTING_RETURN_FAIL);
151 Evas_Object *sub_layout = elm_layout_add(navi_bar);
152 elm_layout_theme_set(sub_layout, "layout", "application", "searchbar_base");
153 elm_object_signal_emit(sub_layout, "elm,state,show,searchbar", "elm");
154 elm_object_part_content_set(sub_layout, "elm.swallow.content", content_list);
156 ad->search_bar = setting_create_searchbar(ad, sub_layout, __searchbar_changed_cb, NULL);
158 control_bar = elm_toolbar_add(navi_bar);
159 setting_retvm_if(control_bar == NULL, -1, "controlbar == NULL");
160 elm_toolbar_shrink_mode_set(control_bar, ELM_TOOLBAR_SHRINK_EXPAND);
162 __create_navibar(ad, sub_layout, navi_bar, control_bar);
164 ad->navi_bar = navi_bar;
165 ad->navi_it = elm_naviframe_top_item_get(ad->navi_bar);
166 ad->sub_layout = sub_layout;
167 ad->scroller = content_list;
169 return SETTING_RETURN_SUCCESS;
173 setting_livebox_main_mouse_up_Gendial_list_cb(void *data, Evas_Object *obj, void *event_info)
179 retm_if(event_info == NULL, "Invalid argument: event info is NULL");
181 SettingLiveboxUG *ad = (SettingLiveboxUG*)data;
182 Elm_Object_Item *item = (Elm_Object_Item *) event_info;
183 elm_genlist_item_selected_set(item, 0);
185 Setting_GenGroupItem_Data *list_item =
186 (Setting_GenGroupItem_Data *) elm_object_item_data_get(item);
188 SETTING_TRACE_DEBUG("%s selected", list_item->keyStr);
190 int current_status = elm_check_state_get(list_item->eo_check);
192 if((current_status == 0) && (ad->select_count < MAX_SELECTION_NUM))
194 elm_check_state_set(list_item->eo_check, 1);
195 list_item->chk_status = 1;
197 // show selection Info : "selected %u items"
199 else if(current_status == 0)
201 // show popup : "be over the count, 4"
203 else if((current_status == 1) && (ad->select_count > 0))
205 elm_check_state_set(list_item->eo_check, 0);
206 list_item->chk_status = 0;
211 // nothing to be selected.
213 SETTING_TRACE_DEBUG("select_count : %u", ad->select_count);
217 setting_livebox_main_chk_btn_cb(void *data, Evas_Object *obj, void *event_info)
224 Setting_GenGroupItem_Data *list_item = (Setting_GenGroupItem_Data *) data;
225 SettingLiveboxUG *ad = list_item->userdata;
227 list_item->chk_status = elm_check_state_get(obj); /* for genlist update status */
229 if((list_item->chk_status == 1) && (ad->select_count < MAX_SELECTION_NUM))
232 // show selection Info : "selected %u items"
234 else if(list_item->chk_status == 1)
236 // recover status of checkbox
237 // And show popup : "be over the count, 4"
238 elm_check_state_set(obj, 0);
239 list_item->chk_status = elm_check_state_get(obj);
241 else if((list_item->chk_status == 0) && (ad->select_count > 0))
247 // nothing to be selected.
249 SETTING_TRACE_DEBUG("select_count : %u", ad->select_count);
252 void setting_livebox_add_genlist_items(void *data)
258 SettingLiveboxUG *ad = (SettingLiveboxUG*)data;
264 char *icon_path = NULL;
268 for (i = 0; i < setting_cfg_get_category_length(); i++)
270 SETTING_TRACE_DEBUG("category name : %s", setting_cfg_get_category_name(i));
271 if (safeStrCmp(setting_cfg_get_category_name(i), KeyStr_Connectivity) == 0)
273 (void)setting_create_Gendial_field_titleItem(ad->scroller,
275 KeyStr_Connectivity, NULL);
277 for (j = 0; j < setting_cfg_get_menu_length(i); j++)
279 keyStr = setting_cfg_get_keyname_idx(i, j);
280 SETTING_TRACE_DEBUG("menu name : [%d] %s", j, keyStr);
281 icon_path = setting_cfg_get_icon_path_idx(i, j);
283 ad->item[cnt] = setting_create_Gendial_field_def(ad->scroller, &(itc_1text_1icon_2),
284 setting_livebox_main_mouse_up_Gendial_list_cb, NULL,
285 SWALLOW_Type_1CHECKICON,
286 NULL, icon_path, 0, keyStr, NULL,
287 setting_livebox_main_chk_btn_cb);
289 ad->item[cnt++]->userdata = ad;
293 else if (safeStrCmp(setting_cfg_get_category_name(i), KeyStr_System) == 0)
295 (void)setting_create_Gendial_field_titleItem(ad->scroller,
297 KeyStr_System, NULL);
298 for (j = 0; j < setting_cfg_get_menu_length(i); j++)
300 keyStr = setting_cfg_get_keyname_idx(i, j);
301 SETTING_TRACE_DEBUG("menu name : [%d] %s", j, keyStr);
302 icon_path = setting_cfg_get_icon_path_idx(i, j);
304 ad->item[cnt] = setting_create_Gendial_field_def(ad->scroller, &(itc_1text_1icon_2),
305 setting_livebox_main_mouse_up_Gendial_list_cb, NULL,
306 SWALLOW_Type_1CHECKICON,
307 NULL, icon_path, 0, keyStr, NULL,
308 setting_livebox_main_chk_btn_cb);
309 ad->item[cnt++]->userdata = ad;
313 else if (safeStrCmp(setting_cfg_get_category_name(i), KeyStr_Applications) == 0)
315 (void)setting_create_Gendial_field_titleItem(ad->scroller,
317 KeyStr_Applications, NULL);
318 for (j = 0; j < setting_cfg_get_menu_length(i); j++)
320 keyStr = setting_cfg_get_keyname_idx(i, j);
321 SETTING_TRACE_DEBUG("menu name : [%d] %s", j, keyStr);
322 icon_path = setting_cfg_get_icon_path_idx(i, j);
324 ad->item[cnt] = setting_create_Gendial_field_def(ad->scroller, &(itc_1text_1icon_2),
325 setting_livebox_main_mouse_up_Gendial_list_cb, NULL,
326 SWALLOW_Type_1CHECKICON,
327 NULL, icon_path, 0, keyStr, NULL,
328 setting_livebox_main_chk_btn_cb);
329 ad->item[cnt++]->userdata = ad;
333 else if (safeStrCmp(setting_cfg_get_category_name(i), KeyStr_DownloadedAPPs) == 0)
335 (void)setting_create_Gendial_field_titleItem(ad->scroller,
337 KeyStr_DownloadedAPPs, NULL);
338 for (j = 0; j < setting_cfg_get_menu_length(i); j++)
340 keyStr = setting_cfg_get_keyname_idx(i, j);
341 SETTING_TRACE_DEBUG("menu name : [%d] %s", j, keyStr);
342 icon_path = setting_cfg_get_icon_path_idx(i, j);
344 ad->item[cnt] = setting_create_Gendial_field_def(ad->scroller, &(itc_1text_1icon_2),
345 setting_livebox_main_mouse_up_Gendial_list_cb, NULL,
346 SWALLOW_Type_1CHECKICON,
347 NULL, icon_path, 0, keyStr, NULL,
348 setting_livebox_main_chk_btn_cb);
349 ad->item[cnt++]->userdata = ad;
354 ad->menu_count = cnt;
355 SETTING_TRACE_DEBUG("total : %u menues ", ad->menu_count);
359 setting_livebox_main_create(void *cb)
363 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
365 SettingLiveboxUG *ad = (SettingLiveboxUG *) cb;
368 ret = __create_frame(ad);
371 return SETTING_RETURN_FAIL;
373 setting_livebox_add_genlist_items(ad);
375 setting_view_livebox_main.is_create = 1;
377 return SETTING_RETURN_SUCCESS;
380 static int setting_livebox_main_destroy(void *cb)
383 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
385 SettingLiveboxUG *ad = (SettingLiveboxUG *) cb;
387 if (ad->ly_main != NULL) {
388 evas_object_del(ad->ly_main);
390 setting_view_livebox_main.is_create = 0;
392 return SETTING_RETURN_SUCCESS;
395 static int setting_livebox_main_update(void *cb)
398 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
400 SettingLiveboxUG *ad = (SettingLiveboxUG *) cb;
402 if (ad->ly_main != NULL) {
403 evas_object_show(ad->ly_main);
406 return SETTING_RETURN_SUCCESS;
409 static int setting_livebox_main_cleanup(void *cb)
412 retv_if(cb == NULL, SETTING_GENERAL_ERR_NULL_DATA_PARAMETER);
414 SettingLiveboxUG *ad = (SettingLiveboxUG *) cb;
416 if (ad->ly_main != NULL) {
417 evas_object_hide(ad->ly_main);
420 return SETTING_RETURN_SUCCESS;