1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
|
#include "e.h"
#include "e_busycover.h"
#include "e_cfg.h"
#include "e_slipshelf.h"
// FIXME: make code work - place busycover in safe area
// FIXME: make theme for it
/* internal calls */
E_Busycover *_e_busycover_new(E_Zone *zone, const char *themedir);
static void _e_busycover_free(E_Busycover *esw);
static int _e_busycover_cb_zone_move_resize(void *data, int type, void *event);
static void _e_busycover_cb_item_sel(void *data, void *data2);
static Evas_Object *_theme_obj_new(Evas *e, const char *custom_dir, const char *group);
/* state */
static Eina_List *busycovers = NULL;
static void
_e_busycover_add_object(E_Busycover *esw)
{
int x, y, w, h;
Evas_Object *o;
esw->base_obj = _theme_obj_new(esw->zone->container->bg_evas,
esw->themedir,
"e/modules/busycover/default");
edje_object_part_text_set(esw->base_obj, "e.text.title", "LOADING");
e_slipshelf_safe_app_region_get(esw->zone, &x, &y, &w, &h);
evas_object_move(esw->base_obj, x, y);
evas_object_resize(esw->base_obj, w, h);
evas_object_layer_set(esw->base_obj, 100);
}
/* called from the module core */
EAPI int
e_busycover_init(void)
{
return 1;
}
EAPI int
e_busycover_shutdown(void)
{
return 1;
}
EAPI E_Busycover *
e_busycover_new(E_Zone *zone, const char *themedir)
{
E_Busycover *esw;
esw = E_OBJECT_ALLOC(E_Busycover, E_BUSYCOVER_TYPE, _e_busycover_free);
if (!esw) return NULL;
esw->zone = zone;
if (themedir) esw->themedir = evas_stringshare_add(themedir);
busycovers = eina_list_append(busycovers, esw);
esw->handlers = eina_list_append
(esw->handlers,
ecore_event_handler_add(E_EVENT_ZONE_MOVE_RESIZE,
_e_busycover_cb_zone_move_resize, esw));
return esw;
}
EAPI E_Busycover_Handle *
e_busycover_push(E_Busycover *esw, const char *message, const char *icon)
{
E_Busycover_Handle *h;
E_OBJECT_CHECK(esw);
E_OBJECT_TYPE_CHECK_RETURN(esw, E_BUSYCOVER_TYPE, NULL);
if (!esw->base_obj) _e_busycover_add_object(esw);
h = calloc(1, sizeof(E_Busycover_Handle));
h->busycover = esw;
if (message) h->message = evas_stringshare_add(message);
if (icon) h->icon = evas_stringshare_add(icon);
esw->handles = eina_list_prepend(esw->handles, h);
edje_object_part_text_set(esw->base_obj, "e.text.label", h->message);
/* FIXME: handle icon... */
evas_object_show(esw->base_obj);
return h;
}
EAPI void
e_busycover_pop(E_Busycover *esw, E_Busycover_Handle *handle)
{
E_OBJECT_CHECK(esw);
E_OBJECT_TYPE_CHECK(esw, E_BUSYCOVER_TYPE);
if (!eina_list_data_find(esw->handles, handle)) return;
esw->handles = eina_list_remove(esw->handles, handle);
if (handle->message) evas_stringshare_del(handle->message);
if (handle->icon) evas_stringshare_del(handle->icon);
free(handle);
if (esw->handles)
{
handle = esw->handles->data;
edje_object_part_text_set(esw->base_obj, "e.text.label",
handle->message);
}
else
{
evas_object_del(esw->base_obj);
esw->base_obj = NULL;
}
}
/* internal calls */
static void
_e_busycover_free(E_Busycover *esw)
{
if (esw->base_obj) evas_object_del(esw->base_obj);
busycovers = eina_list_remove(busycovers, esw);
while (esw->handlers)
{
if (esw->handlers->data)
ecore_event_handler_del(esw->handlers->data);
esw->handlers = eina_list_remove_list(esw->handlers, esw->handlers);
}
if (esw->themedir) evas_stringshare_del(esw->themedir);
free(esw);
}
static int
_e_busycover_cb_zone_move_resize(void *data, int type, void *event)
{
E_Event_Zone_Move_Resize *ev;
E_Busycover *esw;
ev = event;
esw = data;
if (esw->zone == ev->zone)
{
int x, y, w, h;
e_slipshelf_safe_app_region_get(esw->zone, &x, &y, &w, &h);
evas_object_move(esw->base_obj, x, y);
evas_object_resize(esw->base_obj, w, h);
}
return 1;
}
static Evas_Object *
_theme_obj_new(Evas *e, const char *custom_dir, const char *group)
{
Evas_Object *o;
o = edje_object_add(e);
if (!e_theme_edje_object_set(o, "base/theme/modules/illume", group))
{
if (custom_dir)
{
char buf[PATH_MAX];
snprintf(buf, sizeof(buf), "%s/illume.edj", custom_dir);
if (edje_object_file_set(o, buf, group))
{
printf("OK FALLBACK %s\n", buf);
}
}
}
return o;
}
|