Expand FDO command arguments and allow other argument parsing again.

SVN revision: 25754
This commit is contained in:
David Walter Seikel 2006-09-11 21:40:17 +00:00
parent 19ea4966bb
commit cf2d8ff0a4
2 changed files with 119 additions and 1 deletions

View File

@ -47,6 +47,7 @@ struct _Ecore_Desktop
char *exec;
char *exec_params;
char *icon;
char *original_icon;
char *icon_class;
char *icon_path;
char *path;

View File

@ -293,6 +293,8 @@ ecore_desktop_get(const char *file, const char *lang)
result->icon =
(char *)ecore_hash_get(result->group, "Icon");
if (result->icon)
result->original_icon = strdup(result->icon);
result->icon_class =
(char *)ecore_hash_get(result->group, "X-Enlightenment-IconClass");
value =
@ -664,6 +666,8 @@ _ecore_desktop_destroy(Ecore_Desktop * desktop)
free(desktop->original_lang);
if (desktop->eap_name)
free(desktop->eap_name);
if (desktop->original_icon)
free(desktop->original_icon);
if (desktop->icon_class)
free(desktop->icon_class);
if (desktop->window_class)
@ -710,8 +714,121 @@ ecore_desktop_get_command(Ecore_Desktop *desktop, Ecore_List *files, int fill)
if (fill && (desktop->exec_params))
{
/* FIXME: Handle the fdo %x replacable params. Some should be stripped, some should be expanded. */
params = strdup(desktop->exec_params);
if (params)
{
Ecore_DList *command;
command = ecore_dlist_new();
if (command)
{
char *p, *t, buf[PATH_MAX + 10];
int len = 0;
ecore_dlist_set_free_cb(command, free);
t = params;
for (p = params; *p; p++)
{
if (*p == '%')
{
*p = '\0';
ecore_dlist_append(command, strdup(t));
*p = '%';
t = p;
}
}
if (t < p)
{
ecore_dlist_append(command, strdup(t));
}
if (!ecore_dlist_is_empty(command))
{
ecore_dlist_goto_first(command);
while ((p = ecore_dlist_next(command)) != NULL)
{
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. */
break;
case 'u' : /* Single URL, multiple invokations if multiple URLs. */
break;
case 'c' : /* Translated Name field frem .desktop file. */
t = desktop->name;
break;
case 'k' : /* Location of the .desktop file, may be a URL, or empty. */
t = desktop->original_path;
break;
case 'F' : /* Multiple file names. If the files are on the net, download first and point to temp files. */
break;
case 'U' : /* Multiple URLs. */
break;
case 'd' : /* Directory of the file in %f. */
break;
case 'D' : /* Directories of the files in %F. */
break;
case 'n' : /* Single filename without path. */
break;
case 'N' : /* Multiple filenames without paths. */
break;
case 'i' : /* "--icon Icon" field from .desktop file, or empty. */
if (desktop->original_icon)
{
snprintf(buf, sizeof(buf), "--icon %s", desktop->original_icon);
t = buf;
}
break;
case 'v' : /* Device field from .desktop file. */
break;
case '%' : /* A '%' character. */
t = "%";
break;
default :
break;
}
if (t)
{
len += strlen(t);
ecore_dlist_previous(command);
ecore_dlist_insert(command, strdup(t));
ecore_dlist_next(command);
ecore_dlist_next(command);
}
len += strlen(p);
}
free(params);
params = malloc(len);
if (params)
{
params[0] = '\0';
ecore_dlist_goto_first(command);
while ((p = ecore_dlist_next(command)) != NULL)
{
if (p[0] == '%')
strcat(params, &p[2]);
else
strcat(params, p);
}
}
}
ecore_list_destroy(command);
}
}
}
else if (desktop->exec_params)
params = strdup(desktop->exec_params);