Update changed code
[profile/ivi/taskmanager.git] / src / _info.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://www.tizenopensource.org/license
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
20 #include <stdio.h>
21
22 #include <appcore-common.h>
23
24 #include "taskmanager.h"
25 #include "_util_log.h"
26 #include "_util_efl.h"
27
28 static void ctxpopup_clear(void *data)
29 {
30         struct appdata *ad = data;
31
32         retm_if(data == NULL, "Invalid argument: appdata is NULL\n");
33
34         if (ad->info_timer) {
35                 ecore_timer_del(ad->info_timer);
36                 ad->info_timer = NULL;
37         }
38
39         if (ad->info_ctxpopup) {
40                 evas_object_del(ad->info_ctxpopup);
41                 ad->info_ctxpopup = NULL;
42         }
43
44 }
45
46 static void label_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
47 {
48         Evas_Object *ly = (Evas_Object *)data;
49         Evas_Coord w, h;
50         Evas_Coord pw, ph;
51
52         retm_if(ly == NULL, "Invalid argument: Evas_Object is NULL\n");
53
54         edje_object_part_geometry_get(_EDJ(ly),
55                         "padding/t", NULL, NULL, &pw, &ph);
56         evas_object_geometry_get(obj, NULL, NULL, &w, &h);
57         evas_object_size_hint_min_set(ly, (w + ph * 2), (h + ph * 2));
58 }
59
60 static void _ctxpopup_hide_cb(void *data, Evas_Object *obj, void *event_info)
61 {
62         struct appdata *ad = (struct appdata *)data;
63         ctxpopup_clear(ad);
64 }
65
66 int _util_move_ctxpopup(Evas_Object *eo, Evas_Object *target)
67 {
68         double scale;
69         Evas_Coord tx, ty, tw, th;
70         Evas_Coord cx, cy;
71
72         retvm_if(eo == NULL, -1, "Invalid argument: ctxpopup is NULL\n");
73
74         scale = elm_config_scale_get();
75
76         evas_object_geometry_get(target, &tx, &ty, &tw, &th);
77
78         cx = tx + (int)(tw * 0.5);
79         cy = ty + (int)(10.0 * scale);
80
81         evas_object_move(eo, cx, cy);
82
83         return 0;
84 }
85
86 static Eina_Bool info_hide_cb(void *data)
87 {
88         struct appdata *ad = data;
89
90         ctxpopup_clear(ad);
91
92         return ECORE_CALLBACK_CANCEL;
93 }
94
95 void create_info_ctxpopup(void *data, Evas_Object *obj, void *event_info)
96 {
97         struct appdata *ad = (struct appdata *)data;
98         Evas_Object *lb, *ly;
99         double scale = 0.0;
100         char buf[128] = {0, };
101
102         retm_if(data == NULL, "Invalid argument: appdata is NULL\n");
103
104         if (ad->info_ctxpopup) {
105                 evas_object_del(ad->info_ctxpopup);
106                 ad->info_ctxpopup = NULL;
107         }
108
109         scale = elm_config_scale_get();
110
111         ad->info_ctxpopup = _add_ctxpopup(ad->win);
112         evas_object_smart_callback_add(ad->info_ctxpopup, "dismissed",
113                                        _ctxpopup_hide_cb, ad);
114
115         ly = _add_layout(ad->info_ctxpopup, EDJ_NAME, "info");
116         evas_object_resize(ly, (int)(240.0 * scale), (int)(105.0 * scale));
117         elm_object_content_set(ad->info_ctxpopup, ly);
118
119         snprintf(buf, sizeof(buf),
120                         "<font_size=22>%s<font_size>", _("IDS_TASKMGR_INFO_MESSAGE"));
121         lb = _add_label(ly, buf);
122         evas_object_event_callback_add(lb, EVAS_CALLBACK_RESIZE,
123                                        label_resize_cb, ly);
124         elm_layout_content_set(ly, "swallow", lb);
125
126         _util_move_ctxpopup(ad->info_ctxpopup, ad->info_btn);
127
128         ad->info_timer = ecore_timer_add(3, info_hide_cb, ad);
129
130         evas_object_show(ad->info_ctxpopup);
131 }
132
133