forked from enlightenment/enlightenment
parent
efa853f59e
commit
954a7a11f6
|
@ -40,6 +40,7 @@ static void _e_app_cb_monitor (void *data, Ecore_File_Monitor *em,
|
|||
static void _e_app_subdir_rescan (E_App *app);
|
||||
static int _e_app_is_eapp (const char *path);
|
||||
static E_App *_e_app_copy (E_App *app);
|
||||
static void _e_app_save_order (E_App *app);
|
||||
|
||||
/* local subsystem globals */
|
||||
static Evas_Hash *_e_apps = NULL;
|
||||
|
@ -281,6 +282,7 @@ e_app_prepend_relative(E_App *add, E_App *before)
|
|||
before->parent->subapps = evas_list_prepend_relative(before->parent->subapps,
|
||||
add, before);
|
||||
|
||||
_e_app_save_order(before->parent);
|
||||
_e_app_change(add, E_APP_ADD);
|
||||
_e_app_change(before->parent, E_APP_ORDER);
|
||||
}
|
||||
|
@ -290,14 +292,18 @@ e_app_append(E_App *add, E_App *parent)
|
|||
{
|
||||
parent->subapps = evas_list_append(parent->subapps, add);
|
||||
|
||||
_e_app_save_order(parent);
|
||||
_e_app_change(add, E_APP_ADD);
|
||||
}
|
||||
|
||||
void
|
||||
e_app_remove(E_App *remove, E_App *parent)
|
||||
e_app_remove(E_App *remove)
|
||||
{
|
||||
parent->subapps = evas_list_remove(parent->subapps, remove);
|
||||
if (!remove->parent) return;
|
||||
|
||||
remove->parent->subapps = evas_list_remove(remove->parent->subapps, remove);
|
||||
|
||||
_e_app_save_order(remove->parent);
|
||||
_e_app_change(remove, E_APP_DEL);
|
||||
}
|
||||
|
||||
|
@ -1026,3 +1032,26 @@ _e_app_copy(E_App *app)
|
|||
|
||||
return a2;
|
||||
}
|
||||
|
||||
static void
|
||||
_e_app_save_order(E_App *app)
|
||||
{
|
||||
FILE *f;
|
||||
char buf[PATH_MAX];
|
||||
Evas_List *l;
|
||||
|
||||
if (!app) return;
|
||||
|
||||
snprintf(buf, sizeof(buf), "%s/.order", app->path);
|
||||
f = fopen(buf, "wb");
|
||||
if (!f) return;
|
||||
|
||||
for (l = app->subapps; l; l = l->next)
|
||||
{
|
||||
E_App *a;
|
||||
|
||||
a = l->data;
|
||||
fprintf(f, "%s\n", ecore_file_get_file(a->path));
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
|
|
|
@ -67,7 +67,7 @@ EAPI int e_app_starting_get(E_App *a);
|
|||
EAPI int e_app_running_get(E_App *a);
|
||||
EAPI void e_app_prepend_relative(E_App *add, E_App *before);
|
||||
EAPI void e_app_append(E_App *add, E_App *parent);
|
||||
EAPI void e_app_remove(E_App *remove, E_App *parent);
|
||||
EAPI void e_app_remove(E_App *remove);
|
||||
|
||||
EAPI void e_app_change_callback_add(void (*func) (void *data, E_App *a, E_App_Change ch), void *data);
|
||||
EAPI void e_app_change_callback_del(void (*func) (void *data, E_App *a, E_App_Change ch), void *data);
|
||||
|
|
|
@ -155,7 +155,9 @@ void
|
|||
e_drag_update(int x, int y)
|
||||
{
|
||||
Evas_List *l;
|
||||
E_Move_Event *ev;
|
||||
E_Enter_Event *enter_ev;
|
||||
E_Move_Event *move_ev;
|
||||
E_Leave_Event *leave_ev;
|
||||
int w, h;
|
||||
|
||||
if (!drag_ee) return;
|
||||
|
@ -171,10 +173,17 @@ e_drag_update(int x, int y)
|
|||
evas_object_geometry_get(drag_obj, NULL, NULL, &w, &h);
|
||||
ecore_evas_move(drag_ee, x - (w / 2), y - (h / 2));
|
||||
|
||||
ev = E_NEW(E_Move_Event, 1);
|
||||
if (!ev) goto end;
|
||||
ev->x = x;
|
||||
ev->y = y;
|
||||
enter_ev = E_NEW(E_Enter_Event, 1);
|
||||
enter_ev->x = x;
|
||||
enter_ev->y = y;
|
||||
|
||||
move_ev = E_NEW(E_Move_Event, 1);
|
||||
move_ev->x = x;
|
||||
move_ev->y = y;
|
||||
|
||||
leave_ev = E_NEW(E_Leave_Event, 1);
|
||||
leave_ev->x = x;
|
||||
leave_ev->y = y;
|
||||
|
||||
for (l = drop_handlers; l; l = l->next)
|
||||
{
|
||||
|
@ -185,16 +194,31 @@ e_drag_update(int x, int y)
|
|||
if (!h->active)
|
||||
continue;
|
||||
|
||||
if ((h->cb.move)
|
||||
&& E_INSIDE(x, y, h->x, h->y, h->w, h->h))
|
||||
if (E_INSIDE(x, y, h->x, h->y, h->w, h->h))
|
||||
{
|
||||
h->cb.move(h->data, drag_type, ev);
|
||||
if (!h->entered)
|
||||
{
|
||||
if (h->cb.enter)
|
||||
h->cb.enter(h->data, drag_type, enter_ev);
|
||||
h->entered = 1;
|
||||
}
|
||||
if (h->cb.move)
|
||||
h->cb.move(h->data, drag_type, move_ev);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (h->entered)
|
||||
{
|
||||
if (h->cb.leave)
|
||||
h->cb.leave(h->data, drag_type, leave_ev);
|
||||
h->entered = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
free(ev);
|
||||
end:
|
||||
return;
|
||||
free(enter_ev);
|
||||
free(move_ev);
|
||||
free(leave_ev);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -252,8 +276,10 @@ end:
|
|||
|
||||
E_Drop_Handler *
|
||||
e_drop_handler_add(void *data,
|
||||
void (*drop_cb)(void *data, const char *type, void *event),
|
||||
void (*enter_cb)(void *data, const char *type, void *event),
|
||||
void (*move_cb)(void *data, const char *type, void *event),
|
||||
void (*leave_cb)(void *data, const char *type, void *event),
|
||||
void (*drop_cb)(void *data, const char *type, void *event),
|
||||
const char *type, int x, int y, int w, int h)
|
||||
{
|
||||
E_Drop_Handler *handler;
|
||||
|
@ -262,8 +288,10 @@ e_drop_handler_add(void *data,
|
|||
if (!handler) return NULL;
|
||||
|
||||
handler->data = data;
|
||||
handler->cb.drop = drop_cb;
|
||||
handler->cb.enter = enter_cb;
|
||||
handler->cb.move = move_cb;
|
||||
handler->cb.leave = leave_cb;
|
||||
handler->cb.drop = drop_cb;
|
||||
handler->type = strdup(type);
|
||||
handler->x = x;
|
||||
handler->y = y;
|
||||
|
|
|
@ -5,8 +5,10 @@
|
|||
#ifdef E_TYPEDEFS
|
||||
|
||||
typedef struct _E_Drop_Handler E_Drop_Handler;
|
||||
typedef struct _E_Drop_Event E_Drop_Event;
|
||||
typedef struct _E_Enter_Event E_Enter_Event;
|
||||
typedef struct _E_Move_Event E_Move_Event;
|
||||
typedef struct _E_Leave_Event E_Leave_Event;
|
||||
typedef struct _E_Drop_Event E_Drop_Event;
|
||||
|
||||
#else
|
||||
#ifndef E_DND_H
|
||||
|
@ -16,17 +18,19 @@ struct _E_Drop_Handler
|
|||
{
|
||||
void *data;
|
||||
struct {
|
||||
void (*drop)(void *data, const char *type, void *event);
|
||||
void (*enter)(void *data, const char *type, void *event);
|
||||
void (*move)(void *data, const char *type, void *event);
|
||||
void (*leave)(void *data, const char *type, void *event);
|
||||
void (*drop)(void *data, const char *type, void *event);
|
||||
} cb;
|
||||
char *type;
|
||||
int x, y, w, h;
|
||||
unsigned char active : 1;
|
||||
unsigned char entered : 1;
|
||||
};
|
||||
|
||||
struct _E_Drop_Event
|
||||
struct _E_Enter_Event
|
||||
{
|
||||
void *data;
|
||||
int x, y;
|
||||
};
|
||||
|
||||
|
@ -35,6 +39,17 @@ struct _E_Move_Event
|
|||
int x, y;
|
||||
};
|
||||
|
||||
struct _E_Leave_Event
|
||||
{
|
||||
int x, y;
|
||||
};
|
||||
|
||||
struct _E_Drop_Event
|
||||
{
|
||||
void *data;
|
||||
int x, y;
|
||||
};
|
||||
|
||||
EAPI int e_dnd_init(void);
|
||||
EAPI int e_dnd_shutdown(void);
|
||||
|
||||
|
@ -46,8 +61,10 @@ EAPI void e_drag_update(int x, int y);
|
|||
EAPI void e_drag_end(int x, int y);
|
||||
|
||||
EAPI E_Drop_Handler *e_drop_handler_add(void *data,
|
||||
void (*drop_cb)(void *data, const char *type, void *event),
|
||||
void (*enter_cb)(void *data, const char *type, void *event),
|
||||
void (*move_cb)(void *data, const char *type, void *event),
|
||||
void (*leave_cb)(void *data, const char *type, void *event),
|
||||
void (*drop_cb)(void *data, const char *type, void *event),
|
||||
const char *type, int x, int y, int w, int h);
|
||||
EAPI void e_drop_handler_del(E_Drop_Handler *handler);
|
||||
|
||||
|
|
|
@ -69,8 +69,10 @@ static void _ibar_bar_cb_mouse_up(void *data, Evas *e, Evas_Object *obj, void
|
|||
static void _ibar_bar_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info);
|
||||
static int _ibar_bar_cb_timer(void *data);
|
||||
static int _ibar_bar_cb_animator(void *data);
|
||||
static void _ibar_bar_cb_drop(void *data, const char *type, void *event);
|
||||
static void _ibar_bar_cb_enter(void *data, const char *type, void *event);
|
||||
static void _ibar_bar_cb_move(void *data, const char *type, void *event);
|
||||
static void _ibar_bar_cb_leave(void *data, const char *type, void *event);
|
||||
static void _ibar_bar_cb_drop(void *data, const char *type, void *event);
|
||||
|
||||
static void _ibar_icon_cb_intercept_move(void *data, Evas_Object *o, Evas_Coord x, Evas_Coord y);
|
||||
static void _ibar_icon_cb_intercept_resize(void *data, Evas_Object *o, Evas_Coord w, Evas_Coord h);
|
||||
|
@ -460,6 +462,11 @@ _ibar_bar_new(IBar *ib, E_Container *con)
|
|||
edje_object_part_swallow(ibb->bar_object, "items", o);
|
||||
evas_object_show(o);
|
||||
|
||||
o = evas_object_rectangle_add(ibb->evas);
|
||||
ibb->drag_object = o;
|
||||
evas_object_color_set(o, 255, 0, 0, 255);
|
||||
evas_object_resize(o, 32, 16);
|
||||
|
||||
if (ibb->ibar->apps)
|
||||
{
|
||||
for (l = ibb->ibar->apps->subapps; l; l = l->next)
|
||||
|
@ -485,11 +492,15 @@ _ibar_bar_new(IBar *ib, E_Container *con)
|
|||
ibb->inset.t = y;
|
||||
ibb->inset.b = 1000 - (y + h);
|
||||
|
||||
ibb->drop_handler = e_drop_handler_add(ibb, _ibar_bar_cb_drop, _ibar_bar_cb_move,
|
||||
#if 0
|
||||
ibb->drop_handler = e_drop_handler_add(ibb,
|
||||
_ibar_bar_cb_enter, _ibar_bar_cb_move,
|
||||
_ibar_bar_cb_leave, _ibar_bar_cb_drop,
|
||||
"enlightenment/eapp",
|
||||
ibb->x + ibb->inset.l, ibb->y + ibb->inset.t,
|
||||
ibb->w - (ibb->inset.l + ibb->inset.r),
|
||||
ibb->h - (ibb->inset.t + ibb->inset.b));
|
||||
#endif
|
||||
|
||||
ibb->gmc = e_gadman_client_new(ibb->con->gadman);
|
||||
e_gadman_client_domain_set(ibb->gmc, "module.ibar", bar_count++);
|
||||
|
@ -1242,7 +1253,7 @@ _ibar_icon_cb_mouse_move(void *data, Evas *e, Evas_Object *obj, void *event_info
|
|||
drag_start = 0;
|
||||
e_drag_start(ic->ibb->con, "enlightenment/eapp", ic->app, ic->app->path, "icon");
|
||||
evas_event_feed_mouse_up(ic->ibb->evas, 1, EVAS_BUTTON_NONE, NULL);
|
||||
e_app_remove(ic->app, ic->ibb->ibar->apps);
|
||||
e_app_remove(ic->app);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1374,6 +1385,93 @@ _ibar_bar_cb_animator(void *data)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_ibar_bar_cb_enter(void *data, const char *type, void *event)
|
||||
{
|
||||
E_Enter_Event *ev;
|
||||
IBar_Bar *ibb;
|
||||
|
||||
ev = event;
|
||||
ibb = data;
|
||||
}
|
||||
|
||||
static void
|
||||
_ibar_bar_cb_move(void *data, const char *type, void *event)
|
||||
{
|
||||
E_Move_Event *ev;
|
||||
IBar_Bar *ibb;
|
||||
IBar_Icon *ic;
|
||||
Evas_Coord x, y, w, h;
|
||||
double iw;
|
||||
int pos;
|
||||
|
||||
ev = event;
|
||||
ibb = data;
|
||||
|
||||
x = ev->x - (ibb->x + ibb->inset.l);
|
||||
y = ev->y - (ibb->y + ibb->inset.t);
|
||||
w = ibb->w - (ibb->inset.l + ibb->inset.r);
|
||||
h = ibb->h - (ibb->inset.t + ibb->inset.b);
|
||||
|
||||
if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) ||
|
||||
(e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP))
|
||||
{
|
||||
iw = w / (double) evas_list_count(ibb->icons);
|
||||
pos = round(x / iw);
|
||||
}
|
||||
else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) ||
|
||||
(e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT))
|
||||
{
|
||||
iw = h / (double) evas_list_count(ibb->icons);
|
||||
pos = round(y / iw);
|
||||
}
|
||||
ic = evas_list_nth(ibb->icons, pos);
|
||||
|
||||
evas_event_freeze(ibb->evas);
|
||||
e_box_freeze(ibb->box_object);
|
||||
e_box_unpack(ibb->drag_object);
|
||||
if (ic)
|
||||
{
|
||||
/* Add new eapp before this icon */
|
||||
e_box_pack_before(ibb->box_object, ic->bg_object, ibb->drag_object);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Add at the end */
|
||||
e_box_pack_end(ibb->box_object, ibb->drag_object);
|
||||
}
|
||||
edje_object_size_min_calc(ibb->drag_object, &w, &h);
|
||||
e_box_pack_options_set(ibb->drag_object,
|
||||
1, 1, /* fill */
|
||||
0, 0, /* expand */
|
||||
0.5, 0.5, /* align */
|
||||
32, 16, /* min */
|
||||
32, 16 /* max */
|
||||
);
|
||||
e_box_thaw(ibb->box_object);
|
||||
evas_event_thaw(ibb->evas);
|
||||
|
||||
_ibar_bar_frame_resize(ibb);
|
||||
}
|
||||
|
||||
static void
|
||||
_ibar_bar_cb_leave(void *data, const char *type, void *event)
|
||||
{
|
||||
E_Leave_Event *ev;
|
||||
IBar_Bar *ibb;
|
||||
|
||||
ev = event;
|
||||
ibb = data;
|
||||
|
||||
evas_event_freeze(ibb->evas);
|
||||
e_box_freeze(ibb->box_object);
|
||||
e_box_unpack(ibb->drag_object);
|
||||
e_box_thaw(ibb->box_object);
|
||||
evas_event_thaw(ibb->evas);
|
||||
|
||||
_ibar_bar_frame_resize(ibb);
|
||||
}
|
||||
|
||||
static void
|
||||
_ibar_bar_cb_drop(void *data, const char *type, void *event)
|
||||
{
|
||||
|
@ -1389,11 +1487,10 @@ _ibar_bar_cb_drop(void *data, const char *type, void *event)
|
|||
ibb = data;
|
||||
app = ev->data;
|
||||
|
||||
printf("_ibar_bar_cb_drop(%d, %d)\n", ev->x, ev->y);
|
||||
|
||||
evas_object_geometry_get(ibb->box_object, &x, &y, &w, &h);
|
||||
x = ev->x - x;
|
||||
y = ev->y - y;
|
||||
x = ev->x - (ibb->x + ibb->inset.l);
|
||||
y = ev->y - (ibb->y + ibb->inset.t);
|
||||
w = ibb->w - (ibb->inset.l + ibb->inset.r);
|
||||
h = ibb->h - (ibb->inset.t + ibb->inset.b);
|
||||
|
||||
if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) ||
|
||||
(e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP))
|
||||
|
@ -1422,47 +1519,6 @@ _ibar_bar_cb_drop(void *data, const char *type, void *event)
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ibar_bar_cb_move(void *data, const char *type, void *event)
|
||||
{
|
||||
E_Move_Event *ev;
|
||||
IBar_Bar *ibb;
|
||||
IBar_Icon *ic;
|
||||
Evas_Coord x, y, w, h;
|
||||
double iw;
|
||||
int pos;
|
||||
|
||||
ev = event;
|
||||
ibb = data;
|
||||
|
||||
evas_object_geometry_get(ibb->box_object, &x, &y, &w, &h);
|
||||
x = ev->x - x;
|
||||
y = ev->y - y;
|
||||
|
||||
if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_BOTTOM) ||
|
||||
(e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_TOP))
|
||||
{
|
||||
iw = w / (double) evas_list_count(ibb->icons);
|
||||
pos = round(x / iw);
|
||||
}
|
||||
else if ((e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_LEFT) ||
|
||||
(e_gadman_client_edge_get(ibb->gmc) == E_GADMAN_EDGE_RIGHT))
|
||||
{
|
||||
iw = h / (double) evas_list_count(ibb->icons);
|
||||
pos = round(y / iw);
|
||||
}
|
||||
ic = evas_list_nth(ibb->icons, pos);
|
||||
/* FIXME, show a marker where the icon will be placed! */
|
||||
if (ic)
|
||||
{
|
||||
/* Add new eapp before this icon */
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Add at the end */
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ibar_bar_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change)
|
||||
{
|
||||
|
@ -1485,10 +1541,12 @@ _ibar_bar_cb_gmc_change(void *data, E_Gadman_Client *gmc, E_Gadman_Change change
|
|||
_ibar_bar_follower_reset(ibb);
|
||||
_ibar_bar_timer_handle(ibb);
|
||||
|
||||
#if 0
|
||||
ibb->drop_handler->x = ibb->x + ibb->inset.l;
|
||||
ibb->drop_handler->y = ibb->y + ibb->inset.t;
|
||||
ibb->drop_handler->w = ibb->w - (ibb->inset.l + ibb->inset.r);
|
||||
ibb->drop_handler->h = ibb->h - (ibb->inset.t + ibb->inset.b);
|
||||
#endif
|
||||
break;
|
||||
case E_GADMAN_CHANGE_EDGE:
|
||||
_ibar_bar_edge_change(ibb, e_gadman_client_edge_get(ibb->gmc));
|
||||
|
|
|
@ -50,6 +50,7 @@ struct _IBar_Bar
|
|||
Evas_Object *overlay_object;
|
||||
Evas_Object *box_object;
|
||||
Evas_Object *event_object;
|
||||
Evas_Object *drag_object;
|
||||
|
||||
Evas_List *icons;
|
||||
|
||||
|
|
|
@ -341,7 +341,9 @@ _pager_face_new(E_Zone *zone)
|
|||
edje_object_part_swallow(face->pager_object, "items", face->table_object);
|
||||
evas_object_show(o);
|
||||
|
||||
face->drop_handler = e_drop_handler_add(face, _pager_drop_cb, NULL, "enlightenment/border",
|
||||
face->drop_handler = e_drop_handler_add(face,
|
||||
NULL, NULL, NULL, _pager_drop_cb,
|
||||
"enlightenment/border",
|
||||
face->fx, face->fy, face->fw, face->fh);
|
||||
|
||||
face->gmc = e_gadman_client_new(zone->container->gadman);
|
||||
|
|
Loading…
Reference in New Issue