Patches from ptomaine.

* Fix for URI escpaing.
 * Add the ability for EFM to recognize different drop actions from other FMs.  The reverse soon to come :)
 * Add option to disable HAL device icons on the desktop.
 * Performing an operation on multiple files will now be done in a single slave process instead of many.

 More to come before and after GSOC :)  If you see him in the channel, give him a high five because he's finally helped pull EFM out of the crapper :P


SVN revision: 35432
This commit is contained in:
Nicholas Hughart 2008-08-11 02:13:22 +00:00
parent 99fc29f7aa
commit e177bb663f
11 changed files with 705 additions and 367 deletions

View File

@ -587,6 +587,8 @@ e_config_init(void)
E_CONFIG_VAL(D, T, thumbscroll_momentum_threshhold, DOUBLE);
E_CONFIG_VAL(D, T, thumbscroll_friction, DOUBLE);
E_CONFIG_VAL(D, T, hal_desktop, INT);
e_config = e_config_domain_load("e", _e_config_edd);
if (e_config)
{
@ -763,6 +765,7 @@ e_config_init(void)
e_config->display_res_hz = 0;
e_config->display_res_rotation = 0;
e_config->hal_desktop = 1;
{
E_Config_Module *em;

View File

@ -286,6 +286,8 @@ struct _E_Config
int thumbscroll_threshhold;
double thumbscroll_momentum_threshhold;
double thumbscroll_friction;
int hal_desktop;
};
struct _E_Config_Module

View File

@ -19,10 +19,11 @@ static void _e_drag_show(E_Drag *drag);
static void _e_drag_hide(E_Drag *drag);
static void _e_drag_move(E_Drag *drag, int x, int y);
static void _e_drag_coords_update(E_Drop_Handler *h, int *dx, int *dy, int *dw, int *dh);
static Ecore_X_Window _e_drag_win_get(E_Drop_Handler *h, int xdnd);
static int _e_drag_win_matches(E_Drop_Handler *h, Ecore_X_Window win, int xdnd);
static void _e_drag_win_show(E_Drop_Handler *h);
static void _e_drag_win_hide(E_Drop_Handler *h);
static void _e_drag_update(Ecore_X_Window root, int x, int y);
static int _e_drag_update(Ecore_X_Window root, int x, int y, Ecore_X_Atom action);
static void _e_drag_end(Ecore_X_Window root, int x, int y);
static void _e_drag_xdnd_end(Ecore_X_Window root, int x, int y);
static void _e_drag_free(E_Drag *drag);
@ -62,6 +63,9 @@ static E_Drag *_drag_current = NULL;
static XDnd *_xdnd = NULL;
static Evas_Hash *_drop_handlers_responsives;
static Ecore_X_Atom _action;
/* externally accessible functions */
EAPI int
@ -98,6 +102,8 @@ e_dnd_init(void)
_event_handlers = evas_list_append(_event_handlers,
ecore_event_handler_add(ECORE_X_EVENT_SELECTION_NOTIFY,
_e_dnd_cb_event_dnd_selection, NULL));
_action = ECORE_X_ATOM_XDND_ACTION_PRIVATE;
return 1;
}
@ -128,6 +134,8 @@ e_dnd_shutdown(void)
evas_list_free(_drop_handlers);
_drop_handlers = NULL;
evas_hash_free(_drop_handlers_responsives);
return 1;
}
@ -491,6 +499,36 @@ e_drag_idler_before(void)
}
}
EAPI void
e_drop_handler_responsive_set(E_Drop_Handler *handler)
{
Ecore_X_Window hwin = _e_drag_win_get(handler, 1);
const char *wid = e_util_winid_str_get(hwin);
_drop_handlers_responsives = evas_hash_add(_drop_handlers_responsives, wid, (void *)handler);
}
EAPI int
e_drop_handler_responsive_get(E_Drop_Handler *handler)
{
Ecore_X_Window hwin = _e_drag_win_get(handler, 1);
const char *wid = e_util_winid_str_get(hwin);
return evas_hash_find(_drop_handlers_responsives, wid) == (void *)handler;
}
EAPI void
e_drop_handler_action_set(Ecore_X_Atom action)
{
_action = action;
}
EAPI Ecore_X_Atom
e_drop_handler_action_get()
{
return _action;
}
/* local subsystem functions */
static void
@ -574,8 +612,8 @@ _e_drag_coords_update(E_Drop_Handler *h, int *dx, int *dy, int *dw, int *dh)
*dy += py;
}
static int
_e_drag_win_matches(E_Drop_Handler *h, Ecore_X_Window win, int xdnd)
static Ecore_X_Window
_e_drag_win_get(E_Drop_Handler *h, int xdnd)
{
Ecore_X_Window hwin = 0;
@ -608,6 +646,15 @@ _e_drag_win_matches(E_Drop_Handler *h, Ecore_X_Window win, int xdnd)
break;
}
}
return hwin;
}
static int
_e_drag_win_matches(E_Drop_Handler *h, Ecore_X_Window win, int xdnd)
{
Ecore_X_Window hwin = _e_drag_win_get(h, xdnd);
if (win == hwin) return 1;
return 0;
}
@ -660,8 +707,8 @@ _e_drag_win_hide(E_Drop_Handler *h)
}
}
static void
_e_drag_update(Ecore_X_Window root, int x, int y)
static int
_e_drag_update(Ecore_X_Window root, int x, int y, Ecore_X_Atom action)
{
Evas_List *l;
E_Event_Dnd_Enter enter_ev;
@ -669,6 +716,7 @@ _e_drag_update(Ecore_X_Window root, int x, int y)
E_Event_Dnd_Leave leave_ev;
int dx, dy, dw, dh;
Ecore_X_Window win, ignore_win[2];
int responsive = 0;
// double t1 = ecore_time_get(); ////
if (_drag_current)
@ -702,12 +750,16 @@ _e_drag_update(Ecore_X_Window root, int x, int y)
enter_ev.x = x - dx;
enter_ev.y = y - dy;
enter_ev.data = NULL;
enter_ev.action = action;
move_ev.x = x - dx;
move_ev.y = y - dy;
move_ev.action = action;
leave_ev.x = x - dx;
leave_ev.y = y - dy;
if (E_INSIDE(x, y, dx, dy, dw, dh) && _e_drag_win_matches(h, win, 0))
{
if(e_drop_handler_responsive_get(h)) responsive = 1;
if (!h->entered)
{
_e_drag_win_show(h);
@ -750,12 +802,16 @@ _e_drag_update(Ecore_X_Window root, int x, int y)
_e_drag_coords_update(h, &dx, &dy, &dw, &dh);
enter_ev.x = x - dx;
enter_ev.y = y - dy;
enter_ev.action = action;
move_ev.x = x - dx;
move_ev.y = y - dy;
move_ev.action = action;
leave_ev.x = x - dx;
leave_ev.y = y - dy;
if (E_INSIDE(x, y, dx, dy, dw, dh) && _e_drag_win_matches(h, win, 1))
{
if(e_drop_handler_responsive_get(h)) responsive = 1;
if (!h->entered)
{
if (h->cb.enter)
@ -776,6 +832,10 @@ _e_drag_update(Ecore_X_Window root, int x, int y)
}
}
}
if(action == ECORE_X_ATOM_ATOM) responsive = 0;
return responsive;
// double t2 = ecore_time_get() - t1; ////
// printf("DND UPDATE %3.7f\n", t2); ////
}
@ -1009,7 +1069,7 @@ _e_dnd_cb_mouse_move(void *data, int type, void *event)
ev = event;
if (ev->win != _drag_win) return 1;
_e_drag_update(_drag_win_root, ev->x, ev->y);
_e_drag_update(_drag_win_root, ev->x, ev->y, ECORE_X_ATOM_ATOM);
return 1;
}
@ -1133,10 +1193,13 @@ _e_dnd_cb_event_dnd_position(void *data, int type, void *event)
{
Ecore_X_Event_Xdnd_Position *ev;
Ecore_X_Rectangle rect;
Ecore_X_Action action;
const char *id;
const char *description = NULL;
Evas_List *l;
int active;
int responsive;
ev = event;
// double t1 = ecore_time_get(); ////
@ -1153,6 +1216,8 @@ _e_dnd_cb_event_dnd_position(void *data, int type, void *event)
rect.width = 0;
rect.height = 0;
action = ev->action;
active = 0;
for (l = _drop_handlers; l; l = l->next)
{
@ -1171,8 +1236,15 @@ _e_dnd_cb_event_dnd_position(void *data, int type, void *event)
}
else
{
_e_drag_update(ev->win, ev->position.x, ev->position.y);
ecore_x_dnd_send_status(1, 0, rect, ECORE_X_DND_ACTION_PRIVATE);
responsive = _e_drag_update(ev->win, ev->position.x, ev->position.y, ev->action);
if(responsive)
{
ecore_x_dnd_send_status(1, 0, rect, _action);
}
else
{
ecore_x_dnd_send_status(1, 0, rect, ECORE_X_ATOM_XDND_ACTION_PRIVATE);
}
}
// double t2 = ecore_time_get() - t1; ////
// printf("DND POS EV 2 %3.7f\n", t2); ////

View File

@ -84,11 +84,13 @@ struct _E_Event_Dnd_Enter
{
void *data;
int x, y;
Ecore_X_Atom action;
};
struct _E_Event_Dnd_Move
{
int x, y;
Ecore_X_Atom action;
};
struct _E_Event_Dnd_Leave
@ -135,6 +137,10 @@ EAPI void e_drop_handler_geometry_set(E_Drop_Handler *handler, int x, int y, int
EAPI int e_drop_inside(E_Drop_Handler *handler, int x, int y);
EAPI void e_drop_handler_del(E_Drop_Handler *handler);
EAPI int e_drop_xdnd_register_set(Ecore_X_Window win, int reg);
EAPI void e_drop_handler_responsive_set(E_Drop_Handler *handler);
EAPI int e_drop_handler_responsive_get(E_Drop_Handler *handler);
EAPI void e_drop_handler_action_set(Ecore_X_Atom action);
EAPI Ecore_X_Atom e_drop_handler_action_get();
#endif
#endif

View File

@ -350,17 +350,20 @@ static void _e_fm2_client_spawn(void);
static E_Fm2_Client *_e_fm2_client_get(void);
static int _e_fm2_client_monitor_add(const char *path);
static void _e_fm2_client_monitor_del(int id, const char *path);
static int _e_fm2_client_file_del(const char *path);
static int _e_fm_client_file_del(const char *args);
static int _e_fm2_client_file_trash(const char *path);
static int _e_fm2_client_file_mkdir(const char *path, const char *rel, int rel_to, int x, int y, int res_w, int res_h);
static int _e_fm2_client_file_move(const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h);
static int _e_fm_client_file_move(const char *args);
static int _e_fm2_client_file_symlink(const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h);
static int _e_fm2_client_file_copy(const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h);
static int _e_fm_client_file_copy(const char *args);
static void _e_fm2_sel_rect_update(void *data);
static inline void _e_fm2_context_menu_append(Evas_Object *obj, const char *path, Evas_List *l, E_Menu *mn, E_Fm2_Icon *ic);
static int _e_fm2_context_list_sort(void *data1, void *data2);
static char *_e_fm_string_append_char(char *str, size_t *size, size_t *len, char c);
static char *_e_fm_string_append_quoted(char *str, size_t *size, size_t *len, const char *src);
static char *_e_fm2_meta_path = NULL;
static Evas_Smart *_e_fm2_smart = NULL;
static Evas_List *_e_fm2_list = NULL;
@ -982,6 +985,7 @@ e_fm2_window_object_set(Evas_Object *obj, E_Object *eobj)
_e_fm2_cb_dnd_leave,
_e_fm2_cb_dnd_drop,
drop, 3, sd->x, sd->y, sd->w, sd->h);
e_drop_handler_responsive_set(sd->drop_handler);
}
EAPI void
@ -1622,28 +1626,13 @@ _e_fm2_client_monitor_add(const char *path)
static void
_e_fm2_client_monitor_del(int id, const char *path)
{
E_Fm2_Client *cl;
cl = _e_fm2_client_get();
if (!cl)
{
_e_fm2_client_message_queue(E_IPC_DOMAIN_FM, E_FM_OP_MONITOR_END,
id, 0, 0,
(void *)path, strlen(path) + 1);
}
else
{
ecore_ipc_client_send(cl->cl, E_IPC_DOMAIN_FM, E_FM_OP_MONITOR_END,
id, 0, 0,
(void *)path, strlen(path) + 1);
cl->req++;
}
_e_fm_client_send(E_FM_OP_MONITOR_END, id, (void *)path, strlen(path) + 1);
}
static int
_e_fm2_client_file_del(const char *path)
_e_fm_client_file_del(const char *files)
{
return _e_fm_client_send_new(E_FM_OP_REMOVE, (void *)path, strlen(path) + 1);
return _e_fm_client_send_new(E_FM_OP_REMOVE, (void *)files, strlen(files) + 1);
}
static int
@ -1672,43 +1661,9 @@ _e_fm2_client_file_mkdir(const char *path, const char *rel, int rel_to, int x, i
}
static int
_e_fm2_client_file_move(const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h)
_e_fm_client_file_move(const char *args)
{
char *d;
int l1, l2, l3, l;
l1 = strlen(path);
l2 = strlen(dest);
l3 = strlen(rel);
l = l1 + 1 + l2 + 1 + l3 + 1 + (sizeof(int) * 3);
d = alloca(l);
strcpy(d, path);
strcpy(d + l1 + 1, dest);
strcpy(d + l1 + 1 + l2 + 1, rel);
memcpy(d + l1 + 1 + l2 + 1 + l3 + 1, &rel_to, sizeof(int));
memcpy(d + l1 + 1 + l2 + 1 + l3 + 1 + sizeof(int), &x, sizeof(int));
memcpy(d + l1 + 1 + l2 + 1 + l3 + 1 + (2 * sizeof(int)), &y, sizeof(int));
if ((x != -9999) && (y != -9999))
{
E_Fm2_Custom_File *cf, cf0;
cf = e_fm2_custom_file_get(dest);
if (!cf)
{
memset(&cf0, 0, sizeof(E_Fm2_Custom_File));
cf = &cf0;
}
cf->geom.x = x;
cf->geom.y = y;
cf->geom.res_w = res_w;
cf->geom.res_h = res_h;
cf->geom.valid = 1;
e_fm2_custom_file_set(dest, cf);
e_fm2_custom_file_flush();
}
return _e_fm_client_send_new(E_FM_OP_MOVE, (void *)d, l);
return _e_fm_client_send_new(E_FM_OP_MOVE, (void *)args, strlen(args) + 1);
}
static int
@ -1753,43 +1708,9 @@ _e_fm2_client_file_symlink(const char *path, const char *dest, const char *rel,
}
static int
_e_fm2_client_file_copy(const char *path, const char *dest, const char *rel, int rel_to, int x, int y, int res_w, int res_h)
_e_fm_client_file_copy(const char *args)
{
char *d;
int l1, l2, l3, l;
l1 = strlen(path);
l2 = strlen(dest);
l3 = strlen(rel);
l = l1 + 1 + l2 + 1 + l3 + 1 + (sizeof(int) * 3);
d = alloca(l);
strcpy(d, path);
strcpy(d + l1 + 1, dest);
strcpy(d + l1 + 1 + l2 + 1, rel);
memcpy(d + l1 + 1 + l2 + 1 + l3 + 1, &rel_to, sizeof(int));
memcpy(d + l1 + 1 + l2 + 1 + l3 + 1 + sizeof(int), &x, sizeof(int));
memcpy(d + l1 + 1 + l2 + 1 + l3 + 1 + (2 * sizeof(int)), &y, sizeof(int));
if ((x != -9999) && (y != -9999))
{
E_Fm2_Custom_File *cf, cf0;
cf = e_fm2_custom_file_get(dest);
if (!cf)
{
memset(&cf0, 0, sizeof(E_Fm2_Custom_File));
cf = &cf0;
}
cf->geom.x = x;
cf->geom.y = y;
cf->geom.res_w = res_w;
cf->geom.res_h = res_h;
cf->geom.valid = 1;
e_fm2_custom_file_set(dest, cf);
e_fm2_custom_file_flush();
}
return _e_fm_client_send_new(E_FM_OP_COPY, (void *)d, l);
return _e_fm_client_send_new(E_FM_OP_COPY, (void *)args, strlen(args) + 1);
}
EAPI int
@ -2130,6 +2051,7 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e)
if (s) e_fm2_hal_storage_add(s);
}
break;
case E_FM_OP_STORAGE_DEL:/*storage del*/
if ((e->data) && (e->size > 0))
{
@ -2151,6 +2073,7 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e)
if (v) e_fm2_hal_volume_add(v);
}
break;
case E_FM_OP_VOLUME_DEL:/*volume del*/
if ((e->data) && (e->size > 0))
{
@ -2175,6 +2098,7 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e)
if (v) e_fm2_hal_mount_add(v, mountpoint);
}
break;
case E_FM_OP_UNMOUNT_DONE:/*unmount done*/
if ((e->data) && (e->size > 1))
{
@ -2190,6 +2114,8 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e)
v->mount_point = NULL;
}
}
break;
case E_FM_OP_ERROR:/*error*/
printf("%s:%s(%d) Error from slave #%d: %s\n", __FILE__, __FUNCTION__, __LINE__, e->ref, e->data);
_e_fm_error_dialog(e->ref, e->data);
@ -2208,14 +2134,24 @@ e_fm2_client_data(Ecore_Ipc_Event_Client_Data *e)
case E_FM_OP_PROGRESS:/*progress*/
{
int percent, seconds;
size_t done, total;
char *src = NULL;
char *dst = NULL;
void *p = e->data;
if (!e->data || e->size != 2 * sizeof(int)) return;
if (!e->data) return;
percent = *(int *)e->data;
seconds = *(int *)(e->data + sizeof(int));
printf("%s:%s(%d) Progress from slave #%d: %d%% done, %d seconds left.\n", __FILE__, __FUNCTION__, __LINE__, e->ref, percent, seconds);
break;
#define UP(value, type) (value) = *(type *)p; p += sizeof(type)
UP(percent, int);
UP(seconds, int);
UP(done, size_t);
UP(total, size_t);
#undef UP
src = p;
dst = p + strlen(src) + 1;
printf("%s:%s(%d) Progress from slave #%d:\n\t%d%% done,\n\t%d seconds left,\n\t%lu done,\n\t%lu total,\n\tsrc = %s,\n\tdst = %s.\n", __FILE__, __FUNCTION__, __LINE__, e->ref, percent, seconds, done, total, src, dst);
}
break;
default:
break;
@ -2538,20 +2474,20 @@ _e_fm2_file_paste(void *data, E_Menu *m, E_Menu_Item *mi)
E_Fm2_Smart_Data *sd;
Evas_List *paths;
const char *dirpath;
const char *filepath;
size_t length = 0;
size_t size = 0;
char *args = NULL;
sd = data;
if (!sd) return;
/* Convert URI list to a list of real paths. */
paths = _e_fm2_uri_path_list_get(_e_fm_file_buffer);
dirpath = e_fm2_real_path_get(sd->obj);
while (paths)
{
char *filepath;
const char *filename;
char buf[PATH_MAX];
int protect = 0;
/* Get file's full path. */
filepath = evas_list_data(paths);
if (!filepath)
{
@ -2559,30 +2495,38 @@ _e_fm2_file_paste(void *data, E_Menu *m, E_Menu_Item *mi)
continue;
}
filename = ecore_file_file_get(filepath);
snprintf(buf, sizeof(buf), "%s/%s", dirpath, filename);
protect = e_filereg_file_protected(filepath);
if (protect)
/* Check if file is protected. */
if (e_filereg_file_protected(filepath))
{
evas_stringshare_del(filepath);
paths = evas_list_remove_list(paths, paths);
continue;
}
/* Put filepath into a string of args.
* If there are more files, put an additional space.
*/
args = _e_fm_string_append_quoted(args, &size, &length, filepath);
args = _e_fm_string_append_char(args, &size, &length, ' ');
if (_e_fm_file_buffer_copying)
{
_e_fm2_client_file_copy(filepath, buf, "", 0,
-9999, -9999, sd->w, sd->h);
}
else if (_e_fm_file_buffer_cutting)
{
_e_fm2_client_file_move(filepath, buf, "", 0,
-9999, -9999, sd->w, sd->h);
}
evas_stringshare_del(filepath);
paths = evas_list_remove_list(paths, paths);
}
/* Add destination to the arguments. */
args = _e_fm_string_append_quoted(args, &size, &length, sd->realpath);
/* Roll the operation! */
if(_e_fm_file_buffer_copying)
{
_e_fm_client_file_copy(args);
}
else
{
_e_fm_client_file_move(args);
}
free(args);
}
static void
@ -3229,7 +3173,7 @@ _e_fm2_uri_escape(const char *path)
dest[i] = *p;
else
{
snprintf(&(dest[i]), 4, "%%%02X", *p);
snprintf(&(dest[i]), 4, "%%%02X", (unsigned char)*p);
i += 2;
}
}
@ -4560,6 +4504,7 @@ _e_fm2_cb_dnd_enter(void *data, const char *type, void *event)
if (strcmp(type, "text/uri-list")) return;
ev = (E_Event_Dnd_Enter *)event;
printf("DND IN %i %i\n", ev->x, ev->y);
e_drop_handler_action_set(ev->action);
}
static void
@ -4575,6 +4520,7 @@ _e_fm2_cb_dnd_move(void *data, const char *type, void *event)
if (strcmp(type, "text/uri-list")) return;
ev = (E_Event_Dnd_Move *)event;
printf("DND MOVE %i %i\n", ev->x, ev->y);
e_drop_handler_action_set(ev->action);
for (l = sd->icons; l; l = l->next) /* FIXME: should only walk regions and skip non-visible ones */
{
ic = l->data;
@ -4688,6 +4634,151 @@ _e_fm2_cb_dnd_leave(void *data, const char *type, void *event)
_e_fm2_dnd_drop_all_hide(sd->obj);
}
static void
_e_fm_file_reorder(const char *file, const char *dst, const char *relative, int after)
{
unsigned int length = strlen(file) + 1 + strlen(dst) + 1 + strlen(relative) + 1 + sizeof(after);
void *data, *p;
data = alloca(length);
if(!data) return;
p = data;
#define P(s) memcpy(p, s, strlen(s) + 1); p += strlen(s) + 1
P(file);
P(dst);
P(relative);
#undef P
memcpy(p, &after, sizeof(int));
_e_fm_client_send_new(E_FM_OP_REORDER, data, length);
}
static void
_e_fm_icon_save_position(const char *file, Evas_Coord x, Evas_Coord y, Evas_Coord w, Evas_Coord h)
{
E_Fm2_Custom_File *cf, new;
if(!file) return;
cf = e_fm2_custom_file_get(file);
if(!cf)
{
memset(&new, 0, sizeof(E_Fm2_Custom_File));
cf = &new;
}
cf->geom.x = x;
cf->geom.y = y;
cf->geom.res_w = w;
cf->geom.res_h = h;
cf->geom.valid = 1;
e_fm2_custom_file_set(file, cf);
e_fm2_custom_file_flush();
}
static void
_e_fm_drop_menu_copy_cb(void *data, E_Menu *m, E_Menu_Item *mi)
{
char *args = data;
if(!data) return;
_e_fm_client_file_copy(args);
}
static void
_e_fm_drop_menu_move_cb(void *data, E_Menu *m, E_Menu_Item *mi)
{
char *args = data;
if(!data) return;
_e_fm_client_file_move(args);
}
static void
_e_fm_drop_menu_abort_cb(void *data, E_Menu *m, E_Menu_Item *mi)
{
char *args = data;
if(!data) return;
}
static void
_e_fm_drop_menu_post_cb(void *data, E_Menu *m)
{
char *args = data;
if(!data) return;
free(args);
}
static void
_e_fm_drop_menu(char *args)
{
E_Menu *menu = e_menu_new();
E_Menu_Item *item = NULL;
E_Manager *man = NULL;
E_Container *con = NULL;
E_Zone *zone = NULL;
int x, y;
if(!menu) return;
item = e_menu_item_new(menu);
e_menu_item_label_set(item, _("Copy"));
e_menu_item_callback_set(item, _e_fm_drop_menu_copy_cb, args);
e_menu_item_icon_edje_set(item,
e_theme_edje_file_get("base/theme/fileman",
"e/fileman/default/button/copy"),
"e/fileman/default/button/copy");
item = e_menu_item_new(menu);
e_menu_item_label_set(item, _("Move"));
e_menu_item_callback_set(item, _e_fm_drop_menu_move_cb, args);
e_menu_item_icon_edje_set(item,
e_theme_edje_file_get("base/theme/fileman",
"e/fileman/default/button/move"),
"e/fileman/default/button/move");
item = e_menu_item_new(menu);
e_menu_item_label_set(item, _("Abort"));
e_menu_item_callback_set(item, _e_fm_drop_menu_abort_cb, args);
e_menu_item_icon_edje_set(item,
e_theme_edje_file_get("base/theme/fileman",
"e/fileman/default/button/abort"),
"e/fileman/default/button/abort");
man = e_manager_current_get();
if (!man)
{
e_object_del(E_OBJECT(menu));
return;
}
con = e_container_current_get(man);
if (!con)
{
e_object_del(E_OBJECT(menu));
return;
}
ecore_x_pointer_xy_get(con->win, &x, &y);
zone = e_util_zone_current_get(man);
if (!zone)
{
e_object_del(E_OBJECT(menu));
return;
}
e_menu_post_deactivate_callback_set(menu, _e_fm_drop_menu_post_cb, args);
e_menu_activate_mouse(menu, zone,
x, y, 1, 1,
E_MENU_POP_DIRECTION_DOWN, 0);
}
static void
_e_fm2_cb_dnd_drop(void *data, const char *type, void *event)
{
@ -4699,6 +4790,11 @@ _e_fm2_cb_dnd_drop(void *data, const char *type, void *event)
const char *fp;
Evas_Coord dx, dy, ox, oy, x, y;
int adjust_icons = 0;
char dirpath[PATH_MAX];
char *args = NULL;
size_t size = 0;
size_t length = 0;
sd = data;
if (!type) return;
@ -4750,24 +4846,24 @@ _e_fm2_cb_dnd_drop(void *data, const char *type, void *event)
ic = il->data;
fp = ll->data;
if (!fp) continue;
snprintf(buf, sizeof(buf), "%s/%s",
sd->realpath, ecore_file_file_get(fp));
printf("mv %s %s\n", (char *)fp, buf);
if ((ic) && (sd->config->view.mode == E_FM2_VIEW_MODE_CUSTOM_ICONS))
{
/* dnd doesnt tell me all the co-ords of the icons being dragged so i can't place them accurately.
* need to fix this. ev->data probably needs to become more compelx than a list of url's
*/
x = ev->x + (ic->x - ox) - ic->drag.x + sd->pos.x;
y = ev->y + (ic->y - oy) - ic->drag.y + sd->pos.y;//ic->y - oy - dy + ev->y + sd->pos.y;
y = ev->y + (ic->y - oy) - ic->drag.y + sd->pos.y;
if (x < 0) x = 0;
if (y < 0) y = 0;
if (sd->config->view.fit_custom_pos)
{
if ((x + ic->w) > sd->w) x = (sd->w - ic->w);
if ((y + ic->h) > sd->h) y = (sd->h - ic->h);
}
_e_fm2_client_file_move(fp, buf, "", 0, x, y, sd->w, sd->h);
if (ic->sd == sd)
{
ic->x = x;
@ -4775,11 +4871,15 @@ _e_fm2_cb_dnd_drop(void *data, const char *type, void *event)
ic->saved_pos = 1;
adjust_icons = 1;
}
snprintf(buf, sizeof(buf), "%s/%s",
sd->realpath, ecore_file_file_get(fp));
_e_fm_icon_save_position(buf, x, y, sd->w, sd->h);
}
else
{
_e_fm2_client_file_move(fp, buf, "", 0, -9999, -9999, sd->w, sd->h);
}
args = _e_fm_string_append_quoted(args, &size, &length, fp);
args = _e_fm_string_append_char(args, &size, &length, ' ');
evas_stringshare_del(fp);
}
if (adjust_icons)
@ -4795,6 +4895,8 @@ _e_fm2_cb_dnd_drop(void *data, const char *type, void *event)
_e_fm2_obj_icons_place(sd);
evas_object_smart_callback_call(sd->obj, "changed", NULL);
}
args = _e_fm_string_append_quoted(args, &size, &length, sd->realpath);
}
else if (sd->drop_icon) /* inot or before/after an icon */
{
@ -4811,76 +4913,44 @@ _e_fm2_cb_dnd_drop(void *data, const char *type, void *event)
snprintf(buf, sizeof(buf), "%s/%s/%s",
sd->realpath, sd->drop_icon->info.file, ecore_file_file_get(fp));
printf("mv %s %s\n", (char *)fp, buf);
_e_fm2_client_file_move(fp, buf, "", 0, -9999, -9999, sd->w, sd->h);
args = _e_fm_string_append_quoted(args, &size, &length, fp);
args = _e_fm_string_append_char(args, &size, &length, ' ');
evas_stringshare_del(fp);
}
snprintf(dirpath, sizeof(dirpath), "%s/%s", sd->realpath, sd->drop_icon->info.file);
args = _e_fm_string_append_quoted(args, &size, &length, dirpath);
}
else
{
if (sd->config->view.mode == E_FM2_VIEW_MODE_LIST) /* list */
if (sd->config->view.mode == E_FM2_VIEW_MODE_LIST && sd->order_file) /* list */
{
if (sd->order_file) /* there is an order file */
for (ll = fsel, il = isel; ll && il; ll = ll->next, il = il->next)
{
if (sd->drop_after)
ic = il->data;
fp = ll->data;
if (!fp) continue;
snprintf(buf, sizeof(buf), "%s/%s",
sd->realpath, ecore_file_file_get(fp));
if (sd->config->view.link_drop)
{
for (ll = fsel, il = isel; ll && il; ll = ll->next, il = il->next)
{
ic = il->data;
fp = ll->data;
if (!fp) continue;
snprintf(buf, sizeof(buf), "%s/%s",
sd->realpath, ecore_file_file_get(fp));
if (sd->config->view.link_drop)
{
printf("ln -s %s %s\n", (char *)fp, buf);
_e_fm2_client_file_symlink(buf, fp, sd->drop_icon->info.file, sd->drop_after, -9999, -9999, sd->h, sd->h);
}
else
{
printf("mv %s %s\n", (char *)fp, buf);
_e_fm2_client_file_move(fp, buf, sd->drop_icon->info.file, sd->drop_after, -9999, -9999, sd->w, sd->h);
}
evas_stringshare_del(fp);
}
printf("ln -s %s %s\n", (char *)fp, buf);
_e_fm2_client_file_symlink(buf, fp, sd->drop_icon->info.file, sd->drop_after, -9999, -9999, sd->h, sd->h);
}
else
{
for (ll = fsel, il = isel; ll && il; ll = ll->next, il = il->next)
{
ic = il->data;
fp = ll->data;
if (!fp) continue;
snprintf(buf, sizeof(buf), "%s/%s",
sd->realpath, ecore_file_file_get(fp));
if (sd->config->view.link_drop)
{
printf("ln -s %s %s\n", (char *)fp, buf);
_e_fm2_client_file_symlink(buf, fp, sd->drop_icon->info.file, sd->drop_after, -9999, -9999, sd->w, sd->h);
}
else
{
printf("mv %s %s\n", (char *)fp, buf);
_e_fm2_client_file_move(fp, buf, sd->drop_icon->info.file, sd->drop_after, -9999, -9999, sd->w, sd->h);
}
evas_stringshare_del(fp);
}
}
}
else /* no order file */
{
for (ll = fsel, il = isel; ll && il; ll = ll->next, il = il->next)
{
ic = il->data;
fp = ll->data;
if (!fp) continue;
/* move the file into the subdir */
snprintf(buf, sizeof(buf), "%s/%s",
sd->realpath, ecore_file_file_get(fp));
printf("mv %s %s\n", (char *)fp, buf);
_e_fm2_client_file_move(fp, buf, "", 0, -9999, -9999, sd->w, sd->h);
evas_stringshare_del(fp);
args = _e_fm_string_append_quoted(args, &size, &length, fp);
args = _e_fm_string_append_char(args, &size, &length, ' ');
}
_e_fm_file_reorder(ecore_file_file_get(fp), sd->realpath, sd->drop_icon->info.file, sd->drop_after);
evas_stringshare_del(fp);
}
args = _e_fm_string_append_quoted(args, &size, &length, sd->realpath);
}
else
{
@ -4889,17 +4959,32 @@ _e_fm2_cb_dnd_drop(void *data, const char *type, void *event)
ic = il->data;
fp = ll->data;
if (!fp) continue;
/* move the file into the subdir */
snprintf(buf, sizeof(buf), "%s/%s",
sd->realpath, ecore_file_file_get(fp));
printf("mv %s %s\n", (char *)fp, buf);
_e_fm2_client_file_move(fp, buf, "", 0, -9999, -9999, sd->w, sd->h);
args = _e_fm_string_append_quoted(args, &size, &length, fp);
args = _e_fm_string_append_char(args, &size, &length, ' ');
evas_stringshare_del(fp);
}
args = _e_fm_string_append_quoted(args, &size, &length, sd->realpath);
}
}
}
if(e_drop_handler_action_get() == ECORE_X_ATOM_XDND_ACTION_COPY)
{
_e_fm_client_file_copy(args);
free(args);
}
else if(e_drop_handler_action_get() == ECORE_X_ATOM_XDND_ACTION_MOVE)
{
_e_fm_client_file_move(args);
free(args);
}
else if(e_drop_handler_action_get() == ECORE_X_ATOM_XDND_ACTION_ASK)
{
_e_fm_drop_menu(args);
}
_e_fm2_dnd_drop_hide(sd->obj);
_e_fm2_dnd_drop_all_hide(sd->obj);
_e_fm2_list_walking++;
@ -6953,8 +7038,11 @@ static void
_e_fm2_file_rename_yes_cb(char *text, void *data)
{
E_Fm2_Icon *ic;
char newpath[4096];
char oldpath[4096];
char oldpath[PATH_MAX];
char newpath[PATH_MAX];
char *args = NULL;
size_t size = 0;
size_t length = 0;
ic = data;
ic->entry_dialog = NULL;
@ -6963,7 +7051,13 @@ _e_fm2_file_rename_yes_cb(char *text, void *data)
snprintf(oldpath, sizeof(oldpath), "%s/%s", ic->sd->realpath, ic->info.file);
snprintf(newpath, sizeof(newpath), "%s/%s", ic->sd->realpath, text);
if (e_filereg_file_protected(oldpath)) return;
_e_fm2_client_file_move(oldpath, newpath, "", 0, -9999, -9999, ic->sd->w, ic->sd->h);
args = _e_fm_string_append_quoted(args, &size, &length, oldpath);
args = _e_fm_string_append_char(args, &size, &length, ' ');
args = _e_fm_string_append_quoted(args, &size, &length, newpath);
_e_fm_client_file_move(args);
free(args);
}
}
@ -7266,11 +7360,63 @@ _e_fm2_file_delete_delete_cb(void *obj)
ic->dialog = NULL;
}
static char *
_e_fm_string_append_char(char *str, size_t *size, size_t *len, char c)
{
if(str == NULL)
{
str = malloc(4096);
str[0] = '\x00';
*size = 4096;
*len = 0;
}
if(*len >= *size - 1)
{
*size += 1024;
str = realloc(str, *size);
}
str[(*len)++] = c;
str[*len] = '\x00';
return str;
}
static char *
_e_fm_string_append_quoted(char *str, size_t *size, size_t *len, const char *src)
{
str = _e_fm_string_append_char(str, size, len, '\'');
while (*src)
{
if (*src == '\'')
{
str = _e_fm_string_append_char(str, size, len, '\'');
str = _e_fm_string_append_char(str, size, len, '\\');
str = _e_fm_string_append_char(str, size, len, '\'');
str = _e_fm_string_append_char(str, size, len, '\'');
}
else
str = _e_fm_string_append_char(str, size, len, *src);
src++;
}
str = _e_fm_string_append_char(str, size, len, '\'');
return str;
}
static void
_e_fm2_file_delete_yes_cb(void *data, E_Dialog *dialog)
{
E_Fm2_Icon *ic;
char buf[4096];
char buf[PATH_MAX];
char *files = NULL;
size_t size = 0;
size_t len = 0;
Evas_List *sel, *l;
E_Fm2_Icon_Info *ici;
@ -7286,18 +7432,23 @@ _e_fm2_file_delete_yes_cb(void *data, E_Dialog *dialog)
ici = l->data;
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ici->file);
if (e_filereg_file_protected(buf)) continue;
printf("rm -rf %s\n", buf);
_e_fm2_client_file_del(buf);
files = _e_fm_string_append_quoted(files, &size, &len, buf);
if(l->next) files = _e_fm_string_append_char(files, &size, &len, ' ');
}
evas_list_free(sel);
}
else
{
snprintf(buf, sizeof(buf), "%s/%s", ic->sd->realpath, ic->info.file);
if (e_filereg_file_protected(buf)) return;
printf("rm -rf %s\n", buf);
_e_fm2_client_file_del(buf);
files = _e_fm_string_append_quoted(files, &size, &len, buf);
}
_e_fm_client_file_del(files);
free(files);
evas_object_smart_callback_call(ic->sd->obj, "files_deleted", NULL);
}

View File

@ -196,7 +196,7 @@ _e_fm2_volume_write(E_Volume *v)
if (!v->storage) return;
id = ecore_file_file_get(v->storage->udi);
printf("vol write %s\n", id);
snprintf(buf, sizeof(buf), "%s/.e/e/fileman/favorites/|%s_%d.desktop",
snprintf(buf, sizeof(buf) - 1, "%s/.e/e/fileman/favorites/|%s_%d.desktop",
e_user_homedir_get(), id, v->partition_number);
f = fopen(buf, "w");
@ -292,13 +292,17 @@ _e_fm2_volume_write(E_Volume *v)
v->udi);
fclose(f);
snprintf(buf2, sizeof(buf2), "%s/Desktop/|%s_%d.desktop",
e_user_homedir_get(), id, v->partition_number);
ecore_file_symlink(buf, buf2);
if(e_config->hal_desktop)
{
snprintf(buf2, sizeof(buf2) - 1, "%s/Desktop/|%s_%d.desktop",
e_user_homedir_get(), id, v->partition_number);
ecore_file_symlink(buf, buf2);
}
/* FIXME: manipulate icon directly */
_e_fm2_file_force_update(buf);
_e_fm2_file_force_update(buf2);
//_e_fm2_file_force_update(buf2);
e_config;
}
}
@ -319,10 +323,14 @@ _e_fm2_volume_erase(E_Volume *v)
e_user_homedir_get(), id, v->partition_number);
ecore_file_unlink(buf);
_e_fm2_file_force_update(buf);
snprintf(buf, sizeof(buf) - 1, "%s/.e/e/fileman/favorites/|%s_%d.desktop",
e_user_homedir_get(), id, v->partition_number);
ecore_file_unlink(buf);
_e_fm2_file_force_update(buf);
if(e_config->hal_desktop)
{
snprintf(buf, sizeof(buf) - 1, "%s/.e/e/fileman/favorites/|%s_%d.desktop",
e_user_homedir_get(), id, v->partition_number);
ecore_file_unlink(buf);
_e_fm2_file_force_update(buf);
}
}
EAPI E_Volume *
@ -488,3 +496,62 @@ _e_fm2_hal_mount_timeout(E_Fm2_Mount *m)
return 0;
}
EAPI void
e_fm2_hal_show_desktop_icons(void)
{
Evas_List *l;
E_Volume *v;
char buf[PATH_MAX] = {0};
char buf2[PATH_MAX] = {0};
const char *id;
for(l = _e_vols; l; l = evas_list_next(l))
{
v = evas_list_data(l);
if(!v) continue;
if (!v->storage) continue;
id = ecore_file_file_get(v->storage->udi);
snprintf(buf, sizeof(buf) - 1, "%s/.e/e/fileman/favorites/|%s_%d.desktop",
e_user_homedir_get(), id, v->partition_number);
snprintf(buf2, sizeof(buf2) - 1, "%s/Desktop/|%s_%d.desktop",
e_user_homedir_get(), id, v->partition_number);
if(ecore_file_exists(buf) && !ecore_file_exists(buf2))
{
ecore_file_symlink(buf, buf2);
_e_fm2_file_force_update(buf2);
}
}
}
EAPI void
e_fm2_hal_hide_desktop_icons(void)
{
Evas_List *l;
E_Volume *v;
char buf[PATH_MAX] = {0};
const char *id;
for(l = _e_vols; l; l = evas_list_next(l))
{
v = evas_list_data(l);
if(!v) continue;
if (!v->storage) continue;
id = ecore_file_file_get(v->storage->udi);
snprintf(buf, sizeof(buf) - 1, "%s/Desktop/|%s_%d.desktop",
e_user_homedir_get(), id, v->partition_number);
if(ecore_file_exists(buf))
{
ecore_file_unlink(buf);
_e_fm2_file_force_update(buf);
}
}
}

