Enlightenment CVS committal Author : onefang Project : e17 Module : libs/ecore
Dir : e17/libs/ecore/src/lib/ecore_desktop Modified Files: ecore_desktop.c Log Message: Handle putting files into commands. Mostly there, still needs some work. In particular it will only include the last of multiple files per command. I'll continue this when I wake up. =================================================================== RCS file: /cvs/e/e17/libs/ecore/src/lib/ecore_desktop/ecore_desktop.c,v retrieving revision 1.61 retrieving revision 1.62 diff -u -3 -r1.61 -r1.62 --- ecore_desktop.c 27 Oct 2006 15:24:30 -0000 1.61 +++ ecore_desktop.c 28 Oct 2006 15:27:12 -0000 1.62 @@ -841,24 +841,24 @@ Ecore_List *result; char *sub_result = NULL, *params = NULL; - /* FIXME: for onefang - * 1. handle a list of files. - * 2. if exec params do not exist then just append files (assume dumb - * .desktop so command becomes "exe params file1 file2 ...") - * 3. if filename does not start with ./ or ../ or / then assume it - * is a path relative to cwd i.e. "file.png" or "blah/file.png" and - * thus %d/%D would be ./ implicitly (but may need to be explicit - * in the command line) - * 4. need to escape filenames as they are part of a long cmd-line so - * spaces, ;, ", ', etc. etc. need escaping - */ - result = ecore_list_new(); if (!result) return NULL; ecore_list_set_free_cb(result, free); if (desktop->exec_params) params = strdup(desktop->exec_params); + +if (files) + { + char *file; + + ecore_list_goto_first(files); + while((file = ecore_list_next(files)) != NULL) + printf("FILE FOR COMMAND IS - %s\n", file); + } + +do +{ if (fill) { Ecore_DList *command; @@ -888,18 +888,26 @@ } if (!ecore_dlist_is_empty(command)) { + if (files) + ecore_list_goto_first(files); ecore_dlist_goto_first(command); while ((p = ecore_dlist_next(command)) != NULL) { + int do_file = 0, is_single = 0, is_URL = 0, is_directory = 0, is_file = 0; + t = NULL; - /* FIXME: implement the rest of these when EFM can pass us files. */ if (p[0] == '%') switch (p[1]) { case 'f': /* Single file name, multiple invokations if multiple files. If the file is on the net, download first and point to temp file. */ + do_file = 1; + is_single = 1; break; case 'u': /* Single URL, multiple invokations if multiple URLs. */ + do_file = 1; + is_single = 1; + is_URL = 1; break; case 'c': /* Translated Name field from .desktop file. */ @@ -911,21 +919,34 @@ break; case 'F': /* Multiple file names. If the files are on the net, download first and point to temp files. */ + do_file = 1; break; case 'U': /* Multiple URLs. */ + do_file = 1; + is_URL = 1; break; case 'd': /* Directory of the file in %f. */ + do_file = 1; + is_single = 1; + is_directory = 1; break; case 'D': /* Directories of the files in %F. */ + do_file = 1; + is_directory = 1; break; case 'n': /* Single filename without path. */ + do_file = 1; + is_single = 1; + is_file = 1; break; case 'N': /* Multiple filenames without paths. */ + do_file = 1; + is_file = 1; break; case 'i': /* "--icon Icon" field from .desktop file, or empty. */ @@ -949,6 +970,58 @@ default: break; } + if (do_file && (files)) + { + char *file; + + while((file = ecore_list_next(files)) != NULL) + { + char *text = NULL, *escaped = NULL; + + if (is_URL) + { + /* FIXME: The spec is unclear about what they mean by URL, + * GIMP uses %U, but doesn't understand file://foo + * For now, just make this the same as is_file. + */ +// text = malloc(strlen(file) + 10); +// if (text) +// sprintf(text, "file://%s", file); + text = strdup(file); + } + else if (is_directory) + { + /* FIXME: for onefang + * if filename does not start with ./ or ../ or / then assume it + * is a path relative to cwd i.e. "file.png" or "blah/file.png" and + * thus %d/%D would be ./ implicitly (but may need to be explicit + * in the command line) + */ + text = ecore_file_get_dir(file); + } + else if (is_file) + text = strdup(ecore_file_get_file(file)); + else + { + /* FIXME: If the file is on the net, download first and point to temp file. */ + text = strdup(file); + } + if (text) + { + escaped = ecore_file_escape_name(text); + free(text); + } + if (escaped) + { + /* FIXME: Need to append these if we are looping. */ + snprintf(buf, sizeof(buf), "%s", escaped); + t = buf; + free(escaped); + } + if (is_single) + break; + } + } if (t) { len += strlen(t); @@ -977,8 +1050,15 @@ ecore_list_destroy(command); } + /* FIXME: still need to loop if there are files left. */ sub_result = ecore_desktop_merge_command(desktop->exec, params); - if (sub_result) ecore_list_append(result, sub_result); + if (sub_result) + { + printf("FULL COMMAND IS - %s\n", sub_result); + ecore_list_append(result, sub_result); + } +} +while((files) && (ecore_list_current(files))); error: if (params) free(params); ------------------------------------------------------------------------- Using Tomcat but need to do more? Need to support web services, security? Get stuff done quickly with pre-integrated technology to make your job easier Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs