5a4b81ad2b523280df9ba70d16fef6e0280044ea
[apps/home/quickpanel.git] / daemon / common.c
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
4  * Licensed under the Flora License, Version 1.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://floralicense.org
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 #include "common.h"
18 #include "quickpanel-ui.h"
19
20 HAPI void quickpanel_util_char_replace(char *text, char s, char t) {
21         retif(text == NULL, , "invalid argument");
22
23         int i = 0, text_len = 0;
24
25         text_len = strlen(text);
26
27         for (i = 0; i < text_len; i++) {
28                 if (*(text + i) == s) {
29                         *(text + i) = t;
30                 }
31         }
32 }
33
34 static void _current_popup_deleted_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
35 {
36         retif(obj == NULL, , "obj is NULL");
37
38         struct appdata *ad = quickpanel_get_app_data();
39         retif(ad == NULL, , "invalid argument");
40
41         if (ad->popup == obj) {
42                 ad->popup = NULL;
43         } else {
44                 ERR("popup is created over the popup");
45         }
46 }
47
48 HAPI void quickpanel_ui_set_current_popup(Evas_Object *popup) {
49         retif(popup == NULL, , "invalid argument");
50
51         struct appdata *ad = quickpanel_get_app_data();
52         retif(ad == NULL, , "invalid argument");
53
54         ad->popup = popup;
55         evas_object_event_callback_add(popup, EVAS_CALLBACK_DEL, _current_popup_deleted_cb, NULL);
56 }
57
58 HAPI void quickpanel_ui_del_current_popup(void) {
59         struct appdata *ad = quickpanel_get_app_data();
60         retif(ad == NULL, , "invalid argument");
61
62         if (ad->popup != NULL) {
63                 evas_object_del(ad->popup);
64         }
65 }