2 #include "e_mod_main.h"
5 # define MAX(x, y) (((x) > (y)) ? (x) : (y))
9 * - Track execution status
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);
21 /* and actually define the gadcon class that this module provides (just 1) */
22 static const E_Gadcon_Client_Class _gadcon_class =
24 GADCON_CLIENT_CLASS_VERSION,
27 _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, _gc_id_del,
28 e_gadcon_site_is_not_toolbar
30 E_GADCON_CLIENT_STYLE_INSET
33 /* actual module specifics */
34 typedef struct _Instance Instance;
35 typedef struct _IBar IBar;
36 typedef struct _IBar_Icon IBar_Icon;
43 E_Drop_Handler *drop_handler;
45 E_Gadcon_Orient orient;
51 Evas_Object *o_box, *o_drop;
52 Evas_Object *o_drop_over, *o_empty;
53 IBar_Icon *ic_drop_before;
57 Evas_Coord dnd_x, dnd_y;
63 Evas_Object *o_holder, *o_icon;
64 Evas_Object *o_holder2, *o_icon2;
69 unsigned char start : 1;
70 unsigned char dnd : 1;
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);
115 static E_Config_DD *conf_edd = NULL;
116 static E_Config_DD *conf_item_edd = NULL;
118 Config *ibar_config = NULL;
120 static E_Gadcon_Client *
121 _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
125 E_Gadcon_Client *gcc;
127 Evas_Coord x, y, w, h;
128 const char *drop[] = { "enlightenment/desktop", "enlightenment/border", "text/uri-list" };
131 inst = E_NEW(Instance, 1);
133 ci = _ibar_config_item_get(id);
135 if (!ci->dir) ci->dir = eina_stringshare_add("default");
136 b = _ibar_new(gc->evas, inst);
138 gcc = e_gadcon_client_new(gc, name, id, style, o);
143 inst->orient = E_GADCON_ORIENT_HORIZ;
145 evas_object_geometry_get(o, &x, &y, &w, &h);
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);
160 _gc_shutdown(E_Gadcon_Client *gcc)
165 ibar_config->instances = eina_list_remove(ibar_config->instances, inst);
166 e_drop_handler_del(inst->drop_handler);
167 _ibar_free(inst->ibar);
172 _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
177 if ((int)orient != -1) inst->orient = orient;
179 switch (inst->orient)
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);
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);
205 e_gadcon_client_min_size_set(gcc, 16, 16);
209 _gc_label(E_Gadcon_Client_Class *client_class __UNUSED__)
215 _gc_icon(E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
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");
228 _gc_id_new(E_Gadcon_Client_Class *client_class __UNUSED__)
232 ci = _ibar_config_item_get(NULL);
237 _gc_id_del(E_Gadcon_Client_Class *client_class __UNUSED__, const char *id __UNUSED__)
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
245 ci = _ibar_config_item_get(id);
248 if (ci->id) eina_stringshare_del(ci->id);
249 ibar_config->items = eina_list_remove(ibar_config->items, ci);
255 _ibar_new(Evas *evas, Instance *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",
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);
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));
292 _ibar_cb_empty_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
294 Evas_Event_Mouse_Down *ev;
299 if (!ibar_config->menu)
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);
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;
315 e_gadcon_canvas_zone_geometry_get(b->inst->gcc->gadcon,
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);
325 _ibar_empty_handle(IBar *b)
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))
345 e_box_pack_options_set(b->o_empty,
348 0.5, 0.5, /* align */
356 evas_object_del(b->o_empty);
366 Efreet_Desktop *desktop;
369 EINA_LIST_FOREACH(b->apps->desktops, l, desktop)
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);
376 _ibar_empty_handle(b);
377 _ibar_resize_handle(b);
385 EINA_LIST_FREE(b->icons, ic)
388 _ibar_empty_handle(b);
392 _ibar_orient_set(IBar *b, int horizontal)
394 e_box_orientation_set(b->o_box, horizontal);
395 e_box_align_set(b->o_box, 0.5, 0.5);
399 _ibar_resize_handle(IBar *b)
405 evas_object_geometry_get(b->o_box, NULL, NULL, &w, &h);
406 if (e_box_orientation_get(b->o_box))
410 e_box_freeze(b->o_box);
411 EINA_LIST_FOREACH(b->icons, l, ic)
413 e_box_pack_options_set(ic->o_holder,
416 0.5, 0.5, /* align */
421 e_box_thaw(b->o_box);
425 _ibar_instance_drop_zone_recalc(Instance *inst)
427 Evas_Coord x, y, w, h;
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);
434 _ibar_config_item_get(const char *id)
438 GADCON_CLIENT_CONFIG_GET(Config_Item, ibar_config->items, _gadcon_class, id);
440 ci = E_NEW(Config_Item, 1);
441 ci->id = eina_stringshare_add(id);
442 ci->dir = eina_stringshare_add("default");
447 ibar_config->items = eina_list_append(ibar_config->items, ci);
452 _ibar_config_update(Config_Item *ci)
457 EINA_LIST_FOREACH(ibar_config->instances, l, inst)
463 if (inst->ci != ci) continue;
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",
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);
478 EINA_LIST_FOREACH(inst->ibar->icons, i, ic)
480 switch (ci->eap_label)
483 edje_object_part_text_set(ic->o_holder2, "e.text.label",
487 edje_object_part_text_set(ic->o_holder2, "e.text.label",
491 edje_object_part_text_set(ic->o_holder2, "e.text.label",
492 ic->app->generic_name);
500 _ibar_icon_at_coord(IBar *b, Evas_Coord x, Evas_Coord y)
505 EINA_LIST_FOREACH(b->icons, l, ic)
507 Evas_Coord dx, dy, dw, dh;
509 evas_object_geometry_get(ic->o_holder, &dx, &dy, &dw, &dh);
510 if (E_INSIDE(x, y, dx, dy, dw, dh)) return ic;
516 _ibar_icon_new(IBar *b, Efreet_Desktop *desktop)
520 ic = E_NEW(IBar_Icon, 1);
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);
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);
554 _ibar_icon_free(IBar_Icon *ic)
556 if (ibar_config->menu)
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;
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);
571 _ibar_icon_fill(IBar_Icon *ic)
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);
586 switch (ic->ibar->inst->ci->eap_label)
588 case 0: /* Eap Name */
589 edje_object_part_text_set(ic->o_holder2, "e.text.label", ic->app->name);
591 case 1: /* Eap Comment */
592 edje_object_part_text_set(ic->o_holder2, "e.text.label", ic->app->comment);
594 case 2: /* Eap Generic */
595 edje_object_part_text_set(ic->o_holder2, "e.text.label", ic->app->generic_name);
601 _ibar_icon_empty(IBar_Icon *ic)
603 if (ic->o_icon) evas_object_del(ic->o_icon);
604 if (ic->o_icon2) evas_object_del(ic->o_icon2);
610 _ibar_icon_signal_emit(IBar_Icon *ic, char *sig, char *src)
613 edje_object_signal_emit(ic->o_holder, sig, src);
615 edje_object_signal_emit(ic->o_icon, sig, src);
617 edje_object_signal_emit(ic->o_holder2, sig, src);
619 edje_object_signal_emit(ic->o_icon2, sig, src);
623 _ibar_cb_app_change(void *data, E_Order *eo __UNUSED__)
628 if (!b->apps) return;
631 _ibar_resize_handle(b);
632 if (b->inst) _gc_orient(b->inst->gcc, -1);
636 _ibar_cb_obj_moveresize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
641 _ibar_resize_handle(inst->ibar);
642 _ibar_instance_drop_zone_recalc(inst);
646 _ibar_cb_menu_icon_new(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
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);
656 _ibar_cb_menu_icon_add(void *data __UNUSED__, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
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);
666 _ibar_cb_menu_icon_properties(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
671 e_desktop_edit(ic->ibar->inst->gcc->gadcon->zone->container, ic->app);
675 _ibar_cb_menu_icon_remove(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
681 ic->ibar->icons = eina_list_remove(ic->ibar->icons, ic);
682 _ibar_resize_handle(ic->ibar);
683 gc = ic->ibar->inst->gcc;
685 e_order_remove(ic->ibar->apps, ic->app);
690 _ibar_cb_menu_configuration(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
695 _config_ibar_module(b->inst->ci);
700 _ibar_cb_menu_add(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
705 e_configure_registry_call("internal/ibar_other",
706 b->inst->gcc->gadcon->zone->container,
712 _ibar_cb_menu_post(void *data __UNUSED__, E_Menu *m __UNUSED__)
714 if (!ibar_config->menu) return;
715 e_object_del(E_OBJECT(ibar_config->menu));
716 ibar_config->menu = NULL;
720 _ibar_cb_icon_mouse_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
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");
731 _ibar_cb_icon_mouse_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
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");
742 _ibar_cb_icon_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
744 Evas_Event_Mouse_Down *ev;
751 ic->drag.x = ev->output.x;
752 ic->drag.y = ev->output.y;
757 else if ((ev->button == 3) && (!ibar_config->menu))
766 /* FIXME: other icon options go here too */
769 if (e_configure_registry_exists("applications/new_application"))
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);
776 mi = e_menu_item_new(m);
777 e_menu_item_separator_set(mi, 1);
780 if (e_configure_registry_exists("applications/ibar_applications"))
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);
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);
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;
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);
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);
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),
813 e_menu_item_submenu_set(mi, mo);
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);
825 _ibar_cb_icon_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj, void *event_info)
827 Evas_Event_Mouse_Up *ev;
833 if ((ev->button == 1) && (ic->mouse_down == 1))
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)
841 if (!strncasecmp(ic->app->url, "file:", 5))
845 act = e_action_find("fileman");
846 if (act) act->func.go(E_OBJECT(obj), ic->app->url + 5);
849 /* TODO: bring back "e,action,start|stop" for the startup_notify apps
850 * when startup_notify is used again
852 _ibar_icon_signal_emit(ic, "e,action,exec", "e");
861 _ibar_cb_icon_mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
863 Evas_Event_Mouse_Move *ev;
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))
879 Evas_Coord x, y, w, h;
881 const char *drag_types[] = { "enlightenment/desktop" };
887 if (ic->ibar->inst->ci->lock_move) return;
889 evas_object_geometry_get(ic->o_icon, &x, &y, &w, &h);
890 d = e_drag_new(ic->ibar->inst->gcc->gadcon->zone->container,
892 ic->app, -1, NULL, _ibar_cb_drag_finished);
893 efreet_desktop_ref(ic->app);
895 o = e_util_desktop_icon_add(ic->app, size, e_drag_evas_get(d));
896 e_drag_object_set(d, o);
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;
904 e_order_remove(ic->ibar->apps, ic->app);
911 _ibar_cb_icon_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
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);
923 _ibar_cb_icon_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
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);
935 _ibar_cb_drop_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
941 evas_object_geometry_get(b->o_drop, &x, &y, NULL, NULL);
942 evas_object_move(b->o_drop_over, x, y);
946 _ibar_cb_drop_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
952 evas_object_geometry_get(b->o_drop, NULL, NULL, &w, &h);
953 evas_object_resize(b->o_drop_over, w, h);
957 _ibar_cb_drag_finished(E_Drag *drag, int dropped __UNUSED__)
959 efreet_desktop_unref(drag->data);
963 _ibar_inst_cb_scroll(void *data)
967 /* Update the position of the dnd to handle for autoscrolling
970 _ibar_drop_position_update(inst, inst->ibar->dnd_x, inst->ibar->dnd_y);
974 _ibar_drop_position_update(Instance *inst, Evas_Coord x, Evas_Coord y)
978 inst->ibar->dnd_x = x;
979 inst->ibar->dnd_y = y;
981 if (inst->ibar->o_drop) e_box_unpack(inst->ibar->o_drop);
982 ic = _ibar_icon_at_coord(inst->ibar, x, y);
984 inst->ibar->ic_drop_before = ic;
987 Evas_Coord ix, iy, iw, ih;
990 evas_object_geometry_get(ic->o_holder, &ix, &iy, &iw, &ih);
991 if (e_box_orientation_get(inst->ibar->o_box))
993 if (x < (ix + (iw / 2))) before = 1;
997 if (y < (iy + (ih / 2))) before = 1;
1000 e_box_pack_before(inst->ibar->o_box, inst->ibar->o_drop, ic->o_holder);
1002 e_box_pack_after(inst->ibar->o_box, inst->ibar->o_drop, ic->o_holder);
1003 inst->ibar->drop_before = before;
1005 else e_box_pack_end(inst->ibar->o_box, inst->ibar->o_drop);
1006 e_box_pack_options_set(inst->ibar->o_drop,
1009 0.5, 0.5, /* align */
1013 _ibar_resize_handle(inst->ibar);
1014 _gc_orient(inst->gcc, -1);
1018 _ibar_inst_cb_enter(void *data, const char *type __UNUSED__, void *event_info)
1020 E_Event_Dnd_Enter *ev;
1022 Evas_Object *o, *o2;
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);
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);
1048 _ibar_inst_cb_move(void *data, const char *type __UNUSED__, void *event_info)
1050 E_Event_Dnd_Move *ev;
1055 _ibar_drop_position_update(inst, ev->x, ev->y);
1056 e_gadcon_client_autoscroll_update(inst->gcc, ev->x, ev->y);
1060 _ibar_inst_cb_leave(void *data, const char *type __UNUSED__, void *event_info __UNUSED__)
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);
1076 _ibar_inst_cb_drop(void *data, const char *type, void *event_info)
1078 E_Event_Dnd_Drop *ev;
1080 Efreet_Desktop *app = NULL;
1081 Eina_List *fl = NULL;
1087 if (!strcmp(type, "enlightenment/desktop"))
1089 else if (!strcmp(type, "enlightenment/border"))
1097 app = e_desktop_border_create(bd);
1098 efreet_desktop_save(app);
1099 e_desktop_edit(e_container_current_get(e_manager_current_get()),
1103 else if (!strcmp(type, "text/uri-list"))
1106 ic = inst->ibar->ic_drop_before;
1109 /* Add new eapp before this icon */
1110 if (!inst->ibar->drop_before)
1115 EINA_LIST_FOREACH(inst->ibar->icons, l, ic2)
1127 if (!ic) goto atend;
1129 e_order_prepend_relative(ic->ibar->apps, app, ic->app);
1131 e_order_files_prepend_relative(ic->ibar->apps, fl, ic->app);
1136 if (inst->ibar->apps)
1139 e_order_append(inst->ibar->apps, app);
1141 e_order_files_append(inst->ibar->apps, fl);
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);
1155 EAPI E_Module_Api e_modapi =
1157 E_MODULE_API_VERSION, "IBar"
1161 e_modapi_init(E_Module *m)
1163 conf_item_edd = E_CONFIG_DD_NEW("IBar_Config_Item", Config_Item);
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);
1174 conf_edd = E_CONFIG_DD_NEW("IBar_Config", Config);
1179 E_CONFIG_LIST(D, T, items, conf_item_edd);
1181 ibar_config = e_config_domain_load("module.ibar", conf_edd);
1187 ibar_config = E_NEW(Config, 1);
1189 ci = E_NEW(Config_Item, 1);
1190 ci->id = eina_stringshare_add("ibar.1");
1191 ci->dir = eina_stringshare_add("default");
1196 ibar_config->items = eina_list_append(ibar_config->items, ci);
1199 ibar_config->module = m;
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));
1210 e_gadcon_provider_register(&_gadcon_class);
1215 e_modapi_shutdown(E_Module *m __UNUSED__)
1217 Ecore_Event_Handler *eh;
1220 e_gadcon_provider_unregister(&_gadcon_class);
1222 if (ibar_config->config_dialog)
1223 e_object_del(E_OBJECT(ibar_config->config_dialog));
1225 EINA_LIST_FREE(ibar_config->handlers, eh)
1226 ecore_event_handler_del(eh);
1228 if (ibar_config->menu)
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;
1235 EINA_LIST_FREE(ibar_config->items, ci)
1237 if (ci->id) eina_stringshare_del(ci->id);
1238 if (ci->dir) eina_stringshare_del(ci->dir);
1241 E_FREE(ibar_config);
1243 E_CONFIG_DD_FREE(conf_item_edd);
1244 E_CONFIG_DD_FREE(conf_edd);
1249 e_modapi_save(E_Module *m __UNUSED__)
1251 e_config_domain_save("module.ibar", conf_edd, ibar_config);
1256 _ibar_cb_config_icons(__UNUSED__ void *data, __UNUSED__ int ev_type, __UNUSED__ void *ev)
1261 EINA_LIST_FOREACH(ibar_config->instances, l, inst)
1263 const Eina_List *l2;
1266 EINA_LIST_FOREACH(inst->ibar->icons, l2, icon)
1267 _ibar_icon_fill(icon);
1269 return ECORE_CALLBACK_PASS_ON;