2 * Copyright (c) 2009-2015 Samsung Electronics Co., Ltd All Rights Reserved
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
19 #include <Elementary.h>
23 #include <notification.h>
25 #include <tzsh_quickpanel_service.h>
26 #include <system_settings.h>
28 #include "quickpanel-ui.h"
29 #include "quickpanel_def.h"
30 #include "common_uic.h"
32 #include "noti_node.h"
34 #include "list_util.h"
35 #include "noti_section.h"
37 #ifdef QP_SCREENREADER_ENABLE
38 #include "accessibility.h"
41 #define NOTI_CLEAR_ALL_SECTION "quickpanel/notisection/clear_all"
42 #define NOTI_DEFAULT_SECTION "quickpanel/notisection/default"
44 static void _noti_section_set_text(Evas_Object *noti_section, int count)
46 char text[128] = { 0, };
51 ERR("Invalid parameter");
55 DBG("count is : %d ", count);
56 format = _("IDS_QP_HEADER_NOTIFICATIONS_HPD_ABB");
57 snprintf(text, sizeof(text) - 1, format, count);
59 old_text = elm_object_part_text_get(noti_section, "elm.text.notifications_number");
60 if (old_text != NULL) {
61 if (strcmp(old_text, text) == 0) {
66 #ifdef QP_SCREENREADER_ENABLE
69 ao = quickpanel_accessibility_screen_reader_object_get(noti_section, SCREEN_READER_OBJ_TYPE_ELM_OBJECT, "focus.label", noti_section);
71 elm_access_info_set(ao, ELM_ACCESS_TYPE, "");
72 elm_access_info_set(ao, ELM_ACCESS_INFO, text);
76 DBG("Trying to set text :%s ", text);
77 elm_object_part_text_set(noti_section, "elm.text.notifications_number", text);
78 elm_object_part_text_set(noti_section, "text.button.clear_all", _("IDS_QP_HEADER_CLEAR_ALL_ABB"));
81 HAPI Evas_Object *quickpanel_noti_section_create(Evas_Object *parent, qp_item_type_e type)
89 ad = quickpanel_get_app_data();
91 ERR("Invalid parameter");
95 section = elm_layout_add(parent);
96 ret = elm_layout_file_set(section, DEFAULT_EDJ, NOTI_CLEAR_ALL_SECTION);
97 if (ret == EINA_FALSE) {
98 ERR("Failed to set a file");
99 evas_object_del(section);
103 evas_object_size_hint_weight_set(section, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
104 evas_object_size_hint_align_set(section, EVAS_HINT_FILL, EVAS_HINT_FILL);
105 quickpanel_uic_initial_resize(section, QP_THEME_LIST_ITEM_NOTI_SECTION_HEIGHT);
106 evas_object_show(section);
108 qid = quickpanel_list_util_item_new(type, NULL);
110 ERR("Unable to create a qid");
111 evas_object_del(section);
114 quickpanel_list_util_item_set_tag(section, qid);
115 quickpanel_list_util_sort_insert(ad->list, section);
117 focus = quickpanel_accessibility_ui_get_focus_object(section);
119 ERR("Unable to get the focus object");
120 quickpanel_list_util_item_del(qid);
121 evas_object_del(section);
124 elm_object_part_content_set(section, "focus", focus);
125 evas_object_smart_callback_add(focus, "clicked", quickpanel_noti_on_clear_all_clicked, NULL);
130 static void _focus_pair_set(Evas_Object *view)
132 Evas_Object *label = NULL;
133 Evas_Object *button = NULL;
134 retif(view == NULL, , "Invalid parameter!");
136 label = elm_object_part_content_get(view, "focus.label");
137 button = elm_object_part_content_get(view, "elm.swallow.icon");
139 if (label != NULL && button != NULL) {
141 elm_object_focus_next_object_set(label, button, ELM_FOCUS_RIGHT);
142 elm_object_focus_next_object_set(label, button, ELM_FOCUS_DOWN);
145 elm_object_focus_next_object_set(button, label, ELM_FOCUS_LEFT);
146 elm_object_focus_next_object_set(button, label, ELM_FOCUS_UP);
150 HAPI void quickpanel_noti_section_update(Evas_Object *noti_section, int noti_count)
152 retif(noti_section == NULL, , "invalid parameter");
154 _noti_section_set_text(noti_section, noti_count);
155 _focus_pair_set(noti_section);
157 quickpanel_noti_set_clear_all_status();
160 HAPI void quickpanel_noti_section_set_deleted_cb(Evas_Object *noti_section,
161 Evas_Object_Event_Cb func, void *data)
163 retif(noti_section == NULL, , "invalid parameter");
164 retif(func == NULL, , "invalid parameter");
166 evas_object_event_callback_add(noti_section, EVAS_CALLBACK_DEL, func, data);
169 HAPI void quickpanel_noti_section_remove(Evas_Object *noti_section)
171 struct appdata *ad = quickpanel_get_app_data();
172 retif(ad == NULL, , "invalid parameter");
173 retif(noti_section == NULL, , "invalid parameter");
175 quickpanel_list_util_item_del_tag(noti_section);
176 quickpanel_list_util_item_unpack_by_object(ad->list, noti_section, 0, 0);