forked from enlightenment/enlightenment
dnd source icon changes based on drop action requested+target
allowed action. We can also change cursor/drag window based on the state info available. I haven't tackled that yet. Kevin Brosius <cobra@compuserve.com> SVN revision: 5765
This commit is contained in:
parent
3e6abee6ea
commit
329a5da29d
61
src/icons.c
61
src/icons.c
|
@ -89,9 +89,11 @@ e_icon_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|||
ecore_window_destroy(ic->view->drag.win);
|
||||
ic->view->drag.started = 0;
|
||||
if(e->mods & ECORE_EVENT_KEY_MODIFIER_SHIFT)
|
||||
ic->view->drag.drop_mode = E_DND_COPY;
|
||||
ecore_dnd_set_mode_copy();
|
||||
else
|
||||
ic->view->drag.drop_mode = E_DND_MOVE;
|
||||
ecore_dnd_set_mode_move();
|
||||
ecore_dnd_set_data(ic->view->win.base);
|
||||
|
||||
/* FIXME: if button use is right mouse then do an ask */
|
||||
|
||||
/* Handle dnd motion(drop) - dragging==0 */
|
||||
|
@ -384,6 +386,18 @@ e_icon_move_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y)
|
|||
ic->view->drag.update = 1;
|
||||
ic->view->changed = 1;
|
||||
|
||||
if(e->mods & ECORE_EVENT_KEY_MODIFIER_SHIFT)
|
||||
{
|
||||
ecore_dnd_set_mode_copy();
|
||||
ic->view->drag.drop_mode = E_DND_COPY;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecore_dnd_set_mode_move();
|
||||
ic->view->drag.drop_mode = E_DND_MOVE;
|
||||
}
|
||||
ecore_dnd_set_data(ic->view->win.base);
|
||||
|
||||
/* Handle dnd motion - dragging==1 */
|
||||
ecore_pointer_xy_get(&x, &y);
|
||||
ecore_window_dnd_handle_motion( ic->view->win.base, x, y, 1);
|
||||
|
@ -514,6 +528,49 @@ e_icon_hide(E_Icon *ic)
|
|||
D_RETURN;
|
||||
}
|
||||
|
||||
void
|
||||
e_icon_hide_delete_pending(E_Icon *ic)
|
||||
{
|
||||
D_ENTER;
|
||||
|
||||
if (!ic->state.visible) D_RETURN;
|
||||
if(ic->state.selected)
|
||||
{
|
||||
if( ic->view->drag.drop_mode == E_DND_MOVE)
|
||||
{
|
||||
evas_hide(ic->view->evas, ic->obj.icon);
|
||||
ic->state.drag_delete = 1;
|
||||
}
|
||||
else
|
||||
/* copy... */
|
||||
{
|
||||
evas_show(ic->view->evas, ic->obj.icon);
|
||||
ic->state.drag_delete = 0;
|
||||
}
|
||||
}
|
||||
|
||||
D_RETURN;
|
||||
}
|
||||
|
||||
void
|
||||
e_icon_show_delete_end(E_Icon *ic, E_dnd_enum dnd_pending_mode)
|
||||
{
|
||||
D_ENTER;
|
||||
|
||||
if (!ic->state.visible) D_RETURN;
|
||||
if(ic->state.drag_delete)
|
||||
{
|
||||
if(dnd_pending_mode==E_DND_DELETED || dnd_pending_mode==E_DND_COPIED)
|
||||
{
|
||||
ic->state.drag_delete = 0;
|
||||
if(dnd_pending_mode==E_DND_COPIED)
|
||||
evas_show(ic->view->evas, ic->obj.icon);
|
||||
}
|
||||
}
|
||||
|
||||
D_RETURN;
|
||||
}
|
||||
|
||||
void
|
||||
e_icon_apply_xy(E_Icon *ic)
|
||||
{
|
||||
|
|
|
@ -14,6 +14,11 @@ typedef struct _E_Icon E_Icon;
|
|||
typedef struct _E_View E_View;
|
||||
#endif
|
||||
|
||||
#ifndef E_DND_TYPEDEF
|
||||
#define E_DND_TYPEDEF
|
||||
typedef enum _E_dnd_enum E_dnd_enum;
|
||||
#endif
|
||||
|
||||
struct _E_Icon
|
||||
{
|
||||
E_Object o;
|
||||
|
@ -55,6 +60,7 @@ struct _E_Icon
|
|||
int visible;
|
||||
int just_selected;
|
||||
int just_executed;
|
||||
int drag_delete;
|
||||
} state;
|
||||
|
||||
struct {
|
||||
|
@ -96,6 +102,8 @@ void e_icon_set_link(E_Icon *ic, char *link);
|
|||
E_Icon *e_icon_find_by_file(E_View *view, char *file);
|
||||
void e_icon_show(E_Icon *ic);
|
||||
void e_icon_hide(E_Icon *ic);
|
||||
void e_icon_hide_delete_pending(E_Icon *ic);
|
||||
void e_icon_show_delete_end(E_Icon *ic, E_dnd_enum dnd_pending_mode);
|
||||
void e_icon_apply_xy(E_Icon *ic);
|
||||
void e_icon_check_permissions(E_Icon *ic);
|
||||
|
||||
|
|
109
src/view.c
109
src/view.c
|
@ -17,6 +17,7 @@ static Ecore_Event *current_ev = NULL;
|
|||
static char **dnd_files = NULL;
|
||||
static int dnd_num_files = 0;
|
||||
static E_dnd_enum dnd_pending_mode;
|
||||
static E_View *v_dnd_source;
|
||||
|
||||
static void e_bg_down_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
|
||||
static void e_bg_up_cb(void *_data, Evas _e, Evas_Object _o, int _b, int _x, int _y);
|
||||
|
@ -45,7 +46,7 @@ static void e_dnd_drop_position(Ecore_Event * ev);
|
|||
static void e_dnd_drop(Ecore_Event * ev);
|
||||
static void e_dnd_drop_request(Ecore_Event * ev);
|
||||
static void e_dnd_drop_request_free(void);
|
||||
static void e_dnd_handle_drop( E_View *v, E_dnd_enum dnd_pending_mode );
|
||||
static void e_dnd_handle_drop( E_View *v );
|
||||
static void e_view_handle_fs(EfsdEvent *ev);
|
||||
static void e_view_handle_fs_restart(void *data);
|
||||
static void e_view_resort_timeout(int val, void *data);
|
||||
|
@ -1053,13 +1054,15 @@ e_dnd_status(Ecore_Event * ev)
|
|||
{
|
||||
Ecore_Event_Dnd_Drop_Status *e;
|
||||
/*
|
||||
typedef struct _ecore_event_dnd_drop_status
|
||||
{
|
||||
Window win, root, source_win;
|
||||
int x, y, w, h;
|
||||
int ok;
|
||||
} Ecore_Event_Dnd_Drop_Status;
|
||||
*/
|
||||
* typedef struct _ecore_event_dnd_drop_status
|
||||
* {
|
||||
* Window win, root, source_win;
|
||||
* int x, y, w, h;
|
||||
* int copy, link, move, private;
|
||||
* int all_position_msgs;
|
||||
* int ok;
|
||||
* } Ecore_Event_Dnd_Drop_Status;
|
||||
*/
|
||||
Evas_List l;
|
||||
|
||||
D_ENTER;
|
||||
|
@ -1072,7 +1075,24 @@ e_dnd_status(Ecore_Event * ev)
|
|||
v = l->data;
|
||||
if (e->win == v->win.base)
|
||||
{
|
||||
|
||||
if( dnd_pending_mode != E_DND_DELETED &&
|
||||
dnd_pending_mode != E_DND_COPIED )
|
||||
{
|
||||
if( e->copy )
|
||||
dnd_pending_mode = E_DND_COPY;
|
||||
else if( e->move )
|
||||
dnd_pending_mode = E_DND_MOVE;
|
||||
else if( e->link )
|
||||
dnd_pending_mode = E_DND_LINK;
|
||||
else
|
||||
dnd_pending_mode = E_DND_ASK;
|
||||
}
|
||||
|
||||
ecore_window_dnd_ok(e->ok);
|
||||
|
||||
v->changed = 1;
|
||||
v->drag.icon_hide = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1990,12 +2010,30 @@ e_view_update(E_View *v)
|
|||
|
||||
if (v->changed)
|
||||
{
|
||||
for (l = v->icons; l; l = l->next)
|
||||
{
|
||||
E_Icon *icon;
|
||||
if(v->drag.icon_hide)
|
||||
{
|
||||
for (l = v->icons; l; l = l->next)
|
||||
{
|
||||
E_Icon *ic;
|
||||
|
||||
icon = l->data;
|
||||
}
|
||||
ic = l->data;
|
||||
e_icon_hide_delete_pending(ic);
|
||||
}
|
||||
v->drag.icon_hide = 0;
|
||||
v_dnd_source = v;
|
||||
}
|
||||
if(v->drag.icon_show)
|
||||
{
|
||||
for (l = v->icons; l; l = l->next)
|
||||
{
|
||||
E_Icon *ic;
|
||||
|
||||
ic = l->data;
|
||||
e_icon_show_delete_end(ic, dnd_pending_mode);
|
||||
}
|
||||
dnd_pending_mode = E_DND_NONE;
|
||||
v->drag.icon_show = 0;
|
||||
}
|
||||
if (v->drag.update)
|
||||
{
|
||||
ecore_window_move(v->drag.win, v->drag.x, v->drag.y);
|
||||
|
@ -2724,6 +2762,22 @@ e_dnd_drop_end(Ecore_Event * ev)
|
|||
v = l->data;
|
||||
if (e->win == v->win.base)
|
||||
{
|
||||
if(v_dnd_source)
|
||||
{
|
||||
if(dnd_pending_mode != E_DND_DELETED &&
|
||||
dnd_pending_mode != E_DND_COPIED )
|
||||
{
|
||||
dnd_pending_mode = E_DND_COPIED;
|
||||
}
|
||||
if( v_dnd_source->drag.matching_drop_attempt )
|
||||
{
|
||||
v_dnd_source->drag.matching_drop_attempt = 0;
|
||||
dnd_pending_mode = E_DND_COPIED;
|
||||
}
|
||||
v_dnd_source->changed = 1;
|
||||
v_dnd_source->drag.icon_show = 1;
|
||||
}
|
||||
|
||||
e_dnd_drop_request_free();
|
||||
D_RETURN;
|
||||
}
|
||||
|
@ -2756,15 +2810,14 @@ e_dnd_drop_position(Ecore_Event * ev)
|
|||
v = l->data;
|
||||
if (e->win == v->win.base)
|
||||
{
|
||||
/* send XdndStatus (even to same view, we'll */
|
||||
/* ignore actions within the same view later */
|
||||
/* during the drop action.) */
|
||||
ecore_window_dnd_send_status_ok(v->win.base, e->source_win,
|
||||
v->location.x, v->location.y,
|
||||
v->size.w, v->size.h
|
||||
);
|
||||
|
||||
if( e->win != e->source_win )
|
||||
{
|
||||
/* send XdndStatus */
|
||||
ecore_window_dnd_send_status_ok(v->win.base, e->source_win,
|
||||
v->location.x, v->location.y,
|
||||
v->size.w, v->size.h
|
||||
);
|
||||
}
|
||||
/* todo - cache window extents, don't send again within these extents. */
|
||||
D_RETURN;
|
||||
}
|
||||
|
@ -2795,8 +2848,14 @@ e_dnd_drop(Ecore_Event * ev)
|
|||
v = l->data;
|
||||
if (e->win == v->win.base)
|
||||
{
|
||||
/* Dropped! Handle data */
|
||||
e_dnd_handle_drop (v, dnd_pending_mode);
|
||||
/* Dropped! Handle data */
|
||||
/* Same view? Mark to skip action */
|
||||
if( e->win == e->source_win )
|
||||
v->drag.matching_drop_attempt = 1;
|
||||
/* Different view? Perform the action... */
|
||||
else
|
||||
e_dnd_handle_drop (v);
|
||||
|
||||
ecore_window_dnd_send_finished(v->win.base, e->source_win);
|
||||
e_dnd_drop_request_free();
|
||||
|
||||
|
@ -2890,7 +2949,7 @@ e_dnd_drop_request_free(void)
|
|||
}
|
||||
|
||||
static void
|
||||
e_dnd_handle_drop( E_View *v, E_dnd_enum dnd_pending_mode )
|
||||
e_dnd_handle_drop( E_View *v )
|
||||
{
|
||||
int in, out;
|
||||
char *filename;
|
||||
|
@ -2923,10 +2982,12 @@ e_dnd_handle_drop( E_View *v, E_dnd_enum dnd_pending_mode )
|
|||
/* Copy files */
|
||||
efsd_copy( e_fs_get_connection(), out, dnd_files,
|
||||
efsd_ops(0) );
|
||||
dnd_pending_mode = E_DND_COPIED;
|
||||
break;
|
||||
case E_DND_MOVE:
|
||||
efsd_move( e_fs_get_connection(), out, dnd_files,
|
||||
efsd_ops(0) );
|
||||
dnd_pending_mode = E_DND_DELETED;
|
||||
break;
|
||||
default:
|
||||
/* nothing yet */
|
||||
|
|
15
src/view.h
15
src/view.h
|
@ -26,14 +26,18 @@ typedef struct _E_Iconbar E_Iconbar;
|
|||
|
||||
#ifndef E_DND_TYPEDEF
|
||||
#define E_DND_TYPEDEF
|
||||
typedef enum {
|
||||
typedef enum _E_dnd_enum E_dnd_enum;
|
||||
#endif
|
||||
|
||||
enum _E_dnd_enum {
|
||||
E_DND_NONE,
|
||||
E_DND_COPY,
|
||||
E_DND_MOVE,
|
||||
E_DND_LINK,
|
||||
E_DND_ASK
|
||||
} E_dnd_enum;
|
||||
#endif
|
||||
E_DND_ASK,
|
||||
E_DND_DELETED,
|
||||
E_DND_COPIED
|
||||
} ;
|
||||
|
||||
struct _E_View
|
||||
{
|
||||
|
@ -128,6 +132,9 @@ struct _E_View
|
|||
} offset;
|
||||
int update;
|
||||
int drop_mode;
|
||||
int icon_hide;
|
||||
int icon_show;
|
||||
int matching_drop_attempt;
|
||||
} drag;
|
||||
struct {
|
||||
int valid;
|
||||
|
|
Loading…
Reference in New Issue