Enlightenment CVS committal Author : raster Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_border.c e_config.c e_dnd.c e_fm.c Log Message: lok's xdnd work =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_border.c,v retrieving revision 1.601 retrieving revision 1.602 diff -u -3 -r1.601 -r1.602 --- e_border.c 18 Aug 2007 02:28:40 -0000 1.601 +++ e_border.c 18 Aug 2007 10:37:16 -0000 1.602 @@ -5736,23 +5736,12 @@ bd->bg_object = o; shape_option = edje_object_data_get(o, "shaped"); - if (shape_option) + if (shape_option && !strcmp(shape_option, "1")) { - if (!strcmp(shape_option, "1")) + if (!bd->shaped) { - if (!bd->shaped) - { - bd->shaped = 1; - ecore_evas_shaped_set(bd->bg_ecore_evas, bd->shaped); - } - } - else - { - if (bd->shaped) - { - bd->shaped = 0; - ecore_evas_shaped_set(bd->bg_ecore_evas, bd->shaped); - } + bd->shaped = 1; + ecore_evas_shaped_set(bd->bg_ecore_evas, bd->shaped); } } else =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_config.c,v retrieving revision 1.265 retrieving revision 1.266 diff -u -3 -r1.265 -r1.266 --- e_config.c 12 Aug 2007 10:30:34 -0000 1.265 +++ e_config.c 18 Aug 2007 10:37:16 -0000 1.266 @@ -919,10 +919,10 @@ E_BINDING_MODIFIER_CTRL | E_BINDING_MODIFIER_ALT, 0, "window_maximized_toggle", NULL); CFG_KEYBIND(E_BINDING_CONTEXT_ANY, "F10", - E_BINDING_MODIFIER_ALT, 0, + E_BINDING_MODIFIER_SHIFT, 0, "window_maximized_toggle", "default vertical"); CFG_KEYBIND(E_BINDING_CONTEXT_ANY, "F10", - E_BINDING_MODIFIER_SHIFT, 0, + E_BINDING_MODIFIER_SHIFT | E_BINDING_MODIFIER_ALT, 0, "window_maximized_toggle", "default horizontal"); CFG_KEYBIND(E_BINDING_CONTEXT_ANY, "r", E_BINDING_MODIFIER_CTRL | E_BINDING_MODIFIER_ALT, 0, =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_dnd.c,v retrieving revision 1.61 retrieving revision 1.62 diff -u -3 -r1.61 -r1.62 --- e_dnd.c 13 May 2007 09:12:30 -0000 1.61 +++ e_dnd.c 18 Aug 2007 10:37:16 -0000 1.62 @@ -59,7 +59,7 @@ static Evas_List *_drag_list = NULL; static E_Drag *_drag_current = NULL; -static XDnd *_xdnd; +static XDnd *_xdnd = NULL; /* externally accessible functions */ @@ -290,10 +290,15 @@ EAPI int e_drag_xdnd_start(E_Drag *drag, int x, int y) { + Ecore_X_Atom actions[] = {ECORE_X_DND_ACTION_MOVE, ECORE_X_DND_ACTION_PRIVATE, + ECORE_X_DND_ACTION_COPY, ECORE_X_DND_ACTION_ASK, + ECORE_X_DND_ACTION_LINK}; if (_drag_win) return 0; _drag_win = ecore_x_window_input_new(drag->container->win, drag->container->x, drag->container->y, drag->container->w, drag->container->h); + + ecore_x_window_show(_drag_win); if (!e_grabinput_get(_drag_win, 1, _drag_win)) { @@ -308,6 +313,7 @@ ecore_x_dnd_aware_set(_drag_win, 1); ecore_x_dnd_types_set(_drag_win, drag->types, drag->num_types); + ecore_x_dnd_actions_set(_drag_win, actions, 5); ecore_x_dnd_begin(_drag_win, drag->data, drag->data_size); _drag_current = drag; @@ -347,6 +353,7 @@ handler->h = h; handler->obj = obj; + handler->entered = 0; _drop_handlers = evas_list_append(_drop_handlers, handler); @@ -676,8 +683,7 @@ move_ev.y = y - dy; leave_ev.x = x - dx; leave_ev.y = y - dy; - if ((_e_drag_win_matches(h, win)) && - (E_INSIDE(x, y, dx, dy, dw, dh))) + if (E_INSIDE(x, y, dx, dy, dw, dh)) { if (!h->entered) { @@ -725,8 +731,7 @@ move_ev.y = y - dy; leave_ev.x = x - dx; leave_ev.y = y - dy; - if ((_e_drag_win_matches(h, win)) && - (E_INSIDE(x, y, dx, dy, dw, dh))) + if (E_INSIDE(x, y, dx, dy, dw, dh)) { if (!h->entered) { @@ -773,13 +778,22 @@ e_grabinput_release(_drag_win, _drag_win); if (_drag_current->type == E_DRAG_XDND) { - e_object_del(E_OBJECT(_drag_current)); - _drag_current = NULL; - if (!ecore_x_dnd_drop()) + int dropped; + + if (!(dropped = ecore_x_dnd_drop())) { ecore_x_window_del(_drag_win); _drag_win = 0; } + + if (_drag_current->cb.finished) + _drag_current->cb.finished(_drag_current, dropped); + + if (_drag_current && !_xdnd) + { + e_object_del(E_OBJECT(_drag_current)); + _drag_current = NULL; + } return; } @@ -883,9 +897,8 @@ _e_drag_coords_update(h, &dx, &dy, &dw, &dh); ev.x = x - dx; ev.y = y - dy; - if ((_e_drag_win_matches(h, win)) && - ((h->cb.drop) && - (E_INSIDE(x, y, dx, dy, dw, dh)))) + if (_e_drag_win_matches(h, win) && h->cb.drop + && E_INSIDE(x, y, dx, dy, dw, dh)) { h->cb.drop(h->cb.data, h->active_type, &ev); dropped = 1; @@ -993,7 +1006,6 @@ int i, j; ev = event; - if (ev->source == _drag_win) return 1; id = e_util_winid_str_get(ev->win); if (!evas_hash_find(_drop_win_hash, id)) return 1; for (l = _drop_handlers; l; l = l->next) @@ -1066,7 +1078,6 @@ ev = event; - if (ev->source == _drag_win) return 1; id = e_util_winid_str_get(ev->win); if (!evas_hash_find(_drop_win_hash, id)) return 1; printf("Xdnd leave\n"); @@ -1114,7 +1125,6 @@ int active; ev = event; - if (ev->source == _drag_win) return 1; id = e_util_winid_str_get(ev->win); if (!evas_hash_find(_drop_win_hash, id)) return 1; @@ -1160,21 +1170,22 @@ { Ecore_X_Event_Xdnd_Finished *ev; - /* - * TODO: - * - Check action - * - Do something if not completed - */ - ev = event; - if (ev->win != _drag_win) return 1; printf("Xdnd finished\n"); if (!ev->completed) - printf("FIXME: XDnd not completed, need to delay deleting _drag_win!!\n"); + return 1; + + if (_drag_current) + { + e_object_del(E_OBJECT(_drag_current)); + _drag_current = NULL; + } + e_grabinput_release(_drag_win, _drag_win); ecore_x_window_del(_drag_win); _drag_win = 0; + return 1; } @@ -1185,7 +1196,6 @@ const char *id; ev = event; - if (ev->source == _drag_win) return 1; id = e_util_winid_str_get(ev->win); if (!evas_hash_find(_drop_win_hash, id)) return 1; printf("Xdnd drop\n"); @@ -1194,6 +1204,7 @@ _xdnd->x = ev->position.x; _xdnd->y = ev->position.y; + return 1; } =================================================================== RCS file: /cvs/e/e17/apps/e/src/bin/e_fm.c,v retrieving revision 1.195 retrieving revision 1.196 diff -u -3 -r1.195 -r1.196 --- e_fm.c 17 Aug 2007 02:59:34 -0000 1.195 +++ e_fm.c 18 Aug 2007 10:37:16 -0000 1.196 @@ -28,6 +28,7 @@ typedef struct _E_Fm2_Action E_Fm2_Action; typedef struct _E_Fm2_Client E_Fm2_Client; typedef struct _E_Fm2_Mount E_Fm2_Mount; +typedef struct _E_Fm2_Uri E_Fm2_Uri; struct _E_Fm2_Smart_Data { @@ -190,6 +191,12 @@ unsigned char delete_me : 1; }; +struct _E_Fm2_Uri +{ + const char *hostname; + const char *path; +}; + static E_Fm2_Mount *_e_fm2_mount(E_Volume *v, void (*mount_ok) (void *data), void (*mount_fail) (void *data), void (*unmount_ok) (void *data), void (*unmount_fail) (void *data), void *data); static void _e_fm2_unmount(E_Fm2_Mount *m); static E_Volume *e_volume_find(const char *udi); @@ -3448,6 +3455,116 @@ return NULL; } +/* Escape illegal caracters within an uri and return an evas_stringshare */ +static const char * +_e_fm2_uri_escape(const char *path) +{ + char dest[PATH_MAX * 3 + 7]; + const char *p; + int i; + + if (!path) return NULL; + memset(dest, 0, PATH_MAX * 3 + 7); + + snprintf(dest, 8, "file://"); + + /* Most app doesn't handle the hostname in the uri so it's put to NULL */ + for (i = 7, p = path; *p != '\0'; p++, i++) + { + if (isalnum(*p) || strchr("/$-_.+!*'()", *p)) + dest[i] = *p; + else + { + char escaped[3]; + snprintf(&(dest[i]), 4, "%%%02X", *p); + i += 2; + } + } + + return evas_stringshare_add(dest); +} + +/* Parse a single uri and return an E_Fm2_Uri struct. + * If the parsing have failed it return NULL. + * The E_Fm2_Uri may have hostname parameter and always a path. + * If there's no hostname in the uri then the hostname parameter is NULL + */ +static E_Fm2_Uri * +_e_fm2_uri_parse(const char *val) +{ + E_Fm2_Uri *uri; + const char *p; + char hostname[HOST_NAME_MAX], path[PATH_MAX]; + int i = 0; + + /* The shortest possible path is file:/// + * anything smaller than that can't be a valid uri + */ + if (strlen(val) <= 7 && strncmp(val, "file://", 7)) return NULL; + memset(path, 0, PATH_MAX); + + /* An uri should be in a form file://<hostname>/<path> */ + p = val + 7; + if (*p != '/') + { + for (i = 0; *p != '/' && *p != '\0' && i < HOST_NAME_MAX; p++, i++) + hostname[i] = *p; + } + hostname[i] = '\0'; + + /* See http://www.faqs.org/rfcs/rfc1738.html for the escaped chars */ + for (p, i = 0; *p != '\0' && i < PATH_MAX; i++, p++) + { + if (*p == '%') + { + path[i] = *(++p); + path[i+1] = *(++p); + path[i] = (char)strtol(&(path[i]), NULL, 16); + path[i+1] = '\0'; + } + else + path[i] = *p; + } + + uri = E_NEW(E_Fm2_Uri, 1); + if (strlen(hostname) > 0) uri->hostname = evas_stringshare_add(hostname); + else uri->hostname = NULL; + uri->path = evas_stringshare_add(path); + + return uri; +} + +/* Takes an Evas_List of uri and return an Evas_List of real paths */ +static Evas_List * +_e_fm2_uri_path_list_get(Evas_List *uri_list) +{ + E_Fm2_Uri *uri; + Evas_List *l, *path_list = NULL; + char current_hostname[HOST_NAME_MAX]; + + if (gethostname(current_hostname, HOST_NAME_MAX) == -1) + current_hostname[0] = '\0'; + + for (l = uri_list; l; l = l->next) + { + if (!(uri = _e_fm2_uri_parse(l->data))) + continue; + + if (!uri->hostname || !strcmp(uri->hostname, "localhost") + || !strcmp(uri->hostname, current_hostname)) + { + path_list = evas_list_append(path_list, uri->path); + } + else + evas_stringshare_del(uri->path); + + if (uri->hostname) evas_stringshare_del(uri->hostname); + E_FREE(uri); + } + + return path_list; +} + static Evas_List * _e_fm2_uri_icon_list_get(Evas_List *uri) { @@ -3456,21 +3573,18 @@ for (l = uri; l; l = l->next) { - const char *u, *path, *file; + const char *path, *file; Evas_Object *fm; E_Fm2_Icon *ic; - u = l->data; + path = l->data; ic = NULL; - if (strlen(u) > 7) + + fm = _e_fm2_file_fm2_find(path); + if (fm) { - path = u + 7; - fm = _e_fm2_file_fm2_find(path); - if (fm) - { - file = ecore_file_file_get(path); - ic = _e_fm2_icon_find(fm, file); - } + file = ecore_file_file_get(path); + ic = _e_fm2_icon_find(fm, file); } icons = evas_list_append(icons, ic); } @@ -4738,7 +4852,7 @@ (!ic->sd->config->view.no_subdir_drop)) _e_fm2_dnd_drop_show(ic, -1); else - _e_fm2_dnd_drop_hide(sd->obj); + _e_fm2_dnd_drop_all_show(sd->obj); } return; } @@ -4807,8 +4921,9 @@ if (!type) return; if (strcmp(type, "text/uri-list")) return; ev = (E_Event_Dnd_Drop *)event; - fsel = ev->data; + printf("DROP: %i %i\n", ev->x, ev->y); + fsel = _e_fm2_uri_path_list_get(ev->data); isel = _e_fm2_uri_icon_list_get(fsel); if (!isel) return; for (l = fsel; l; l = l->next) @@ -4821,7 +4936,7 @@ for (l = isel; l; l = l->next) { ic = l->data; - if (ic->drag.src) + if (ic && ic->drag.src) { ox = ic->x; oy = ic->y; @@ -4835,6 +4950,7 @@ break; } } + /* note - logic. * if drop file prefix path matches extra_file_source then it can be * and indirect link - dont MOVE the file just add filename to list. @@ -4849,7 +4965,7 @@ for (ll = fsel, il = isel; ll && il; ll = ll->next, il = il->next) { ic = il->data; - fp = _e_fm2_icon_desktop_url_eval(ll->data); + fp = ll->data; if (!fp) continue; snprintf(buf, sizeof(buf), "%s/%s", sd->realpath, ecore_file_file_get(fp)); @@ -4906,7 +5022,7 @@ for (ll = fsel, il = isel; ll && il; ll = ll->next, il = il->next) { ic = il->data; - fp = _e_fm2_icon_desktop_url_eval(ll->data); + fp = ll->data; if (!fp) continue; /* move the file into the subdir */ snprintf(buf, sizeof(buf), "%s/%s/%s", @@ -4927,7 +5043,7 @@ for (ll = fsel, il = isel; ll && il; ll = ll->next, il = il->next) { ic = il->data; - fp = _e_fm2_icon_desktop_url_eval(ll->data); + fp = ll->data; if (!fp) continue; snprintf(buf, sizeof(buf), "%s/%s", sd->realpath, ecore_file_file_get(fp)); @@ -4949,7 +5065,7 @@ for (ll = fsel, il = isel; ll && il; ll = ll->next, il = il->next) { ic = il->data; - fp = _e_fm2_icon_desktop_url_eval(ll->data); + fp = ll->data; if (!fp) continue; snprintf(buf, sizeof(buf), "%s/%s", sd->realpath, ecore_file_file_get(fp)); @@ -4972,7 +5088,7 @@ for (ll = fsel, il = isel; ll && il; ll = ll->next, il = il->next) { ic = il->data; - fp = _e_fm2_icon_desktop_url_eval(ll->data); + fp = ll->data; if (!fp) continue; /* move the file into the subdir */ snprintf(buf, sizeof(buf), "%s/%s", @@ -4988,7 +5104,7 @@ for (ll = fsel, il = isel; ll && il; ll = ll->next, il = il->next) { ic = il->data; - fp = _e_fm2_icon_desktop_url_eval(ll->data); + fp = ll->data; if (!fp) continue; /* move the file into the subdir */ snprintf(buf, sizeof(buf), "%s/%s", @@ -5000,6 +5116,7 @@ } } } + _e_fm2_dnd_drop_hide(sd->obj); _e_fm2_dnd_drop_all_hide(sd->obj); _e_fm2_list_walking++; @@ -5018,6 +5135,7 @@ _e_fm2_list_remove = evas_list_remove_list(_e_fm2_list_remove, _e_fm2_list_remove); } } + evas_list_free(fsel); evas_list_free(isel); } @@ -5222,16 +5340,44 @@ static void _e_fm2_cb_drag_finished(E_Drag *drag, int dropped) { - Evas_List *fsel; - char *f; + E_Fm2_Uri *uri; + const char *p; + char buf[PATH_MAX * 3 + 7]; + Evas_Object *fm; + int i; - fsel = drag->data; - while (fsel) + memset(buf, 0, sizeof(buf)); + for (p = drag->data, i = 0; p && *p != '\0'; p++, i++) { - f = fsel->data; - free(f); - fsel = evas_list_remove_list(fsel, fsel); + if (*p == '\r') + { + p++; + i = -1; + uri = _e_fm2_uri_parse(buf); + memset(buf, 0, sizeof(buf)); + if (!uri) continue; + + fm = _e_fm2_file_fm2_find(uri->path); + if (fm) + { + const char *file; + E_Fm2_Icon *ic; + + file = ecore_file_file_get(uri->path); + ic = _e_fm2_icon_find(fm, file); + ic->drag.dnd = 0; + if (ic->obj) evas_object_show(ic->obj); + if (ic->obj_icon) evas_object_show(ic->obj_icon); + } + + if (uri->hostname) evas_stringshare_del(uri->hostname); + evas_stringshare_del(uri->path); + E_FREE(uri); + } + else + buf[i] = *p; } + free(drag->data); } static void @@ -5256,10 +5402,10 @@ Evas_Object *o, *o2; Evas_Coord x, y, w, h; const char *drag_types[] = { "text/uri-list" }, *realpath; - char buf[4096]; + char buf[PATH_MAX + 8], *sel = NULL; E_Container *con = NULL; Evas_List *l, *sl, *fsel = NULL; - int i; + int i, sel_length = 0; switch (ic->sd->eobj->type) { @@ -5293,21 +5439,39 @@ sl = e_fm2_selected_list_get(ic->sd->obj); for (l = sl, i = 0; l; l = l->next, i++) { + const char *s; ici = l->data; - /* file:///path is correct: file://<host>/<path> with null <host> */ - if (!strcmp(realpath, "/")) - snprintf(buf, sizeof(buf), "file:///%s", ici->file); + snprintf(buf, sizeof(buf), "%s/%s", realpath, ici->file); + + s = _e_fm2_uri_escape(buf); + if (!s) continue; + if (sel_length == 0) + { + sel_length = strlen(s) + 2; + sel = malloc(sel_length + 1); + if (!sel) break; + sel[0] = '\0'; + } else - snprintf(buf, sizeof(buf), "file://%s/%s", realpath, ici->file); - fsel = evas_list_append(fsel, strdup(buf)); + { + sel_length += strlen(s) + 2; + sel = realloc(sel, sel_length+1); + if (!sel) break; + } + sel = strcat(sel, s); + sel = strcat(sel, "\r\n"); + evas_stringshare_del(s); + ici->ic->drag.dnd = 1; if (ici->ic->obj) evas_object_hide(ici->ic->obj); if (ici->ic->obj_icon) evas_object_hide(ici->ic->obj_icon); } evas_list_free(sl); + if (!sel) return; + d = e_drag_new(con, x, y, drag_types, 1, - fsel, -1, NULL, _e_fm2_cb_drag_finished); + sel, strlen(sel), NULL, _e_fm2_cb_drag_finished); o = edje_object_add(e_drag_evas_get(d)); if (ic->sd->config->view.mode == E_FM2_VIEW_MODE_LIST) { @@ -5353,9 +5517,10 @@ edje_object_signal_emit(o2, "e,state,selected", "e"); e_drag_object_set(d, o); e_drag_resize(d, w, h); - e_drag_start(d, - ic->drag.x + ic->x + ic->sd->x - ic->sd->pos.x, - ic->drag.y + ic->y + ic->sd->y - ic->sd->pos.y); + + e_drag_xdnd_start(d, + ic->drag.x + ic->x + ic->sd->x - ic->sd->pos.x, + ic->drag.y + ic->y + ic->sd->y - ic->sd->pos.y); e_util_evas_fake_mouse_up_later(evas_object_evas_get(ic->sd->obj), 1); } ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs