2 #include "e_mod_main.h"
4 /* gadcon requirements */
5 static E_Gadcon_Client *_gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style);
6 static void _gc_shutdown(E_Gadcon_Client *gcc);
7 static void _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient);
8 static const char *_gc_label(const E_Gadcon_Client_Class *client_class);
9 static Evas_Object *_gc_icon(const E_Gadcon_Client_Class *client_class, Evas *evas);
10 static const char *_gc_id_new(const E_Gadcon_Client_Class *client_class);
11 static void _gc_id_del(const E_Gadcon_Client_Class *client_class, const char *id);
12 /* and actually define the gadcon class that this module provides (just 1) */
13 static const E_Gadcon_Client_Class _gadcon_class =
15 GADCON_CLIENT_CLASS_VERSION,
18 _gc_init, _gc_shutdown, _gc_orient, _gc_label, _gc_icon, _gc_id_new, _gc_id_del,
19 e_gadcon_site_is_not_toolbar
21 E_GADCON_CLIENT_STYLE_INSET
24 /* actual module specifics */
26 typedef struct _Instance Instance;
28 typedef struct _IBox IBox;
29 typedef struct _IBox_Icon IBox_Icon;
36 E_Drop_Handler *drop_handler;
38 E_Gadcon_Orient orient;
46 Evas_Object *o_drop_over;
48 IBox_Icon *ic_drop_before;
52 Evas_Coord dnd_x, dnd_y;
58 Evas_Object *o_holder;
60 Evas_Object *o_holder2;
65 unsigned char start : 1;
66 unsigned char dnd : 1;
72 static IBox *_ibox_new(Evas *evas, E_Zone *zone);
73 static void _ibox_free(IBox *b);
74 static void _ibox_cb_empty_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
75 static void _ibox_empty_handle(IBox *b);
76 static void _ibox_fill(IBox *b);
77 static void _ibox_empty(IBox *b);
78 static void _ibox_orient_set(IBox *b, int horizontal);
79 static void _ibox_resize_handle(IBox *b);
80 static void _ibox_instance_drop_zone_recalc(Instance *inst);
81 static IBox_Icon *_ibox_icon_find(IBox *b, E_Border *bd);
82 static IBox_Icon *_ibox_icon_at_coord(IBox *b, Evas_Coord x, Evas_Coord y);
83 static IBox_Icon *_ibox_icon_new(IBox *b, E_Border *bd);
84 static void _ibox_icon_free(IBox_Icon *ic);
85 static void _ibox_icon_fill(IBox_Icon *ic);
86 static void _ibox_icon_fill_label(IBox_Icon *ic);
87 static void _ibox_icon_empty(IBox_Icon *ic);
88 static void _ibox_icon_signal_emit(IBox_Icon *ic, char *sig, char *src);
89 static Eina_List *_ibox_zone_find(E_Zone *zone);
90 static void _ibox_cb_obj_moveresize(void *data, Evas *e, Evas_Object *obj, void *event_info);
91 static void _ibox_cb_menu_configuration(void *data, E_Menu *m, E_Menu_Item *mi);
92 static void _ibox_cb_icon_mouse_in(void *data, Evas *e, Evas_Object *obj, void *event_info);
93 static void _ibox_cb_icon_mouse_out(void *data, Evas *e, Evas_Object *obj, void *event_info);
94 static void _ibox_cb_icon_mouse_down(void *data, Evas *e, Evas_Object *obj, void *event_info);
95 static void _ibox_cb_icon_mouse_up(void *data, Evas *e, Evas_Object *obj, void *event_info);
96 static void _ibox_cb_icon_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
97 static void _ibox_cb_icon_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
98 static void _ibox_cb_icon_resize(void *data, Evas *e, Evas_Object *obj, void *event_info);
99 static void _ibox_cb_drag_finished(E_Drag *drag, int dropped);
100 static void _ibox_inst_cb_enter(void *data, const char *type, void *event_info);
101 static void _ibox_inst_cb_move(void *data, const char *type, void *event_info);
102 static void _ibox_inst_cb_leave(void *data, const char *type, void *event_info);
103 static void _ibox_inst_cb_drop(void *data, const char *type, void *event_info);
104 static void _ibox_drop_position_update(Instance *inst, Evas_Coord x, Evas_Coord y);
105 static void _ibox_inst_cb_scroll(void *data);
106 static Eina_Bool _ibox_cb_event_border_add(void *data, int type, void *event);
107 static Eina_Bool _ibox_cb_event_border_remove(void *data, int type, void *event);
108 static Eina_Bool _ibox_cb_event_border_iconify(void *data, int type, void *event);
109 static Eina_Bool _ibox_cb_event_border_uniconify(void *data, int type, void *event);
110 static Eina_Bool _ibox_cb_event_border_icon_change(void *data, int type, void *event);
111 static Eina_Bool _ibox_cb_event_border_urgent_change(void *data, int type, void *event);
112 static Eina_Bool _ibox_cb_event_border_zone_set(void *data, int type, void *event);
113 static Eina_Bool _ibox_cb_event_desk_show(void *data, int type, void *event);
114 static Config_Item *_ibox_config_item_get(const char *id);
116 static E_Config_DD *conf_edd = NULL;
117 static E_Config_DD *conf_item_edd = NULL;
119 Config *ibox_config = NULL;
121 static E_Gadcon_Client *
122 _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
126 E_Gadcon_Client *gcc;
128 Evas_Coord x, y, w, h;
129 const char *drop[] = { "enlightenment/border" };
132 inst = E_NEW(Instance, 1);
134 ci = _ibox_config_item_get(id);
137 b = _ibox_new(gc->evas, gc->zone);
142 gcc = e_gadcon_client_new(gc, name, id, style, o);
147 inst->orient = E_GADCON_ORIENT_HORIZ;
149 evas_object_geometry_get(o, &x, &y, &w, &h);
151 e_drop_handler_add(E_OBJECT(inst->gcc), inst,
152 _ibox_inst_cb_enter, _ibox_inst_cb_move,
153 _ibox_inst_cb_leave, _ibox_inst_cb_drop,
154 drop, 1, x, y, w, h);
155 evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE,
156 _ibox_cb_obj_moveresize, inst);
157 evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE,
158 _ibox_cb_obj_moveresize, inst);
159 ibox_config->instances = eina_list_append(ibox_config->instances, inst);
164 _gc_shutdown(E_Gadcon_Client *gcc)
169 ibox_config->instances = eina_list_remove(ibox_config->instances, inst);
170 e_drop_handler_del(inst->drop_handler);
171 _ibox_free(inst->ibox);
176 _gc_orient(E_Gadcon_Client *gcc, E_Gadcon_Orient orient)
181 if ((int)orient != -1) inst->orient = orient;
183 switch (inst->orient)
185 case E_GADCON_ORIENT_FLOAT:
186 case E_GADCON_ORIENT_HORIZ:
187 case E_GADCON_ORIENT_TOP:
188 case E_GADCON_ORIENT_BOTTOM:
189 case E_GADCON_ORIENT_CORNER_TL:
190 case E_GADCON_ORIENT_CORNER_TR:
191 case E_GADCON_ORIENT_CORNER_BL:
192 case E_GADCON_ORIENT_CORNER_BR:
193 _ibox_orient_set(inst->ibox, 1);
194 e_gadcon_client_aspect_set(gcc, eina_list_count(inst->ibox->icons) * 16, 16);
197 case E_GADCON_ORIENT_VERT:
198 case E_GADCON_ORIENT_LEFT:
199 case E_GADCON_ORIENT_RIGHT:
200 case E_GADCON_ORIENT_CORNER_LT:
201 case E_GADCON_ORIENT_CORNER_RT:
202 case E_GADCON_ORIENT_CORNER_LB:
203 case E_GADCON_ORIENT_CORNER_RB:
204 _ibox_orient_set(inst->ibox, 0);
205 e_gadcon_client_aspect_set(gcc, 16, eina_list_count(inst->ibox->icons) * 16);
211 e_gadcon_client_min_size_set(gcc, 16, 16);
215 _gc_label(const E_Gadcon_Client_Class *client_class __UNUSED__)
221 _gc_icon(const E_Gadcon_Client_Class *client_class __UNUSED__, Evas *evas)
226 o = edje_object_add(evas);
227 snprintf(buf, sizeof(buf), "%s/e-module-ibox.edj",
228 e_module_dir_get(ibox_config->module));
229 edje_object_file_set(o, buf, "icon");
234 _gc_id_new(const E_Gadcon_Client_Class *client_class)
236 static char buf[4096];
238 snprintf(buf, sizeof(buf), "%s.%d", client_class->name,
239 eina_list_count(ibox_config->instances) + 1);
244 _gc_id_del(const E_Gadcon_Client_Class *client_class __UNUSED__, const char *id __UNUSED__)
246 /* yes - don't do this. on shutdown gadgets are deleted and this means config
247 * for them is deleted - that means empty config is saved. keep them around
248 * as if u add a gadget back it can pick up its old config again
251 ci = _ibox_config_item_get(id);
254 if (ci->id) eina_stringshare_del(ci->id);
255 ibox_config->items = eina_list_remove(ibox_config->items, ci);
261 _ibox_new(Evas *evas, E_Zone *zone)
266 b->o_box = e_box_add(evas);
267 e_box_homogenous_set(b->o_box, 1);
268 e_box_orientation_set(b->o_box, 1);
269 e_box_align_set(b->o_box, 0.5, 0.5);
278 evas_object_del(b->o_box);
279 if (b->o_drop) evas_object_del(b->o_drop);
280 if (b->o_drop_over) evas_object_del(b->o_drop_over);
281 if (b->o_empty) evas_object_del(b->o_empty);
286 _ibox_cb_empty_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
288 Evas_Event_Mouse_Down *ev;
296 if (ev->button != 3) return;
299 mi = e_menu_item_new(m);
300 e_menu_item_label_set(mi, _("Settings"));
301 e_util_menu_item_theme_icon_set(mi, "configure");
302 e_menu_item_callback_set(mi, _ibox_cb_menu_configuration, b);
304 m = e_gadcon_client_util_menu_items_append(b->inst->gcc, m, 0);
306 e_gadcon_canvas_zone_geometry_get(b->inst->gcc->gadcon,
307 &cx, &cy, NULL, NULL);
308 e_menu_activate_mouse(m,
309 e_util_zone_current_get(e_manager_current_get()),
310 cx + ev->output.x, cy + ev->output.y, 1, 1,
311 E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
312 evas_event_feed_mouse_up(b->inst->gcc->gadcon->evas, ev->button,
313 EVAS_BUTTON_NONE, ev->timestamp, NULL);
317 _ibox_empty_handle(IBox *b)
325 b->o_empty = evas_object_rectangle_add(evas_object_evas_get(b->o_box));
326 evas_object_event_callback_add(b->o_empty, EVAS_CALLBACK_MOUSE_DOWN, _ibox_cb_empty_mouse_down, b);
327 evas_object_color_set(b->o_empty, 0, 0, 0, 0);
328 evas_object_show(b->o_empty);
329 e_box_pack_end(b->o_box, b->o_empty);
330 evas_object_geometry_get(b->o_box, NULL, NULL, &w, &h);
331 if (e_box_orientation_get(b->o_box))
335 e_box_pack_options_set(b->o_empty,
338 0.5, 0.5, /* align */
346 evas_object_del(b->o_empty);
359 bl = e_container_border_list_first(b->zone->container);
360 while ((bd = e_container_border_list_next(bl)))
363 if ((b->inst->ci->show_zone == 0) && (bd->iconic))
367 else if ((b->inst->ci->show_zone == 1) && (bd->iconic))
373 else if ((b->inst->ci->show_desk == 0) && (bd->zone == b->zone))
377 else if ((b->inst->ci->show_desk == 1) && (bd->zone == b->zone) &&
378 (bd->desk == e_desk_current_get(b->zone)))
386 ic = _ibox_icon_new(b, bd);
387 b->icons = eina_list_append(b->icons, ic);
388 e_box_pack_end(b->o_box, ic->o_holder);
391 e_container_border_list_free(bl);
393 _ibox_empty_handle(b);
394 _ibox_resize_handle(b);
402 _ibox_icon_free(b->icons->data);
403 b->icons = eina_list_remove_list(b->icons, b->icons);
405 _ibox_empty_handle(b);
409 _ibox_orient_set(IBox *b, int horizontal)
411 e_box_orientation_set(b->o_box, horizontal);
412 e_box_align_set(b->o_box, 0.5, 0.5);
416 _ibox_resize_handle(IBox *b)
422 evas_object_geometry_get(b->o_box, NULL, NULL, &w, &h);
423 if (e_box_orientation_get(b->o_box))
427 e_box_freeze(b->o_box);
428 for (l = b->icons; l; l = l->next)
431 e_box_pack_options_set(ic->o_holder,
434 0.5, 0.5, /* align */
439 e_box_thaw(b->o_box);
443 _ibox_instance_drop_zone_recalc(Instance *inst)
445 Evas_Coord x, y, w, h;
447 e_gadcon_client_viewport_geometry_get(inst->gcc, &x, &y, &w, &h);
448 e_drop_handler_geometry_set(inst->drop_handler, x, y, w, h);
452 _ibox_icon_find(IBox *b, E_Border *bd)
457 for (l = b->icons; l; l = l->next)
461 if (ic->border == bd) return ic;
467 _ibox_icon_at_coord(IBox *b, Evas_Coord x, Evas_Coord y)
472 for (l = b->icons; l; l = l->next)
474 Evas_Coord dx, dy, dw, dh;
477 evas_object_geometry_get(ic->o_holder, &dx, &dy, &dw, &dh);
478 if (E_INSIDE(x, y, dx, dy, dw, dh)) return ic;
484 _ibox_icon_new(IBox *b, E_Border *bd)
488 ic = E_NEW(IBox_Icon, 1);
489 e_object_ref(E_OBJECT(bd));
492 ic->o_holder = edje_object_add(evas_object_evas_get(b->o_box));
493 e_theme_edje_object_set(ic->o_holder, "base/theme/modules/ibox",
494 "e/modules/ibox/icon");
495 evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_IN, _ibox_cb_icon_mouse_in, ic);
496 evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_OUT, _ibox_cb_icon_mouse_out, ic);
497 evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_DOWN, _ibox_cb_icon_mouse_down, ic);
498 evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_UP, _ibox_cb_icon_mouse_up, ic);
499 evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOUSE_MOVE, _ibox_cb_icon_mouse_move, ic);
500 evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_MOVE, _ibox_cb_icon_move, ic);
501 evas_object_event_callback_add(ic->o_holder, EVAS_CALLBACK_RESIZE, _ibox_cb_icon_resize, ic);
502 evas_object_show(ic->o_holder);
504 ic->o_holder2 = edje_object_add(evas_object_evas_get(b->o_box));
505 e_theme_edje_object_set(ic->o_holder2, "base/theme/modules/ibox",
506 "e/modules/ibox/icon_overlay");
507 evas_object_layer_set(ic->o_holder2, 9999);
508 evas_object_pass_events_set(ic->o_holder2, 1);
509 evas_object_show(ic->o_holder2);
516 _ibox_icon_free(IBox_Icon *ic)
518 if (ic->ibox->ic_drop_before == ic)
519 ic->ibox->ic_drop_before = NULL;
520 _ibox_icon_empty(ic);
521 evas_object_del(ic->o_holder);
522 evas_object_del(ic->o_holder2);
523 e_object_unref(E_OBJECT(ic->border));
528 _ibox_icon_fill(IBox_Icon *ic)
530 ic->o_icon = e_border_icon_add(ic->border, evas_object_evas_get(ic->ibox->o_box));
531 edje_object_part_swallow(ic->o_holder, "e.swallow.content", ic->o_icon);
532 evas_object_pass_events_set(ic->o_icon, 1);
533 evas_object_show(ic->o_icon);
534 ic->o_icon2 = e_border_icon_add(ic->border, evas_object_evas_get(ic->ibox->o_box));
535 edje_object_part_swallow(ic->o_holder2, "e.swallow.content", ic->o_icon2);
536 evas_object_pass_events_set(ic->o_icon2, 1);
537 evas_object_show(ic->o_icon2);
539 _ibox_icon_fill_label(ic);
543 _ibox_icon_fill_label(IBox_Icon *ic)
545 const char *label = NULL;
547 switch (ic->ibox->inst->ci->icon_label)
550 label = ic->border->client.netwm.name;
552 label = ic->border->client.icccm.name;
556 label = ic->border->client.icccm.title;
560 label = ic->border->client.icccm.class;
564 label = ic->border->client.netwm.icon_name;
566 label = ic->border->client.icccm.icon_name;
570 label = e_border_name_get(ic->border);
574 if (!label) label = "?";
575 edje_object_part_text_set(ic->o_holder2, "e.text.label", label);
579 _ibox_icon_empty(IBox_Icon *ic)
581 if (ic->o_icon) evas_object_del(ic->o_icon);
582 if (ic->o_icon2) evas_object_del(ic->o_icon2);
588 _ibox_icon_signal_emit(IBox_Icon *ic, char *sig, char *src)
591 edje_object_signal_emit(ic->o_holder, sig, src);
593 edje_object_signal_emit(ic->o_icon, sig, src);
595 edje_object_signal_emit(ic->o_holder2, sig, src);
597 edje_object_signal_emit(ic->o_icon2, sig, src);
601 _ibox_zone_find(E_Zone *zone)
603 Eina_List *ibox = NULL;
606 for (l = ibox_config->instances; l; l = l->next)
611 if (inst->ci->show_zone == 0)
612 ibox = eina_list_append(ibox, inst->ibox);
613 else if ((inst->ci->show_zone == 1) && (inst->ibox->zone == zone))
614 ibox = eina_list_append(ibox, inst->ibox);
620 _ibox_cb_obj_moveresize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
625 _ibox_resize_handle(inst->ibox);
626 _ibox_instance_drop_zone_recalc(inst);
630 _ibox_cb_icon_mouse_in(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
635 _ibox_icon_signal_emit(ic, "e,state,focused", "e");
636 if (ic->ibox->inst->ci->show_label)
638 _ibox_icon_fill_label(ic);
639 _ibox_icon_signal_emit(ic, "e,action,show,label", "e");
644 _ibox_cb_icon_mouse_out(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
649 _ibox_icon_signal_emit(ic, "e,state,unfocused", "e");
650 if (ic->ibox->inst->ci->show_label)
651 _ibox_icon_signal_emit(ic, "e,action,hide,label", "e");
655 _ibox_cb_icon_mouse_down(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
657 Evas_Event_Mouse_Down *ev;
664 ic->drag.x = ev->output.x;
665 ic->drag.y = ev->output.y;
669 else if (ev->button == 3)
677 /* FIXME: other icon options go here too */
678 mi = e_menu_item_new(m);
679 e_menu_item_label_set(mi, _("Settings"));
680 e_util_menu_item_theme_icon_set(mi, "configure");
681 e_menu_item_callback_set(mi, _ibox_cb_menu_configuration, ic->ibox);
683 m = e_gadcon_client_util_menu_items_append(ic->ibox->inst->gcc, m, 0);
685 e_gadcon_canvas_zone_geometry_get(ic->ibox->inst->gcc->gadcon,
686 &cx, &cy, NULL, NULL);
687 e_menu_activate_mouse(m,
688 e_util_zone_current_get(e_manager_current_get()),
689 cx + ev->output.x, cy + ev->output.y, 1, 1,
690 E_MENU_POP_DIRECTION_DOWN, ev->timestamp);
695 _ibox_cb_icon_mouse_up(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
697 Evas_Event_Mouse_Up *ev;
702 if ((ev->button == 1) && (!ic->drag.dnd))
704 e_border_uniconify(ic->border);
705 e_border_focus_set(ic->border, 1, 1);
710 _ibox_cb_icon_mouse_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info)
712 Evas_Event_Mouse_Move *ev;
721 dx = ev->cur.output.x - ic->drag.x;
722 dy = ev->cur.output.y - ic->drag.y;
723 if (((dx * dx) + (dy * dy)) >
724 (e_config->drag_resist * e_config->drag_resist))
728 Evas_Coord x, y, w, h;
729 const char *drag_types[] = { "enlightenment/border" };
730 E_Gadcon_Client *gcc;
734 evas_object_geometry_get(ic->o_icon, &x, &y, &w, &h);
735 d = e_drag_new(ic->ibox->inst->gcc->gadcon->zone->container,
737 ic->border, -1, NULL, _ibox_cb_drag_finished);
738 o = e_border_icon_add(ic->border, e_drag_evas_get(d));
739 e_drag_object_set(d, o);
741 e_drag_resize(d, w, h);
742 e_drag_start(d, ic->drag.x, ic->drag.y);
743 e_object_ref(E_OBJECT(ic->border));
744 ic->ibox->icons = eina_list_remove(ic->ibox->icons, ic);
745 _ibox_resize_handle(ic->ibox);
746 gcc = ic->ibox->inst->gcc;
754 _ibox_cb_icon_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
760 evas_object_geometry_get(ic->o_holder, &x, &y, NULL, NULL);
761 evas_object_move(ic->o_holder2, x, y);
762 evas_object_raise(ic->o_holder2);
766 _ibox_cb_icon_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
772 evas_object_geometry_get(ic->o_holder, NULL, NULL, &w, &h);
773 evas_object_resize(ic->o_holder2, w, h);
774 evas_object_raise(ic->o_holder2);
778 _ibox_cb_drag_finished(E_Drag *drag, int dropped)
783 if (!dropped) e_border_uniconify(bd);
784 e_object_unref(E_OBJECT(bd));
788 _ibox_cb_drop_move(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
794 evas_object_geometry_get(b->o_drop, &x, &y, NULL, NULL);
795 evas_object_move(b->o_drop_over, x, y);
799 _ibox_cb_drop_resize(void *data, Evas *e __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
805 evas_object_geometry_get(b->o_drop, NULL, NULL, &w, &h);
806 evas_object_resize(b->o_drop_over, w, h);
810 _ibox_inst_cb_scroll(void *data)
814 /* Update the position of the dnd to handle for autoscrolling
817 _ibox_drop_position_update(inst, inst->ibox->dnd_x, inst->ibox->dnd_y);
821 _ibox_drop_position_update(Instance *inst, Evas_Coord x, Evas_Coord y)
825 inst->ibox->dnd_x = x;
826 inst->ibox->dnd_y = y;
828 if (inst->ibox->o_drop)
829 e_box_unpack(inst->ibox->o_drop);
830 ic = _ibox_icon_at_coord(inst->ibox, x, y);
831 inst->ibox->ic_drop_before = ic;
834 Evas_Coord ix, iy, iw, ih;
837 evas_object_geometry_get(ic->o_holder, &ix, &iy, &iw, &ih);
838 if (e_box_orientation_get(inst->ibox->o_box))
840 if (x < (ix + (iw / 2))) before = 1;
844 if (y < (iy + (ih / 2))) before = 1;
847 e_box_pack_before(inst->ibox->o_box, inst->ibox->o_drop, ic->o_holder);
849 e_box_pack_after(inst->ibox->o_box, inst->ibox->o_drop, ic->o_holder);
850 inst->ibox->drop_before = before;
852 else e_box_pack_end(inst->ibox->o_box, inst->ibox->o_drop);
853 e_box_pack_options_set(inst->ibox->o_drop,
856 0.5, 0.5, /* align */
860 _ibox_resize_handle(inst->ibox);
861 _gc_orient(inst->gcc, -1);
865 _ibox_inst_cb_enter(void *data, const char *type __UNUSED__, void *event_info)
867 E_Event_Dnd_Enter *ev;
873 o = edje_object_add(evas_object_evas_get(inst->ibox->o_box));
874 inst->ibox->o_drop = o;
875 o2 = edje_object_add(evas_object_evas_get(inst->ibox->o_box));
876 inst->ibox->o_drop_over = o2;
877 evas_object_event_callback_add(o, EVAS_CALLBACK_MOVE, _ibox_cb_drop_move, inst->ibox);
878 evas_object_event_callback_add(o, EVAS_CALLBACK_RESIZE, _ibox_cb_drop_resize, inst->ibox);
879 e_theme_edje_object_set(o, "base/theme/modules/ibox",
880 "e/modules/ibox/drop");
881 e_theme_edje_object_set(o2, "base/theme/modules/ibox",
882 "e/modules/ibox/drop_overlay");
883 evas_object_layer_set(o2, 19999);
885 evas_object_show(o2);
886 _ibox_drop_position_update(inst, ev->x, ev->y);
887 e_gadcon_client_autoscroll_cb_set(inst->gcc, _ibox_inst_cb_scroll, inst);
888 e_gadcon_client_autoscroll_update(inst->gcc, ev->x, ev->y);
892 _ibox_inst_cb_move(void *data, const char *type __UNUSED__, void *event_info)
894 E_Event_Dnd_Move *ev;
899 _ibox_drop_position_update(inst, ev->x, ev->y);
900 e_gadcon_client_autoscroll_update(inst->gcc, ev->x, ev->y);
904 _ibox_inst_cb_leave(void *data, const char *type __UNUSED__, void *event_info __UNUSED__)
909 inst->ibox->ic_drop_before = NULL;
910 evas_object_del(inst->ibox->o_drop);
911 inst->ibox->o_drop = NULL;
912 evas_object_del(inst->ibox->o_drop_over);
913 inst->ibox->o_drop_over = NULL;
914 e_gadcon_client_autoscroll_cb_set(inst->gcc, NULL, NULL);
915 _ibox_resize_handle(inst->ibox);
916 _gc_orient(inst->gcc, -1);
920 _ibox_inst_cb_drop(void *data, const char *type, void *event_info)
922 E_Event_Dnd_Drop *ev;
931 if (!strcmp(type, "enlightenment/border"))
938 if (!bd->iconic) e_border_iconify(bd);
940 ic2 = inst->ibox->ic_drop_before;
943 /* Add new eapp before this icon */
944 if (!inst->ibox->drop_before)
946 for (l = inst->ibox->icons; l; l = l->next)
958 if (!ic2) goto atend;
960 if (_ibox_icon_find(b, bd)) return;
961 ic = _ibox_icon_new(b, bd);
963 b->icons = eina_list_prepend_relative(b->icons, ic, ic2);
964 e_box_pack_before(b->o_box, ic->o_holder, ic2->o_holder);
970 if (_ibox_icon_find(b, bd)) return;
971 ic = _ibox_icon_new(b, bd);
973 b->icons = eina_list_append(b->icons, ic);
974 e_box_pack_end(b->o_box, ic->o_holder);
977 evas_object_del(inst->ibox->o_drop);
978 inst->ibox->o_drop = NULL;
979 evas_object_del(inst->ibox->o_drop_over);
980 inst->ibox->o_drop_over = NULL;
981 _ibox_empty_handle(b);
982 e_gadcon_client_autoscroll_cb_set(inst->gcc, NULL, NULL);
983 _ibox_resize_handle(inst->ibox);
984 _gc_orient(inst->gcc, -1);
988 _ibox_cb_event_border_add(void *data __UNUSED__, int type __UNUSED__, void *event)
990 E_Event_Border_Add *ev;
997 desk = e_desk_current_get(ev->border->zone);
998 if (ev->border->iconic)
1000 Eina_List *l, *ibox;
1001 ibox = _ibox_zone_find(ev->border->zone);
1002 for (l = ibox; l; l = l->next)
1005 if (_ibox_icon_find(b, ev->border)) continue;
1006 if ((b->inst->ci->show_desk) && (ev->border->desk != desk) && (!ev->border->sticky)) continue;
1007 ic = _ibox_icon_new(b, ev->border);
1009 b->icons = eina_list_append(b->icons, ic);
1010 e_box_pack_end(b->o_box, ic->o_holder);
1011 _ibox_empty_handle(b);
1012 _ibox_resize_handle(b);
1013 _gc_orient(b->inst->gcc, -1);
1017 ibox = eina_list_remove_list(ibox, ibox);
1019 return ECORE_CALLBACK_PASS_ON;
1023 _ibox_cb_event_border_remove(void *data __UNUSED__, int type __UNUSED__, void *event)
1025 E_Event_Border_Remove *ev;
1028 Eina_List *l, *ibox;
1031 /* find icon and remove if there */
1032 ibox = _ibox_zone_find(ev->border->zone);
1033 for (l = ibox; l; l = l->next)
1036 ic = _ibox_icon_find(b, ev->border);
1038 _ibox_icon_free(ic);
1039 b->icons = eina_list_remove(b->icons, ic);
1040 _ibox_empty_handle(b);
1041 _ibox_resize_handle(b);
1042 _gc_orient(b->inst->gcc, -1);
1045 ibox = eina_list_remove_list(ibox, ibox);
1047 return ECORE_CALLBACK_PASS_ON;
1051 _ibox_cb_event_border_iconify(void *data __UNUSED__, int type __UNUSED__, void *event)
1053 E_Event_Border_Iconify *ev;
1056 Eina_List *l, *ibox;
1060 /* add icon for ibox for right zone */
1061 /* do some sort of anim when iconifying */
1062 desk = e_desk_current_get(ev->border->zone);
1063 ibox = _ibox_zone_find(ev->border->zone);
1064 for (l = ibox; l; l = l->next)
1067 if (_ibox_icon_find(b, ev->border)) continue;
1068 if ((b->inst->ci->show_desk) && (ev->border->desk != desk) && (!ev->border->sticky)) continue;
1069 ic = _ibox_icon_new(b, ev->border);
1071 b->icons = eina_list_append(b->icons, ic);
1072 e_box_pack_end(b->o_box, ic->o_holder);
1073 _ibox_empty_handle(b);
1074 _ibox_resize_handle(b);
1075 _gc_orient(b->inst->gcc, -1);
1079 ibox = eina_list_remove_list(ibox, ibox);
1080 return ECORE_CALLBACK_PASS_ON;
1084 _ibox_cb_event_border_uniconify(void *data __UNUSED__, int type __UNUSED__, void *event)
1086 E_Event_Border_Uniconify *ev;
1089 Eina_List *l, *ibox;
1092 /* del icon for ibox for right zone */
1093 /* do some sort of anim when uniconifying */
1094 ibox = _ibox_zone_find(ev->border->zone);
1095 for (l = ibox; l; l = l->next)
1098 ic = _ibox_icon_find(b, ev->border);
1100 _ibox_icon_free(ic);
1101 b->icons = eina_list_remove(b->icons, ic);
1102 _ibox_empty_handle(b);
1103 _ibox_resize_handle(b);
1104 _gc_orient(b->inst->gcc, -1);
1108 ibox = eina_list_remove_list(ibox, ibox);
1110 return ECORE_CALLBACK_PASS_ON;
1114 _ibox_cb_event_border_icon_change(void *data __UNUSED__, int type __UNUSED__, void *event)
1116 E_Event_Border_Icon_Change *ev;
1119 Eina_List *l, *ibox;
1123 ibox = _ibox_zone_find(ev->border->zone);
1124 for (l = ibox; l; l = l->next)
1127 ic = _ibox_icon_find(b, ev->border);
1129 _ibox_icon_empty(ic);
1130 _ibox_icon_fill(ic);
1134 ibox = eina_list_remove_list(ibox, ibox);
1136 return ECORE_CALLBACK_PASS_ON;
1140 _ibox_cb_event_border_urgent_change(void *data __UNUSED__, int type __UNUSED__, void *event)
1142 E_Event_Border_Urgent_Change *ev;
1145 Eina_List *l, *ibox;
1149 ibox = _ibox_zone_find(ev->border->zone);
1150 for (l = ibox; l; l = l->next)
1153 ic = _ibox_icon_find(b, ev->border);
1155 if (ev->border->client.icccm.urgent)
1157 e_gadcon_urgent_show(b->inst->gcc->gadcon);
1158 edje_object_signal_emit(ic->o_holder, "e,state,urgent", "e");
1159 edje_object_signal_emit(ic->o_holder2, "e,state,urgent", "e");
1163 edje_object_signal_emit(ic->o_holder, "e,state,not_urgent", "e");
1164 edje_object_signal_emit(ic->o_holder2, "e,state,not_urgent", "e");
1168 return ECORE_CALLBACK_PASS_ON;
1172 _ibox_cb_event_border_zone_set(void *data __UNUSED__, int type __UNUSED__, void *event)
1174 E_Event_Border_Zone_Set *ev;
1177 /* delete from current zone ibox, add to new one */
1178 if (ev->border->iconic)
1185 _ibox_cb_event_desk_show(void *data __UNUSED__, int type __UNUSED__, void *event)
1187 E_Event_Desk_Show *ev;
1189 Eina_List *l, *ibox;
1192 /* delete all wins from ibox and add only for current desk */
1193 ibox = _ibox_zone_find(ev->desk->zone);
1194 for (l = ibox; l; l = l->next)
1197 if (b->inst->ci->show_desk)
1201 _ibox_resize_handle(b);
1202 _gc_orient(b->inst->gcc, -1);
1207 ibox = eina_list_remove_list(ibox, ibox);
1209 return ECORE_CALLBACK_PASS_ON;
1212 static Config_Item *
1213 _ibox_config_item_get(const char *id)
1217 GADCON_CLIENT_CONFIG_GET(Config_Item, ibox_config->items, _gadcon_class, id);
1219 ci = E_NEW(Config_Item, 1);
1220 ci->id = eina_stringshare_add(id);
1225 ibox_config->items = eina_list_append(ibox_config->items, ci);
1230 _ibox_config_update(Config_Item *ci)
1233 for (l = ibox_config->instances; l; l = l->next)
1238 if (inst->ci != ci) continue;
1240 _ibox_empty(inst->ibox);
1241 _ibox_fill(inst->ibox);
1242 _ibox_resize_handle(inst->ibox);
1243 _gc_orient(inst->gcc, -1);
1248 _ibox_cb_menu_configuration(void *data, E_Menu *m __UNUSED__, E_Menu_Item *mi __UNUSED__)
1255 for (l = ibox_config->config_dialog; l; l = l->next)
1257 E_Config_Dialog *cfd;
1260 if (cfd->data == b->inst->ci)
1266 if (ok) _config_ibox_module(b->inst->ci);
1269 /***************************************************************************/
1272 EAPI E_Module_Api e_modapi =
1274 E_MODULE_API_VERSION,
1279 e_modapi_init(E_Module *m)
1281 conf_item_edd = E_CONFIG_DD_NEW("IBox_Config_Item", Config_Item);
1284 #define T Config_Item
1285 #define D conf_item_edd
1286 E_CONFIG_VAL(D, T, id, STR);
1287 E_CONFIG_VAL(D, T, show_label, INT);
1288 E_CONFIG_VAL(D, T, show_zone, INT);
1289 E_CONFIG_VAL(D, T, show_desk, INT);
1290 E_CONFIG_VAL(D, T, icon_label, INT);
1292 conf_edd = E_CONFIG_DD_NEW("IBox_Config", Config);
1297 E_CONFIG_LIST(D, T, items, conf_item_edd);
1299 ibox_config = e_config_domain_load("module.ibox", conf_edd);
1304 ibox_config = E_NEW(Config, 1);
1306 ci = E_NEW(Config_Item, 1);
1307 ci->id = eina_stringshare_add("ibox.1");
1312 ibox_config->items = eina_list_append(ibox_config->items, ci);
1315 ibox_config->module = m;
1317 ibox_config->handlers = eina_list_append
1318 (ibox_config->handlers, ecore_event_handler_add
1319 (E_EVENT_BORDER_ADD, _ibox_cb_event_border_add, NULL));
1320 ibox_config->handlers = eina_list_append
1321 (ibox_config->handlers, ecore_event_handler_add
1322 (E_EVENT_BORDER_REMOVE, _ibox_cb_event_border_remove, NULL));
1323 ibox_config->handlers = eina_list_append
1324 (ibox_config->handlers, ecore_event_handler_add
1325 (E_EVENT_BORDER_ICONIFY, _ibox_cb_event_border_iconify, NULL));
1326 ibox_config->handlers = eina_list_append
1327 (ibox_config->handlers, ecore_event_handler_add
1328 (E_EVENT_BORDER_UNICONIFY, _ibox_cb_event_border_uniconify, NULL));
1329 ibox_config->handlers = eina_list_append
1330 (ibox_config->handlers, ecore_event_handler_add
1331 (E_EVENT_BORDER_ICON_CHANGE, _ibox_cb_event_border_icon_change, NULL));
1332 ibox_config->handlers = eina_list_append
1333 (ibox_config->handlers, ecore_event_handler_add
1334 (E_EVENT_BORDER_URGENT_CHANGE,
1335 _ibox_cb_event_border_urgent_change, NULL));
1336 ibox_config->handlers = eina_list_append
1337 (ibox_config->handlers, ecore_event_handler_add
1338 (E_EVENT_BORDER_ZONE_SET, _ibox_cb_event_border_zone_set, NULL));
1339 ibox_config->handlers = eina_list_append
1340 (ibox_config->handlers, ecore_event_handler_add
1341 (E_EVENT_DESK_SHOW, _ibox_cb_event_desk_show, NULL));
1343 /* FIXME: add these later for things taskbar-like functionality
1344 ibox_config->handlers = eina_list_append
1345 (ibox_config->handlers, ecore_event_handler_add
1346 (E_EVENT_BORDER_DESK_SET, _ibox_cb_event_border_zone_set, NULL));
1347 ibox_config->handlers = eina_list_append
1348 (ibox_config->handlers, ecore_event_handler_add
1349 (E_EVENT_BORDER_SHOW, _ibox_cb_event_border_zone_set, NULL));
1350 ibox_config->handlers = eina_list_append
1351 (ibox_config->handlers, ecore_event_handler_add
1352 (E_EVENT_BORDER_HIDE, _ibox_cb_event_border_zone_set, NULL));
1353 ibox_config->handlers = eina_list_append
1354 (ibox_config->handlers, ecore_event_handler_add
1355 (E_EVENT_BORDER_STACK, _ibox_cb_event_border_zone_set, NULL));
1356 ibox_config->handlers = eina_list_append
1357 (ibox_config->handlers, ecore_event_handler_add
1358 (E_EVENT_BORDER_STICK, _ibox_cb_event_border_zone_set, NULL));
1360 e_gadcon_provider_register(&_gadcon_class);
1365 e_modapi_shutdown(E_Module *m __UNUSED__)
1367 e_gadcon_provider_unregister(&_gadcon_class);
1369 while (ibox_config->handlers)
1371 ecore_event_handler_del(ibox_config->handlers->data);
1372 ibox_config->handlers = eina_list_remove_list(ibox_config->handlers, ibox_config->handlers);
1375 while (ibox_config->config_dialog)
1376 /* there is no need to eves_list_remove_list. It is done implicitly in
1377 * dialog _free_data function
1379 e_object_del(E_OBJECT(ibox_config->config_dialog->data));
1381 while (ibox_config->items)
1385 ci = ibox_config->items->data;
1386 ibox_config->items = eina_list_remove_list(ibox_config->items, ibox_config->items);
1388 eina_stringshare_del(ci->id);
1394 E_CONFIG_DD_FREE(conf_item_edd);
1395 E_CONFIG_DD_FREE(conf_edd);
1400 e_modapi_save(E_Module *m __UNUSED__)
1402 e_config_domain_save("module.ibox", conf_edd, ibox_config);