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 <notification.h>
20 #include "quickpanel-ui.h"
21 #include "quickpanel_def.h"
24 #include "noti_section.h"
25 #include "list_util.h"
26 #ifdef QP_SCREENREADER_ENABLE
27 #include "accessibility.h"
30 #define NOTI_CLEAR_ALL_SECTION "quickpanel/notisection/clear_all"
31 #define NOTI_DEFAULT_SECTION "quickpanel/notisection/default"
33 static void _noti_section_set_text(Evas_Object *noti_section, int count)
35 #ifdef QP_SCREENREADER_ENABLE
36 Evas_Object *ao = NULL;
39 DBG("count is : %d ", count);
41 char text[128] = {0,};
43 const char *old_text = NULL;
45 retif(noti_section == NULL, , "invalid parameter");
47 format = _("IDS_QP_HEADER_NOTIFICATIONS_HPD_ABB");
48 snprintf(text, sizeof(text), format, count);
50 old_text = elm_object_part_text_get(noti_section, "elm.text.notifications_number");
51 if (old_text != NULL) {
52 if (strcmp(old_text, text) == 0) {
57 #ifdef QP_SCREENREADER_ENABLE
58 ao = quickpanel_accessibility_screen_reader_object_get(noti_section,
59 SCREEN_READER_OBJ_TYPE_ELM_OBJECT, "focus.label", noti_section);
62 elm_access_info_set(ao, ELM_ACCESS_TYPE, "");
63 elm_access_info_set(ao, ELM_ACCESS_INFO, text);
67 DBG("Trying to set text :%s ", text);
69 elm_object_part_text_set(noti_section, "elm.text.notifications_number", text);
70 elm_object_part_text_set(noti_section, "text.button.clear_all", _("IDS_QP_HEADER_CLEAR_ALL_ABB"));
73 HAPI Evas_Object *quickpanel_noti_section_create(Evas_Object *parent, qp_item_type_e type)
75 Eina_Bool ret = EINA_FALSE;
76 Evas_Object *section = NULL;
78 struct appdata *ad = quickpanel_get_app_data();
79 retif(ad == NULL, NULL, "invalid parameter");
80 retif(parent == NULL, NULL, "invalid parameter");
82 section = elm_layout_add(parent);
83 if (type == QP_ITEM_TYPE_ONGOING_NOTI_GROUP) {
84 ret = elm_layout_file_set(section, DEFAULT_EDJ,
85 NOTI_CLEAR_ALL_SECTION);
86 } else { //in higgs there is only one type of notifications
87 ret = elm_layout_file_set(section, DEFAULT_EDJ,
88 NOTI_CLEAR_ALL_SECTION);
90 retif(ret == EINA_FALSE, NULL, "failed to load layout");
92 evas_object_size_hint_weight_set(section, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
93 evas_object_size_hint_align_set(section, EVAS_HINT_FILL, EVAS_HINT_FILL);
94 quickpanel_uic_initial_resize(section, QP_THEME_LIST_ITEM_NOTI_SECTION_HEIGHT);
95 evas_object_show(section);
98 = quickpanel_list_util_item_new(type, NULL);
99 quickpanel_list_util_item_set_tag(section, qid);
100 quickpanel_list_util_sort_insert(ad->list, section);
102 Evas_Object *focus = quickpanel_accessibility_ui_get_focus_object(section);
103 elm_object_part_content_set(section, "focus", focus);
104 evas_object_smart_callback_add(focus, "clicked", quickpanel_noti_on_clear_all_clicked, NULL);
106 focus = quickpanel_accessibility_ui_get_focus_object(section);
107 elm_object_part_content_set(section, "focus.label", focus);
112 static void _focus_pair_set(Evas_Object *view)
114 Evas_Object *label = NULL;
115 Evas_Object *button = NULL;
116 retif(view == NULL, , "Invalid parameter!");
118 label = elm_object_part_content_get(view, "focus.label");
119 button = elm_object_part_content_get(view, "elm.swallow.icon");
121 if (label != NULL && button != NULL) {
123 elm_object_focus_next_object_set(label, button, ELM_FOCUS_RIGHT);
124 elm_object_focus_next_object_set(label, button, ELM_FOCUS_DOWN);
127 elm_object_focus_next_object_set(button, label, ELM_FOCUS_LEFT);
128 elm_object_focus_next_object_set(button, label, ELM_FOCUS_UP);
132 HAPI void quickpanel_noti_section_update(Evas_Object *noti_section, int noti_count)
134 retif(noti_section == NULL, , "invalid parameter");
136 _noti_section_set_text(noti_section, noti_count);
137 _focus_pair_set(noti_section);
139 quickpanel_noti_set_clear_all_status();
142 HAPI void quickpanel_noti_section_set_deleted_cb(Evas_Object *noti_section,
143 Evas_Object_Event_Cb func, void *data)
145 retif(noti_section == NULL, , "invalid parameter");
146 retif(func == NULL, , "invalid parameter");
148 evas_object_event_callback_add(noti_section, EVAS_CALLBACK_DEL, func, data);
151 HAPI void quickpanel_noti_section_remove(Evas_Object *noti_section)
153 struct appdata *ad = quickpanel_get_app_data();
154 retif(ad == NULL, , "invalid parameter");
155 retif(noti_section == NULL, , "invalid parameter");
157 quickpanel_list_util_item_del_tag(noti_section);
158 quickpanel_list_util_item_unpack_by_object(ad->list, noti_section, 0, 0);