View File

@ -25,4 +25,7 @@ EAPI E_Fm2_Mount *e_fm2_hal_mount(E_Volume *v,
void *data);
EAPI void e_fm2_hal_unmount(E_Fm2_Mount *m);
EAPI void e_fm2_hal_show_desktop_icons(void);
EAPI void e_fm2_hal_hide_desktop_icons(void);
#endif

View File

@ -140,7 +140,7 @@ static void _e_fm_handle_error_response(int id, E_Fm_Op_Type type);
static int _e_client_send(int id, E_Fm_Op_Type type, void *data, int size);
static int _e_fm_slave_run(E_Fm_Op_Type type, const char *src, const char *dst, int id);
static int _e_fm_slave_run(E_Fm_Op_Type type, const char *args, int id);
static E_Fm_Slave *_e_fm_slave_get(int id);
static int _e_fm_slave_send(E_Fm_Slave *slave, E_Fm_Op_Type type, void *data, int size);
static int _e_fm_slave_data_cb(void *data, int type, void *event);
@ -160,10 +160,10 @@ static void _e_file_mon_list_sync(E_Dir *ed);
static int _e_cb_file_mon_list_idler(void *data);
static int _e_cb_fop_trash_idler(void *data);
static char *_e_str_list_remove(Evas_List **list, char *str);
static void _e_path_fix_order(const char *path, const char *rel, int rel_to, int x, int y);
static void _e_fm_reorder(const char *file, const char *dst, const char *relative, int after);
static void _e_dir_del(E_Dir *ed);
static const char *_e_prepare_command(E_Fm_Op_Type type, const char *src, const char *dst);
static const char *_e_prepare_command(E_Fm_Op_Type type, const char *args);
#ifdef HAVE_EDBUS
@ -1256,7 +1256,7 @@ _e_fm_mkdir_try(E_Fm_Task *task)
}
else
{
_e_path_fix_order(task->src, task->rel, task->rel_to, task->x, task->y);
_e_fm_reorder(ecore_file_file_get(task->src), ecore_file_dir_get(task->src), task->rel, task->rel_to);
_e_fm_task_remove(task);
}
}
@ -1315,6 +1315,7 @@ _e_fm_handle_error_response(int id, E_Fm_Op_Type type)
}
}
static int
_e_ipc_cb_server_data(void *data, int type, void *event)
{
@ -1322,7 +1323,6 @@ _e_ipc_cb_server_data(void *data, int type, void *event)
e = event;
if (e->major != 6/*E_IPC_DOMAIN_FM*/) return 1;
printf("EFM: %d\n", e->minor);
switch (e->minor)
{
case E_FM_OP_MONITOR_START: /* monitor dir (and implicitly list) */
@ -1332,12 +1332,13 @@ _e_ipc_cb_server_data(void *data, int type, void *event)
break;
case E_FM_OP_MONITOR_END: /* monitor dir end */
{
printf("End listing directory: %s\n", e->data);
_e_fm_monitor_end(e->ref, e->data);
}
break;
case E_FM_OP_REMOVE: /* fop delete file/dir */
{
_e_fm_slave_run(E_FM_OP_REMOVE, (const char *)e->data, NULL, e->ref);
_e_fm_slave_run(E_FM_OP_REMOVE, (const char *)e->data, e->ref);
}
break;
case E_FM_OP_TRASH: /* fop trash file/dir */
@ -1356,32 +1357,12 @@ _e_ipc_cb_server_data(void *data, int type, void *event)
break;
case E_FM_OP_MOVE: /* fop mv file/dir */
{
const char *src, *dst, *rel;
int rel_to, x, y;
src = e->data;
dst = src + strlen(src) + 1;
rel = dst + strlen(dst) + 1;
memcpy(&rel_to, rel + strlen(rel) + 1, sizeof(int));
memcpy(&x, rel + strlen(rel) + 1 + sizeof(int), sizeof(int));
memcpy(&y, rel + strlen(rel) + 1 + sizeof(int), sizeof(int));
_e_fm_slave_run(E_FM_OP_MOVE, src, dst, e->ref);
_e_fm_slave_run(E_FM_OP_MOVE, (const char *)e->data, e->ref);
}
break;
case E_FM_OP_COPY: /* fop cp file/dir */
{
const char *src, *dst, *rel;
int rel_to, x, y;
src = e->data;
dst = src + strlen(src) + 1;
rel = dst + strlen(dst) + 1;
memcpy(&rel_to, rel + strlen(rel) + 1, sizeof(int));
memcpy(&x, rel + strlen(rel) + 1 + sizeof(int), sizeof(int));