Migrating source code to RSA from private.
[framework/uifw/e17.git] / src / modules / ibar / e_mod_main.c
1 #include "e.h"
2 #include "e_mod_main.h"
3
4 #ifndef MAX
5 # define MAX(x, y) (((x) > (y)) ? (x) : (y))
6 #endif
7
8 /* TODO:
9  * - Track execution status
10  */
11
12 /* gadcon requirements */
13 static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
14 static void _gc_shutdown(E_Gadcon_Client *gcc);
15 static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
16 static const char *_gc_label(E_Gadcon_Client_Class *client_class);
17 static Evas_Object *_gc_icon(E_Gadcon_Client_Class *client_class, Evas *evas);
18 static const char *_gc_id_new(E_Gadcon_Client_Class *client_class);
19 static void _gc_id_del(E_Gadcon_Client_Class *client_class, const char *id);
20
21 /* and actually define the gadcon class that this module provides (just 1) */
22 static const E_Gadcon_Client_Class _gadcon_class =
23 {
24    GADCON_CLIENT_CLASS_VERSION,
25      "ibar",
26      {
27         _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, _gc_id_del,
28         e_gadcon_site_is_not_toolbar
29      },
30    E_GADCON_CLIENT_STYLE_INSET
31 };
32
33 /* actual module specifics */
34 typedef struct _Instance  Instance;
35 typedef struct _IBar IBar;
36 typedef struct _IBar_Icon IBar_Icon;
37
38 struct _Instance
39 {
40    E_Gadcon_Client *gcc;
41    Evas_Object *o_ibar;
42    IBar *ibar;
43    E_Drop_Handler *drop_handler;
44    Config_Item *ci;
45    E_Gadcon_Orient orient;
46 };
47
48 struct _IBar
49 {
50    Instance *inst;
51    Evas_Object *o_box, *o_drop;
52    Evas_Object *o_drop_over, *o_empty;
53    IBar_Icon *ic_drop_before;
54    int drop_before;
55    E_Order *apps;
56    Eina_List *icons;
57    Evas_Coord dnd_x, dnd_y;
58 };
59
60 struct _IBar_Icon
61 {
62    IBar *ibar;
63    Evas_Object *o_holder, *o_icon;
64    Evas_Object *o_holder2, *o_icon2;
65    Efreet_Desktop *app;
66    int mouse_down;
67    struct 
68      {
69         unsigned char start : 1;
70         unsigned char dnd : 1;
71         int x, y;
72      } drag;
73 };
74
75 static IBar *_ibar_new(Evas *evas, Instance *inst);
76 static void _ibar_free(IBar *b);
77 static void _ibar_cb_empty_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
78 static void _ibar_empty_handle(IBar *b);
79 static void _ibar_fill(IBar *b);
80 static void _ibar_empty(IBar *b);
81 static void _ibar_orient_set(IBar *b, int horizontal);
82 static void _ibar_resize_handle(IBar *b);
83 static void _ibar_instance_drop_zone_recalc(Instance *inst);
84 static Config_Item *_ibar_config_item_get(const char *id);
85 static IBar_Icon *_ibar_icon_at_coord(IBar *b, Evas_Coord x, Evas_Coord y);
86 static IBar_Icon *_ibar_icon_new(IBar *b, Efreet_Desktop *desktop);
87 static void _ibar_icon_free(IBar_Icon *ic);
88 static void _ibar_icon_fill(IBar_Icon *ic);
89 static void _ibar_icon_empty(IBar_Icon *ic);
90 static void _ibar_icon_signal_emit(IBar_Icon *ic, char *sig, char *src);
91 static void _ibar_cb_app_change(void *data, E_Order *eo);
92 static void _ibar_cb_obj_moveresize(void *data, Evas *e, Evas_Object *obj, void *event_info);
93 static void _ibar_cb_menu_icon_new(void *data, E_Menu *m, E_Menu_Item *mi);
94 static void _ibar_cb_menu_icon_add(void *data, E_Menu *m, E_Menu_Item *mi);
95 static void _ibar_cb_menu_icon_properties(void *data, E_Menu *m, E_Menu_Item *mi);
96 static void _ibar_cb_menu_icon_remove(void *data, E_Menu *m, E_Menu_Item *mi);
97 static void _ibar_cb_menu_configuration(void *data, E_Menu *m, E_Menu_Item *mi);
98 static void _ibar_cb_menu_post(void *data, E_Menu *m);
99 static void _ibar_cb_icon_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
100 static void _ibar_cb_icon_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
101 static void _ibar_cb_icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
102 static void _ibar_cb_icon_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
103 static void _ibar_cb_icon_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
104 static void _ibar_cb_icon_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
105 static void _ibar_cb_icon_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
106 static void _ibar_inst_cb_enter(void *data, const char *type, void *event_info);
107 static void _ibar_inst_cb_move(void *data, const char *type, void *event_info);
108 static void _ibar_inst_cb_leave(void *data, const char *type, void *event_info);
109 static void _ibar_inst_cb_drop(void *data, const char *type, void *event_info);
110 static void _ibar_cb_drag_finished(E_Drag *data, int dropped);
111 static void _ibar_drop_position_update(Instance *inst, Evas_Coord x, Evas_Coord y);
112 static void _ibar_inst_cb_scroll(void *data);
113 static Eina_Bool  _ibar_cb_config_icons(void *data, int ev_type, void *ev);
114
115 static E_Config_DD *conf_edd = NULL;
116 static E_Config_DD *conf_item_edd = NULL;
117
118 Config *ibar_config = NULL;
119
120 static E_Gadcon_Client *
121 _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
122 {
123    IBar *b;
124    Evas_Object *o;
125    E_Gadcon_Client *gcc;
126    Instance *inst;
127    Evas_Coord x, y, w, h;
128    const char *drop[] = { "enlightenment/desktop", "enlightenment/border", "text/uri-list" };
129    Config_Item *ci;
130
131    inst = E_NEW(Instance, 1);
132
133    ci = _ibar_config_item_get(id);
134    inst->ci = ci;
135    if (!ci->dir) ci->dir = eina_stringshare_add("default");
136    b = _ibar_new(gc->evas, inst);
137    o = b->o_box;
138    gcc = e_gadcon_client_new(gc, name, id, style, o);
139    gcc->data = inst;
140
141    inst->gcc = gcc;
142    inst->o_ibar = o;
143    inst->orient = E_GADCON_ORIENT_HORIZ;
144
145    evas_object_geometry_get(o, &x, &y, &w, &h);
146    inst->drop_handler =
147      e_drop_handler_add(E_OBJECT(inst->gcc), inst,
148                         _ibar_inst_cb_enter, _ibar_inst_cb_move,
149                         _ibar_inst_cb_leave, _ibar_inst_cb_drop,
150                         drop, 3, x, y, w,  h);
151    evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE,
152                                   _ibar_cb_obj_moveresize, inst);
153    evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE,
154                                   _ibar_cb_obj_moveresize, inst);
155    ibar_config->instances = eina_list_append(ibar_config->instances, inst);
156    return gcc;
157 }
158
159 static void
160 _gc_shutdown(E_Gadcon_Client *gcc)
161 {
162    Instance *inst;
163
164    inst = gcc->data;
165    ibar_config->instances = eina_list_remove(ibar_config->instances, inst);
166    e_drop_handler_del(inst->drop_handler);
167    _ibar_free(inst->ibar);
168    E_FREE(inst);
169 }
170
171 static void
172 _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
173 {
174    Instance *inst;
175
176    inst = gcc->data;
177    if ((int)orient != -1) inst->orient = orient;
178
179    switch (inst->orient)
180      {
181       case E_GADCON_ORIENT_FLOAT:
182       case E_GADCON_ORIENT_HORIZ:
183       case E_GADCON_ORIENT_TOP:
184       case E_GADCON_ORIENT_BOTTOM:
185       case E_GADCON_ORIENT_CORNER_TL:
186       case E_GADCON_ORIENT_CORNER_TR:
187       case E_GADCON_ORIENT_CORNER_BL:
188       case E_GADCON_ORIENT_CORNER_BR:
189         _ibar_orient_set(inst->ibar, 1);
190         e_gadcon_client_aspect_set(gcc, eina_list_count(inst->ibar->icons) * 16, 16);
191         break;
192       case E_GADCON_ORIENT_VERT:
193       case E_GADCON_ORIENT_LEFT:
194       case E_GADCON_ORIENT_RIGHT:
195       case E_GADCON_ORIENT_CORNER_LT:
196       case E_GADCON_ORIENT_CORNER_RT:
197       case E_GADCON_ORIENT_CORNER_LB:
198       case E_GADCON_ORIENT_CORNER_RB:
199         _ibar_orient_set(inst->ibar, 0);
200         e_gadcon_client_aspect_set(gcc, 16, eina_list_count(inst->ibar->icons) * 16);
201         break;
202       default:
203         break;
204      }
205    e_gadcon_client_min_size_set(gcc, 16, 16);
206 }
207
208 static const char *
209 _gc_label(E_Gadcon_Client_Class *client_class __UNUSED__)
210 {
211    return _("IBar");
212 }
213
214 static Evas_Object *
215 _gc_icon(E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
216 {
217    Evas_Object *o;
218    char buf[PATH_MAX];
219
220    o = edje_object_add(evas);
221    snprintf(buf, sizeof(buf), "%s/e-module-ibar.edj",
222             e_module_dir_get(ibar_config->module));
223    edje_object_file_set(o, buf, "icon");
224    return o;
225 }
226
227 static const char *
228 _gc_id_new(E_Gadcon_Client_Class *client_class __UNUSED__)
229 {
230    Config_Item *ci;
231
232    ci = _ibar_config_item_get(NULL);
233    return ci->id;
234 }
235
236 static void
237 _gc_id_del(E_Gadcon_Client_Class *client_class __UNUSED__, const char *id __UNUSED__)
238 {
239 /* yes - don't do this. on shutdown gadgets are deleted and this means config
240  * for them is deleted - that means empty config is saved. keep them around
241  * as if u add a gadget back it can pick up its old config again
242  * 
243    Config_Item *ci;
244
245    ci = _ibar_config_item_get(id);
246    if (ci)
247      {
248         if (ci->id) eina_stringshare_del(ci->id);
249         ibar_config->items = eina_list_remove(ibar_config->items, ci);
250      }
251  */
252 }
253
254 static IBar *
255 _ibar_new(Evas *evas, Instance *inst)
256 {
257    IBar *b;
258    char buf[PATH_MAX];
259
260    b = E_NEW(IBar, 1);
261    inst->ibar = b;
262    b->inst = inst;
263    b->o_box = e_box_add(evas);
264    e_box_homogenous_set(b->o_box, 1);
265    e_box_orientation_set(b->o_box, 1);
266    e_box_align_set(b->o_box, 0.5, 0.5);
267    if (inst->ci->dir[0] != '/')
268      e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s/.order", 
269                          inst->ci->dir);
270    else
271      eina_strlcpy(buf, inst->ci->dir, sizeof(buf));
272    b->apps = e_order_new(buf);
273    e_order_update_callback_set(b->apps, _ibar_cb_app_change, b);
274    _ibar_fill(b);
275    return b;
276 }
277
278 static void
279 _ibar_free(IBar *b)
280 {
281    _ibar_empty(b);
282    evas_object_del(b->o_box);
283    if (b->o_drop) evas_object_del(b->o_drop);
284    if (b->o_drop_over) evas_object_del(b->o_drop_over);
285    if (b->o_empty) evas_object_del(b->o_empty);
286    e_order_update_callback_set(b->apps, NULL, NULL);
287    if (b->apps) e_object_del(E_OBJECT(b->apps));
288    E_FREE(b);
289 }
290
291 static void
292 _ibar_cb_empty_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
293 {
294    Evas_Event_Mouse_Down *ev;
295    IBar *b;
296
297    ev = event_info;
298    b = data;
299    if (!ibar_config->menu)
300      {
301         E_Menu *m;
302         E_Menu_Item *mi;
303         int cx, cy, cw, ch;
304
305         m = e_menu_new();
306         mi = e_menu_item_new(m);
307         e_menu_item_label_set(mi, _("Settings"));
308         e_util_menu_item_theme_icon_set(mi, "configure");
309         e_menu_item_callback_set(mi, _ibar_cb_menu_configuration, b);
310
311         m = e_gadcon_client_util_menu_items_append(b->inst->gcc, m, 0);
312         e_menu_post_deactivate_callback_set(m, _ibar_cb_menu_post, NULL);
313         ibar_config->menu = m;
314
315         e_gadcon_canvas_zone_geometry_get(b->inst->gcc->gadcon,
316                                           &cx, &cy, &cw, &ch);
317         e_menu_activate_mouse(m,
318                               e_util_zone_current_get(e_manager_current_get()),
319                               cx + ev->output.x, cy + ev->output.y, 1, 1,
320                               E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
321      }
322 }
323
324 static void
325 _ibar_empty_handle(IBar *b)
326 {
327    if (!b->icons)
328      {
329         if (!b->o_empty)
330           {
331              Evas_Coord w, h;
332
333              b->o_empty = evas_object_rectangle_add(evas_object_evas_get(b->o_box));
334              evas_object_event_callback_add(b->o_empty, 
335                                             EVAS_CALLBACK_MOUSE_DOWN, 
336                                             _ibar_cb_empty_mouse_down, b);
337              evas_object_color_set(b->o_empty, 0, 0, 0, 0);
338              evas_object_show(b->o_empty);
339              e_box_pack_end(b->o_box, b->o_empty);
340              evas_object_geometry_get(b->o_box, NULL, NULL, &w, &h);
341              if (e_box_orientation_get(b->o_box))
342                w = h;
343              else
344                h = w;
345              e_box_pack_options_set(b->o_empty,
346                                     1, 1, /* fill */
347                                     1, 1, /* expand */
348                                     0.5, 0.5, /* align */
349                                     w, h, /* min */
350                                     9999, 9999 /* max */
351                                     );
352           }
353      }
354    else if (b->o_empty)
355      {
356         evas_object_del(b->o_empty);
357         b->o_empty = NULL;
358      }
359 }
360
361 static void
362 _ibar_fill(IBar *b)
363 {
364    if (b->apps)
365      {
366         Efreet_Desktop *desktop;
367         const Eina_List *l;
368
369         EINA_LIST_FOREACH(b->apps->desktops, l, desktop)
370           {
371              IBar_Icon *ic = _ibar_icon_new(b, desktop);
372              b->icons = eina_list_append(b->icons, ic);
373              e_box_pack_end(b->o_box, ic->o_holder);
374           }
375      }
376    _ibar_empty_handle(b);
377    _ibar_resize_handle(b);
378 }
379
380 static void
381 _ibar_empty(IBar *b)
382 {
383    IBar_Icon *ic;
384
385    EINA_LIST_FREE(b->icons, ic)
386      _ibar_icon_free(ic);
387
388    _ibar_empty_handle(b);
389 }
390
391 static void
392 _ibar_orient_set(IBar *b, int horizontal)
393 {
394    e_box_orientation_set(b->o_box, horizontal);
395    e_box_align_set(b->o_box, 0.5, 0.5);
396 }
397
398 static void
399 _ibar_resize_handle(IBar *b)
400 {
401    const Eina_List *l;
402    IBar_Icon *ic;
403    Evas_Coord w, h;
404
405    evas_object_geometry_get(b->o_box, NULL, NULL, &w, &h);
406    if (e_box_orientation_get(b->o_box))
407      w = h;
408    else
409      h = w;
410    e_box_freeze(b->o_box);
411    EINA_LIST_FOREACH(b->icons, l, ic)
412      {
413         e_box_pack_options_set(ic->o_holder,
414                                1, 1, /* fill */
415                                0, 0, /* expand */
416                                0.5, 0.5, /* align */
417                                w, h, /* min */
418                                w, h /* max */
419                                );
420      }
421    e_box_thaw(b->o_box);
422 }
423
424 static void
425 _ibar_instance_drop_zone_recalc(Instance *inst)
426 {
427    Evas_Coord x, y, w, h;
428
429    e_gadcon_client_viewport_geometry_get(inst->gcc, &x, &y, &w, &h);
430    e_drop_handler_geometry_set(inst->drop_handler, x, y, w, h);
431 }  
432
433 static Config_Item *
434 _ibar_config_item_get(const char *id)
435 {
436    Config_Item *ci;
437
438    GADCON_CLIENT_CONFIG_GET(Config_Item, ibar_config->items, _gadcon_class, id);
439
440    ci = E_NEW(Config_Item, 1);
441    ci->id = eina_stringshare_add(id);
442    ci->dir = eina_stringshare_add("default");
443    ci->show_label = 1;
444    ci->eap_label = 0;
445    ci->lock_move= 0;
446
447    ibar_config->items = eina_list_append(ibar_config->items, ci);
448    return ci;
449 }
450
451 void
452 _ibar_config_update(Config_Item *ci)
453 {
454    const Eina_List *l;
455    Instance *inst;
456
457    EINA_LIST_FOREACH(ibar_config->instances, l, inst)
458      {
459         char buf[PATH_MAX];
460         const Eina_List *i;
461         IBar_Icon *ic;
462
463         if (inst->ci != ci) continue;
464
465         _ibar_empty(inst->ibar);
466         if (inst->ibar->apps)
467           e_object_del(E_OBJECT(inst->ibar->apps));
468         if (inst->ci->dir[0] != '/')
469           e_user_dir_snprintf(buf, sizeof(buf), "applications/bar/%s/.order", 
470                               inst->ci->dir);
471         else
472           eina_strlcpy(buf, inst->ci->dir, sizeof(buf));
473         inst->ibar->apps = e_order_new(buf);
474         _ibar_fill(inst->ibar);
475         _ibar_resize_handle(inst->ibar);
476         _gc_orient(inst->gcc, -1);
477
478         EINA_LIST_FOREACH(inst->ibar->icons, i, ic)
479           {
480              switch (ci->eap_label)
481                {
482                 case 0:
483                   edje_object_part_text_set(ic->o_holder2, "e.text.label", 
484                                             ic->app->name);
485                   break;
486                 case 1:
487                   edje_object_part_text_set(ic->o_holder2, "e.text.label", 
488                                             ic->app->comment);
489                   break;
490                 case 2:
491                   edje_object_part_text_set(ic->o_holder2, "e.text.label", 
492                                             ic->app->generic_name);
493                   break;
494                }
495           }
496      }
497 }
498
499 static IBar_Icon *
500 _ibar_icon_at_coord(IBar *b, Evas_Coord x, Evas_Coord y)
501 {
502    const Eina_List *l;
503    IBar_Icon *ic;
504
505    EINA_LIST_FOREACH(b->icons, l, ic)
506      {
507         Evas_Coord dx, dy, dw, dh;
508
509         evas_object_geometry_get(ic->o_holder, &dx, &dy, &dw, &dh);
510         if (E_INSIDE(x, y, dx, dy, dw, dh)) return ic;
511      }
512    return NULL;
513 }
514
515 static IBar_Icon *
516 _ibar_icon_new(IBar *b, Efreet_Desktop *desktop)
517 {
518    IBar_Icon *ic;
519
520    ic = E_NEW(IBar_Icon, 1);
521    ic->ibar = b;
522    ic->app = desktop;
523    ic->o_holder = edje_object_add(evas_object_evas_get(b->o_box));
524    e_theme_edje_object_set(ic->o_holder, "base/theme/modules/ibar",
525                            "e/modules/ibar/icon");
526    evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_IN,  
527                                   _ibar_cb_icon_mouse_in,  ic);
528    evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_OUT, 
529                                   _ibar_cb_icon_mouse_out, ic);
530    evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_DOWN, 
531                                   _ibar_cb_icon_mouse_down, ic);
532    evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_UP, 
533                                   _ibar_cb_icon_mouse_up, ic);
534    evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_MOVE, 
535                                   _ibar_cb_icon_mouse_move, ic);
536    evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOVE, 
537                                   _ibar_cb_icon_move, ic);
538    evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_RESIZE, 
539                                   _ibar_cb_icon_resize, ic);
540    evas_object_show(ic->o_holder);
541
542    ic->o_holder2 = edje_object_add(evas_object_evas_get(b->o_box));
543    e_theme_edje_object_set(ic->o_holder2, "base/theme/modules/ibar",
544                            "e/modules/ibar/icon_overlay");
545    evas_object_layer_set(ic->o_holder2, 9999);
546    evas_object_pass_events_set(ic->o_holder2, 1);
547    evas_object_show(ic->o_holder2);
548
549    _ibar_icon_fill(ic);
550    return ic;
551 }
552
553 static void
554 _ibar_icon_free(IBar_Icon *ic)
555 {
556    if (ibar_config->menu)
557      {
558         e_menu_post_deactivate_callback_set(ibar_config->menu, NULL, NULL);
559         e_object_del(E_OBJECT(ibar_config->menu));
560         ibar_config->menu = NULL;
561      }
562    if (ic->ibar->ic_drop_before == ic)
563      ic->ibar->ic_drop_before = NULL;
564    _ibar_icon_empty(ic);
565    evas_object_del(ic->o_holder);
566    evas_object_del(ic->o_holder2);
567    E_FREE(ic);
568 }
569
570 static void
571 _ibar_icon_fill(IBar_Icon *ic)
572 {
573    if (ic->o_icon) evas_object_del(ic->o_icon);
574    ic->o_icon = e_icon_add(evas_object_evas_get(ic->ibar->o_box));
575    e_icon_fdo_icon_set(ic->o_icon, ic->app->icon);
576    edje_object_part_swallow(ic->o_holder, "e.swallow.content", ic->o_icon);
577    evas_object_pass_events_set(ic->o_icon, 1);
578    evas_object_show(ic->o_icon);
579    if (ic->o_icon2) evas_object_del(ic->o_icon2);
580    ic->o_icon2 = e_icon_add(evas_object_evas_get(ic->ibar->o_box));
581    e_icon_fdo_icon_set(ic->o_icon2, ic->app->icon);
582    edje_object_part_swallow(ic->o_holder2, "e.swallow.content", ic->o_icon2);
583    evas_object_pass_events_set(ic->o_icon2, 1);
584    evas_object_show(ic->o_icon2);
585
586    switch (ic->ibar->inst->ci->eap_label) 
587      {
588       case 0: /* Eap Name */
589         edje_object_part_text_set(ic->o_holder2, "e.text.label", ic->app->name);
590         break;
591       case 1: /* Eap Comment */
592         edje_object_part_text_set(ic->o_holder2, "e.text.label", ic->app->comment);
593         break;  
594       case 2: /* Eap Generic */
595         edje_object_part_text_set(ic->o_holder2, "e.text.label", ic->app->generic_name);
596         break;  
597      }
598 }
599
600 static void
601 _ibar_icon_empty(IBar_Icon *ic)
602 {
603    if (ic->o_icon) evas_object_del(ic->o_icon);
604    if (ic->o_icon2) evas_object_del(ic->o_icon2);
605    ic->o_icon = NULL;
606    ic->o_icon2 = NULL;
607 }
608
609 static void
610 _ibar_icon_signal_emit(IBar_Icon *ic, char *sig, char *src)
611 {
612    if (ic->o_holder)
613      edje_object_signal_emit(ic->o_holder, sig, src);
614    if (ic->o_icon)
615      edje_object_signal_emit(ic->o_icon, sig, src);
616    if (ic->o_holder2)
617      edje_object_signal_emit(ic->o_holder2, sig, src);
618    if (ic->o_icon2)
619      edje_object_signal_emit(ic->o_icon2, sig, src);
620 }
621
622 static void
623 _ibar_cb_app_change(void *data, E_Order *eo __UNUSED__)
624 {
625    IBar *b;
626
627    b = data;
628    if (!b->apps) return;
629    _ibar_empty(b);
630    _ibar_fill(b);
631    _ibar_resize_handle(b);
632    if (b->inst) _gc_orient(b->inst->gcc, -1);
633 }
634
635 static void
636 _ibar_cb_obj_moveresize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
637 {
638    Instance *inst;
639
640    inst = data;
641    _ibar_resize_handle(inst->ibar);
642    _ibar_instance_drop_zone_recalc(inst);
643 }
644
645 static void 
646 _ibar_cb_menu_icon_new(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__) 
647 {
648    E_Container *con;
649
650    if (!e_configure_registry_exists("applications/new_application")) return;
651    con = e_container_current_get(e_manager_current_get());
652    e_configure_registry_call("applications/new_application", con, NULL);
653 }
654
655 static void 
656 _ibar_cb_menu_icon_add(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__) 
657 {
658    E_Container *con;
659
660    if (!e_configure_registry_exists("applications/ibar_applications")) return;
661    con = e_container_current_get(e_manager_current_get());
662    e_configure_registry_call("applications/ibar_applications", con, NULL);
663 }
664
665 static void
666 _ibar_cb_menu_icon_properties(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
667 {
668    IBar_Icon *ic;
669
670    ic = data;
671    e_desktop_edit(ic->ibar->inst->gcc->gadcon->zone->container, ic->app);
672 }
673
674 static void
675 _ibar_cb_menu_icon_remove(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
676 {
677    IBar_Icon *ic;
678    E_Gadcon_Client *gc;
679
680    ic = data;
681    ic->ibar->icons = eina_list_remove(ic->ibar->icons, ic);
682    _ibar_resize_handle(ic->ibar);
683    gc = ic->ibar->inst->gcc;
684    _gc_orient(gc, -1);
685    e_order_remove(ic->ibar->apps, ic->app);
686    _ibar_icon_free(ic);
687 }
688
689 static void
690 _ibar_cb_menu_configuration(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
691 {
692    IBar *b;
693
694    b = data;
695    _config_ibar_module(b->inst->ci);
696 }
697
698 /*
699 static void
700 _ibar_cb_menu_add(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
701 {
702    IBar *b;
703
704    b = data;
705    e_configure_registry_call("internal/ibar_other",
706                              b->inst->gcc->gadcon->zone->container,
707                              b->apps->path);
708 }
709 */
710
711 static void
712 _ibar_cb_menu_post(void *data __UNUSED__, E_Menu *m __UNUSED__)
713 {
714    if (!ibar_config->menu) return;
715    e_object_del(E_OBJECT(ibar_config->menu));
716    ibar_config->menu = NULL;
717 }
718
719 static void
720 _ibar_cb_icon_mouse_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
721 {
722    IBar_Icon *ic;
723
724    ic = data;
725    _ibar_icon_signal_emit(ic, "e,state,focused", "e");
726    if (ic->ibar->inst->ci->show_label)
727      _ibar_icon_signal_emit(ic, "e,action,show,label", "e");
728 }
729
730 static void
731 _ibar_cb_icon_mouse_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
732 {
733    IBar_Icon *ic;
734
735    ic = data;
736    _ibar_icon_signal_emit(ic, "e,state,unfocused", "e");
737    if (ic->ibar->inst->ci->show_label)
738      _ibar_icon_signal_emit(ic, "e,action,hide,label", "e");
739 }
740
741 static void
742 _ibar_cb_icon_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
743 {
744    Evas_Event_Mouse_Down *ev;
745    IBar_Icon *ic;
746
747    ev = event_info;
748    ic = data;
749    if (ev->button == 1)
750      {
751         ic->drag.x = ev->output.x;
752         ic->drag.y = ev->output.y;
753         ic->drag.start = 1;
754         ic->drag.dnd = 0;
755         ic->mouse_down = 1;
756      }
757    else if ((ev->button == 3) && (!ibar_config->menu))
758      {
759         E_Menu *m, *mo;
760         E_Menu_Item *mi;
761         char buf[256];
762         int cx, cy;
763
764         m = e_menu_new();
765
766         /* FIXME: other icon options go here too */
767         mo = e_menu_new();
768
769         if (e_configure_registry_exists("applications/new_application")) 
770           {
771              mi = e_menu_item_new(m);
772              e_menu_item_label_set(mi, _("Create new Icon"));
773              e_util_menu_item_theme_icon_set(mi, "document-new");
774              e_menu_item_callback_set(mi, _ibar_cb_menu_icon_new, NULL);
775
776              mi = e_menu_item_new(m);
777              e_menu_item_separator_set(mi, 1);
778           }
779
780         if (e_configure_registry_exists("applications/ibar_applications")) 
781           {
782              mi = e_menu_item_new(m);
783              e_menu_item_label_set(mi, _("Contents"));
784              e_util_menu_item_theme_icon_set(mi, "list-add");
785              e_menu_item_callback_set(mi, _ibar_cb_menu_icon_add, NULL);
786           }
787
788         mi = e_menu_item_new(m);
789         e_menu_item_label_set(mi, _("Settings"));
790         e_util_menu_item_theme_icon_set(mi, "configure");
791         e_menu_item_callback_set(mi, _ibar_cb_menu_configuration, ic->ibar);
792
793         m = e_gadcon_client_util_menu_items_append(ic->ibar->inst->gcc, m, 0);
794         e_menu_post_deactivate_callback_set(m, _ibar_cb_menu_post, NULL);
795         ibar_config->menu = m;
796
797         mi = e_menu_item_new(mo);
798         e_menu_item_label_set(mi, _("Properties"));
799         e_util_menu_item_theme_icon_set(mi, "configure");
800         e_menu_item_callback_set(mi, _ibar_cb_menu_icon_properties, ic);
801
802         mi = e_menu_item_new(mo);
803         e_menu_item_label_set(mi, _("Remove"));
804         e_util_menu_item_theme_icon_set(mi, "list-remove");
805         e_menu_item_callback_set(mi, _ibar_cb_menu_icon_remove, ic);
806
807         mi = e_menu_item_new_relative(m, NULL);
808         snprintf(buf, sizeof(buf), "Icon %s", ic->app->name);
809         e_menu_item_label_set(mi, _(buf));
810         e_util_desktop_menu_item_icon_add(ic->app, 
811                                           e_util_icon_size_normalize(24 * e_scale), 
812                                           mi);
813         e_menu_item_submenu_set(mi, mo);
814
815         e_gadcon_canvas_zone_geometry_get(ic->ibar->inst->gcc->gadcon,
816                                           &cx, &cy, NULL, NULL);
817         e_menu_activate_mouse(m,
818                               e_util_zone_current_get(e_manager_current_get()),
819                               cx + ev->output.x, cy + ev->output.y, 1, 1,
820                               E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
821      }
822 }
823
824 static void
825 _ibar_cb_icon_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
826 {
827    Evas_Event_Mouse_Up *ev;
828    IBar_Icon *ic;
829
830    ev = event_info;
831    ic = data;
832
833    if ((ev->button == 1) && (ic->mouse_down == 1))
834      {
835         if (!ic->drag.dnd)
836           {
837              if (ic->app->type == EFREET_DESKTOP_TYPE_APPLICATION)
838                e_exec(ic->ibar->inst->gcc->gadcon->zone, ic->app, NULL, NULL, "ibar");
839              else if (ic->app->type == EFREET_DESKTOP_TYPE_LINK)
840                {
841                   if (!strncasecmp(ic->app->url, "file:", 5))
842                     {
843                        E_Action *act;
844
845                        act = e_action_find("fileman");
846                        if (act) act->func.go(E_OBJECT(obj), ic->app->url + 5);
847                     }
848                }
849              /* TODO: bring back "e,action,start|stop" for the startup_notify apps
850               *       when startup_notify is used again
851               */
852              _ibar_icon_signal_emit(ic, "e,action,exec", "e");
853           }
854         ic->drag.start = 0;
855         ic->drag.dnd = 0;
856         ic->mouse_down = 0;
857      }
858 }
859
860 static void
861 _ibar_cb_icon_mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
862 {
863    Evas_Event_Mouse_Move *ev;
864    IBar_Icon *ic;
865
866    ev = event_info;
867    ic = data;
868    if (ic->drag.start)
869      {
870         int dx, dy;
871
872         dx = ev->cur.output.x - ic->drag.x;
873         dy = ev->cur.output.y - ic->drag.y;
874         if (((dx * dx) + (dy * dy)) >
875             (e_config->drag_resist * e_config->drag_resist))
876           {
877              E_Drag *d;
878              Evas_Object *o;
879              Evas_Coord x, y, w, h;
880              unsigned int size;
881              const char *drag_types[] = { "enlightenment/desktop" };
882              E_Gadcon_Client *gc;
883
884              ic->drag.dnd = 1;
885              ic->drag.start = 0;
886
887              if (ic->ibar->inst->ci->lock_move) return;
888
889              evas_object_geometry_get(ic->o_icon, &x, &y, &w, &h);
890              d = e_drag_new(ic->ibar->inst->gcc->gadcon->zone->container,
891                             x, y, drag_types, 1,
892                             ic->app, -1, NULL, _ibar_cb_drag_finished);
893              efreet_desktop_ref(ic->app);
894              size = MAX(w, h);
895              o = e_util_desktop_icon_add(ic->app, size, e_drag_evas_get(d));
896              e_drag_object_set(d, o);
897
898              e_drag_resize(d, w, h);
899              e_drag_start(d, ic->drag.x, ic->drag.y);
900              ic->ibar->icons = eina_list_remove(ic->ibar->icons, ic);
901              _ibar_resize_handle(ic->ibar);
902              gc = ic->ibar->inst->gcc;
903              _gc_orient(gc, -1);
904              e_order_remove(ic->ibar->apps, ic->app);
905              _ibar_icon_free(ic);
906           }
907      }
908 }
909
910 static void
911 _ibar_cb_icon_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
912 {
913    IBar_Icon *ic;
914    Evas_Coord x, y;
915
916    ic = data;
917    evas_object_geometry_get(ic->o_holder, &x, &y, NULL, NULL);
918    evas_object_move(ic->o_holder2, x, y);
919    evas_object_raise(ic->o_holder2);
920 }
921
922 static void
923 _ibar_cb_icon_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
924 {
925    IBar_Icon *ic;
926    Evas_Coord w, h;
927
928    ic = data;
929    evas_object_geometry_get(ic->o_holder, NULL, NULL, &w, &h);
930    evas_object_resize(ic->o_holder2, w, h);
931    evas_object_raise(ic->o_holder2);
932 }
933
934 static void
935 _ibar_cb_drop_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
936 {
937    IBar *b;
938    Evas_Coord x, y;
939
940    b = data;
941    evas_object_geometry_get(b->o_drop, &x, &y, NULL, NULL);
942    evas_object_move(b->o_drop_over, x, y);
943 }
944
945 static void
946 _ibar_cb_drop_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
947 {
948    IBar *b;
949    Evas_Coord w, h;
950
951    b = data;
952    evas_object_geometry_get(b->o_drop, NULL, NULL, &w, &h);
953    evas_object_resize(b->o_drop_over, w, h);
954 }
955
956 static void
957 _ibar_cb_drag_finished(E_Drag *drag, int dropped __UNUSED__)
958 {
959    efreet_desktop_unref(drag->data);
960 }
961
962 static void
963 _ibar_inst_cb_scroll(void *data)
964 {
965    Instance *inst;
966
967    /* Update the position of the dnd to handle for autoscrolling
968     * gadgets. */
969    inst = data;
970    _ibar_drop_position_update(inst, inst->ibar->dnd_x, inst->ibar->dnd_y);
971 }
972
973 static void
974 _ibar_drop_position_update(Instance *inst, Evas_Coord x, Evas_Coord y)
975 {
976    IBar_Icon *ic;
977
978    inst->ibar->dnd_x = x;
979    inst->ibar->dnd_y = y;
980
981    if (inst->ibar->o_drop) e_box_unpack(inst->ibar->o_drop);
982    ic = _ibar_icon_at_coord(inst->ibar, x, y);
983
984    inst->ibar->ic_drop_before = ic;
985    if (ic)
986      {
987         Evas_Coord ix, iy, iw, ih;
988         int before = 0;
989
990         evas_object_geometry_get(ic->o_holder, &ix, &iy, &iw, &ih);
991         if (e_box_orientation_get(inst->ibar->o_box))
992           {
993              if (x < (ix + (iw / 2))) before = 1;
994           }
995         else
996           {
997              if (y < (iy + (ih / 2))) before = 1;
998           }
999         if (before)
1000           e_box_pack_before(inst->ibar->o_box, inst->ibar->o_drop, ic->o_holder);
1001         else
1002           e_box_pack_after(inst->ibar->o_box, inst->ibar->o_drop, ic->o_holder);
1003         inst->ibar->drop_before = before;
1004      }
1005    else e_box_pack_end(inst->ibar->o_box, inst->ibar->o_drop);
1006    e_box_pack_options_set(inst->ibar->o_drop,
1007                           1, 1, /* fill */
1008                           1, 1, /* expand */
1009                           0.5, 0.5, /* align */
1010                           1, 1, /* min */
1011                           -1, -1 /* max */
1012                           );
1013    _ibar_resize_handle(inst->ibar);
1014    _gc_orient(inst->gcc, -1);
1015 }
1016
1017 static void
1018 _ibar_inst_cb_enter(void *data, const char *type __UNUSED__, void *event_info)
1019 {
1020    E_Event_Dnd_Enter *ev;
1021    Instance *inst;
1022    Evas_Object *o, *o2;
1023
1024    ev = event_info;
1025    inst = data;
1026    o = edje_object_add(evas_object_evas_get(inst->ibar->o_box));
1027    inst->ibar->o_drop = o;
1028    o2 = edje_object_add(evas_object_evas_get(inst->ibar->o_box));
1029    inst->ibar->o_drop_over = o2;
1030    evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE, 
1031                                   _ibar_cb_drop_move, inst->ibar);
1032    evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, 
1033                                   _ibar_cb_drop_resize, inst->ibar);
1034    e_theme_edje_object_set(o, "base/theme/modules/ibar",
1035                            "e/modules/ibar/drop");
1036    e_theme_edje_object_set(o2, "base/theme/modules/ibar",
1037                            "e/modules/ibar/drop_overlay");
1038    evas_object_layer_set(o2, 19999);
1039    evas_object_show(o);
1040    evas_object_show(o2);
1041
1042    _ibar_drop_position_update(inst, ev->x, ev->y);
1043    e_gadcon_client_autoscroll_cb_set(inst->gcc, _ibar_inst_cb_scroll, inst);
1044    e_gadcon_client_autoscroll_update(inst->gcc, ev->x, ev->y);
1045 }
1046
1047 static void
1048 _ibar_inst_cb_move(void *data, const char *type __UNUSED__, void *event_info)
1049 {
1050    E_Event_Dnd_Move *ev;
1051    Instance *inst;
1052
1053    ev = event_info;
1054    inst = data;
1055    _ibar_drop_position_update(inst, ev->x, ev->y);
1056    e_gadcon_client_autoscroll_update(inst->gcc, ev->x, ev->y);
1057 }
1058
1059 static void
1060 _ibar_inst_cb_leave(void *data, const char *type __UNUSED__, void *event_info __UNUSED__)
1061 {
1062    Instance *inst;
1063
1064    inst = data;
1065    inst->ibar->ic_drop_before = NULL;
1066    evas_object_del(inst->ibar->o_drop);
1067    inst->ibar->o_drop = NULL;
1068    evas_object_del(inst->ibar->o_drop_over);
1069    inst->ibar->o_drop_over = NULL;
1070    _ibar_resize_handle(inst->ibar);
1071    e_gadcon_client_autoscroll_cb_set(inst->gcc, NULL, NULL);
1072    _gc_orient(inst->gcc, -1);
1073 }
1074
1075 static void
1076 _ibar_inst_cb_drop(void *data, const char *type, void *event_info)
1077 {
1078    E_Event_Dnd_Drop *ev;
1079    Instance *inst;
1080    Efreet_Desktop *app = NULL;
1081    Eina_List *fl = NULL;
1082    IBar_Icon *ic;
1083
1084    ev = event_info;
1085    inst = data;
1086
1087    if (!strcmp(type, "enlightenment/desktop"))
1088      app = ev->data;
1089    else if (!strcmp(type, "enlightenment/border"))
1090      {
1091         E_Border *bd;
1092
1093         bd = ev->data;
1094         app = bd->desktop;
1095         if (!app)
1096           {
1097              app = e_desktop_border_create(bd);
1098              efreet_desktop_save(app);
1099              e_desktop_edit(e_container_current_get(e_manager_current_get()), 
1100                             app);
1101           }
1102      }
1103    else if (!strcmp(type, "text/uri-list"))
1104      fl = ev->data;
1105
1106    ic = inst->ibar->ic_drop_before;
1107    if (ic)
1108      {
1109         /* Add new eapp before this icon */
1110         if (!inst->ibar->drop_before)
1111           {
1112              const Eina_List *l;
1113              IBar_Icon *ic2;
1114
1115              EINA_LIST_FOREACH(inst->ibar->icons, l, ic2)
1116                {
1117                   if (ic2 == ic)
1118                     {
1119                        if (l->next)
1120                          ic = l->next->data;
1121                        else
1122                          ic = NULL;
1123                        break;
1124                     }
1125                }
1126           }
1127         if (!ic) goto atend;
1128         if (app)
1129           e_order_prepend_relative(ic->ibar->apps, app, ic->app);
1130         else if (fl)
1131           e_order_files_prepend_relative(ic->ibar->apps, fl, ic->app);
1132      }
1133    else
1134      {
1135         atend:
1136         if (inst->ibar->apps)
1137           {
1138              if (app)
1139                e_order_append(inst->ibar->apps, app);
1140              else if (fl)
1141                e_order_files_append(inst->ibar->apps, fl);
1142           }
1143      }
1144    evas_object_del(inst->ibar->o_drop);
1145    inst->ibar->o_drop = NULL;
1146    evas_object_del(inst->ibar->o_drop_over);
1147    inst->ibar->o_drop_over = NULL;
1148    e_gadcon_client_autoscroll_cb_set(inst->gcc, NULL, NULL);
1149    _ibar_empty_handle(inst->ibar);
1150    _ibar_resize_handle(inst->ibar);
1151    _gc_orient(inst->gcc, -1);
1152 }
1153
1154 /* module setup */
1155 EAPI E_Module_Api e_modapi =
1156 {
1157    E_MODULE_API_VERSION, "IBar"
1158 };
1159
1160 EAPI void *
1161 e_modapi_init(E_Module *m)
1162 {
1163    conf_item_edd = E_CONFIG_DD_NEW("IBar_Config_Item", Config_Item);
1164 #undef T
1165 #undef D
1166 #define T Config_Item
1167 #define D conf_item_edd
1168    E_CONFIG_VAL(D, T, id, STR);
1169    E_CONFIG_VAL(D, T, dir, STR);
1170    E_CONFIG_VAL(D, T, show_label, INT);
1171    E_CONFIG_VAL(D, T, eap_label, INT);
1172    E_CONFIG_VAL(D, T, lock_move, INT);
1173
1174    conf_edd = E_CONFIG_DD_NEW("IBar_Config", Config);
1175 #undef T
1176 #undef D
1177 #define T Config
1178 #define D conf_edd
1179    E_CONFIG_LIST(D, T, items, conf_item_edd);
1180
1181    ibar_config = e_config_domain_load("module.ibar", conf_edd);
1182
1183    if (!ibar_config)
1184      {
1185         Config_Item *ci;
1186
1187         ibar_config = E_NEW(Config, 1);
1188
1189         ci = E_NEW(Config_Item, 1);
1190         ci->id = eina_stringshare_add("ibar.1");
1191         ci->dir = eina_stringshare_add("default");
1192         ci->show_label = 1;
1193         ci->eap_label = 0;
1194         ci->lock_move= 0;
1195
1196         ibar_config->items = eina_list_append(ibar_config->items, ci);
1197      }
1198  
1199    ibar_config->module = m;
1200
1201    ibar_config->handlers = 
1202      eina_list_append(ibar_config->handlers,
1203                       ecore_event_handler_add(E_EVENT_CONFIG_ICON_THEME, 
1204                                               _ibar_cb_config_icons, NULL));
1205    ibar_config->handlers = 
1206      eina_list_append(ibar_config->handlers,
1207                       ecore_event_handler_add(EFREET_EVENT_ICON_CACHE_UPDATE,
1208                                               _ibar_cb_config_icons, NULL));
1209
1210    e_gadcon_provider_register(&_gadcon_class);
1211    return m;
1212 }
1213
1214 EAPI int
1215 e_modapi_shutdown(E_Module *m __UNUSED__)
1216 {
1217    Ecore_Event_Handler *eh;
1218    Config_Item *ci;
1219
1220    e_gadcon_provider_unregister(&_gadcon_class);
1221
1222    if (ibar_config->config_dialog)
1223      e_object_del(E_OBJECT(ibar_config->config_dialog));
1224
1225    EINA_LIST_FREE(ibar_config->handlers, eh)
1226      ecore_event_handler_del(eh);
1227
1228    if (ibar_config->menu)
1229      {
1230         e_menu_post_deactivate_callback_set(ibar_config->menu, NULL, NULL);
1231         e_object_del(E_OBJECT(ibar_config->menu));
1232         ibar_config->menu = NULL;
1233      }
1234
1235    EINA_LIST_FREE(ibar_config->items, ci)
1236      {
1237         if (ci->id) eina_stringshare_del(ci->id);
1238         if (ci->dir) eina_stringshare_del(ci->dir);
1239         E_FREE(ci);
1240      }
1241    E_FREE(ibar_config);
1242    ibar_config = NULL;
1243    E_CONFIG_DD_FREE(conf_item_edd);
1244    E_CONFIG_DD_FREE(conf_edd);
1245    return 1;
1246 }
1247
1248 EAPI int
1249 e_modapi_save(E_Module *m __UNUSED__)
1250 {
1251    e_config_domain_save("module.ibar", conf_edd, ibar_config);
1252    return 1;
1253 }
1254
1255 static Eina_Bool
1256 _ibar_cb_config_icons(__UNUSED__ void *data, __UNUSED__ int ev_type, __UNUSED__ void *ev)
1257 {
1258    const Eina_List *l;
1259    Instance *inst;
1260
1261    EINA_LIST_FOREACH(ibar_config->instances, l, inst)
1262      {
1263         const Eina_List *l2;
1264         IBar_Icon *icon;
1265
1266         EINA_LIST_FOREACH(inst->ibar->icons, l2, icon)
1267           _ibar_icon_fill(icon);
1268      }
1269    return ECORE_CALLBACK_PASS_ON;
1270 }