Boiler plate code verification and AUTHORS&NOTICE&LICENSE verification
[apps/core/preloaded/taskmanager.git] / src / _info.c
1 /*
2  * org.tizen.taskmgr
3  * Copyright (c) 2012 Samsung Electronics Co., Ltd.
4  *
5  * Licensed under the Flora License, Version 1.0 (the License);
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  *     http://www.tizenopensource.org/license
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an AS IS BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17
18
19
20
21 #include <stdio.h>
22
23 #include <appcore-common.h>
24
25 #include "taskmanager.h"
26 #include "_util_log.h"
27 #include "_util_efl.h"
28
29 static void ctxpopup_clear(void *data)
30 {
31         struct appdata *ad = data;
32
33         retm_if(data == NULL, "Invalid argument: appdata is NULL\n");
34
35         if (ad->info_timer) {
36                 ecore_timer_del(ad->info_timer);
37                 ad->info_timer = NULL;
38         }
39
40         if (ad->info_ctxpopup) {
41                 evas_object_del(ad->info_ctxpopup);
42                 ad->info_ctxpopup = NULL;
43         }
44
45 }
46
47 static void label_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
48 {
49         Evas_Object *ly = (Evas_Object *)data;
50         Evas_Coord w, h;
51         Evas_Coord pw, ph;
52
53         retm_if(ly == NULL, "Invalid argument: Evas_Object is NULL\n");
54
55         edje_object_part_geometry_get(_EDJ(ly),
56                         "padding/t", NULL, NULL, &pw, &ph);
57         evas_object_geometry_get(obj, NULL, NULL, &w, &h);
58         evas_object_size_hint_min_set(ly, (w + ph * 2), (h + ph * 2));
59 }
60
61 static void _ctxpopup_hide_cb(void *data, Evas_Object *obj, void *event_info)
62 {
63         struct appdata *ad = (struct appdata *)data;
64         ctxpopup_clear(ad);
65 }
66
67 int _util_move_ctxpopup(Evas_Object *eo, Evas_Object *target)
68 {
69         double scale;
70         Evas_Coord tx, ty, tw, th;
71         Evas_Coord cx, cy;
72
73         retvm_if(eo == NULL, -1, "Invalid argument: ctxpopup is NULL\n");
74
75         scale = elm_config_scale_get();
76
77         evas_object_geometry_get(target, &tx, &ty, &tw, &th);
78
79         cx = tx + (int)(tw * 0.5);
80         cy = ty + (int)(10.0 * scale);
81
82         evas_object_move(eo, cx, cy);
83
84         return 0;
85 }
86
87 static Eina_Bool info_hide_cb(void *data)
88 {
89         struct appdata *ad = data;
90
91         ctxpopup_clear(ad);
92
93         return ECORE_CALLBACK_CANCEL;
94 }
95
96 void create_info_ctxpopup(void *data, Evas_Object *obj, void *event_info)
97 {
98         struct appdata *ad = (struct appdata *)data;
99         Evas_Object *lb, *ly;
100         double scale = 0.0;
101         char buf[128] = {0, };
102
103         retm_if(data == NULL, "Invalid argument: appdata is NULL\n");
104
105         if (ad->info_ctxpopup) {
106                 evas_object_del(ad->info_ctxpopup);
107                 ad->info_ctxpopup = NULL;
108         }
109
110         scale = elm_config_scale_get();
111
112         ad->info_ctxpopup = _add_ctxpopup(ad->win);
113         evas_object_smart_callback_add(ad->info_ctxpopup, "dismissed",
114                                        _ctxpopup_hide_cb, ad);
115
116         ly = _add_layout(ad->info_ctxpopup, EDJ_NAME, "info");
117         evas_object_resize(ly, (int)(240.0 * scale), (int)(105.0 * scale));
118         elm_object_content_set(ad->info_ctxpopup, ly);
119
120         snprintf(buf, sizeof(buf),
121                         "<font_size=22>%s<font_size>", _("IDS_TASKMGR_INFO_MESSAGE"));
122         lb = _add_label(ly, buf);
123         evas_object_event_callback_add(lb, EVAS_CALLBACK_RESIZE,
124                                        label_resize_cb, ly);
125         elm_layout_content_set(ly, "swallow", lb);
126
127         _util_move_ctxpopup(ad->info_ctxpopup, ad->info_btn);
128
129         ad->info_timer = ecore_timer_add(3, info_hide_cb, ad);
130
131         evas_object_show(ad->info_ctxpopup);
132 }
133
134