tizen 2.4 release
[apps/home/ug-setting-notification-efl.git] / ug-setting-notification-do-not-disturb-efl / src / excepted-apps-efl.c
1 /*
2  * Copyright (c) 2009 - 2015 Samsung Electronics Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18
19 #include <Elementary.h>
20 #include <libintl.h>
21 #include <ui-gadget-module.h>
22 #include <package_manager.h>
23 #include "log.h"
24 #include "notification-setting-info.h"
25 #include "common-efl.h"
26
27 static Evas_Object* _create_edit_exception_apps_list(ug_data *ugd)
28 {
29         Evas_Object *parent = ugd->naviframe;
30         Evas_Object *genlist;
31
32         genlist = elm_genlist_add(parent);
33         elm_genlist_mode_set(genlist, ELM_LIST_SCROLL);
34         elm_genlist_mode_set(genlist, ELM_LIST_COMPRESS);
35
36         /* Add Smart Callback */
37         evas_object_smart_callback_add(genlist, "realized", gl_realized_cb, NULL);
38         evas_object_smart_callback_add(genlist, "loaded", gl_loaded_cb, NULL);
39         evas_object_smart_callback_add(genlist, "longpressed", gl_longpressed_cb, NULL);
40         evas_object_smart_callback_add(genlist, "contracted", gl_contracted_cb, NULL);
41
42         append_gl_group_index(genlist, APP_STRING("IDS_ST_HEADER_EXCLUDED_APPS_ABB"));
43         append_gl_item_list(genlist, get_excepted_apps_list(), ITEM_STYLE_DEFAULT);
44         append_gl_group_index(genlist, APP_STRING("IDS_ST_HEADER_INCLUDED_APPS_ABB"));
45         append_gl_item_list(genlist, get_not_excepted_apps_list(), ITEM_STYLE_DEFAULT);
46
47         return genlist;
48 }
49
50
51 static void _done_button_cb(void *data, Evas_Object *obj, void *event_info)
52 {
53         NOTISET_DBG("");
54
55         ug_data* u_data = get_ug_data();
56         Eina_List *temp = NULL;
57         Eina_List *list = NULL;
58
59         elm_naviframe_item_pop(data);
60
61         EVAS_OBJECT_DELIF(u_data->done_button);
62         EVAS_OBJECT_DELIF(u_data->cancel_button);
63         EVAS_OBJECT_DELIF(u_data->list_sub);
64
65         if (u_data->list_main) {
66                 list = get_excepted_apps_list();
67                 while (list) {
68                         item_info_s *item = (item_info_s*)eina_list_data_get(list);
69                         if (item->do_not_disturb_except == false) {
70                                 set_excepted_apps(item->appid, item->do_not_disturb_except);
71                         }
72                         list = eina_list_next(list);
73                 }
74
75                 list = get_not_excepted_apps_list();
76                 while (list) {
77                         item_info_s *item = (item_info_s*)eina_list_data_get(list);
78                         if (item->do_not_disturb_except == TRUE) {
79                                 set_excepted_apps(item->appid, item->do_not_disturb_except);
80                         }
81                         list = eina_list_next(list);
82                 }
83
84                 create_do_not_disturb_application_list();
85                 elm_genlist_clear(u_data->list_main);
86                 do_not_disturb_append_item_in_list(u_data->list_main);
87
88         }
89 }
90
91
92 void _cancel_button_cb(void *data, Evas_Object *obj, void *event_info)
93 {
94         ret_if(!data);
95         elm_naviframe_item_pop(data);
96         ug_data* u_data = get_ug_data();
97
98         EVAS_OBJECT_DELIF(u_data->done_button);
99         EVAS_OBJECT_DELIF(u_data->cancel_button);
100         EVAS_OBJECT_DELIF(u_data->list_sub);
101 }
102
103 void exception_application_clicked_cb(void *data, Evas_Object *obj, void *event_info)
104 {
105         NOTISET_DBG("");
106         ug_data* u_data = get_ug_data();
107         ret_if(!u_data);
108
109         Evas_Object *genlist = NULL;
110         Elm_Object_Item* navi_item = NULL;
111         Evas_Object *cancel_btn = NULL;
112         Evas_Object *done_btn = NULL;
113
114         create_do_not_disturb_application_list();
115
116         u_data->list_sub = _create_edit_exception_apps_list(u_data);
117         //genlist = NULL;
118
119         /* Push to naviframe */
120         navi_item = elm_naviframe_item_push(u_data->naviframe, APP_STRING("IDS_ST_HEADER_MANAGE_EXCLUDED_APPS_ABB"), NULL, NULL, u_data->list_sub, NULL);
121
122         /* Title Cancel Button */
123         cancel_btn = elm_button_add(u_data->naviframe);
124         elm_object_style_set(cancel_btn, "naviframe/title_left");
125         evas_object_smart_callback_add(cancel_btn, "clicked", _cancel_button_cb, u_data->naviframe);
126         elm_object_text_set(cancel_btn, APP_STRING("IDS_TPLATFORM_ACBUTTON_CANCEL_ABB"));
127         elm_object_item_part_content_set(navi_item, "title_left_btn", cancel_btn);
128         u_data->cancel_button = cancel_btn;
129
130         /* Title Done Button */
131         done_btn = elm_button_add(u_data->naviframe);
132         elm_object_style_set(done_btn, "naviframe/title_right");
133         evas_object_smart_callback_add(done_btn, "clicked", _done_button_cb, u_data->naviframe);
134         elm_object_text_set(done_btn, APP_STRING("IDS_TPLATFORM_ACBUTTON_DONE_ABB"));
135         elm_object_item_part_content_set(navi_item, "title_right_btn", done_btn);
136         u_data->done_button = done_btn;
137
138 }
139