summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-07-07 23:34:27 +0100
committerCarsten Haitzler (Rasterman) <raster@rasterman.com>2020-07-07 23:34:27 +0100
commit0b1c4100efade6585c1a21bea0d910df013091c4 (patch)
tree472662cb6bda027a6cd6abadae1729bc263da191 /src
parent3bbab5a22fd047a2cad066be734a69d1df4f98d0 (diff)
e gadgets - as per email to e-devbel - it's easier to fix old so rm new
new gadget infra--
Diffstat (limited to 'src')
-rw-r--r--src/bin/e_bryce.c1488
-rw-r--r--src/bin/e_bryce.h22
-rw-r--r--src/bin/e_bryce_editor.c444
-rw-r--r--src/bin/e_config.c99
-rw-r--r--src/bin/e_gadget.c3535
-rw-r--r--src/bin/e_gadget.h155
-rw-r--r--src/bin/e_gadget_loader.c354
-rw-r--r--src/bin/e_gadget_runner.c1270
-rw-r--r--src/bin/e_gadget_types.h30
-rw-r--r--src/bin/e_includes.h2
-rw-r--r--src/bin/e_int_menus.c22
-rw-r--r--src/bin/e_main.c13
-rw-r--r--src/bin/generated/meson.build8
-rw-r--r--src/bin/meson.build22
-rw-r--r--src/modules/backlight/e_mod_main.c12
-rw-r--r--src/modules/backlight/gadget/backlight.c302
-rw-r--r--src/modules/backlight/gadget/backlight.h14
-rw-r--r--src/modules/backlight/gadget/mod.c22
-rw-r--r--src/modules/backlight/meson.build4
-rw-r--r--src/modules/bluez5/e_mod_main.c98
-rw-r--r--src/modules/bluez5/e_mod_main.h4
-rw-r--r--src/modules/conf_display/e_int_config_desklock.c9
-rw-r--r--src/modules/luncher/bar.c2066
-rw-r--r--src/modules/luncher/config.c572
-rw-r--r--src/modules/luncher/e-module-luncher.edjbin13065 -> 0 bytes
-rw-r--r--src/modules/luncher/grid.c754
-rw-r--r--src/modules/luncher/luncher.h114
-rw-r--r--src/modules/luncher/meson.build7
-rw-r--r--src/modules/luncher/mod.c108
-rw-r--r--src/modules/luncher/module.desktop36
-rw-r--r--src/modules/meson.build5
-rw-r--r--src/modules/mixer/backend.c (renamed from src/modules/mixer/gadget/backend.c)3
-rw-r--r--src/modules/mixer/backend.h (renamed from src/modules/mixer/gadget/backend.h)0
-rw-r--r--src/modules/mixer/e_mod_main.c15
-rw-r--r--src/modules/mixer/gadget/mixer.c423
-rw-r--r--src/modules/mixer/gadget/mixer.h30
-rw-r--r--src/modules/mixer/gadget/mod.c36
-rw-r--r--src/modules/mixer/meson.build6
-rw-r--r--src/modules/mixer/mixer.h9
-rw-r--r--src/modules/packagekit/e_mod_main.c136
-rw-r--r--src/modules/packagekit/e_mod_packagekit.c46
-rw-r--r--src/modules/packagekit/e_mod_packagekit.h3
-rw-r--r--src/modules/pager/e_mod_config.c2
-rw-r--r--src/modules/pager/e_mod_main.c72
-rw-r--r--src/modules/pager/e_mod_main.h25
-rw-r--r--src/modules/pager/gadget/config.c685
-rw-r--r--src/modules/pager/gadget/mod.c108
-rw-r--r--src/modules/pager/gadget/pager.c2991
-rw-r--r--src/modules/pager/gadget/pager.h51
-rw-r--r--src/modules/pager/meson.build6
-rw-r--r--src/modules/start/e_mod_main.c4
-rw-r--r--src/modules/start/meson.build3
-rw-r--r--src/modules/start/start.c227
-rw-r--r--src/modules/sysinfo/batman/batman.c759
-rw-r--r--src/modules/sysinfo/batman/batman.h114
-rw-r--r--src/modules/sysinfo/batman/batman_config.c611
-rw-r--r--src/modules/sysinfo/batman/batman_fallback.c1291
-rw-r--r--src/modules/sysinfo/batman/batman_sysctl.c398
-rw-r--r--src/modules/sysinfo/batman/batman_udev.c393
-rw-r--r--src/modules/sysinfo/batman/batman_upower.c419
-rw-r--r--src/modules/sysinfo/cpuclock/cpuclock.c1168
-rw-r--r--src/modules/sysinfo/cpuclock/cpuclock.h33
-rw-r--r--src/modules/sysinfo/cpuclock/cpuclock_config.c633
-rw-r--r--src/modules/sysinfo/cpumonitor/cpumonitor.c502
-rw-r--r--src/modules/sysinfo/cpumonitor/cpumonitor.h12
-rw-r--r--src/modules/sysinfo/cpumonitor/cpumonitor_config.c171
-rw-r--r--src/modules/sysinfo/cpumonitor/cpumonitor_proc.c114
-rw-r--r--src/modules/sysinfo/cpumonitor/cpumonitor_sysctl.c125
-rw-r--r--src/modules/sysinfo/e-module-sysinfo.edjbin7340 -> 0 bytes
-rw-r--r--src/modules/sysinfo/memusage/memusage.c586
-rw-r--r--src/modules/sysinfo/memusage/memusage.h25
-rw-r--r--src/modules/sysinfo/memusage/memusage_config.c171
-rw-r--r--src/modules/sysinfo/memusage/memusage_proc.c98
-rw-r--r--src/modules/sysinfo/memusage/memusage_sysctl.c172
-rw-r--r--src/modules/sysinfo/meson.build44
-rw-r--r--src/modules/sysinfo/mod.c222
-rw-r--r--src/modules/sysinfo/module.desktop8
-rw-r--r--src/modules/sysinfo/netstatus/netstatus.c509
-rw-r--r--src/modules/sysinfo/netstatus/netstatus.h29
-rw-r--r--src/modules/sysinfo/netstatus/netstatus_config.c419
-rw-r--r--src/modules/sysinfo/netstatus/netstatus_proc.c93
-rw-r--r--src/modules/sysinfo/netstatus/netstatus_sysctl.c188
-rw-r--r--src/modules/sysinfo/sysinfo.c176
-rw-r--r--src/modules/sysinfo/sysinfo.h302
-rw-r--r--src/modules/sysinfo/thermal/thermal.c509
-rw-r--r--src/modules/sysinfo/thermal/thermal.h28
-rw-r--r--src/modules/sysinfo/thermal/thermal_config.c369
-rw-r--r--src/modules/sysinfo/thermal/thermal_fallback.c435
-rw-r--r--src/modules/sysinfo/thermal/thermal_sysctl.c212
-rw-r--r--src/modules/sysinfo/thermal/thermal_udev.c51
-rw-r--r--src/modules/teamwork/e-module-teamwork.edjbin13926 -> 0 bytes
-rw-r--r--src/modules/teamwork/e_mod_config.c182
-rw-r--r--src/modules/teamwork/e_mod_main.c181
-rw-r--r--src/modules/teamwork/e_mod_main.h99
-rw-r--r--src/modules/teamwork/e_mod_tw.c1297
-rw-r--r--src/modules/teamwork/meson.build17
-rw-r--r--src/modules/teamwork/module.desktop24
-rw-r--r--src/modules/teamwork/wl.c138
-rw-r--r--src/modules/teamwork/wl_teamwork.c46
-rw-r--r--src/modules/teamwork/wl_teamwork.h93
-rw-r--r--src/modules/teamwork/x11.c143
-rw-r--r--src/modules/time/clock.c516
-rw-r--r--src/modules/time/clock.h94
-rw-r--r--src/modules/time/config.c634
-rw-r--r--src/modules/time/e-module-time.edjbin14062 -> 0 bytes
-rw-r--r--src/modules/time/meson.build7
-rw-r--r--src/modules/time/mod.c142
-rw-r--r--src/modules/time/module.desktop9
-rw-r--r--src/modules/time/time.c385
-rw-r--r--src/modules/wireless/connman.c1673
-rw-r--r--src/modules/wireless/e-module-wireless.edjbin21146 -> 0 bytes
-rw-r--r--src/modules/wireless/meson.build6
-rw-r--r--src/modules/wireless/mod.c54
-rw-r--r--src/modules/wireless/module.desktop10
-rw-r--r--src/modules/wireless/wireless.c1657
-rw-r--r--src/modules/wireless/wireless.h140
-rw-r--r--src/modules/xkbswitch/e_mod_main.c10
-rw-r--r--src/modules/xkbswitch/gadget/mod.c29
-rw-r--r--src/modules/xkbswitch/gadget/xkbswitch.c341
-rw-r--r--src/modules/xkbswitch/gadget/xkbswitch.h25
-rw-r--r--src/modules/xkbswitch/meson.build5
-rw-r--r--src/protocol/e-gadget.xml42
122 files changed, 126 insertions, 35734 deletions
diff --git a/src/bin/e_bryce.c b/src/bin/e_bryce.c
deleted file mode 100644
index e242686d2..000000000
--- a/src/bin/e_bryce.c
+++ /dev/null
@@ -1,1488 +0,0 @@
1#include "e.h"
2
3#define DEFAULT_LAYER E_LAYER_CLIENT_ABOVE
4#define E_BRYCE_TYPE 0xE31338
5
6static unsigned int bryce_version = 2;
7
8typedef struct Bryce
9{
10 E_Object *e_obj_inherit;
11 Eina_Stringshare *name;
12
13 Evas_Object *bryce;
14 Evas_Object *events;
15 Evas_Object *layout;
16 Evas_Object *site;
17 Evas_Object *scroller;
18 Evas_Object *autohide_event;
19 Eina_List *zone_obstacles;
20 Eina_List *spacers;
21
22 Evas_Object *parent; //comp_object is not an elm widget
23 Eina_Stringshare *style;
24 int size;
25 int x, y;
26 int last_w, last_h;
27 int autohide_size;
28 E_Layer layer;
29 unsigned int zone;
30 E_Gadget_Site_Orient orient;
31 E_Gadget_Site_Anchor anchor;
32
33 Ecore_Job *calc_job;
34 Ecore_Timer *save_timer;
35 Ecore_Timer *autohide_timer;
36 unsigned int autohide_blocked;
37 Eina_List *popups;
38 void *event_info;
39 unsigned int last_timestamp;
40
41 E_Menu *menu;
42
43 /* config: do not bitfield! */
44 Eina_Bool autosize;
45 Eina_Bool autohide;
46 unsigned int version;
47
48 Eina_Bool hidden E_BITFIELD;
49 Eina_Bool animating E_BITFIELD;
50 Eina_Bool mouse_in E_BITFIELD;
51 Eina_Bool noshadow E_BITFIELD;
52 Eina_Bool size_changed E_BITFIELD;
53 Eina_Bool editing E_BITFIELD;
54} Bryce;
55
56typedef struct Bryces
57{
58 Eina_List *bryces;
59} Bryces;
60
61static E_Config_DD *edd_bryces;
62static E_Config_DD *edd_bryce;
63static Bryces *bryces;
64static E_Action *resize_act;
65static Eina_List *handlers;
66
67
68static void _bryce_menu(Bryce *b, Evas_Object *g);
69
70#define BRYCE_GET(obj) \
71 Bryce *b; \
72 b = evas_object_data_get((obj), "__bryce"); \
73 if (!b) abort()
74
75static void
76_bryce_obstacle_del(void *obs)
77{
78 Bryce *b = e_object_data_get(obs);
79
80 b->zone_obstacles = eina_list_remove(b->zone_obstacles, obs);
81}
82
83static void
84_bryce_autohide_end(void *data, E_Efx_Map_Data *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED)
85{
86 Bryce *b = data;
87
88 b->animating = 0;
89}
90
91static void
92_bryce_autohide_coords(Bryce *b, int *x, int *y)
93{
94 int ox, oy, ow, oh;
95 E_Gadget_Site_Anchor an;
96
97 if (b->parent == e_comp->elm)
98 {
99 E_Zone *zone;
100
101 zone = e_comp_zone_number_get(b->zone);
102 ox = zone->x, oy = zone->y, ow = zone->w, oh = zone->h;
103 }
104 else
105 evas_object_geometry_get(b->parent, &ox, &oy, &ow, &oh);
106 an = e_gadget_site_anchor_get(b->site);
107
108 if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
109 {
110 *x = b->x;
111
112 if (an & E_GADGET_SITE_ANCHOR_TOP)
113 *y = oy - lround(e_scale * b->size) + lround(e_scale * b->autohide_size);
114 if (an & E_GADGET_SITE_ANCHOR_BOTTOM)
115 *y = oy + oh - lround(e_scale * b->autohide_size);
116 }
117 else if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
118 {
119 *y = b->y;
120
121 if (an & E_GADGET_SITE_ANCHOR_LEFT)
122 *x = ox - lround(e_scale * b->size) + lround(e_scale * b->autohide_size);
123 if (an & E_GADGET_SITE_ANCHOR_RIGHT)
124 *x = ox + ow - lround(e_scale * b->autohide_size);
125 }
126}
127
128static void
129_bryce_position(Bryce *b, int w, int h, int *nx, int *ny)
130{
131 int ox, oy, ow, oh;
132 int x, y;
133 E_Gadget_Site_Anchor an;
134
135 if (b->parent == e_comp->elm)
136 {
137 E_Zone *zone;
138
139 zone = e_comp_zone_number_get(b->zone);
140 ox = zone->x, oy = zone->y, ow = zone->w, oh = zone->h;
141 if (starting)
142 {
143 E_Zone *zone2;
144
145 zone2 = e_comp_object_util_zone_get(b->bryce);
146 if (zone != zone2)
147 evas_object_move(b->bryce, ox, oy);
148 }
149 }
150 else
151 evas_object_geometry_get(b->parent, &ox, &oy, &ow, &oh);
152 x = ox + (ow - w) / 2;
153 x = E_CLAMP(x, ox, ox + ow / 2);
154 y = oy + (oh - h) / 2;
155 y = E_CLAMP(y, oy, oy + oh / 2);
156 an = e_gadget_site_anchor_get(b->site);
157 if (an & E_GADGET_SITE_ANCHOR_LEFT)
158 x = ox;
159 if (an & E_GADGET_SITE_ANCHOR_TOP)
160 y = oy;
161 if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
162 {
163 if (an & E_GADGET_SITE_ANCHOR_RIGHT)
164 x = ox + ow - w;
165 if (an & E_GADGET_SITE_ANCHOR_BOTTOM)
166 y = oy + oh - lround(e_scale * b->size);
167 if (!b->autosize)
168 x = ox;
169 }
170 else if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
171 {
172 if (an & E_GADGET_SITE_ANCHOR_RIGHT)
173 x = ox + ow - lround(e_scale * b->size);
174 if (an & E_GADGET_SITE_ANCHOR_BOTTOM)
175 y = oy + oh - h;
176 if (!b->autosize)
177 y = oy;
178 }
179 b->x = x, b->y = y;
180 if (b->animating)
181 {
182 if (b->hidden)
183 {
184 _bryce_autohide_coords(b, &x, &y);
185 e_efx_move(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), 0.5, _bryce_autohide_end, b);
186 }
187 else
188 e_efx_move(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), 0.5, _bryce_autohide_end, b);
189 }
190 else if (b->hidden)
191 _bryce_autohide_coords(b, &x, &y);
192
193 if (nx && ny)
194 *nx = x, *ny = y;
195 else
196 evas_object_move(b->bryce, x, y);
197}
198
199static void
200_bryce_autosize(Bryce *b)
201{
202 int lw, lh, sw, sh, maxw, maxh, x, y, w, h;
203
204 E_FREE_FUNC(b->calc_job, ecore_job_del);
205 if (!b->autosize)
206 {
207 if (b->parent == e_comp->elm)
208 {
209 w = e_comp_zone_number_get(b->zone)->w;
210 if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
211 e_zone_useful_geometry_get(e_comp_zone_number_get(b->zone), NULL, NULL, NULL, &h);
212 else
213 h = e_comp_zone_number_get(b->zone)->h;
214 }
215 else
216 evas_object_geometry_get(b->parent, NULL, NULL, &w, &h);
217 if (b->size_changed)
218 elm_object_content_unset(b->scroller);
219 _bryce_position(b, w, h, &x, &y);
220 evas_object_move(b->bryce, x, y);
221 if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
222 e_efx_resize(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), w, lround(b->size * e_scale), 0.1, NULL, NULL);
223 else if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
224 e_efx_resize(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), lround(b->size * e_scale), h, 0.1, NULL, NULL);
225 evas_object_smart_need_recalculate_set(b->site, 1);
226 evas_object_size_hint_min_set(b->site, -1, -1);
227 if (b->size_changed)
228 elm_object_content_set(b->scroller, b->site);
229 b->size_changed = 0;
230 return;
231 }
232 if (b->parent == e_comp->elm) //screen-based bryce
233 {
234 E_Zone *zone;
235
236 zone = e_comp_zone_number_get(b->zone);
237 if (zone)
238 {
239 maxw = zone->w;
240 if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
241 e_zone_useful_geometry_get(e_comp_zone_number_get(b->zone), NULL, NULL, NULL, &maxh);
242 else
243 maxh = zone->h;
244 }
245 else return;
246 }
247 else
248 evas_object_geometry_get(b->parent, NULL, NULL, &maxw, &maxh);
249 do
250 {
251 if (b->size_changed)
252 {
253 evas_object_geometry_get(b->bryce, NULL, NULL, &w, &h);
254 elm_object_content_unset(b->scroller);
255 if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
256 {
257 if (!h) h = 1;
258 evas_object_resize(b->bryce, w * lround(b->size * e_scale) / h, lround(b->size * e_scale));
259 evas_object_resize(b->site, w * lround(b->size * e_scale) / h, lround(b->size * e_scale));
260 }
261 else if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
262 {
263 if (!w) w = 1;
264 evas_object_resize(b->bryce, lround(b->size * e_scale), h * lround(b->size * e_scale) / w);
265 evas_object_resize(b->site, lround(b->size * e_scale), h * lround(b->size * e_scale) / w);
266 }
267 evas_object_smart_need_recalculate_set(b->site, 1);
268 evas_object_size_hint_min_set(b->site, -1, -1);
269 evas_object_smart_calculate(b->site);
270 elm_object_content_set(b->scroller, b->site);
271 }
272 evas_object_size_hint_min_get(b->site, &sw, &sh);
273 if ((!sw) && (!sh)) b->size_changed = 1;
274 }
275 while ((!sw) && (!sh));
276 edje_object_size_min_calc(elm_layout_edje_get(b->layout), &lw, &lh);
277 _bryce_position(b, lw + sw, lh + sh, &x, &y);
278 if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
279 w = MIN(MAX(lw + sw, lround(b->size * e_scale)), maxw), h = lround(b->size * e_scale);
280 else if (b->orient == E_GADGET_SITE_ORIENT_VERTICAL)
281 w = lround(b->size * e_scale), h = MIN(MAX(lh + sh, lround(b->size * e_scale)), maxh);
282 evas_object_move(b->bryce, x, y);
283 e_efx_resize(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), w, h, 0.1, NULL, NULL);
284 b->size_changed = 0;
285}
286
287static Eina_Bool
288_bryce_autohide_timeout(Bryce *b)
289{
290 int x = 0, y = 0;
291
292 b->autohide_timer = NULL;
293 b->hidden = b->animating = 1;
294 _bryce_autohide_coords(b, &x, &y);
295 e_efx_move(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(x, y), 0.5, _bryce_autohide_end, b);
296 return EINA_FALSE;
297}
298
299static void
300_bryce_autohide_moveresize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
301{
302 Bryce *b = data;
303 int x, y, w, h;
304
305 evas_object_geometry_get(obj, &x, &y, &w, &h);
306 evas_object_geometry_set(b->autohide_event, x, y, w, h);
307}
308
309static void
310_bryce_autohide_show(Bryce *b)
311{
312 E_FREE_FUNC(b->autohide_timer, ecore_timer_del);
313 if (b->animating && (!b->hidden)) return;
314 e_efx_move(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(b->x, b->y), 0.5, _bryce_autohide_end, b);
315 b->animating = 1;
316 b->hidden = 0;
317}
318
319static void
320_bryce_autohide_hide(Bryce *b)
321{
322 if (b->autohide_blocked) return;
323 if (b->autohide_timer)
324 ecore_timer_loop_reset(b->autohide_timer);
325 else
326 b->autohide_timer = ecore_timer_loop_add(1.0, (Ecore_Task_Cb)_bryce_autohide_timeout, b);
327}
328
329static void
330_bryce_autohide_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
331{
332 Bryce *b = data;
333
334 _bryce_autohide_hide(b);
335 b->mouse_in = 0;
336}
337
338static void
339_bryce_autohide_mouse_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
340{
341 Bryce *b = data;
342
343 b->mouse_in = 1;
344 _bryce_autohide_show(b);
345}
346
347static void
348_bryce_autohide_setup(Bryce *b)
349{
350 int x, y, w, h;
351
352 if (!b->autohide) return;
353 b->autohide_event = evas_object_rectangle_add(evas_object_evas_get(b->bryce));
354 evas_object_geometry_get(b->bryce, &x, &y, &w, &h);
355 evas_object_geometry_set(b->autohide_event, x, y, w, h);
356 evas_object_color_set(b->autohide_event, 0, 0, 0, 0);
357 evas_object_repeat_events_set(b->autohide_event, 1);
358 evas_object_layer_set(b->autohide_event, b->layer + 1);
359 evas_object_show(b->autohide_event);
360 evas_object_event_callback_add(b->autohide_event, EVAS_CALLBACK_MOUSE_IN, _bryce_autohide_mouse_in, b);
361 evas_object_event_callback_add(b->autohide_event, EVAS_CALLBACK_MOUSE_OUT, _bryce_autohide_mouse_out, b);
362 evas_object_event_callback_add(b->bryce, EVAS_CALLBACK_MOVE, _bryce_autohide_moveresize, b);
363 evas_object_event_callback_add(b->bryce, EVAS_CALLBACK_RESIZE, _bryce_autohide_moveresize, b);
364 ecore_evas_pointer_xy_get(e_comp->ee, &x, &y);
365 if (!E_INSIDE(x, y, b->x, b->y, w, h))
366 _bryce_autohide_hide(b);
367}
368
369static void
370_bryce_style(Evas_Object *site, Eina_Stringshare *name, Evas_Object *g)
371{
372 Evas_Object *ly, *prev;
373 char buf[1024];
374
375 BRYCE_GET(site);
376
377 ly = elm_layout_add(b->site);
378 snprintf(buf, sizeof(buf), "e/bryce/%s/%s", b->style ?: "default", name ?: "plain");
379 if (!e_theme_edje_object_set(ly, NULL, buf))
380 {
381 evas_object_del(ly);
382 return;
383 }
384 if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
385 elm_layout_signal_emit(ly, "e,state,orient,horizontal", "e");
386 else
387 elm_layout_signal_emit(ly, "e,state,orient,vertical", "e");
388 edje_object_message_signal_process(elm_layout_edje_get(ly));
389 prev = e_gadget_util_layout_style_init(g, ly);
390 elm_object_part_content_set(ly, "e.swallow.content", g);
391 evas_object_smart_callback_call(g, "gadget_reparent", ly);
392 evas_object_del(prev);
393}
394
395static void
396_bryce_site_hints(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
397{
398 Bryce *b = data;
399 int w, h;
400
401 evas_object_size_hint_min_get(obj, &w, &h);
402 if ((w < 0) || (h < 0)) return;
403 if (b->autosize && (!b->calc_job))
404 b->calc_job = ecore_job_add((Ecore_Cb)_bryce_autosize, b);
405}
406
407static E_Comp_Object_Type
408_bryce_shadow_type(const Bryce *b)
409{
410 if ((b->layer == E_LAYER_DESKTOP_TOP) || b->noshadow)
411 return E_COMP_OBJECT_TYPE_NONE;
412 return E_COMP_OBJECT_TYPE_POPUP;
413}
414
415static void
416_bryce_restack(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
417{
418 Bryce *b = data;
419 E_Layer layer;
420
421 layer = evas_object_layer_get(obj);
422 if (layer > DEFAULT_LAYER) return;
423 b->layer = layer;
424 if ((!b->noshadow) && (layer != b->layer))
425 e_comp_object_util_type_set(b->bryce, _bryce_shadow_type(b));
426}
427
428static Eina_Bool
429_bryce_moveresize_save(void *data)
430{
431 Bryce *b = data;
432 int w, h;
433 int size;
434
435 b->save_timer = NULL;
436 evas_object_geometry_get(b->bryce, NULL, NULL, &w, &h);
437 if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
438 size = h;
439 else
440 size = w;
441 size = lround(size / e_scale);
442 if (b->size == size) return EINA_FALSE;
443 e_config_save_queue();
444 b->size = size;
445 return EINA_FALSE;
446}
447
448static void
449_bryce_zone_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
450{
451 Bryce *b = data;
452 e_object_del(E_OBJECT(b->e_obj_inherit));
453}
454
455static void
456_bryce_zone_moveresize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
457{
458 Bryce *b = data;
459 if (!b->calc_job)
460 b->calc_job = ecore_job_add((Ecore_Cb)_bryce_autosize, b);
461}
462
463static void
464_bryce_zone_setup(Bryce *b)
465{
466 Evas_Object *zone_clip;
467
468 zone_clip = evas_object_clip_get(b->bryce);
469 if (zone_clip)
470 {
471 evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_DEL, _bryce_zone_del, b);
472 evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_MOVE, _bryce_zone_moveresize, b);
473 evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_RESIZE, _bryce_zone_moveresize, b);
474 }
475 zone_clip = e_comp_zone_number_get(b->zone)->bg_clip_object;
476 evas_object_clip_set(b->bryce, zone_clip);
477 evas_object_event_callback_add(zone_clip, EVAS_CALLBACK_DEL, _bryce_zone_del, b);
478 evas_object_event_callback_add(zone_clip, EVAS_CALLBACK_MOVE, _bryce_zone_moveresize, b);
479 evas_object_event_callback_add(zone_clip, EVAS_CALLBACK_RESIZE, _bryce_zone_moveresize, b);
480}
481
482static void
483_bryce_rename(Bryce *b, int num)
484{
485 char buf[1024], buf2[1024], *name, *p;
486
487 name = strdup(b->name);
488 if (b->version >= 2)
489 {
490 p = strrchr(name, '_');
491 p[0] = 0;
492 }
493 snprintf(buf, sizeof(buf), "__bryce%s", name);
494 snprintf(buf2, sizeof(buf2), "__bryce%s_%d", name, num);
495 e_gadget_site_rename(buf, buf2);
496 if (b->version >= 2)
497 {
498 snprintf(buf, sizeof(buf), "%s_%u", name, num);
499 eina_stringshare_replace(&b->name, buf);
500 }
501 free(name);
502}
503
504static void
505_bryce_moveresize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
506{
507 Bryce *b = data;
508 int x, y, w, h;
509 E_Zone *zone;
510 int size;
511
512 evas_object_geometry_get(obj, &x, &y, &w, &h);
513 evas_object_geometry_set(b->events, x, y, w, h);
514 if (b->autohide)
515 {
516 E_FREE_LIST(b->zone_obstacles, e_object_del);
517 return;
518 }
519 if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
520 size = h;
521 else
522 size = w;
523 if (((b->orient == E_GADGET_SITE_ORIENT_VERTICAL) && (w != b->last_w)) ||
524 ((b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL) && (h != b->last_h)))
525 {
526 evas_object_smart_need_recalculate_set(b->site, 1);
527 evas_object_size_hint_min_set(b->site, -1, -1);
528 }
529 b->last_w = w, b->last_h = h;
530
531 if (size && (b->size != size))
532 {
533 if (b->save_timer)
534 ecore_timer_loop_reset(b->save_timer);
535 else
536 b->save_timer = ecore_timer_loop_add(0.5, _bryce_moveresize_save, b);
537 }
538
539 if (starting) return;
540 zone = e_comp_object_util_zone_get(obj);
541 if (zone)
542 {
543 Eina_Bool vertical = b->orient == E_GADGET_SITE_ORIENT_VERTICAL;
544 if (b->zone_obstacles)
545 {
546 Eina_List *l;
547 E_Zone_Obstacle *obs;
548
549 EINA_LIST_FOREACH(b->zone_obstacles, l, obs)
550 e_zone_obstacle_modify(obs, &(Eina_Rectangle){b->x, b->y, w, h}, vertical);
551 }
552 else
553 {
554 void *obs;
555
556 obs = e_zone_obstacle_add(e_comp_object_util_zone_get(obj), NULL,
557 &(Eina_Rectangle){b->x, b->y, w, h}, vertical);
558 e_object_data_set(obs, b);
559 E_OBJECT_DEL_SET(obs, _bryce_obstacle_del);
560 b->zone_obstacles = eina_list_append(b->zone_obstacles, obs);
561 }
562 }
563 else
564 {
565 /* determine "closest" zone:
566 * calculate size of rect between bryce and zone
567 * smallest rect = closest zone
568 */
569 Eina_List *l;
570 E_Zone *lz;
571 size = 0;
572
573 E_FREE_LIST(b->zone_obstacles, e_object_del);
574 EINA_LIST_FOREACH(e_comp->zones, l, lz)
575 {
576 int cw, ch;
577
578 if (x < lz->x)
579 cw = lz->x + lz->w - x;
580 else
581 cw = x + w - lz->x;
582 if (y < lz->y)
583 ch = lz->y + lz->h - y;
584 else
585 ch = y + h - lz->y;
586 if (size >= cw * ch) continue;
587 size = cw * ch;
588 zone = lz;
589 }
590 }
591 if (!zone) return;
592 if (b->zone == zone->num) return;
593 e_config_save_queue();
594 _bryce_rename(b, zone->num);
595 b->zone = zone->num;
596 _bryce_zone_setup(b);
597 _bryce_autosize(b);
598}
599
600static void
601_bryce_mouse_wheel(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
602{
603 Bryce *b = data;
604 Evas_Event_Mouse_Wheel *ev = event_info;
605
606 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
607 if (e_bindings_wheel_evas_event_handle(E_BINDING_CONTEXT_ANY, b->e_obj_inherit, ev))
608 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
609}
610
611static void
612_bryce_popup_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
613{
614 Bryce *b = data;
615
616 b->autohide_blocked--;
617 b->popups = eina_list_remove(b->popups, obj);
618 if (!b->autohide) return;
619 if (!b->mouse_in)
620 _bryce_autohide_hide(b);
621}
622
623static void
624_bryce_popup(Bryce *b, Evas_Object *popup)
625{
626 evas_object_event_callback_add(popup, EVAS_CALLBACK_HIDE, _bryce_popup_hide, b);
627 b->autohide_blocked++;
628 b->popups = eina_list_append(b->popups, popup);
629 if (b->autohide)
630 _bryce_autohide_show(b);
631}
632
633static void
634_bryce_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
635{
636 Bryce *b = data;
637 Evas_Object *p;
638 Evas_Object *zone_clip;
639 void *obs;
640
641 if (b->menu)
642 {
643 e_menu_deactivate(b->menu);
644 e_object_del(E_OBJECT(b->menu));
645 b->menu = NULL;
646 }
647 EINA_LIST_FREE(b->zone_obstacles, obs)
648 {
649 E_OBJECT_DEL_SET(obs, NULL);
650 e_object_del(obs);
651 }
652 evas_object_del(b->autohide_event);
653 E_FREE_FUNC(b->events, evas_object_del);
654 E_FREE_FUNC(b->calc_job, ecore_job_del);
655 E_FREE_FUNC(b->autohide_timer, ecore_timer_del);
656 ecore_timer_del(b->save_timer);
657 EINA_LIST_FREE(b->popups, p)
658 evas_object_event_callback_del(p, EVAS_CALLBACK_HIDE, _bryce_popup_hide);
659 zone_clip = evas_object_clip_get(b->bryce);
660 if (zone_clip)
661 {
662 evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_DEL, _bryce_zone_del, b);
663 evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_MOVE, _bryce_zone_moveresize, b);
664 evas_object_event_callback_del_full(zone_clip, EVAS_CALLBACK_RESIZE, _bryce_zone_moveresize, b);
665 }
666 E_FREE(b->e_obj_inherit);
667 b->bryce = NULL;
668 b->site = NULL;
669}
670
671static void
672_bryce_object_free(E_Object *eobj)
673{
674 Bryce *b = e_object_data_get(eobj);
675 evas_object_hide(b->bryce);
676 evas_object_del(b->bryce);
677}
678
679static void
680_bryce_style_menu(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
681{
682 Bryce *b = data;
683 char buf[1024];
684
685 snprintf(buf, sizeof(buf), "e/bryce/%s", b->style ?: "default");
686 e_object_data_set(event_info, e_theme_collection_items_find(NULL, buf));
687}
688
689static void
690_bryce_gadgets_menu_close(void *data, Evas_Object *obj)
691{
692 Bryce *b = data;
693
694 b->autohide_blocked--;
695 b->editing = 0;
696 evas_object_layer_set(b->bryce, b->layer);
697 evas_object_hide(obj);
698 evas_object_del(obj);
699 if (b->autohide && (!b->mouse_in))
700 _bryce_autohide_hide(b);
701}
702
703static void
704_bryce_gadgets_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
705{
706 Bryce *b = data;
707 Evas_Object *comp_object;
708
709 b->autohide_blocked++;
710 b->editing = 1;
711 comp_object = e_gadget_site_edit(b->site);
712 evas_object_layer_set(b->bryce, E_LAYER_POPUP);
713 e_comp_object_util_autoclose(comp_object, _bryce_gadgets_menu_close, e_comp_object_util_autoclose_on_escape, b);
714}
715
716static void
717_bryce_autosize_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
718{
719 Bryce *b = data;
720
721 e_bryce_autosize_set(b->bryce, !b->autosize);
722}
723
724static void
725_bryce_autohide_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
726{
727 Bryce *b = data;
728
729 e_bryce_autohide_set(b->bryce, !b->autohide);
730}
731
732static void
733_bryce_remove_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
734{
735 Bryce *b = data;
736 bryces->bryces = eina_list_remove(bryces->bryces, data);
737 e_gadget_site_del(b->site);
738 eina_stringshare_del(b->name);
739 eina_stringshare_del(b->style);
740 evas_object_hide(b->bryce);
741 evas_object_del(b->bryce);
742 e_config_save_queue();
743}
744
745static void
746_bryce_wizard_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
747{
748 Bryce *b = data;
749 Evas_Object *editor;
750
751 editor = e_bryce_edit(b->bryce);
752 _bryce_popup(b, editor);
753}
754
755static void
756_bryce_gadget_settings_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
757{
758 Evas_Object *g = data;
759 e_gadget_configure(g);
760}
761
762static void
763_bryce_gadget_remove_menu(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
764{
765 Evas_Object *g = data;
766 e_gadget_del(g);
767 e_config_save_queue();
768}
769
770static void
771_bryce_menu_post_cb(void *data, E_Menu *m)
772{
773 Bryce *b = data;
774 if (b->menu != m) return;
775 b->menu = NULL;
776}
777
778static void
779_bryce_menu_populate(Bryce *b, E_Menu *m, Evas_Object *g)
780{
781 E_Menu_Item *mi;
782 const char *s = NULL;
783
784 if (g) s = e_gadget_type_get(g);
785 if (s) e_menu_title_set(m, e_gadget_type_get(g));
786 else e_menu_title_set(m, _("Gadget Bar"));
787
788 if (g)
789 {
790 mi = e_menu_item_new(m);
791 e_menu_item_label_set(mi, _("Settings"));
792 e_util_menu_item_theme_icon_set(mi, "preferences-system");
793 e_menu_item_callback_set(mi, _bryce_gadget_settings_menu, g);
794
795 mi = e_menu_item_new(m);
796 e_menu_item_label_set(mi, _("Delete"));
797 e_util_menu_item_theme_icon_set(mi, "list-remove");
798 e_menu_item_callback_set(mi, _bryce_gadget_remove_menu, g);
799
800 e_gadget_menu_populate(g, m);
801
802 mi = e_menu_item_new(m);
803 e_menu_item_separator_set(mi, 1);
804 }
805
806 mi = e_menu_item_new(m);
807 e_menu_item_label_set(mi, _("Autosize"));
808 e_menu_item_check_set(mi, 1);
809 e_menu_item_toggle_set(mi, b->autosize);
810 e_menu_item_callback_set(mi, _bryce_autosize_menu, b);
811
812 mi = e_menu_item_new(m);
813 e_menu_item_label_set(mi, _("Autohide"));
814 e_menu_item_check_set(mi, 1);
815 e_menu_item_toggle_set(mi, b->autohide);
816 e_menu_item_callback_set(mi, _bryce_autohide_menu, b);
817
818 mi = e_menu_item_new(m);
819 e_menu_item_label_set(mi, _("Bar Settings"));
820 e_menu_item_callback_set(mi, _bryce_wizard_menu, b);
821
822 mi = e_menu_item_new(m);
823 e_menu_item_label_set(mi, _("Add Gadget"));
824 e_menu_item_callback_set(mi, _bryce_gadgets_menu, b);
825
826 mi = e_menu_item_new(m);
827 e_menu_item_label_set(mi, _("Delete Bar"));
828 e_util_menu_item_theme_icon_set(mi, "list-remove");
829 e_menu_item_callback_set(mi, _bryce_remove_menu, b);
830
831 if (b->menu)
832 {
833 e_menu_deactivate(b->menu);
834 e_object_del(E_OBJECT(b->menu));
835 }
836 b->menu = m;
837 e_menu_post_deactivate_callback_set(m, _bryce_menu_post_cb, b);
838}
839
840static void
841_bryce_owner_menu(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
842{
843 Bryce *b = data;
844 E_Menu_Item *mi = event_info;
845 E_Menu *subm;
846
847 e_menu_item_label_set(mi, _("Gadget Bar"));
848
849 subm = e_menu_new();
850 e_menu_hold_mode_set(subm, EINA_FALSE);
851 e_menu_item_submenu_set(mi, subm);
852 e_object_unref(E_OBJECT(subm));
853
854 _bryce_menu_populate(b, subm, NULL);
855}
856
857static void
858_bryce_gadget_popup(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
859{
860 _bryce_popup(data, event_info);
861}
862
863static void
864_bryce_gadget_locked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
865{
866 Bryce *b = data;
867
868 b->autohide_blocked++;
869 if (b->autohide)
870 _bryce_autohide_show(b);
871}
872
873static void
874_bryce_gadget_unlocked(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
875{
876 Bryce *b = data;
877
878 b->autohide_blocked--;
879 if (b->autohide && (!b->mouse_in))
880 _bryce_autohide_hide(b);
881}
882
883static void
884_bryce_site_anchor(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
885{
886 Bryce *b = data;
887
888 e_bryce_orient(b->bryce, e_gadget_site_orient_get(obj), e_gadget_site_anchor_get(obj));
889}
890
891static void
892_bryce_gadget_size_request(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
893{
894 Evas_Coord_Size *size = event_info;
895 Bryce *b = data;
896
897 edje_object_part_geometry_get(elm_layout_edje_get(b->layout), "e.swallow.content", NULL, NULL, &size->w, &size->h);
898}
899
900static void
901_bryce_context(Evas_Object *site, Evas_Object *g, unsigned int timestamp)
902{
903 Bryce *b = evas_object_data_get(site, "__bryce");
904 if (b)
905 {
906 b->last_timestamp = timestamp;
907 _bryce_menu(b, g);
908 }
909}
910
911static void
912_bryce_context_cancel(Evas_Object *site, Evas_Object *g EINA_UNUSED, unsigned int timestamp)
913{
914 Bryce *b = evas_object_data_get(site, "__bryce");
915 if (b)
916 {
917 b->last_timestamp = timestamp;
918 if (b->menu)
919 {
920 e_menu_deactivate(b->menu);
921 e_object_del(E_OBJECT(b->menu));
922 b->menu = NULL;
923 }
924 }
925}
926
927static void
928_bryce_orient(Bryce *b)
929{
930 char buf[1024];
931
932 evas_object_del(b->site);
933
934 snprintf(buf, sizeof(buf), "__bryce%s", b->name);
935 b->site = e_gadget_site_add(b->orient, buf);
936 E_EXPAND(b->site);
937 E_FILL(b->site);
938 evas_object_data_set(b->site, "__bryce", b);
939 elm_object_content_set(b->scroller, b->site);
940 e_gadget_site_owner_setup(b->site, b->anchor, _bryce_style, _bryce_context, _bryce_context_cancel);
941 if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
942 {
943 elm_layout_signal_emit(b->layout, "e,state,orient,horizontal", "e");
944 elm_layout_signal_emit(b->scroller, "e,state,orient,horizontal", "e");
945 elm_scroller_policy_set(b->scroller, ELM_SCROLLER_POLICY_AUTO, ELM_SCROLLER_POLICY_OFF);
946 }
947 else
948 {
949 elm_layout_signal_emit(b->layout, "e,state,orient,vertical", "e");
950 elm_layout_signal_emit(b->scroller, "e,state,orient,vertical", "e");
951 elm_scroller_policy_set(b->scroller, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_AUTO);
952 }
953 evas_object_event_callback_add(b->site, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _bryce_site_hints, b);
954 evas_object_smart_callback_add(b->site, "gadget_site_anchor", _bryce_site_anchor, b);
955 evas_object_smart_callback_add(b->site, "gadget_site_style_menu", _bryce_style_menu, b);
956 evas_object_smart_callback_add(b->site, "gadget_site_owner_menu", _bryce_owner_menu, b);
957 evas_object_smart_callback_add(b->site, "gadget_site_popup", _bryce_gadget_popup, b);
958 evas_object_smart_callback_add(b->site, "gadget_site_locked", _bryce_gadget_locked, b);
959 evas_object_smart_callback_add(b->site, "gadget_site_unlocked", _bryce_gadget_unlocked, b);
960 evas_object_smart_callback_add(b->site, "gadget_site_parent_size_request", _bryce_gadget_size_request, b);
961}
962
963static void
964_bryce_style_apply(Bryce *b)
965{
966 char buf[1024];
967 Eina_Bool noshadow;
968
969 snprintf(buf, sizeof(buf), "e/bryce/%s/base", b->style ?: "default");
970 e_theme_edje_object_set(b->layout, NULL, buf);
971 noshadow = b->noshadow;
972 b->noshadow = !!elm_layout_data_get(b->layout, "noshadow");
973 if (b->bryce && (noshadow != b->noshadow))
974 e_comp_object_util_type_set(b->bryce, _bryce_shadow_type(b));
975}
976
977static void
978_bryce_create(Bryce *b, Evas_Object *parent)
979{
980 Evas_Object *ly, *bryce, *scr;
981
982 b->e_obj_inherit = E_OBJECT_ALLOC(E_Object, E_BRYCE_TYPE, _bryce_object_free);
983 b->events = evas_object_rectangle_add(e_comp->evas);
984 evas_object_repeat_events_set(b->events, EINA_TRUE);
985 evas_object_color_set(b->events, 0, 0, 0, 0);
986 evas_object_name_set(b->events, "b->events");
987 evas_object_show(b->events);
988 e_object_data_set(b->e_obj_inherit, b);
989 b->layout = ly = elm_layout_add(parent);
990 _bryce_style_apply(b);
991
992 b->scroller = scr = elm_scroller_add(ly);
993 elm_scroller_bounce_set(scr, 0, 0);
994 elm_object_style_set(scr, "bryce");
995 _bryce_orient(b);
996 elm_object_part_content_set(ly, "e.swallow.content", scr);
997 evas_object_show(ly);
998 b->bryce = bryce = e_comp_object_util_add(ly, _bryce_shadow_type(b));
999// evas_object_repeat_events_set(evas_object_smart_parent_get(ly), 1);
1000 evas_object_smart_member_add(b->events, bryce);
1001 evas_object_raise(b->events);
1002 evas_object_data_set(bryce, "comp_skip", (void*)1);
1003 evas_object_layer_set(bryce, b->layer);
1004 evas_object_lower(bryce);
1005
1006 b->parent = parent;
1007 {
1008 const char *str;
1009
1010 str = elm_layout_data_get(ly, "hidden_state_size");
1011 if (str && str[0])
1012 b->autohide_size = strtol(str, NULL, 10);
1013 }
1014 evas_object_data_set(bryce, "__bryce", b);
1015 evas_object_event_callback_add(bryce, EVAS_CALLBACK_DEL, _bryce_del, b);
1016 evas_object_event_callback_add(bryce, EVAS_CALLBACK_RESTACK, _bryce_restack, b);
1017 evas_object_event_callback_add(bryce, EVAS_CALLBACK_MOVE, _bryce_moveresize, b);
1018 evas_object_event_callback_add(bryce, EVAS_CALLBACK_RESIZE, _bryce_moveresize, b);
1019 evas_object_event_callback_add(b->events, EVAS_CALLBACK_MOUSE_WHEEL, _bryce_mouse_wheel, b);
1020
1021 _bryce_zone_setup(b);
1022 _bryce_autohide_setup(b);
1023 _bryce_autosize(b);
1024}
1025
1026static Eina_Bool
1027_bryce_act_resize(E_Object *obj, const char *params, E_Binding_Event_Wheel *ev)
1028{
1029 Bryce *b;
1030 int size, step = 4;
1031 char buf[64];
1032
1033 if (obj->type != E_BRYCE_TYPE) return EINA_FALSE;
1034 if (params && params[0])
1035 {
1036 step = strtol(params, NULL, 10);
1037 step = MAX(step, 4);
1038 }
1039 b = e_object_data_get(obj);
1040 size = b->size;
1041 if (ev->z < 0)//up
1042 b->size += step;
1043 else
1044 b->size -= step;
1045 b->size = E_CLAMP(b->size, 20, 256);
1046 if (dblequal(e_scale, 1.0))
1047 snprintf(buf, sizeof(buf), "%dpx", b->size);
1048 else
1049 snprintf(buf, sizeof(buf), "%dpx (%ldpx scaled)", b->size, lround(b->size * e_scale));
1050 elm_object_part_text_set(b->layout, "e.text", buf);
1051 elm_object_signal_emit(b->layout, "e,action,resize", "e");
1052 e_config_save_queue();
1053 if (size == b->size) return EINA_TRUE;
1054 b->size_changed = 1;
1055 if (!b->calc_job)
1056 b->calc_job = ecore_job_add((Ecore_Cb)_bryce_autosize, b);
1057 return EINA_TRUE;
1058}
1059
1060static void
1061_bryce_menu(Bryce *b, Evas_Object *g)
1062{
1063 E_Menu *m;
1064 int x = 0, y = 0, w = 1, h = 1;
1065
1066 m = e_menu_new();
1067 e_menu_hold_mode_set(m, EINA_FALSE);
1068 _bryce_menu_populate(b, m, g);
1069 if (g)
1070 evas_object_geometry_get(g, &x, &y, &w, &h);
1071 else
1072 evas_pointer_canvas_xy_get(e_comp->evas, &x, &y);
1073 e_menu_activate_mouse(m, e_zone_current_get(), x, y, w, h,
1074 E_MENU_POP_DIRECTION_AUTO, b->last_timestamp);
1075 _bryce_popup(b, m->comp_object);
1076}
1077
1078static Eina_Bool
1079_bryce_zone_useful_geometry_changed(void *d EINA_UNUSED, int t EINA_UNUSED, E_Event_Zone_Move_Resize *ev)
1080{
1081 Eina_List *l;
1082 Bryce *b;
1083
1084 EINA_LIST_FOREACH(bryces->bryces, l, b)
1085 {
1086 if (b->bryce && (b->zone == ev->zone->num) &&
1087 (b->orient == E_GADGET_SITE_ORIENT_VERTICAL))
1088 _bryce_autosize(b);
1089 }
1090 return ECORE_CALLBACK_RENEW;
1091}
1092
1093static void
1094_bryce_comp_resize(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1095{
1096 Eina_List *l;
1097 Bryce *b;
1098
1099 EINA_LIST_FOREACH(bryces->bryces, l, b)
1100 {
1101 if (e_comp_zone_number_get(b->zone))
1102 {
1103 if (b->bryce) continue;
1104 _bryce_create(b, e_comp->elm);
1105 evas_object_show(b->bryce);
1106 }
1107 }
1108}
1109
1110E_API Evas_Object *
1111e_bryce_add(Evas_Object *parent, const char *name, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an)
1112{
1113 Bryce *b;
1114 const char *z;
1115
1116 b = E_NEW(Bryce, 1);
1117 b->size = 48;
1118 b->name = eina_stringshare_add(name);
1119 z = strrchr(name, '_');
1120 b->zone = strtoul(z + 1, NULL, 10);
1121 b->anchor = an;
1122 b->orient = orient;
1123 b->layer = DEFAULT_LAYER;
1124 b->version = bryce_version;
1125 _bryce_create(b, parent);
1126 bryces->bryces = eina_list_append(bryces->bryces, b);
1127 e_config_save_queue();
1128 return b->bryce;
1129}
1130
1131E_API void
1132e_bryce_orient(Evas_Object *bryce, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an)
1133{
1134 const char *loc = NULL, *loc2 = NULL;
1135 char buf[1024], buf2[1024];
1136
1137 BRYCE_GET(bryce);
1138 if ((b->orient == orient) && (b->anchor == an)) return;
1139 if (an & E_GADGET_SITE_ANCHOR_TOP)
1140 loc = "top";
1141 else if (an & E_GADGET_SITE_ANCHOR_BOTTOM)
1142 loc = "bottom";
1143 else if (an & E_GADGET_SITE_ANCHOR_LEFT)
1144 loc = "left";
1145 else if (an & E_GADGET_SITE_ANCHOR_RIGHT)
1146 loc = "right";
1147 if (an & E_GADGET_SITE_ANCHOR_RIGHT)
1148 loc2 = "right";
1149 else if (an & E_GADGET_SITE_ANCHOR_LEFT)
1150 loc2 = "left";
1151 else if (an & E_GADGET_SITE_ANCHOR_TOP)
1152 loc2 = "top";
1153 else if (an & E_GADGET_SITE_ANCHOR_BOTTOM)
1154 loc2 = "bottom";
1155
1156 snprintf(buf, sizeof(buf), "__bryce%s", b->name);
1157 snprintf(buf2, sizeof(buf2), "__brycebryce_%s_%s_%d", loc, loc2, b->zone);
1158 e_gadget_site_rename(buf, buf2);
1159 b->orient = orient;
1160 b->anchor = an;
1161 snprintf(buf2, sizeof(buf2), "bryce_%s_%s_%d", loc, loc2, b->zone);
1162 eina_stringshare_replace(&b->name, buf2);
1163 _bryce_orient(b);
1164 _bryce_autosize(b);
1165}
1166
1167E_API Evas_Object *
1168e_bryce_site_get(Evas_Object *bryce)
1169{
1170 BRYCE_GET(bryce);
1171
1172 return b->site;
1173}
1174
1175E_API Eina_Bool
1176e_bryce_autosize_get(Evas_Object *bryce)
1177{
1178 BRYCE_GET(bryce);
1179 return b->autosize;
1180}
1181
1182E_API void
1183e_bryce_autosize_set(Evas_Object *bryce, Eina_Bool set)
1184{
1185 BRYCE_GET(bryce);
1186 set = !!set;
1187
1188 if (b->autosize == set) return;
1189 b->autosize = set;
1190 if (set)
1191 {
1192 while (b->spacers)
1193 e_gadget_del(eina_list_data_get(b->spacers));
1194 }
1195 e_config_save_queue();
1196 _bryce_autosize(b);
1197}
1198
1199E_API Eina_Bool
1200e_bryce_autohide_get(Evas_Object *bryce)
1201{
1202 BRYCE_GET(bryce);
1203 return b->autohide;
1204}
1205
1206E_API void
1207e_bryce_autohide_set(Evas_Object *bryce, Eina_Bool set)
1208{
1209 BRYCE_GET(bryce);
1210 set = !!set;
1211
1212 if (b->autohide == set) return;
1213 b->autohide = set;
1214
1215 if (set)
1216 _bryce_autohide_setup(b);
1217 else
1218 {
1219 E_FREE_FUNC(b->autohide_event, evas_object_del);
1220 evas_object_event_callback_del_full(bryce, EVAS_CALLBACK_MOVE, _bryce_autohide_moveresize, b);
1221 evas_object_event_callback_del_full(bryce, EVAS_CALLBACK_RESIZE, _bryce_autohide_moveresize, b);
1222 if (!b->hidden) return;
1223 e_efx_move(b->bryce, E_EFX_EFFECT_SPEED_LINEAR, E_EFX_POINT(b->x, b->y), 0.5, _bryce_autohide_end, b);
1224 b->animating = 1;
1225 b->hidden = 0;
1226 }
1227 e_config_save_queue();
1228}
1229
1230E_API Eina_List *
1231e_bryce_list(Evas_Object *parent)
1232{
1233 Eina_List *l, *ret = NULL;
1234 Bryce *b;
1235
1236 if (!parent) parent = e_comp->elm;
1237 EINA_LIST_FOREACH(bryces->bryces, l, b)
1238 {
1239 if (!b->bryce) continue;
1240 if (parent == b->parent)
1241 ret = eina_list_append(ret, b->bryce);
1242 }
1243 return ret;
1244}
1245
1246E_API Eina_Bool
1247e_bryce_exists(Evas_Object *parent, Evas_Object *bryce, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an)
1248{
1249 Eina_List *l;
1250 Bryce *b;
1251 int zone = -1;
1252
1253 if (!parent) parent = e_comp->elm;
1254 if (parent == e_comp->elm)
1255 {
1256 E_Shelf *es;
1257 E_Zone *z;
1258
1259 z = e_zone_current_get();
1260 zone = z->num;
1261 /* FIXME: remove shelf block once shelves are dead */
1262 l = e_shelf_list_all();
1263 EINA_LIST_FREE(l, es)
1264 {
1265 if (es->zone != z) continue;
1266 switch (es->cfg->orient)
1267 {
1268#define ORIENT_CHECK(ORIENT, ANCHOR1, ANCHOR2) \
1269 if ((orient == E_GADGET_SITE_ORIENT_##ORIENT) && \
1270 ((an == (E_GADGET_SITE_ANCHOR_##ANCHOR1)) || \
1271 ((an & E_GADGET_SITE_ANCHOR_##ANCHOR2) && (!es->cfg->fit_along)))) \
1272 return EINA_TRUE; \
1273 break
1274 default: break;
1275 case E_GADCON_ORIENT_LEFT:
1276 ORIENT_CHECK(VERTICAL, LEFT, LEFT);
1277 case E_GADCON_ORIENT_RIGHT:
1278 ORIENT_CHECK(VERTICAL, RIGHT, RIGHT);
1279 case E_GADCON_ORIENT_TOP:
1280 ORIENT_CHECK(HORIZONTAL, TOP, TOP);
1281 case E_GADCON_ORIENT_BOTTOM:
1282 ORIENT_CHECK(HORIZONTAL, BOTTOM, BOTTOM);
1283 case E_GADCON_ORIENT_CORNER_TL:
1284 ORIENT_CHECK(HORIZONTAL, TOP | E_GADGET_SITE_ANCHOR_LEFT, TOP);
1285 case E_GADCON_ORIENT_CORNER_TR:
1286 ORIENT_CHECK(HORIZONTAL, TOP | E_GADGET_SITE_ANCHOR_RIGHT, TOP);
1287 case E_GADCON_ORIENT_CORNER_BL:
1288 ORIENT_CHECK(HORIZONTAL, BOTTOM | E_GADGET_SITE_ANCHOR_LEFT, BOTTOM);
1289 case E_GADCON_ORIENT_CORNER_BR:
1290 ORIENT_CHECK(HORIZONTAL, BOTTOM | E_GADGET_SITE_ANCHOR_RIGHT, BOTTOM);
1291 case E_GADCON_ORIENT_CORNER_LT:
1292 ORIENT_CHECK(VERTICAL, LEFT | E_GADGET_SITE_ANCHOR_TOP, LEFT);
1293 case E_GADCON_ORIENT_CORNER_RT:
1294 ORIENT_CHECK(VERTICAL, RIGHT | E_GADGET_SITE_ANCHOR_TOP, RIGHT);
1295 case E_GADCON_ORIENT_CORNER_LB:
1296 ORIENT_CHECK(VERTICAL, LEFT | E_GADGET_SITE_ANCHOR_BOTTOM, LEFT);
1297 case E_GADCON_ORIENT_CORNER_RB:
1298 ORIENT_CHECK(VERTICAL, RIGHT | E_GADGET_SITE_ANCHOR_BOTTOM, RIGHT);
1299#undef ORIENT_CHECK
1300 }
1301 }
1302 /* end FIXME */
1303 }
1304 EINA_LIST_FOREACH(bryces->bryces, l, b)
1305 {
1306 if (!b->bryce) continue;
1307 if (b->bryce == bryce) return EINA_FALSE;
1308 if (parent != b->parent) continue;
1309 if (b->orient != orient) continue;
1310 if ((zone >= 0) && ((int)b->zone != zone)) continue;
1311 if ((b->anchor & an) == an) return EINA_TRUE;
1312 if (b->autosize) continue;
1313 if (b->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
1314 {
1315 if ((b->anchor & E_GADGET_SITE_ANCHOR_BOTTOM) && (an & E_GADGET_SITE_ANCHOR_BOTTOM))
1316 return EINA_TRUE;
1317 if ((b->anchor & E_GADGET_SITE_ANCHOR_TOP) && (an & E_GADGET_SITE_ANCHOR_TOP))
1318 return EINA_TRUE;
1319 }
1320 else
1321 {
1322 if ((b->anchor & E_GADGET_SITE_ANCHOR_LEFT) && (an & E_GADGET_SITE_ANCHOR_LEFT))
1323 return EINA_TRUE;
1324 if ((b->anchor & E_GADGET_SITE_ANCHOR_RIGHT) && (an & E_GADGET_SITE_ANCHOR_RIGHT))
1325 return EINA_TRUE;
1326 }
1327 }
1328 return EINA_FALSE;
1329}
1330
1331E_API void
1332e_bryce_style_set(Evas_Object *bryce, const char *style)
1333{
1334 BRYCE_GET(bryce);
1335
1336 eina_stringshare_replace(&b->style, style);
1337 _bryce_style_apply(b);
1338 e_config_save_queue();
1339 evas_object_smart_callback_call(b->site, "gadget_site_style", NULL);
1340}
1341
1342/* FIXME */
1343EINTERN void
1344e_bryce_save(void)
1345{
1346 e_config_domain_save("e_bryces", edd_bryces, bryces);
1347}
1348
1349static void
1350bryce_spacer_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
1351{
1352 Bryce *b = data;
1353
1354 b->spacers = eina_list_remove(b->spacers, obj);
1355}
1356
1357static Evas_Object *
1358bryce_spacer_create(Evas_Object *parent, int *id, E_Gadget_Site_Orient orient)
1359{
1360 Bryce *b;
1361 Eina_List *l;
1362 Evas_Object *r;
1363
1364 if (!orient) return NULL;
1365
1366 /* only allow on bryces */
1367 EINA_LIST_FOREACH(bryces->bryces, l, b)
1368 {
1369 if (b->editing || (parent == b->site)) break;
1370 }
1371 if (!b) return NULL;
1372 if (b->autosize) return NULL;
1373 r = evas_object_rectangle_add(e_comp->evas);
1374 evas_object_event_callback_add(r, EVAS_CALLBACK_DEL, bryce_spacer_del, b);
1375 b->spacers = eina_list_append(b->spacers, r);
1376 E_EXPAND(r);
1377 E_FILL(r);
1378 /* FIXME: this should be better for demo gadgets... */
1379 if (*id < 0)
1380 {
1381 evas_object_size_hint_aspect_set(r, EVAS_ASPECT_CONTROL_BOTH, 1, 1);
1382 evas_object_color_set(r, 255, 0, 0, 255);
1383 }
1384 else
1385 evas_object_color_set(r, 0, 0, 0, 0);
1386 return r;
1387}
1388
1389EINTERN void
1390e_bryce_init(void)
1391{
1392 resize_act = e_action_add("bryce_resize");
1393 e_action_predef_name_set(_("Bryces"), _("Resize Gadget Bar"), "bryce_resize", NULL, "syntax: step, example: 4", 1);
1394 resize_act->func.go_wheel = _bryce_act_resize;
1395
1396 edd_bryce = E_CONFIG_DD_NEW("Bryce", Bryce);
1397 E_CONFIG_VAL(edd_bryce, Bryce, name, STR);
1398 E_CONFIG_VAL(edd_bryce, Bryce, style, STR);
1399 E_CONFIG_VAL(edd_bryce, Bryce, zone, UINT);
1400 E_CONFIG_VAL(edd_bryce, Bryce, size, INT);
1401 E_CONFIG_VAL(edd_bryce, Bryce, layer, UINT);
1402 E_CONFIG_VAL(edd_bryce, Bryce, autosize, UCHAR);
1403 E_CONFIG_VAL(edd_bryce, Bryce, autohide, UCHAR);
1404 E_CONFIG_VAL(edd_bryce, Bryce, orient, UINT);
1405 E_CONFIG_VAL(edd_bryce, Bryce, anchor, UINT);
1406 E_CONFIG_VAL(edd_bryce, Bryce, version, UINT);
1407
1408 edd_bryces = E_CONFIG_DD_NEW("Bryces", Bryces);
1409 E_CONFIG_LIST(edd_bryces, Bryces, bryces, edd_bryce);
1410 bryces = e_config_domain_load("e_bryces", edd_bryces);
1411
1412 if (bryces)
1413 {
1414 Eina_List *l;
1415 Bryce *b;
1416
1417 EINA_LIST_FOREACH(bryces->bryces, l, b)
1418 {
1419 if (b->version < 2)
1420 {
1421 /* I broke this the first time by forgetting the __bryce prefix :(
1422 */
1423 _bryce_rename(b, b->zone);
1424 if (b->version < 1)
1425 {
1426 char buf[1024];
1427
1428 snprintf(buf, sizeof(buf), "%s_%u", b->name, b->zone);
1429 eina_stringshare_replace(&b->name, buf);
1430 }
1431 }
1432 b->version = bryce_version;
1433 if (!e_comp_zone_number_get(b->zone)) continue;
1434 b->layer = E_CLAMP(b->layer, E_LAYER_DESKTOP_TOP, E_LAYER_CLIENT_ABOVE);
1435 _bryce_create(b, e_comp->elm);
1436 evas_object_show(b->bryce);
1437 }
1438 }
1439 else
1440 bryces = E_NEW(Bryces, 1);
1441
1442 evas_object_event_callback_add(e_comp->canvas->resize_object, EVAS_CALLBACK_RESIZE, _bryce_comp_resize, NULL);
1443 E_LIST_HANDLER_APPEND(handlers, E_EVENT_ZONE_USEFUL_GEOMETRY_CHANGED, _bryce_zone_useful_geometry_changed, NULL);
1444 e_gadget_type_add("Spacer Bar", bryce_spacer_create, NULL);
1445}
1446
1447EINTERN void
1448e_bryce_shutdown(void)
1449{
1450 Bryce *b;
1451
1452 E_CONFIG_DD_FREE(edd_bryce);
1453 E_CONFIG_DD_FREE(edd_bryces);
1454 EINA_LIST_FREE(bryces->bryces, b)
1455 {
1456 E_Zone *zone;
1457 void *obs;
1458
1459 EINA_LIST_FREE(b->zone_obstacles, obs)
1460 {
1461 E_OBJECT_DEL_SET(obs, NULL);
1462 e_object_del(obs);
1463 }
1464 evas_object_event_callback_del(b->bryce, EVAS_CALLBACK_DEL, _bryce_del);
1465 EINA_LIST_FREE(b->popups, obs)
1466 evas_object_event_callback_del(obs, EVAS_CALLBACK_HIDE, _bryce_popup_hide);
1467 evas_object_hide(b->bryce);
1468 evas_object_del(b->bryce);
1469 evas_object_del(b->autohide_event);
1470 eina_stringshare_del(b->name);
1471 eina_stringshare_del(b->style);
1472 ecore_job_del(b->calc_job);
1473 ecore_timer_del(b->save_timer);
1474 ecore_timer_del(b->autohide_timer);
1475 zone = e_comp_zone_number_get(b->zone);
1476 if (zone)
1477 {
1478 evas_object_event_callback_del(zone->bg_clip_object, EVAS_CALLBACK_DEL, _bryce_zone_del);
1479 evas_object_event_callback_del(zone->bg_clip_object, EVAS_CALLBACK_MOVE, _bryce_zone_moveresize);
1480 evas_object_event_callback_del(zone->bg_clip_object, EVAS_CALLBACK_RESIZE, _bryce_zone_moveresize);
1481 }
1482 free(b->e_obj_inherit);
1483 free(b);
1484 }
1485 E_FREE_LIST(handlers, ecore_event_handler_del);
1486 E_FREE(bryces);
1487 e_gadget_type_del("Spacer Bar");
1488}
diff --git a/src/bin/e_bryce.h b/src/bin/e_bryce.h
deleted file mode 100644
index 3f575a2d8..000000000
--- a/src/bin/e_bryce.h
+++ /dev/null
@@ -1,22 +0,0 @@
1#ifndef E_TYPEDEFS
2#ifndef E_BRYCE_H
3# define E_BRYCE_H
4
5EINTERN void e_bryce_init(void);
6EINTERN void e_bryce_shutdown(void);
7
8E_API Evas_Object *e_bryce_add(Evas_Object *parent, const char *name, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an);
9E_API void e_bryce_orient(Evas_Object *bryce, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an);
10E_API Evas_Object *e_bryce_site_get(Evas_Object *bryce);
11E_API Eina_Bool e_bryce_autosize_get(Evas_Object *bryce);
12E_API void e_bryce_autosize_set(Evas_Object *bryce, Eina_Bool set);
13E_API Eina_Bool e_bryce_autohide_get(Evas_Object *bryce);
14E_API void e_bryce_autohide_set(Evas_Object *bryce, Eina_Bool set);
15E_API Eina_Bool e_bryce_exists(Evas_Object *parent, Evas_Object *bryce, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an);
16E_API Eina_List *e_bryce_list(Evas_Object *parent);
17E_API void e_bryce_style_set(Evas_Object *bryce, const char *style);
18
19E_API Evas_Object *e_bryce_editor_add(Evas_Object *parent, Evas_Object *bryce);
20E_API Evas_Object *e_bryce_edit(Evas_Object *bryce);
21#endif
22#endif
diff --git a/src/bin/e_bryce_editor.c b/src/bin/e_bryce_editor.c
deleted file mode 100644
index 63db0718a..000000000
--- a/src/bin/e_bryce_editor.c
+++ /dev/null
@@ -1,444 +0,0 @@
1#include "e.h"
2
3#define DEFAULT_AUTOSIZE EINA_TRUE
4#define DEFAULT_AUTOHIDE EINA_FALSE
5#define DEFAULT_LAYER E_LAYER_CLIENT_EDGE
6
7typedef struct Bryce_Info
8{
9 E_Gadget_Site_Anchor anchor;
10 E_Gadget_Site_Orient orient;
11 Eina_Stringshare *style;
12 Eina_Bool stack_under;
13 Eina_Bool autohide;
14 Eina_Bool autosize;
15} Bryce_Info;
16
17
18static void _editor_add_bottom(void *data, Evas_Object *obj, const char *sig, const char *src);
19static void _editor_add_top(void *data, Evas_Object *obj, const char *sig, const char *src);
20static void _editor_add_left(void *data, Evas_Object *obj, const char *sig, const char *src);
21static void _editor_add_right(void *data, Evas_Object *obj, const char *sig, const char *src);
22
23static void
24setup_exists(Evas_Object *bryce, Evas_Object *editor, Evas_Object *parent, E_Gadget_Site_Anchor an)
25{
26 if ((an != E_GADGET_SITE_ANCHOR_TOP) &&
27 e_bryce_exists(parent, bryce, E_GADGET_SITE_ORIENT_HORIZONTAL, E_GADGET_SITE_ANCHOR_BOTTOM | an))
28 elm_object_signal_emit(editor, "e,bryce,exists,bottom", "e");
29 if ((an != E_GADGET_SITE_ANCHOR_BOTTOM) &&
30 e_bryce_exists(parent, bryce, E_GADGET_SITE_ORIENT_HORIZONTAL, E_GADGET_SITE_ANCHOR_TOP | an))
31 elm_object_signal_emit(editor, "e,bryce,exists,top", "e");
32 if ((an != E_GADGET_SITE_ANCHOR_RIGHT) &&
33 e_bryce_exists(parent, bryce, E_GADGET_SITE_ORIENT_VERTICAL, E_GADGET_SITE_ANCHOR_LEFT | an))
34 elm_object_signal_emit(editor, "e,bryce,exists,left", "e");
35 if ((an != E_GADGET_SITE_ANCHOR_LEFT) &&
36 e_bryce_exists(parent, bryce, E_GADGET_SITE_ORIENT_VERTICAL, E_GADGET_SITE_ANCHOR_RIGHT | an))
37 elm_object_signal_emit(editor, "e,bryce,exists,right", "e");
38}
39
40static void
41_editor_bryce_add(Evas_Object *obj)
42{
43 Evas_Object *b, *site;
44 char buf[1024];
45 const char *loc = "", *loc2 = "";
46 Bryce_Info *bi;
47 E_Zone *zone;
48 E_Gadget_Site_Gravity gravity = E_GADGET_SITE_GRAVITY_CENTER;
49
50 bi = evas_object_data_get(obj, "__bryce_info");
51 b = evas_object_data_get(obj, "__bryce_editor_bryce");
52 if (bi->anchor & E_GADGET_SITE_ANCHOR_TOP)
53 loc = "top";
54 else if (bi->anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
55 loc = "bottom";
56 else if (bi->anchor & E_GADGET_SITE_ANCHOR_LEFT)
57 loc = "left";
58 else if (bi->anchor & E_GADGET_SITE_ANCHOR_RIGHT)
59 loc = "right";
60 if (bi->anchor & E_GADGET_SITE_ANCHOR_RIGHT)
61 loc2 = "right";
62 else if (bi->anchor & E_GADGET_SITE_ANCHOR_LEFT)
63 loc2 = "left";
64 else if (bi->anchor & E_GADGET_SITE_ANCHOR_TOP)
65 loc2 = "top";
66 else if (bi->anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
67 loc2 = "bottom";
68
69 zone = e_comp_object_util_zone_get(obj);
70 if (!zone) zone = e_zone_current_get();
71 snprintf(buf, sizeof(buf), "bryce_%s_%s_%d", loc, loc2, zone->num);
72 if (bi->orient == E_GADGET_SITE_ORIENT_HORIZONTAL)
73 {
74 if (bi->anchor & E_GADGET_SITE_ANCHOR_LEFT)
75 gravity = E_GADGET_SITE_GRAVITY_LEFT;
76 else if (bi->anchor & E_GADGET_SITE_ANCHOR_RIGHT)
77 gravity = E_GADGET_SITE_GRAVITY_RIGHT;
78 }
79 else
80 {
81 if (bi->anchor & E_GADGET_SITE_ANCHOR_TOP)
82 gravity = E_GADGET_SITE_GRAVITY_TOP;
83 else if (bi->anchor & E_GADGET_SITE_ANCHOR_BOTTOM)
84 gravity = E_GADGET_SITE_GRAVITY_BOTTOM;
85 }
86 if (b)
87 {
88 e_bryce_orient(b, bi->orient, bi->anchor);
89 site = e_bryce_site_get(b);
90 }
91 else
92 {
93 b = e_bryce_add(e_comp->elm, buf, bi->orient, bi->anchor);
94 site = e_bryce_site_get(b);
95
96 e_gadget_site_gadget_add(site, "Start", 0);
97 e_gadget_site_gadget_add(site, "Digital Clock", 0);
98 e_gadget_site_gadget_add(site, "Wireless", 0);
99 }
100
101 e_gadget_site_gravity_set(site, gravity);
102 e_bryce_style_set(b, bi->style);
103 e_bryce_autohide_set(b, bi->autohide);
104 e_bryce_autosize_set(b, bi->autosize);
105 evas_object_layer_set(b, bi->stack_under ? E_LAYER_DESKTOP_TOP : E_LAYER_CLIENT_ABOVE);
106 evas_object_del(obj);
107}
108
109static void
110_editor_finish(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
111{
112 _editor_bryce_add(data);
113}
114
115static void
116_editor_autosize(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
117{
118 Bryce_Info *bi = data;
119
120 bi->autosize = !bi->autosize;
121}
122
123static void
124_editor_autohide(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
125{
126 Bryce_Info *bi = data;
127
128 bi->autohide = !bi->autohide;
129}
130
131static void
132_editor_stacking(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
133{
134 Bryce_Info *bi = data;
135
136 bi->stack_under = !bi->stack_under;
137}
138
139static void
140_editor_style_click(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
141{
142 const char *g;
143 char style[1024] = {0};
144 Bryce_Info *bi;
145 Evas_Object *ly, *box, *ck, *button, *bryce;
146
147 ly = elm_object_part_content_get(obj, "e.swallow.content");
148 elm_layout_file_get(ly, NULL, &g);
149 g += (sizeof("e/bryce/") - 1);
150 memcpy(style, g, MIN(sizeof(style) - 1, (size_t)(strchr(g, '/') - g)));
151
152 bryce = evas_object_data_get(data, "__bryce_editor_bryce");
153 bi = evas_object_data_get(data, "__bryce_info");
154 bi->style = eina_stringshare_add(style);
155 e_theme_edje_object_set(data, NULL, "e/bryce/editor/finish");
156 elm_object_part_text_set(data, "e.text", _("Finishing touches... (4/4)"));
157 box = elm_box_add(data);
158 elm_box_padding_set(box, 0, 20 * e_scale);
159
160 ck = elm_check_add(box);
161 elm_object_focus_allow_set(ck, 0);
162 E_ALIGN(ck, 0, 0.5);
163 evas_object_show(ck);
164 elm_object_text_set(ck, _("Automatically size based on contents"));
165 evas_object_smart_callback_add(ck, "changed", _editor_autosize, bi);
166 if (bryce)
167 {
168 bi->autosize = e_bryce_autosize_get(bryce);
169 elm_check_state_set(ck, bi->autosize);
170 }
171 elm_box_pack_end(box, ck);
172
173 ck = elm_check_add(box);
174 elm_object_focus_allow_set(ck, 0);
175 E_ALIGN(ck, 0, 0.5);
176 evas_object_show(ck);
177 elm_object_text_set(ck, _("Automatically hide"));
178 evas_object_smart_callback_add(ck, "changed", _editor_autohide, bi);
179 if (bryce)
180 {
181 bi->autohide = e_bryce_autohide_get(bryce);
182 elm_check_state_set(ck, bi->autohide);
183 }
184 elm_box_pack_end(box, ck);
185
186 ck = elm_check_add(box);
187 elm_object_focus_allow_set(ck, 0);
188 E_ALIGN(ck, 0, 0.5);
189 evas_object_show(ck);
190 elm_object_text_set(ck, _("Do not stack above windows"));
191 evas_object_smart_callback_add(ck, "changed", _editor_stacking, bi);
192 if (bryce)
193 {
194 bi->stack_under = evas_object_layer_get(bryce) == E_LAYER_DESKTOP_TOP;
195 elm_check_state_set(ck, bi->stack_under);
196 }
197 elm_box_pack_end(box, ck);
198
199 //ck = elm_check_add(box);
200 //elm_object_text_set(ck, _("Allow windows to overlap"));
201 //evas_object_smart_callback_add(ck, "changed", _editor_overlap, data);
202 //elm_box_pack_end(box, ck);
203
204 button = elm_button_add(data);
205 evas_object_show(button);
206 elm_object_text_set(button, _("Finish!"));
207 evas_object_smart_callback_add(button, "clicked", _editor_finish, data);
208 elm_box_pack_end(box, button);
209
210 elm_object_part_content_set(data, "e.swallow.content", box);
211}
212
213static void
214_editor_style(Evas_Object *obj)
215{
216 Eina_List *l;
217 Eina_Stringshare *style;
218 Evas_Object *box;
219 int w;
220
221 evas_object_geometry_get(obj, NULL, NULL, &w, NULL);
222 box = elm_box_add(obj);
223 e_theme_edje_object_set(obj, NULL, "e/bryce/editor/style");
224 elm_object_part_text_set(obj, "e.text", _("Choose style (3/4)"));
225 elm_box_homogeneous_set(box, 1);
226 elm_box_padding_set(box, 0, 20 * e_scale);
227 l = elm_theme_group_base_list(NULL, "e/bryce/");
228 EINA_LIST_FREE(l, style)
229 {
230 Evas_Object *ly, *bryce;
231 char buf[1024] = {0};
232 size_t len;
233
234 if (!eina_str_has_suffix(style, "/base"))
235 {
236 eina_stringshare_del(style);
237 continue;
238 }
239 ly = elm_layout_add(box);
240 e_theme_edje_object_set(ly, NULL, "e/bryce/editor/style/item");
241 bryce = edje_object_add(evas_object_evas_get(box));
242 elm_object_part_content_set(ly, "e.swallow.content", bryce);
243 len = strlen(style);
244 strncpy(buf, style + sizeof("e/bryce/") - 1,
245 MIN(sizeof(buf) - 1, len - (sizeof("e/bryce/") - 1) - (sizeof("/base") - 1)));
246 buf[0] = toupper(buf[0]);
247 elm_object_part_text_set(ly, "e.text", buf);
248 e_comp_object_util_del_list_append(ly, bryce);
249 e_theme_edje_object_set(bryce, NULL, style);
250 evas_object_size_hint_min_set(bryce, w * 2 / 3, 48 * e_scale);
251 evas_object_show(ly);
252 evas_object_event_callback_add(ly, EVAS_CALLBACK_MOUSE_DOWN, _editor_style_click, obj);
253 elm_box_pack_end(box, ly);
254 }
255 elm_object_part_content_set(obj, "e.swallow.content", box);
256}
257
258static void
259_editor_info_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
260{
261 Bryce_Info *bi = data;
262
263 eina_stringshare_del(bi->style);
264 free(bi);
265}
266
267static void
268_editor_add(Evas_Object *obj, E_Gadget_Site_Orient orient, E_Gadget_Site_Anchor an)
269{
270 char buf[1024];
271 Bryce_Info *bi;
272
273 bi = evas_object_data_get(obj, "__bryce_info");
274 if (bi)
275 {
276 bi->anchor |= an;
277 _editor_style(obj);
278 }
279 else
280 {
281 bi = E_NEW(Bryce_Info, 1);
282 bi->anchor = an;
283 bi->orient = orient;
284 evas_object_data_set(obj, "__bryce_info", bi);
285 evas_object_event_callback_add(obj, EVAS_CALLBACK_DEL, _editor_info_del, bi);
286 snprintf(buf, sizeof(buf), "e/bryce/editor/side/%s",
287 orient == E_GADGET_SITE_ORIENT_HORIZONTAL ? "horizontal" : "vertical");
288 e_theme_edje_object_set(obj, NULL, buf);
289 elm_object_part_text_set(obj, "e.text", _("Choose position (2/4)"));
290 if (an & E_GADGET_SITE_ANCHOR_BOTTOM)
291 elm_object_signal_emit(obj, "e,state,bottom", "e");
292 else if (an & E_GADGET_SITE_ANCHOR_RIGHT)
293 elm_object_signal_emit(obj, "e,state,right", "e");
294 setup_exists(evas_object_data_get(obj, "__bryce_editor_bryce"), obj,
295 evas_object_data_get(obj, "__bryce_editor_site"), an);
296 }
297}
298
299static void
300_editor_add_bottom(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
301{
302 _editor_add(obj, E_GADGET_SITE_ORIENT_HORIZONTAL, E_GADGET_SITE_ANCHOR_BOTTOM);
303}
304
305static void
306_editor_add_top(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
307{
308 _editor_add(obj, E_GADGET_SITE_ORIENT_HORIZONTAL, E_GADGET_SITE_ANCHOR_TOP);
309}
310
311static void
312_editor_add_left(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
313{
314 _editor_add(obj, E_GADGET_SITE_ORIENT_VERTICAL, E_GADGET_SITE_ANCHOR_LEFT);
315}
316
317static void
318_editor_add_center(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
319{
320 _editor_add(obj, E_GADGET_SITE_ORIENT_NONE, E_GADGET_SITE_ANCHOR_NONE);
321}
322
323static void
324_editor_add_right(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
325{
326 _editor_add(obj, E_GADGET_SITE_ORIENT_VERTICAL, E_GADGET_SITE_ANCHOR_RIGHT);
327}
328
329static void
330_editor_dismiss(void *data EINA_UNUSED, Evas_Object *obj, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
331{
332 evas_object_del(obj);
333}
334
335E_API Evas_Object *
336e_bryce_editor_add(Evas_Object *parent, Evas_Object *bryce)
337{
338 Evas_Object *editor;
339
340 editor = elm_layout_add(parent);
341 evas_object_data_set(editor, "__bryce_editor_site", parent);
342 evas_object_data_set(editor, "__bryce_editor_bryce", bryce);
343 e_theme_edje_object_set(editor, NULL, "e/bryce/editor/side");
344 elm_object_part_text_set(editor, "e.text", _("Choose screen edge (1/4)"));
345
346 setup_exists(bryce, editor, parent, 0);
347
348 elm_object_signal_callback_add(editor, "e,action,dismiss", "e", _editor_dismiss, editor);
349 elm_object_signal_callback_add(editor, "e,bryce,add,bottom", "e", _editor_add_bottom, editor);
350 elm_object_signal_callback_add(editor, "e,bryce,add,top", "e", _editor_add_top, editor);
351 elm_object_signal_callback_add(editor, "e,bryce,add,left", "e", _editor_add_left, editor);
352 elm_object_signal_callback_add(editor, "e,bryce,add,right", "e", _editor_add_right, editor);
353 elm_object_signal_callback_add(editor, "e,bryce,add,center", "e", _editor_add_center, editor);
354 return editor;
355}
356
357static Ecore_Event_Handler *handler;
358
359static void
360_bryce_edit_key_location(Evas_Object *obj, Ecore_Event_Key *ev)
361{
362 if (eina_streq(ev->key, "Up"))
363 _editor_add(obj, E_GADGET_SITE_ORIENT_HORIZONTAL, E_GADGET_SITE_ANCHOR_TOP);
364 else if (eina_streq(ev->key, "Down"))
365 _editor_add(obj, E_GADGET_SITE_ORIENT_HORIZONTAL, E_GADGET_SITE_ANCHOR_BOTTOM);
366 else if (eina_streq(ev->key, "Left"))
367 _editor_add(obj, E_GADGET_SITE_ORIENT_VERTICAL, E_GADGET_SITE_ANCHOR_LEFT);
368 else if (eina_streq(ev->key, "Right"))
369 _editor_add(obj, E_GADGET_SITE_ORIENT_VERTICAL, E_GADGET_SITE_ANCHOR_RIGHT);
370}
371
372static Eina_Bool
373_bryce_edit_key_handler(void *data, int t EINA_UNUSED, Ecore_Event_Key *ev)
374{
375 if (eina_streq(ev->key, "Escape"))
376 {
377 elm_layout_signal_emit(data, "e,action,dismiss", "e");
378 return ECORE_CALLBACK_RENEW;
379 }
380 if (evas_object_data_get(data, "__bryce_info"))
381 {
382 const char *grp;
383
384 edje_object_file_get(data, NULL, &grp);
385 if (!strncmp(grp, "e/bryce/editor/side/", sizeof("e/bryce/editor/side/") - 1))
386 _bryce_edit_key_location(data, ev);
387 else if (!strncmp(grp, "e/bryce/editor/style", sizeof("e/bryce/editor/style") - 1))
388 {
389 Evas_Object *bx, *o;
390 Eina_List *l;
391 int n;
392
393 bx = elm_object_part_content_get(data, "e.swallow.content");
394 l = elm_box_children_get(bx);
395 n = strtol(ev->key, NULL, 10);
396 if (n > 0)
397 {
398 o = eina_list_nth(l, n - 1);
399 if (o)
400 _editor_style_click(data, NULL, o, NULL);
401 }
402 eina_list_free(l);
403 }
404 else if (eina_streq(ev->key, "Return") || eina_streq(ev->key, "KP_Enter"))
405 _editor_bryce_add(data);
406 }
407 else
408 _bryce_edit_key_location(data, ev);
409 return ECORE_CALLBACK_RENEW;
410}
411
412static void
413_bryce_edit_end(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
414{
415 e_bindings_disabled_set(0);
416 e_comp_ungrab_input(1, 1);
417 evas_object_hide(data);
418 evas_object_del(data);
419 E_FREE_FUNC(handler, ecore_event_handler_del);
420}
421
422E_API Evas_Object *
423e_bryce_edit(Evas_Object *bryce)
424{
425 Evas_Object *editor, *comp_object;
426 E_Zone *zone;
427 int x, y, w, h;
428
429 zone = e_zone_current_get();
430 x = zone->x, y = zone->y, w = zone->w, h = zone->h;
431 e_bindings_disabled_set(1);
432 editor = e_bryce_editor_add(e_comp->elm, bryce);
433
434 evas_object_geometry_set(editor, x, y, w, h);
435 comp_object = e_comp_object_util_add(editor, E_COMP_OBJECT_TYPE_NONE);
436 evas_object_event_callback_add(editor, EVAS_CALLBACK_DEL, _bryce_edit_end, comp_object);
437 evas_object_layer_set(comp_object, E_LAYER_POPUP);
438 evas_object_show(comp_object);
439
440 e_comp_object_util_autoclose(comp_object, NULL, e_comp_object_util_autoclose_on_escape, NULL);
441 e_comp_grab_input(1, 1);
442 handler = ecore_event_handler_add(ECORE_EVENT_KEY_UP, (Ecore_Event_Handler_Cb)_bryce_edit_key_handler, editor);
443 return comp_object;
444}
diff --git a/src/bin/e_config.c b/src/bin/e_config.c
index 48abc692a..6c792d4f2 100644
--- a/src/bin/e_config.c
+++ b/src/bin/e_config.c
@@ -59,37 +59,6 @@ typedef struct _E_Color_Class
59 int r3, g3, b3, a3; 59 int r3, g3, b3, a3;
60} E_Color_Class; 60} E_Color_Class;
61 61
62static void
63_e_config_binding_mouse_add(E_Binding_Context ctxt, int button, E_Binding_Modifier mod, int any_mod, const char *action, const char *params)
64{
65 E_Config_Binding_Mouse *binding;
66
67 binding = calloc(1, sizeof(E_Config_Binding_Mouse));
68 binding->context = ctxt;
69 binding->button = button;
70 binding->modifiers = mod;
71 binding->any_mod = any_mod;
72 binding->action = eina_stringshare_add(action);
73 binding->params = eina_stringshare_add(params);
74 e_bindings->mouse_bindings = eina_list_append(e_bindings->mouse_bindings, binding);
75}
76
77static void
78_e_config_binding_wheel_add(E_Binding_Context ctxt, int direction, int z, E_Binding_Modifier mod, int any_mod, const char *action, const char *params)
79{
80 E_Config_Binding_Wheel *binding;
81
82 binding = calloc(1, sizeof(E_Config_Binding_Wheel));
83 binding->context = ctxt;
84 binding->direction = direction;
85 binding->z = z;
86 binding->modifiers = mod;
87 binding->any_mod = any_mod;
88 binding->action = eina_stringshare_add(action);
89 binding->params = eina_stringshare_add(params);
90 e_bindings->wheel_bindings = eina_list_append(e_bindings->wheel_bindings, binding);
91}
92
93static Eina_Bool 62static Eina_Bool
94_e_config_cb_efreet_cache_update(void *data EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED) 63_e_config_cb_efreet_cache_update(void *data EINA_UNUSED, int type EINA_UNUSED, void *ev EINA_UNUSED)
95{ 64{
@@ -1384,53 +1353,8 @@ e_config_load(void)
1384 } 1353 }
1385 CONFIG_VERSION_CHECK(20) 1354 CONFIG_VERSION_CHECK(20)
1386 { 1355 {
1387 Eina_List *l;
1388 E_Config_Binding_Mouse *ebm;
1389 E_Config_Module *em, *module;
1390
1391 CONFIG_VERSION_UPDATE_INFO(20); 1356 CONFIG_VERSION_UPDATE_INFO(20);
1392 1357 e_config_save_queue();
1393 EINA_LIST_FOREACH(e_bindings->mouse_bindings, l, ebm)
1394 {
1395 if (eina_streq(ebm->action, "window_move"))
1396 {
1397 _e_config_binding_mouse_add(E_BINDING_CONTEXT_ANY, ebm->button, ebm->modifiers,
1398 ebm->any_mod, "gadget_move", NULL);
1399 }
1400 else if (eina_streq(ebm->action, "window_resize"))
1401 {
1402 _e_config_binding_mouse_add(E_BINDING_CONTEXT_ANY, ebm->button, ebm->modifiers,
1403 ebm->any_mod, "gadget_resize", NULL);
1404 }
1405 else if (eina_streq(ebm->action, "window_menu"))
1406 {
1407 _e_config_binding_mouse_add(E_BINDING_CONTEXT_ANY, ebm->button, ebm->modifiers,
1408 ebm->any_mod, "gadget_menu", NULL);
1409 _e_config_binding_mouse_add(E_BINDING_CONTEXT_ANY, ebm->button, ebm->modifiers,
1410 ebm->any_mod, "bryce_menu", NULL);
1411 }
1412 }
1413 _e_config_binding_wheel_add(E_BINDING_CONTEXT_ANY, 0, 1, E_BINDING_MODIFIER_CTRL, 0, "bryce_resize", NULL);
1414 _e_config_binding_wheel_add(E_BINDING_CONTEXT_ANY, 0, -1, E_BINDING_MODIFIER_CTRL, 0, "bryce_resize", NULL);
1415
1416 EINA_LIST_FOREACH(e_config->modules, l, em)
1417 {
1418 if (!em->enabled) continue;
1419 if (eina_streq(em->name, "connman"))
1420 {
1421 module = E_NEW(E_Config_Module, 1);
1422 module->name = eina_stringshare_add("wireless");
1423 module->enabled = 1;
1424 e_config->modules = eina_list_append(e_config->modules, module);
1425 }
1426 else if (eina_streq(em->name, "clock"))
1427 {
1428 module = E_NEW(E_Config_Module, 1);
1429 module->name = eina_stringshare_add("time");
1430 module->enabled = 1;
1431 e_config->modules = eina_list_append(e_config->modules, module);
1432 }
1433 }
1434 } 1358 }
1435 1359
1436 CONFIG_VERSION_CHECK(21) 1360 CONFIG_VERSION_CHECK(21)
@@ -1558,23 +1482,7 @@ e_config_load(void)
1558 } 1482 }
1559 CONFIG_VERSION_CHECK(28) 1483 CONFIG_VERSION_CHECK(28)
1560 { 1484 {
1561 Eina_List *l, *ll;
1562 E_Config_Binding_Mouse *ebm;
1563
1564 CONFIG_VERSION_UPDATE_INFO(28); 1485 CONFIG_VERSION_UPDATE_INFO(28);
1565 EINA_LIST_FOREACH_SAFE(e_bindings->mouse_bindings, l, ll, ebm)
1566 {
1567 if ((eina_streq(ebm->action, "gadget_menu")) ||
1568 (eina_streq(ebm->action, "bryce_menu")))
1569 {
1570 e_bindings->mouse_bindings =
1571 eina_list_remove_list
1572 (e_bindings->mouse_bindings, l);
1573 eina_stringshare_del(ebm->action);
1574 eina_stringshare_del(ebm->params);
1575 free(ebm);
1576 }
1577 }
1578 e_config_save_queue(); 1486 e_config_save_queue();
1579 } 1487 }
1580 CONFIG_VERSION_CHECK(29) 1488 CONFIG_VERSION_CHECK(29)
@@ -2423,16 +2331,11 @@ e_config_bindings_free(E_Config_Bindings *ecb)
2423static void 2331static void
2424_e_config_save_cb(void *data EINA_UNUSED) 2332_e_config_save_cb(void *data EINA_UNUSED)
2425{ 2333{
2426 EINTERN void e_gadget_save(void);
2427 EINTERN void e_bryce_save(void);
2428
2429 e_config_profile_save(); 2334 e_config_profile_save();
2430 e_module_save_all(); 2335 e_module_save_all();
2431 elm_config_save(); 2336 elm_config_save();
2432 e_config_domain_save("e", _e_config_edd, e_config); 2337 e_config_domain_save("e", _e_config_edd, e_config);
2433 e_config_domain_save("e_bindings", _e_config_binding_edd, e_bindings); 2338 e_config_domain_save("e_bindings", _e_config_binding_edd, e_bindings);
2434 e_gadget_save();
2435 e_bryce_save();
2436 _e_config_save_defer = NULL; 2339 _e_config_save_defer = NULL;
2437} 2340}
2438 2341
diff --git a/src/bin/e_gadget.c b/src/bin/e_gadget.c
deleted file mode 100644
index de6d89cba..000000000
--- a/src/bin/e_gadget.c
+++ /dev/null
@@ -1,3535 +0,0 @@
1#include "e.h"
2
3
4#ifdef HAVE_WAYLAND
5EINTERN void e_gadget_runner_init(void);
6EINTERN void e_gadget_runner_shutdown(void);
7EINTERN void e_gadget_runner_save(void);
8#endif
9
10#define SNAP_DISTANCE 5
11#define E_GADGET_TYPE 0xE31337
12
13#define IS_HORIZ(orient) \
14 ((orient) == E_GADGET_SITE_ORIENT_HORIZONTAL)
15
16#define IS_VERT(orient) \
17 ((orient) == E_GADGET_SITE_ORIENT_VERTICAL)
18
19#define ZGS_GET(obj) \
20 E_Gadget_Site *zgs; \
21 zgs = evas_object_data_get((obj), "__e_gadget_site"); \
22 if (!zgs) abort()
23
24typedef struct E_Gadget_Config E_Gadget_Config;
25
26typedef struct E_Gadget_Site
27{
28 Eina_Stringshare *name;
29 Eina_Bool autoadd;
30 E_Gadget_Site_Gravity gravity;
31 E_Gadget_Site_Orient orient;
32 E_Gadget_Site_Anchor anchor;
33 Eina_List *gadgets;
34 Eina_Inlist *gadget_list;
35
36 Eina_Bool longpressed : 1;
37 Eina_Bool dragged : 1;
38 Evas_Coord down_1_x, down_1_y, down_3_x, down_3_y;
39 Ecore_Timer *down_timer;
40
41 Evas_Object *layout;
42 Evas_Object *events;
43 E_Gadget_Style_Cb style_cb;
44 E_Gadget_Context_Cb context_cb;
45 E_Gadget_Context_Cb context_cancel_cb;
46 int cur_size;
47 Ecore_Job *calc_job;
48
49 E_Gadget_Config *action;
50 Ecore_Event_Handler *move_handler;
51 Ecore_Event_Handler *mouse_up_handler;
52
53 Evas_Object *editor;
54} E_Gadget_Site;
55
56
57struct E_Gadget_Config
58{
59 EINA_INLIST;
60 int id;
61 struct
62 {
63 Eina_Stringshare *domain;
64 Eina_Stringshare *type;
65 } external;
66 int zone;
67 Eina_Stringshare *type;
68 E_Object *e_obj_inherit;
69 Evas_Object *display;
70 Evas_Object *gadget;
71 struct
72 {
73 Evas_Object *obj;
74 int minw, minh;
75 Eina_Stringshare *name;
76 } style;
77 E_Gadget_Configure_Cb configure;
78 Evas_Object *cfg_object;
79 E_Gadget_Menu_Populate_Cb populate;
80 Eina_List *popups;
81 E_Gadget_Site *site;
82 E_Menu *menu;
83
84 struct
85 {
86 Evas_Object *popup;
87 Evas_Smart_Cb allow;
88 Evas_Smart_Cb deny;
89 void *data;
90 } allow_deny;
91
92 Eina_Hash *drop_handlers;
93
94 double x, y; //fixed % positioning
95 double w, h; //fixed % sizing
96 Evas_Point offset; //offset from mouse down
97 Evas_Point down; //coords from mouse down
98 E_Gadget_Config *orig; //gadget is a copy of the original gadget during a move
99 E_Gadget_Site_Anchor resizing;
100 Eina_Bool moving E_BITFIELD;
101 Eina_Bool display_del E_BITFIELD; //deleted using ->display
102};
103
104typedef struct E_Gadget_Sites
105{
106 Eina_List *sites;
107} E_Gadget_Sites;
108
109typedef struct E_Gadget_External_Type
110{
111 E_Gadget_External_Create_Cb cb;
112 E_Gadget_External_Wizard_Cb wizard;
113 E_Gadget_External_Name_Cb name;
114} E_Gadget_External_Type;
115
116typedef struct E_Gadget_Type
117{
118 E_Gadget_Create_Cb cb;
119 E_Gadget_Wizard_Cb wizard;
120} E_Gadget_Type;
121
122typedef struct Gadget_Item
123{
124 Evas_Object *box;
125 Evas_Object *editor;
126 Evas_Object *gadget;
127 Evas_Object *site;
128 Elm_Object_Item *it;
129} Gadget_Item;
130
131#define DESKLOCK_DEMO_LAYER (E_LAYER_CLIENT_POPUP - 100)
132
133static Eina_List *desktop_handlers;
134static Evas_Object *desktop_rect;
135static Evas_Object *desktop_editor;
136static Eina_Bool added;
137
138static Evas_Object *pointer_site;
139static Eina_List *pointer_site_handlers;
140
141static Eina_Hash *gadget_external_domains;
142static Eina_Hash *gadget_types;
143static E_Gadget_Sites *sites;
144static Eina_List *handlers;
145
146static Evas_Object *comp_site;
147
148static E_Action *move_act;
149static E_Action *resize_act;
150static E_Action *configure_act;
151
152static E_Config_DD *edd_sites;
153static E_Config_DD *edd_site;
154static E_Config_DD *edd_gadget;
155
156static void _gadget_object_finalize(E_Gadget_Config *zgc);
157static Eina_Bool _gadget_object_create(E_Gadget_Config *zgc);
158static void _editor_pointer_site_init(E_Gadget_Site_Orient orient, Evas_Object *site, Evas_Object *editor, Eina_Bool );
159static void _gadget_drop_handler_moveresize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED);
160static void _edit_site_del(void *data, Evas *e, Evas_Object *obj, void *event_info);
161
162static void
163_site_recalc_job_cb(E_Gadget_Site *zgs)
164{
165 zgs->calc_job = NULL;
166 evas_object_smart_need_recalculate_set(zgs->layout, 1);
167}
168
169static void
170_site_recalc_job(E_Gadget_Site *zgs)
171{
172 if (zgs->calc_job) ecore_job_del(zgs->calc_job);
173 zgs->calc_job = ecore_job_add((Ecore_Cb)_site_recalc_job_cb, zgs);
174}
175
176static E_Gadget_External_Type *
177_gadget_external_type_get(const char *domain, const char *type)
178{
179 Eina_Hash *h;
180 if (!gadget_external_domains) return NULL;
181 h = eina_hash_find(gadget_external_domains, domain);
182 if (!h) return NULL;
183 return eina_hash_find(h, type);
184}
185
186static Eina_Bool
187_editor_site_visible(void)
188{
189 Eina_List *l;
190 E_Gadget_Site *zgs;
191
192 if (desktop_editor) return evas_object_visible_get(desktop_editor);
193 EINA_LIST_FOREACH(sites->sites, l, zgs)
194 if (zgs->editor && evas_object_visible_get(zgs->editor)) return EINA_TRUE;
195 return EINA_FALSE;
196}
197
198static void
199_comp_site_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
200{
201 Eina_List *l;
202 E_Gadget_Config *zgc;
203
204 evas_object_resize(data, e_comp->w, e_comp->h);
205 ZGS_GET(comp_site);
206 EINA_LIST_FOREACH(zgs->gadgets, l, zgc)
207 {
208 if (!zgc->display)
209 _gadget_object_create(zgc);
210 else if (!e_comp_zone_number_get(zgc->zone))
211 evas_object_del(zgc->display);
212 }
213}
214
215static void
216_gadget_free(E_Gadget_Config *zgc)
217{
218 if (zgc->menu)
219 {
220 e_menu_deactivate(zgc->menu);
221 e_object_del(E_OBJECT(zgc->menu));
222 zgc->menu = NULL;
223 }
224 evas_object_del(zgc->display);
225 eina_stringshare_del(zgc->type);
226 eina_stringshare_del(zgc->external.type);
227 eina_stringshare_del(zgc->external.domain);
228 eina_stringshare_del(zgc->style.name);
229 free(zgc);
230}
231
232static E_Gadget_Config *
233_gadget_at_xy(E_Gadget_Site *zgs, int x, int y, E_Gadget_Config *exclude)
234{
235 Eina_List *l;
236 E_Gadget_Config *zgc, *saved = NULL;
237
238 EINA_LIST_FOREACH(zgs->gadgets, l, zgc)
239 {
240 int ox, oy, ow, oh;
241
242 if (!zgc->gadget) continue;
243
244 evas_object_geometry_get(zgc->display, &ox, &oy, &ow, &oh);
245 if (E_INSIDE(x, y, ox, oy, ow, oh))
246 {
247 if (zgc == exclude) saved = zgc;
248 else return zgc;
249 }
250 }
251 return saved;
252}
253
254static void
255_gravity_apply(E_Gadget_Site *zgs, E_Gadget_Site_Gravity gravity)
256{
257 double ax = 0.5, ay = 0.5;
258
259 switch (gravity)
260 {
261 case E_GADGET_SITE_GRAVITY_LEFT:
262 ax = 0;
263 break;
264 case E_GADGET_SITE_GRAVITY_RIGHT:
265 ax = 1;
266 break;
267 default: break;
268 }
269 switch (gravity)
270 {
271 case E_GADGET_SITE_GRAVITY_TOP:
272 ay = 0;
273 break;
274 case E_GADGET_SITE_GRAVITY_BOTTOM:
275 ay = 1;
276 break;
277 default: break;
278 }
279 elm_box_align_set(zgs->layout, ax, ay);
280 evas_object_smart_callback_call(zgs->layout, "gadget_site_gravity", NULL);
281}
282
283static void
284_gadget_reparent(E_Gadget_Site *zgs, E_Gadget_Config *zgc)
285{
286 Eina_Inlist *l = EINA_INLIST_GET(zgc);
287 E_Gadget_Config *z;
288
289 if (!zgs->orient)
290 {
291 evas_object_layer_set(zgc->display, evas_object_layer_get(zgs->layout));
292 evas_object_stack_below(zgc->display, zgs->events);
293 if (evas_object_visible_get(zgs->events))
294 evas_object_show(zgc->display);
295 return;
296 }
297 switch (zgs->gravity)
298 {
299 case E_GADGET_SITE_GRAVITY_NONE:
300 /* fake */
301 break;
302 case E_GADGET_SITE_GRAVITY_LEFT:
303 case E_GADGET_SITE_GRAVITY_TOP:
304 for (l = l->prev; l; l = l->prev)
305 {
306 z = EINA_INLIST_CONTAINER_GET(l, E_Gadget_Config);
307 if (!z->display) continue;
308 elm_box_pack_after(zgs->layout, zgc->display, z->display);
309 return;
310 }
311 elm_box_pack_end(zgs->layout, zgc->display);
312 break;
313 default:
314 for (l = l->next; l; l = l->next)
315 {
316 z = EINA_INLIST_CONTAINER_GET(l, E_Gadget_Config);
317 if (!z->display) continue;
318 elm_box_pack_before(zgs->layout, zgc->display, z->display);
319 return;
320 }
321 /* right aligned: pack on left */
322 elm_box_pack_start(zgs->layout, zgc->display);
323 }
324}
325
326static void
327_desktop_rect_obj_add(Evas_Object *obj)
328{
329 if (!desktop_rect) return;
330 evas_object_smart_member_add(obj, desktop_rect);
331 evas_object_propagate_events_set(obj, 0);
332 if (e_comp->autoclose.obj != obj) return;
333 evas_object_smart_member_add(e_comp->autoclose.rect, desktop_rect);
334 evas_object_propagate_events_set(e_comp->autoclose.rect, 0);
335}
336
337static void
338_gadget_popup_hide(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
339{
340 E_Gadget_Config *zgc = data;
341 if (desktop_editor) evas_object_show(desktop_editor);
342 zgc->popups = eina_list_remove(zgc->popups, event_info);
343}
344
345static void
346_gadget_popup(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
347{
348 E_Gadget_Config *zgc = data;
349 E_Gadget_Site *zgs = zgc->site;
350
351 if (event_info && elm_object_widget_check(event_info))
352 elm_object_tree_focus_allow_set(event_info, 0);
353 if (event_info) _desktop_rect_obj_add(event_info);
354 evas_object_smart_callback_call(zgs->layout, "gadget_site_popup", event_info);
355 if (!event_info) return;
356 evas_object_event_callback_add(event_info, EVAS_CALLBACK_HIDE, _gadget_popup_hide, zgc);
357 if (desktop_editor) evas_object_hide(desktop_editor);
358 if (eina_list_data_find(zgc->popups, event_info))
359 ERR("gadget_popup called multiple times for same popup");
360 zgc->popups = eina_list_append(zgc->popups, event_info);
361}
362
363static void
364_gadget_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
365{
366 E_Gadget_Config *zgc = data;
367
368 zgc->display_del = obj == zgc->display;
369 if (!e_object_is_del(zgc->e_obj_inherit))
370 e_object_del(zgc->e_obj_inherit);
371}
372
373static void
374_gadget_util_allow_deny_cleanup(E_Gadget_Config *zgc)
375{
376 zgc->allow_deny.allow = zgc->allow_deny.deny = NULL;
377 zgc->allow_deny.data = NULL;
378 evas_object_hide(zgc->allow_deny.popup);
379 E_FREE_FUNC(zgc->allow_deny.popup, evas_object_del);
380}
381
382static void
383_gadget_drop_handler_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
384{
385 E_Gadget_Config *zgc = data;
386
387 if (zgc->drop_handlers)//may be calling during object_free
388 eina_hash_del_by_key(zgc->drop_handlers, &obj);
389}
390
391static void
392_gadget_object_free(E_Object *eobj)
393{
394 E_Gadget_Config *zgc;
395 Evas_Object *g;
396
397 g = e_object_data_get(eobj);
398 zgc = evas_object_data_get(g, "__e_gadget");
399 evas_object_smart_callback_call(zgc->site->layout, "gadget_destroyed", zgc->gadget);
400 evas_object_event_callback_del_full(zgc->gadget, EVAS_CALLBACK_DEL, _gadget_del, zgc);
401 if (zgc->display_del || (zgc->gadget == zgc->display))
402 zgc->display = NULL;
403 else
404 {
405 evas_object_event_callback_del_full(zgc->display, EVAS_CALLBACK_DEL, _gadget_del, zgc);
406 E_FREE_FUNC(zgc->display, evas_object_del);
407 }
408 zgc->gadget = NULL;
409
410 if (zgc->drop_handlers)
411 {
412 Evas_Object **drop_object;
413 Eina_Iterator *it = eina_hash_iterator_key_new(zgc->drop_handlers);
414
415 EINA_ITERATOR_FOREACH(it, drop_object)
416 {
417 evas_object_event_callback_del(*drop_object, EVAS_CALLBACK_MOVE, _gadget_drop_handler_moveresize);
418 evas_object_event_callback_del(*drop_object, EVAS_CALLBACK_RESIZE, _gadget_drop_handler_moveresize);
419 evas_object_event_callback_del(*drop_object, EVAS_CALLBACK_DEL, _gadget_drop_handler_del);
420 }
421 eina_iterator_free(it);
422 }
423
424 E_FREE_FUNC(zgc->drop_handlers, eina_hash_free);
425 E_FREE_FUNC(zgc->gadget, evas_object_del);
426 E_FREE_FUNC(zgc->cfg_object, evas_object_del);
427 E_FREE_FUNC(zgc->style.obj, evas_object_del);
428 _gadget_util_allow_deny_cleanup(zgc);
429 E_FREE(zgc->e_obj_inherit);
430 zgc->configure = NULL;
431 zgc->display_del = zgc->moving = zgc->resizing = 0;
432 if (zgc->id == -1) _gadget_free(zgc);
433}
434
435static void
436_gadget_remove(E_Gadget_Config *zgc)
437{
438 int id = zgc->id;
439 evas_object_smart_callback_call(zgc->site->layout, "gadget_removed", zgc->gadget);
440 zgc->site->gadget_list = eina_inlist_remove(zgc->site->gadget_list, EINA_INLIST_GET(zgc));
441 zgc->site->gadgets = eina_list_remove(zgc->site->gadgets, zgc);
442 if (id >= 0)
443 {
444 _gadget_free(zgc);
445 e_config_save_queue();
446 }
447 else
448 evas_object_del(zgc->display);
449}
450
451static void
452_gadget_wizard_end(void *data, int id)
453{
454 E_Gadget_Config *zgc = data;
455
456 zgc->id = id;
457 evas_object_smart_callback_call(zgc->site->layout, "gadget_site_unlocked", NULL);
458 e_comp_ungrab_input(1, 1);
459 if (id > 0)
460 {
461 _gadget_object_finalize(zgc);
462 added = 0;
463 }
464 else
465 _gadget_remove(zgc);
466}
467
468static void
469_gadget_wizard_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
470{
471 E_Gadget_Config *zgc = data;
472
473 if (zgc->cfg_object == obj) zgc->cfg_object = NULL;
474 if (desktop_editor) evas_object_show(desktop_editor);
475}
476
477static void
478_gadget_object_hints(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
479{
480 E_Gadget_Config *zgc = data;
481 _site_recalc_job(zgc->site);
482}
483
484static Eina_Bool
485_gadget_object_create(E_Gadget_Config *zgc)
486{
487 E_Gadget_Type *t = NULL;
488 E_Gadget_External_Type *te = NULL;
489 Evas_Object *g;
490
491 if (zgc->external.domain)
492 {
493 te = _gadget_external_type_get(zgc->external.domain, zgc->external.type);
494 if (!te) return EINA_TRUE; //can't create yet
495 }
496 else
497 {
498 t = eina_hash_find(gadget_types, zgc->type);
499 if (!t) return EINA_TRUE; //can't create yet
500 }
501
502 if (!zgc->id)
503 {
504 if ((t && t->wizard) || (te && te->wizard))
505 {
506 if (t)
507 zgc->cfg_object = t->wizard(_gadget_wizard_end, zgc, zgc->site->layout);
508 else
509 zgc->cfg_object = te->wizard(_gadget_wizard_end, zgc, zgc->external.type, zgc->site->layout);
510 if (!zgc->cfg_object)
511 {
512 added = 1;
513 if (desktop_editor) evas_object_show(desktop_editor);
514 return EINA_FALSE;
515 }
516 e_comp_grab_input(1, 1);
517 evas_object_event_callback_add(zgc->cfg_object, EVAS_CALLBACK_DEL, _gadget_wizard_del, zgc);
518 _desktop_rect_obj_add(zgc->cfg_object);
519 evas_object_smart_callback_call(zgc->site->layout, "gadget_site_popup", zgc->cfg_object);
520 evas_object_smart_callback_call(zgc->site->layout, "gadget_site_locked", NULL);
521 return EINA_TRUE;
522 }
523 }
524 if (desktop_editor) evas_object_show(desktop_editor);
525 if ((zgc->zone >= 0) && (!e_comp_zone_number_get(zgc->zone))) return EINA_FALSE;
526 /* if id is < 0, gadget creates dummy config for demo use
527 * if id is 0, gadget creates new config and returns id
528 * otherwise, config of `id` is applied to created object
529 *
530 * a gadget should return NULL for any demo instance where it
531 * should not be shown
532 */
533 if (t)
534 g = t->cb(zgc->site->layout, &zgc->id, zgc->site->orient);
535 else
536 g = te->cb(zgc->site->layout, zgc->external.type, &zgc->id, zgc->site->orient);
537 if (zgc->id < 0)
538 {
539 if (!g) return EINA_FALSE;
540 }
541 EINA_SAFETY_ON_NULL_RETURN_VAL(g, EINA_FALSE);
542 added = 1;
543
544 zgc->e_obj_inherit = E_OBJECT_ALLOC(E_Object, E_GADGET_TYPE, _gadget_object_free);
545 e_object_data_set(zgc->e_obj_inherit, g);
546 zgc->gadget = zgc->display = g;
547 evas_object_event_callback_add(g, EVAS_CALLBACK_CHANGED_SIZE_HINTS, _gadget_object_hints, zgc);
548 evas_object_smart_callback_add(g, "gadget_popup", _gadget_popup, zgc);
549 evas_object_data_set(g, "__e_gadget", zgc);
550 if (zgc->site->style_cb)
551 zgc->site->style_cb(zgc->site->layout, zgc->style.name, g);
552
553 if (!zgc->site->orient)
554 evas_object_smart_need_recalculate_set(zgc->site->layout, 1);
555 evas_object_event_callback_priority_add(g, EVAS_CALLBACK_DEL, EVAS_CALLBACK_PRIORITY_AFTER, _gadget_del, zgc);
556 _gadget_reparent(zgc->site, zgc);
557 if (elm_object_widget_check(zgc->gadget))
558 elm_object_tree_focus_allow_set(zgc->gadget, 0);
559 evas_object_raise(zgc->site->events);
560
561 evas_object_smart_callback_call(zgc->site->layout, "gadget_created", g);
562 evas_object_show(zgc->display);
563 if (zgc->site->editor) _desktop_rect_obj_add(zgc->display);
564 return EINA_TRUE;
565}
566
567static void
568_gadget_object_finalize(E_Gadget_Config *zgc)
569{
570 zgc->moving = 0;
571 if (_gadget_object_create(zgc))
572 {
573 if (!zgc->display) return;
574 evas_object_smart_callback_call(zgc->site->layout, "gadget_added", zgc->gadget);
575 e_config_save_queue();
576 return;
577 }
578 zgc->site->gadgets = eina_list_remove(zgc->site->gadgets, zgc);
579 zgc->site->gadget_list = eina_inlist_remove(zgc->site->gadget_list, EINA_INLIST_GET(zgc));
580 eina_stringshare_del(zgc->type);
581 eina_stringshare_del(zgc->external.type);
582 eina_stringshare_del(zgc->external.domain);
583 free(zgc);
584}
585
586static void
587_site_gadget_aspect(E_Gadget_Config *zgc, Evas_Coord *ww, Evas_Coord *hh, int ax, int ay, Evas_Aspect_Control aspect)
588{
589 if (aspect && ax && ay)
590 {
591 switch (aspect)
592 {
593 case EVAS_ASPECT_CONTROL_HORIZONTAL:
594 *hh = (*ww * (double)ay / ax) + 0.99999999;
595 break;
596 case EVAS_ASPECT_CONTROL_VERTICAL:
597 *ww = (*hh * (double)ax / ay) + 0.99999999;
598 break;
599 default:
600 if (IS_HORIZ(zgc->site->orient))
601 *ww = (*hh * (double)ax / ay) + 0.99999999;
602 else if (IS_VERT(zgc->site->orient))
603 *hh = (*ww * (double)ay / ax) + 0.99999999;
604 else if (aspect)
605 {
606 double ar = ax / (double) ay;
607
608 if (ax == ay)
609 {
610 if (*ww > *hh)
611 *hh = *ww;
612 else
613 *ww = *hh;
614 }
615 else if (ar > 1.0)
616 *hh = (*ww * (double)ay / ax) + 0.99999999;
617 else
618 *ww = (*hh * (double)ax / ay) + 0.99999999;
619 }
620 }
621 }
622}
623
624static Eina_Bool
625_site_gadget_resize(Evas_Object *g, int w, int h, Evas_Coord *ww, Evas_Coord *hh, Evas_Coord *ow, Evas_Coord *oh)
626{
627 Evas_Coord mnw, mnh, mxw, mxh;
628 E_Gadget_Config *zgc;
629 Evas_Aspect_Control aspect;
630 int ax, ay;
631 double ex, ey;
632 Eina_Bool ret = EINA_FALSE;
633
634 zgc = evas_object_data_get(g, "__e_gadget");
635 w -= zgc->style.minw;
636 h -= zgc->style.minh;
637
638 evas_object_size_hint_min_get(g, &mnw, &mnh);
639 evas_object_size_hint_max_get(g, &mxw, &mxh);
640 evas_object_size_hint_aspect_get(g, &aspect, &ax, &ay);
641 evas_object_size_hint_weight_get(g, &ex, &ey);
642
643 if (IS_HORIZ(zgc->site->orient))
644 {
645 *ww = mnw, *hh = h;
646 if (!(*ww)) *ww = *hh;
647 if (dblequal(ex, EVAS_HINT_EXPAND) && (!aspect)) ret = EINA_TRUE;
648 }
649 else if (IS_VERT(zgc->site->orient))
650 {
651 *hh = mnh, *ww = w;
652 if (!(*hh)) *hh = *ww;
653 if (dblequal(ey, EVAS_HINT_EXPAND) && (!aspect)) ret = EINA_TRUE;
654 }
655 else
656 {
657 *ww = mnw, *hh = mnh;
658 if ((!(*ww)) || ((*ww) < w)) *ww = w;
659 if ((!(*hh)) || ((*hh) < h)) *hh = h;
660 }
661 _site_gadget_aspect(zgc, ww, hh, ax, ay, aspect);
662 *ww += zgc->style.minw;
663 *hh += zgc->style.minh;
664 *ow = *ww, *oh = *hh;
665 if ((!ax) && (!ay))
666 {
667 if ((mxw >= 0) && (mxw < *ow)) *ow = mxw;
668 if ((mxh >= 0) && (mxh < *oh)) *oh = mxh;
669 }
670 if (!zgc->site->orient)
671 {
672 if ((w < (*ow)) || (h < (*oh)))
673 {
674 if (evas_smart_objects_calculating_get(e_comp->evas))
675 _site_recalc_job(zgc->site);
676 else
677 evas_object_smart_need_recalculate_set(zgc->site->layout, 1);
678 }
679 }
680 //fprintf(stderr, "%s: %dx%d\n", zgc->type, *ow, *oh);
681 evas_object_resize(zgc->display, *ow, *oh);
682 return ret;
683}
684
685static void
686_site_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
687{
688 int x, y, w, h;
689 E_Gadget_Site *zgs = data;
690
691 evas_object_geometry_get(obj, &x, &y, &w, &h);
692 evas_object_geometry_set(zgs->events, x, y, w, h);
693 evas_object_raise(zgs->events);
694 if (!zgs->orient)
695 evas_object_smart_need_recalculate_set(zgs->layout, 1);
696}
697
698static void
699_site_layout_orient(Evas_Object *o, E_Gadget_Site *zgs)
700{
701 Evas_Coord x, y, w, h, xx, yy;
702 Eina_List *l;
703 double ax, ay;
704 E_Gadget_Config *zgc;
705 int mw, mh, sw, sh, rw, rh, bw, bh, prev_w = 0, prev_h = 0;
706 int groups = 0, avg;
707 Eina_Bool prev_ex = 0, after = 0;
708 struct Size
709 {
710 Evas_Coord_Size size;
711 Evas_Coord_Size clipped;
712 Evas_Coord_Size before;
713 Evas_Coord_Size after;
714 Eina_Bool expand;
715 Evas_Object *obj;
716 } *size, *psize = NULL;
717 Eina_List *expand = NULL, *gadgets = NULL;
718 Evas_Coord_Size parent_size;
719
720 evas_object_geometry_get(o, &x, &y, &w, &h);
721 if ((!w) && (!h)) return;
722 parent_size.w = parent_size.h = -1;
723 evas_object_smart_callback_call(elm_object_parent_widget_get(zgs->layout), "gadget_site_parent_size_request", &parent_size);
724 if ((parent_size.w < 0) || (parent_size.h < 0))
725 evas_object_geometry_get(elm_object_parent_widget_get(zgs->layout), NULL, NULL, &bw, &bh);
726 else
727 bw = parent_size.w, bh = parent_size.h;
728 rw = bw, rh = bh;
729 evas_object_size_hint_min_get(o, &mw, &mh);
730 evas_object_size_hint_min_get(zgs->layout, &sw, &sh);
731 evas_object_geometry_set(zgs->events, x, y, w, h);
732
733 evas_object_box_align_get(o, &ax, &ay);
734
735 xx = x;
736 yy = y;
737
738 EINA_LIST_FOREACH(zgs->gadgets, l, zgc)
739 {
740 int ww, hh, ow, oh;
741 Eina_Bool ex;
742
743 if (!zgc->display) continue;
744 ex = _site_gadget_resize(zgc->gadget, w, h, &ww, &hh, &ow, &oh);
745 if (ex && prev_ex)
746 {
747 /* multiple spacers */
748 evas_object_resize(zgc->display, 0, 0);
749 continue;
750 }
751 size = E_NEW(struct Size, 1);
752 size->size.w = ww;
753 size->size.h = hh;
754 size->clipped.w = ow;
755 size->clipped.h = oh;
756 size->expand = ex;
757 if (ex)
758 {
759 if (psize)
760 {
761 psize->after.w = prev_w, psize->after.h = prev_h;
762 groups++;
763 }
764 psize = size;
765 size->before.w = prev_w;
766 size->before.h = prev_h;
767 prev_w = prev_h = 0;
768 }
769 size->obj = zgc->display;
770 prev_w += ow;
771 prev_h += oh;
772 prev_ex = ex;
773 gadgets = eina_list_append(gadgets, size);
774 if (ex)
775 {
776 expand = eina_list_append(expand, size);
777 continue;
778 }
779 if (IS_HORIZ(zgs->orient))
780 rw = MAX(rw - ow, 0);
781 else if (IS_VERT(zgs->orient))
782 rh = MAX(rh - oh, 0);
783 }
784 if (expand)
785 {
786 size = eina_list_last_data_get(expand);
787 psize = eina_list_last_data_get(gadgets);
788 if (size != psize)
789 {
790 if ((!size->after.w) && (!size->after.h))
791 {
792 size->after.w = prev_w, size->after.h = prev_h;
793 groups++;
794 }
795 }
796 if (!groups) groups++;
797
798 size = eina_list_data_get(expand);
799 if (IS_HORIZ(zgs->orient))
800 {
801 after = !size->before.w;
802 avg = (bw - rw) / groups;
803 }
804 else
805 {
806 after = !size->before.h;
807 avg = (bh - rh) / groups;
808 }
809 }
810 EINA_LIST_FREE(expand, size)
811 {
812 if (IS_HORIZ(zgs->orient))
813 {
814 if (rw)
815 {
816 size->size.w = size->clipped.w = rw / eina_list_count(expand);
817 if (eina_list_count(expand) > 1)
818 {
819 int gw;
820 if (after)
821 gw = size->after.w;
822 else
823 gw = size->before.w;
824 if (gw > avg)
825 size->size.w = size->clipped.w -= (gw - avg);
826 else
827 size->size.w = size->clipped.w += abs(gw - avg);
828 size->size.w = size->clipped.w -= size->after.w / 2;
829 size->size.w = size->clipped.w = MAX(size->size.w, 0);
830 rw -= size->size.w;
831 }
832 }
833 else
834 size->size.w = size->clipped.w = 0;
835 }
836 else if (IS_VERT(zgs->orient))
837 {
838 if (rh)
839 {
840 size->size.h = size->clipped.h = rh / eina_list_count(expand);
841 if (eina_list_count(expand) > 1)
842 {
843 int gh;
844 if (after)
845 gh = size->after.h;
846 else
847 gh = size->before.h;
848 if (gh > avg)
849 size->size.h = size->clipped.h -= (gh - avg);
850 else
851 size->size.h = size->clipped.h += abs(gh - avg);
852 size->size.h = size->clipped.h -= size->after.h / 2;
853 size->size.h = size->clipped.h = MAX(size->size.h, 0);
854 rh -= size->size.h;
855 }
856 }
857 else
858 size->size.h = size->clipped.h = 0;
859 }
860 evas_object_resize(size->obj, size->clipped.w, size->clipped.h);
861 }
862
863 if (zgs->gravity % 2)//left/top
864 {
865 EINA_LIST_FREE(gadgets, size)
866 {
867 Evas_Coord gx = xx, gy = yy;
868
869 if (IS_HORIZ(zgs->orient))
870 gx += (Evas_Coord)(((double)(size->size.w - size->clipped.w)) * 0.5),
871 gy += (h / 2) - (size->clipped.h / 2);
872 else if (IS_VERT(zgs->orient))
873 gy += (Evas_Coord)(((double)(size->size.h - size->clipped.h)) * 0.5),
874 gx += (w / 2) - (size->clipped.w / 2);
875 evas_object_move(size->obj, gx, gy);
876 if (IS_HORIZ(zgs->orient))
877 xx += size->clipped.w;
878 else
879 yy += size->clipped.h;
880 free(size);
881 }
882 }
883 else if (zgs->gravity)
884 {
885 if (IS_HORIZ(zgs->orient))
886 xx += w;
887 else
888 yy += h;
889
890 E_LIST_REVERSE_FREE(gadgets, size)
891 {
892 Evas_Coord gx = xx, gy = yy;
893
894 if (IS_HORIZ(zgs->orient))
895 gx -= (Evas_Coord)(((double)(size->size.w - size->clipped.w)) * 0.5) + size->clipped.w,
896 gy += (h / 2) - (size->clipped.h / 2);
897 else
898 gy -= (Evas_Coord)(((double)(size->size.h - size->clipped.h)) * 0.5) + size->clipped.h,
899 gx += (w / 2) - (size->clipped.w / 2);
900 evas_object_move(size->obj, gx, gy);
901 if (IS_HORIZ(zgs->orient))
902 xx -= size->clipped.w;
903 else
904 yy -= size->clipped.h;
905 free(size);
906 }
907 }
908
909 if (IS_HORIZ(zgs->orient))
910 zgs->cur_size = abs(xx - x);
911 else if (IS_VERT(zgs->orient))
912 zgs->cur_size = abs(yy - y);
913
914 w = IS_HORIZ(zgs->orient) ? zgs->cur_size : w;
915 h = IS_VERT(zgs->orient) ? zgs->cur_size : h;
916 if ((w == mw) && (h == mh) && (sw == sh) && (sw == -1))
917 {
918 /* FIXME: https://phab.enlightenment.org/T4747 */
919 evas_object_size_hint_min_set(o, -1, -1);
920 }
921 evas_object_size_hint_min_set(o, w, h);
922}
923
924static void
925_site_layout(Evas_Object *o, Evas_Object_Box_Data *priv EINA_UNUSED, void *data)
926{
927 E_Gadget_Site *zgs = data;
928 Evas_Coord x, y, w, h;//, px, py;
929 Eina_List *l;
930 double ax, ay;
931 E_Gadget_Config *zgc;
932
933 evas_object_geometry_get(o, &x, &y, &w, &h);
934 evas_object_geometry_set(zgs->events, x, y, w, h);
935
936 evas_object_box_align_get(o, &ax, &ay);
937
938 if (zgs->orient)
939 {
940 _site_layout_orient(o, zgs);
941 return;
942 }
943 if ((!w) || (!h)) return;
944 EINA_LIST_FOREACH(zgs->gadgets, l, zgc)
945 {
946 Evas_Coord gx = x, gy = y;
947 int ww, hh, ow, oh;
948 E_Zone *zone;
949
950 if (!zgc->display) continue;
951 if (zgc->moving)
952 {
953 if (zgs->layout != pointer_site) continue;
954 _site_gadget_resize(zgc->gadget, w, h, &ww, &hh, &ow, &oh);
955 }
956 else
957 {
958 if (zgc->zone >= 0)
959 {
960 zone = e_comp_zone_number_get(zgc->zone);
961 x = gx = zone->x;
962 y = gy = zone->y;
963 w = zone->w;
964 h = zone->h;
965 }
966
967 _site_gadget_resize(zgc->gadget, w * zgc->w, h * zgc->h, &ww, &hh, &ow, &oh);
968 if (zgc->x > -1.0)
969 {
970 gx = x + zgc->x * w;
971 gx += (Evas_Coord)(((double)(ww - ow)) * 0.5 * -ax);
972 }
973 if (zgc->y > -1.0)
974 {
975 gy = y + zgc->y * h;
976 gy += (Evas_Coord)(((double)(hh - oh)) * 0.5 * -ay);
977 }
978 }
979 if (zgs->gravity)
980 {
981#if 0//FIXME
982 if (zgs->gravity % 2)//left/top
983 {
984 if (gx < px) gx = px;
985 }
986 else if ()
987 {
988 if (gx > px) gx = px;
989 }
990
991 if (zgs->gravity % 2)//left/top
992 {
993 if (gy < py) gy = py;
994 }
995 else
996 {
997 if (gy > py) gy = py;
998 }
999#endif
1000 }
1001
1002 evas_object_move(zgc->display, gx, gy);
1003#if 0//FIXME
1004 if (zgs->gravity is horizontal or something)
1005 px = gx + (-ax * ow);
1006 else
1007 py = gy + (-ay * oh);
1008#endif
1009 if (eina_list_count(zgs->gadgets) == 1)
1010 {
1011 int mw, mh, sw, sh;
1012
1013 evas_object_size_hint_min_get(o, &mw, &mh);
1014 evas_object_size_hint_min_get(zgs->layout, &sw, &sh);
1015 if ((ow == mw) && (oh == mh) && (sw == sh) && (sw == -1))
1016 {
1017 /* FIXME: https://phab.enlightenment.org/T4747 */
1018 evas_object_size_hint_min_set(o, -1, -1);
1019 }
1020 evas_object_size_hint_min_set(o, ow, oh);
1021 }
1022 }
1023}
1024
1025static Eina_Bool
1026_gadget_mouse_resize(E_Gadget_Config *zgc, int t EINA_UNUSED, Ecore_Event_Mouse_Move *ev)
1027{
1028 int x, y, w, h;//site geom
1029 int ox, oy, ow, oh;//gadget geom
1030 double gw, gh;
1031 int dx, dy;
1032 int ax, ay;
1033 Evas_Aspect_Control aspect;
1034
1035 evas_object_geometry_get(zgc->display, &ox, &oy, &ow, &oh);
1036 evas_object_size_hint_aspect_get(zgc->gadget, &aspect, &ax, &ay);
1037 if (zgc->zone >= 0)
1038 {
1039 E_Zone *zone;
1040
1041 zone = e_comp_zone_number_get(zgc->zone);
1042 x = zone->x, y = zone->y, w = zone->w, h = zone->h;
1043 }
1044 else
1045 evas_object_geometry_get(zgc->site->layout, &x, &y, &w, &h);
1046 /* restore screen-based geometry to canvas size */
1047 gw = zgc->w * w;
1048 gh = zgc->h * h;
1049
1050 /* apply mouse movement to canvas size */
1051 dx = ev->x - zgc->down.x, dy = ev->y - zgc->down.y;
1052 if (zgc->resizing & E_GADGET_SITE_ANCHOR_LEFT)
1053 gw -= dx;
1054 else
1055 gw += dx;
1056 if (zgc->resizing & E_GADGET_SITE_ANCHOR_TOP)
1057 gh -= dy;
1058 else
1059 gh += dy;
1060
1061 /* apply aspect based on mouse position change */
1062 dx = abs(ev->x - zgc->down.x);
1063 dy = abs(ev->y - zgc->down.y);
1064 if (dx > dy)
1065 {
1066 /* use horizontal motion if most of event is horizontal */
1067 int ww = lround(gw), hh = lround(gh);
1068 _site_gadget_aspect(zgc, &ww, &hh, ax, ay, EVAS_ASPECT_CONTROL_HORIZONTAL);
1069 gh = hh;
1070 }
1071 else if (dy > dx)
1072 {
1073 /* use vertical motion if most of event is vertical */
1074 int ww = lround(gw), hh = lround(gh);
1075 _site_gadget_aspect(zgc, &ww, &hh, ax, ay, EVAS_ASPECT_CONTROL_VERTICAL);
1076 gw = ww;
1077 }
1078 else if ((dx == dy) && (ax != ay))
1079 {
1080 /* use aspect values to calculate equal motion on both axes */
1081 int ww = lround(gw), hh = lround(gh);
1082 if (ax > ay)
1083 {
1084 _site_gadget_aspect(zgc, &ww, &hh, ax, ay, EVAS_ASPECT_CONTROL_VERTICAL);
1085 gw = ww;
1086 }
1087 else
1088 {
1089 _site_gadget_aspect(zgc, &ww, &hh, ax, ay, EVAS_ASPECT_CONTROL_HORIZONTAL);
1090 gh = hh;
1091 }
1092 }
1093
1094 /* calculate new position based on resize amount */
1095 dx = ev->x - zgc->down.x, dy = ev->y - zgc->down.y;
1096 if (zgc->resizing & E_GADGET_SITE_ANCHOR_LEFT)
1097 {
1098 zgc->x = (((zgc->x + zgc->w) * (double)w) - gw) / (double)w;
1099 }
1100 if (zgc->resizing & E_GADGET_SITE_ANCHOR_TOP)
1101 {
1102 zgc->y = (((zgc->y + zgc->h) * (double)h) - gh) / (double)h;
1103 }
1104
1105 zgc->w = gw / w;
1106 zgc->h = gh / h;
1107 zgc->down.x = ev->x;
1108 zgc->down.y = ev->y;
1109 evas_object_smart_need_recalculate_set(zgc->site->layout, 1);
1110 e_config_save_queue();
1111 return ECORE_CALLBACK_RENEW;
1112}
1113
1114static void
1115_gadget_util_add(E_Gadget_Site *zgs, const char *domain, const char *type, int id)
1116{
1117 E_Gadget_Config *zgc;
1118
1119 zgc = E_NEW(E_Gadget_Config, 1);
1120 zgc->id = id;
1121 if (domain)
1122 {
1123 zgc->external.domain = eina_stringshare_add(domain);
1124 zgc->external.type = eina_stringshare_add(type);
1125 }
1126 else
1127 zgc->type = eina_stringshare_add(type);
1128 zgc->x = zgc->y = -1;
1129 zgc->site = zgs;
1130 zgc->zone = -1;
1131 if (zgc->site->orient)
1132 zgc->w = zgc->h = -1;
1133 else
1134 {
1135 E_Zone *zone = e_zone_current_get();
1136 zgc->w = (96 * e_scale) / (double)zone->w;
1137 zgc->h = (96 * e_scale) / (double)zone->h;
1138 }
1139 zgc->site->gadgets = eina_list_append(zgc->site->gadgets, zgc);
1140 zgs->gadget_list = eina_inlist_append(zgs->gadget_list, EINA_INLIST_GET(zgc));
1141 _gadget_object_finalize(zgc);
1142}
1143
1144static Eina_Bool
1145_gadget_act_resize_end(E_Object *obj, const char *params EINA_UNUSED, E_Binding_Event_Mouse_Button *ev EINA_UNUSED)
1146{
1147 E_Gadget_Config *zgc;
1148 Evas_Object *g;
1149
1150 if (obj->type != E_GADGET_TYPE) return EINA_FALSE;
1151 g = e_object_data_get(obj);
1152 zgc = evas_object_data_get(g, "__e_gadget");
1153 zgc->resizing = 0;
1154
1155 E_FREE_FUNC(zgc->site->move_handler, ecore_event_handler_del);
1156 evas_object_smart_need_recalculate_set(zgc->site->layout, 1);
1157 return EINA_TRUE;
1158}
1159
1160static void
1161_gadget_popups_clear(E_Gadget_Config *zgc)
1162{
1163 Eina_List *l, *ll;
1164 Evas_Object *popup;
1165
1166 EINA_LIST_FOREACH_SAFE(zgc->popups, l, ll, popup)
1167 evas_object_del(popup);
1168}
1169
1170static Eina_Bool
1171_gadget_act_move(E_Object *obj, const char *params EINA_UNUSED, E_Binding_Event_Mouse_Button *ev EINA_UNUSED)
1172{
1173 E_Gadget_Config *zgc, *z;
1174 Evas_Object *g;
1175 int w, h;
1176
1177 if (obj->type != E_GADGET_TYPE) return EINA_FALSE;
1178
1179 g = e_object_data_get(obj);
1180 zgc = evas_object_data_get(g, "__e_gadget");
1181 zgc->moving = 1;
1182 _editor_pointer_site_init(zgc->site->orient, NULL, NULL, 1);
1183 e_gadget_site_owner_setup(pointer_site, zgc->site->anchor, NULL, NULL, NULL);
1184 ZGS_GET(pointer_site);
1185 if (zgc->external.domain)
1186 _gadget_util_add(zgs, zgc->external.domain, zgc->external.type, zgc->id);
1187 else
1188 _gadget_util_add(zgs, NULL, zgc->type, zgc->id);
1189 z = eina_list_data_get(zgs->gadgets);
1190 if (!z)
1191 {
1192 E_FREE_FUNC(pointer_site, evas_object_del);
1193 zgc->moving = 0;
1194 return EINA_TRUE;
1195 }
1196 _gadget_popups_clear(zgc);
1197 z->moving = 1;
1198 evas_object_pass_events_set(zgc->site->layout, 1);
1199 evas_object_geometry_get(g, NULL, NULL, &w, &h);
1200 evas_object_resize(pointer_site, w, h);
1201 eina_stringshare_refplace(&z->style.name, zgc->style.name);
1202 z->orig = zgc;
1203 return EINA_TRUE;
1204}
1205
1206static Eina_Bool
1207_gadget_act_resize(E_Object *obj, const char *params EINA_UNUSED, E_Binding_Event_Mouse_Button *ev)
1208{
1209 E_Gadget_Config *zgc;
1210 Evas_Object *g;
1211 int x, y, w, h;
1212
1213 if (obj->type != E_GADGET_TYPE) return EINA_FALSE;
1214
1215 g = e_object_data_get(obj);
1216 zgc = evas_object_data_get(g, "__e_gadget");
1217 if (zgc->site->orient) return EINA_FALSE;
1218 _gadget_popups_clear(zgc);
1219 evas_object_geometry_get(g, &x, &y, &w, &h);
1220 if (ev->canvas.x < x + (w / 3))
1221 zgc->resizing = E_GADGET_SITE_ANCHOR_LEFT;
1222 else if (ev->canvas.x > x + (w * 2 / 3))
1223 zgc->resizing = E_GADGET_SITE_ANCHOR_RIGHT;
1224 if (ev->canvas.y < y + (h / 3))
1225 zgc->resizing |= E_GADGET_SITE_ANCHOR_TOP;
1226 else if (ev->canvas.y > y + (h * 2 / 3))
1227 zgc->resizing |= E_GADGET_SITE_ANCHOR_BOTTOM;
1228 if (!zgc->site->move_handler)
1229 zgc->site->move_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_MOVE, (Ecore_Event_Handler_Cb)_gadget_mouse_resize, zgc);
1230 return EINA_TRUE;
1231}
1232
1233static void
1234_gadget_act_configure_object_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
1235{
1236 E_Gadget_Config *zgc = data;
1237
1238 zgc->cfg_object = NULL;
1239}
1240
1241static void
1242_gadget_configure(E_Gadget_Config *zgc)
1243{
1244 if (!zgc->configure) return;
1245 if (zgc->cfg_object)
1246 {
1247 evas_object_raise(zgc->cfg_object);
1248 evas_object_show(zgc->cfg_object);
1249 return;
1250 }
1251 zgc->cfg_object = zgc->configure(zgc->gadget);
1252 if (!zgc->cfg_object) return;
1253 evas_object_event_callback_add(zgc->cfg_object, EVAS_CALLBACK_DEL, _gadget_act_configure_object_del, zgc);
1254 evas_object_smart_callback_call(zgc->display, "gadget_popup", zgc->cfg_object);
1255}
1256
1257static void
1258_gadget_menu_populate(E_Gadget_Config *zgc, E_Menu *m)
1259{
1260 if (!zgc->populate) return;
1261 zgc->populate(zgc->gadget, m);
1262}
1263
1264static Eina_Bool
1265_gadget_act_configure(E_Object *obj, const char *params EINA_UNUSED, E_Binding_Event_Mouse_Button *ev EINA_UNUSED)
1266{
1267 E_Gadget_Config *zgc;
1268 Evas_Object *g;
1269
1270 if (obj->type != E_GADGET_TYPE) return EINA_FALSE;
1271
1272 g = e_object_data_get(obj);
1273 zgc = evas_object_data_get(g, "__e_gadget");
1274 _gadget_configure(zgc);
1275 return EINA_TRUE;
1276}
1277
1278static void
1279_gadget_menu_remove(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
1280{
1281 E_Gadget_Config *zgc = data;
1282
1283 _gadget_remove(zgc);
1284}
1285
1286static void
1287_gadget_menu_configure(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi EINA_UNUSED)
1288{
1289 _gadget_configure(data);
1290}
1291
1292static void
1293_gadget_style_menu_item_del(void *mi)
1294{
1295 eina_stringshare_del(e_object_data_get(mi));
1296}
1297
1298static void
1299_gadget_menu_style(void *data, E_Menu *m EINA_UNUSED, E_Menu_Item *mi)
1300{
1301 E_Gadget_Config *zgc = data;
1302 Eina_Stringshare *style = e_object_data_get(E_OBJECT(mi));
1303
1304 eina_stringshare_refplace(&zgc->style.name, style);
1305 if (zgc->site->style_cb)
1306 zgc->site->style_cb(zgc->site->layout, style, zgc->gadget);
1307}
1308
1309static void
1310_gadget_menu(Evas_Object *g, unsigned int timestamp)
1311{
1312 E_Gadget_Config *zgc;
1313 E_Menu_Item *mi;
1314 E_Menu *subm;
1315 int x, y;
1316
1317 zgc = evas_object_data_get(g, "__e_gadget");
1318 _gadget_popups_clear(zgc);
1319
1320 zgc->menu = e_menu_new();
1321 e_menu_hold_mode_set(zgc->menu, EINA_FALSE);
1322 if (zgc->type)
1323 {
1324 char buf[1024];
1325
1326 strncpy(buf, zgc->type, sizeof(buf) - 1);
1327 buf[0] = toupper(buf[0]);
1328 e_menu_title_set(zgc->menu, buf);
1329 }
1330 evas_object_smart_callback_call(g, "gadget_menu", zgc->menu);
1331 if (zgc->configure)
1332 {
1333 mi = e_menu_item_new(zgc->menu);
1334 e_menu_item_label_set(mi, _("Settings"));
1335 e_util_menu_item_theme_icon_set(mi, "configure");
1336 e_menu_item_callback_set(mi, _gadget_menu_configure, zgc);
1337 }
1338 if (zgc->menu->items)
1339 {
1340 mi = e_menu_item_new(zgc->menu);
1341 e_menu_item_separator_set(mi, 1);
1342 }
1343 subm = e_menu_new();
1344 e_menu_hold_mode_set(subm, EINA_FALSE);
1345 evas_object_smart_callback_call(zgc->site->layout, "gadget_site_style_menu", subm);
1346 if (e_object_data_get(E_OBJECT(subm)))
1347 {
1348 Eina_List *styles = e_object_data_get(E_OBJECT(subm));
1349 Eina_Stringshare *style;
1350
1351 mi = e_menu_item_new(zgc->menu);
1352 e_menu_item_label_set(mi, _("Look"));
1353 e_util_menu_item_theme_icon_set(mi, "preferences-look");
1354 e_menu_item_submenu_set(mi, subm);
1355 e_object_unref(E_OBJECT(subm));
1356
1357 EINA_LIST_FREE(styles, style)
1358 {
1359 char buf[1024];
1360
1361 if (eina_streq(style, "base"))
1362 {
1363 eina_stringshare_del(style);
1364 continue;
1365 }
1366 mi = e_menu_item_new(subm);
1367 strncpy(buf, style, sizeof(buf) - 1);
1368 buf[0] = toupper(buf[0]);
1369 e_menu_item_label_set(mi, buf);
1370 snprintf(buf, sizeof(buf), "enlightenment/%s", style);
1371 e_util_menu_item_theme_icon_set(mi, buf);
1372 e_menu_item_radio_group_set(mi, 1);
1373 e_menu_item_radio_set(mi, 1);
1374 e_menu_item_toggle_set(mi, style == zgc->style.name);
1375 e_menu_item_disabled_set(mi, mi->toggle);
1376 e_object_data_set(E_OBJECT(mi), style);
1377 E_OBJECT_DEL_SET(mi, _gadget_style_menu_item_del);
1378 e_menu_item_callback_set(mi, _gadget_menu_style, zgc);
1379 }
1380 }
1381 else
1382 e_object_del(E_OBJECT(subm));
1383
1384
1385 mi = e_menu_item_new(zgc->menu);
1386 evas_object_smart_callback_call(zgc->site->layout, "gadget_site_owner_menu", mi);
1387 if (mi->label)
1388 {
1389 mi = e_menu_item_new(zgc->menu);
1390 e_menu_item_separator_set(mi, 1);
1391 }
1392 else
1393 e_object_del(E_OBJECT(mi));
1394
1395 mi = e_menu_item_new(zgc->menu);
1396 e_menu_item_label_set(mi, _("Delete"));
1397 e_util_menu_item_theme_icon_set(mi, "list-remove");
1398 e_menu_item_callback_set(mi, _gadget_menu_remove, zgc);
1399
1400 evas_pointer_canvas_xy_get(e_comp->evas, &x, &y);
1401 e_menu_activate_mouse(zgc->menu,
1402 e_zone_current_get(),
1403 x, y, 1, 1,
1404 E_MENU_POP_DIRECTION_AUTO, timestamp);
1405 _desktop_rect_obj_add(zgc->menu->comp_object);
1406 evas_object_smart_callback_call(zgc->site->layout, "gadget_site_popup", zgc->menu->comp_object);
1407}
1408
1409static void
1410_gadget_menu_cancel(Evas_Object *g, unsigned int timestamp EINA_UNUSED)
1411{
1412 E_Gadget_Config *zgc;
1413
1414 zgc = evas_object_data_get(g, "__e_gadget");
1415 if (zgc->menu)
1416 {
1417 e_menu_deactivate(zgc->menu);
1418 e_object_del(E_OBJECT(zgc->menu));
1419 zgc->menu = NULL;
1420 }
1421}
1422
1423static Eina_Bool
1424_site_longpress_menu(void *data)
1425{
1426 E_Gadget_Site *zgs = data;
1427 E_Gadget_Config *zgc;
1428 Evas_Object *g = NULL;
1429
1430 zgs->down_timer = NULL;
1431 zgs->longpressed = EINA_TRUE;
1432 zgc = _gadget_at_xy(zgs, zgs->down_1_x, zgs->down_1_y, NULL);
1433 if (zgc) g = zgc->gadget;
1434 if (zgs->context_cb) zgs->context_cb(zgs->layout, g, ecore_loop_time_get() * 1000);
1435 return EINA_FALSE;
1436}
1437
1438static Eina_Bool
1439_site_mouse_up_handle(E_Gadget_Site *zgs, int t EINA_UNUSED, Ecore_Event_Mouse_Button *ev)
1440{
1441 if (e_bindings_mouse_up_ecore_event_handle(E_BINDING_CONTEXT_ANY, zgs->action->e_obj_inherit, ev))
1442 {
1443 evas_object_pointer_mode_set(zgs->events, EVAS_OBJECT_POINTER_MODE_NOGRAB);
1444 zgs->action = NULL;
1445 E_FREE_FUNC(zgs->mouse_up_handler, ecore_event_handler_del);
1446 }
1447 return ECORE_CALLBACK_RENEW;
1448}
1449
1450static void
1451_site_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1452{
1453 E_Gadget_Site *zgs = data;
1454 E_Gadget_Config *zgc;
1455 Evas_Event_Mouse_Down *ev = event_info;
1456 E_Action *act;
1457
1458 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1459 zgc = _gadget_at_xy(zgs, ev->output.x, ev->output.y, NULL);
1460 if (zgc)
1461 {
1462 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1463 act = e_bindings_mouse_down_evas_event_handle(E_BINDING_CONTEXT_ANY, zgc->e_obj_inherit, event_info);
1464 if (!act) ev->event_flags &= ~EVAS_EVENT_FLAG_ON_HOLD;
1465 else if (act->func.end_mouse)
1466 {
1467 int x, y;
1468
1469 evas_object_pointer_mode_set(obj, EVAS_OBJECT_POINTER_MODE_NOGRAB_NO_REPEAT_UPDOWN);
1470 zgs->action = zgc;
1471 if (!zgs->mouse_up_handler)
1472 zgs->mouse_up_handler = ecore_event_handler_add(ECORE_EVENT_MOUSE_BUTTON_UP, (Ecore_Event_Handler_Cb)_site_mouse_up_handle, zgs);
1473
1474 evas_object_geometry_get(zgc->display, &x, &y, NULL, NULL);
1475 zgc->offset.x = ev->canvas.x - x;
1476 zgc->offset.y = ev->canvas.y - y;
1477 zgc->down.x = ev->canvas.x;
1478 zgc->down.y = ev->canvas.y;
1479 }
1480 if (act) return;
1481 }
1482 if (ev->button == 1)
1483 {
1484 zgs->longpressed = EINA_FALSE;
1485 zgs->dragged = EINA_FALSE;
1486 zgs->down_1_x = ev->canvas.x;
1487 zgs->down_1_y = ev->canvas.y;
1488 E_FREE_FUNC(zgs->down_timer, ecore_timer_del);
1489 zgs->down_timer = ecore_timer_add(1.0, _site_longpress_menu, zgs);
1490 }
1491 else if (ev->button == 3)
1492 {
1493 zgs->down_3_x = ev->canvas.x;
1494 zgs->down_3_y = ev->canvas.y;
1495 }
1496}
1497
1498static void
1499_site_mouse_up(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1500{
1501 E_Gadget_Site *zgs = data;
1502 Evas_Event_Mouse_Up *ev = event_info;
1503
1504 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1505 if (ev->button == 1)
1506 {
1507 E_FREE_FUNC(zgs->down_timer, ecore_timer_del);
1508 if ((zgs->longpressed) || (zgs->dragged))
1509 {
1510 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1511 zgs->longpressed = EINA_FALSE;
1512 zgs->dragged = EINA_FALSE;
1513 }
1514 }
1515 else if (ev->button == 3)
1516 {
1517 if (!is_dragged(ev->canvas.x - zgs->down_3_x,
1518 ev->canvas.y - zgs->down_3_y))
1519 {
1520 E_Gadget_Config *zgc;
1521 Evas_Object *g = NULL;
1522
1523 zgc = _gadget_at_xy(zgs, zgs->down_3_x, zgs->down_3_y, NULL);
1524 if (zgc) g = zgc->gadget;
1525 if (zgs->context_cb) zgs->context_cb(zgs->layout, g, ev->timestamp);
1526 ev->event_flags |= EVAS_EVENT_FLAG_ON_HOLD;
1527 }
1528 }
1529}
1530
1531static void
1532_site_mouse_move(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
1533{
1534 E_Gadget_Site *zgs = data;
1535 Evas_Event_Mouse_Move *ev = event_info;
1536
1537 if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
1538
1539 if ((zgs->down_timer) || (zgs->longpressed))
1540 {
1541 if (is_dragged(ev->cur.canvas.x - zgs->down_1_x,
1542 ev->cur.canvas.y - zgs->down_1_y))
1543 {
1544 if (zgs->down_timer)
1545 {
1546 E_FREE_FUNC(zgs->down_timer, ecore_timer_del);
1547 }
1548 if (!zgs->dragged)
1549 {
1550 E_Gadget_Config *zgc;
1551 Evas_Object *g = NULL;
1552
1553 zgs->dragged = EINA_TRUE;
1554 zgc = _gadget_at_xy(zgs, zgs->down_1_x, zgs->down_1_y, NULL);
1555 if (zgc) g = zgc->gadget;
1556 if (zgs->context_cancel_cb) zgs->context_cancel_cb(zgs->layout, g, ev->timestamp);
1557 }
1558 }
1559 }
1560}
1561
1562static void
1563_site_drop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
1564{
1565 E_Gadget_Site *zgs = data, *drop;
1566 Eina_List *l;
1567 E_Gadget_Config *zgc, *dzgc;
1568 int mx, my;
1569 int x, y, w, h;
1570
1571 drop = evas_object_data_get(event_info, "__e_gadget_site");
1572 evas_pointer_canvas_xy_get(e_comp->evas, &mx, &my);
1573 evas_object_geometry_get(zgs->layout, &x, &y, &w, &h);
1574 if (!E_INSIDE(mx, my, x, y, w, h)) return;
1575
1576 EINA_LIST_FOREACH(zgs->gadgets, l, zgc)
1577 {
1578 if (!zgc->display) continue;
1579
1580 evas_object_geometry_get(zgc->display, &x, &y, &w, &h);
1581 if (E_INSIDE(mx, my, x, y, w, h)) break;
1582 }
1583 if (zgc)
1584 {
1585 Eina_Bool pre = EINA_FALSE;
1586 if (IS_HORIZ(zgs->orient))
1587 {
1588 if (mx <= x + (w / 2))
1589 pre = EINA_TRUE;
1590 }
1591 else if (IS_VERT(zgs->orient))
1592 {
1593 if (my <= y + (h / 2))
1594 pre = EINA_TRUE;
1595 }
1596 else {} //FIXME
1597 if (zgs->orient)
1598 {
1599 Eina_List *ll;
1600
1601 if (pre)
1602 EINA_LIST_REVERSE_FOREACH(drop->gadgets, ll, dzgc)
1603 {
1604 evas_object_smart_callback_call(zgs->layout, "gadget_moved", dzgc->gadget);
1605 if (dzgc->id == -1) dzgc->id = 0;
1606 evas_object_del(dzgc->gadget);
1607 zgs->gadget_list = eina_inlist_prepend_relative(zgs->gadget_list,
1608 EINA_INLIST_GET(dzgc), EINA_INLIST_GET(zgc));
1609 zgs->gadgets = eina_list_prepend_relative_list(zgs->gadgets, dzgc, l);
1610 dzgc->site = zgs;
1611 dzgc->zone = -1;
1612 _gadget_object_finalize(dzgc);
1613 }
1614 else
1615 EINA_LIST_REVERSE_FOREACH(drop->gadgets, ll, dzgc)
1616 {
1617 evas_object_smart_callback_call(zgs->layout, "gadget_moved", dzgc->gadget);
1618 if (dzgc->id == -1) dzgc->id = 0;
1619 evas_object_del(dzgc->gadget);
1620 zgs->gadget_list = eina_inlist_append_relative(zgs->gadget_list,
1621 EINA_INLIST_GET(dzgc), EINA_INLIST_GET(zgc));
1622 zgs->gadgets = eina_list_append_relative_list(zgs->gadgets, dzgc, l);
1623 dzgc->site = zgs;
1624 dzgc->zone = -1;
1625 _gadget_object_finalize(dzgc);
1626 }
1627 }
1628 else
1629 {
1630 int dx, dy, dw, dh, gx, gy, gw, gh;
1631
1632 /* FIXME: this should place _(around)_ the gadget that got dropped on */
1633 evas_object_geometry_get(drop->layout, &dx, &dy, &dw, &dh);
1634 evas_object_geometry_get(zgs->layout, &x, &y, &w, &h);
1635 EINA_LIST_FOREACH(drop->gadgets, l, dzgc)
1636 {
1637 E_Zone *zone;
1638 /* calculate positioning offsets and normalize based on drop point */
1639 evas_object_geometry_get(dzgc->display, &gx, &gy, &gw, &gh);
1640 evas_object_smart_callback_call(