ecore_desktop_get_command can now return a list of commands if it needs to.

SVN revision: 26788
This commit is contained in:
David Walter Seikel 2006-10-25 10:25:15 +00:00
parent 0c4a5165df
commit 7981a62c63
2 changed files with 29 additions and 13 deletions

View File

@ -209,7 +209,7 @@ extern "C"
Ecore_Hash *ecore_desktop_ini_get(const char *file); Ecore_Hash *ecore_desktop_ini_get(const char *file);
Ecore_Desktop *ecore_desktop_get(const char *file, const char *lang); Ecore_Desktop *ecore_desktop_get(const char *file, const char *lang);
void ecore_desktop_save(Ecore_Desktop * desktop); void ecore_desktop_save(Ecore_Desktop * desktop);
EAPI char *ecore_desktop_get_command(Ecore_Desktop * desktop, EAPI Ecore_List *ecore_desktop_get_command(Ecore_Desktop * desktop,
Ecore_List * files, int fill); Ecore_List * files, int fill);
EAPI char *ecore_desktop_merge_command(char *exec, char *params); EAPI char *ecore_desktop_merge_command(char *exec, char *params);
void ecore_desktop_destroy(Ecore_Desktop * desktop); void ecore_desktop_destroy(Ecore_Desktop * desktop);

View File

@ -505,6 +505,7 @@ error:
void void
ecore_desktop_save(Ecore_Desktop * desktop) ecore_desktop_save(Ecore_Desktop * desktop)
{ {
Ecore_List *commands;
char *temp; char *temp;
int trash = 0; int trash = 0;
@ -555,9 +556,16 @@ ecore_desktop_save(Ecore_Desktop * desktop)
} }
} }
temp = ecore_desktop_get_command(desktop, NULL, 0); /* We are not passing a list of files, so we only expect one command. */
if (temp) commands = ecore_desktop_get_command(desktop, NULL, 0);
ecore_hash_set(desktop->group, strdup("Exec"), temp); if (commands)
{
temp = ecore_list_first(commands);
if (temp)
ecore_hash_set(desktop->group, strdup("Exec"), strdup(temp));
ecore_list_destroy(commands);
}
if (desktop->name) if (desktop->name)
ecore_hash_set(desktop->group, strdup("Name"), ecore_hash_set(desktop->group, strdup("Name"),
strdup(desktop->name)); strdup(desktop->name));
@ -827,10 +835,11 @@ ecore_desktop_home_get()
return strdup(home); return strdup(home);
} }
EAPI char * EAPI Ecore_List *
ecore_desktop_get_command(Ecore_Desktop * desktop, Ecore_List * files, int fill) ecore_desktop_get_command(Ecore_Desktop * desktop, Ecore_List * files, int fill)
{ {
char *result = NULL, *params = NULL; Ecore_List *result;
char *sub_result = NULL, *params = NULL;
/* FIXME: for onefang /* FIXME: for onefang
* 1. handle a list of files. * 1. handle a list of files.
@ -840,17 +849,22 @@ ecore_desktop_get_command(Ecore_Desktop * desktop, Ecore_List * files, int fill)
* is a path relative to cwd i.e. "file.png" or "blah/file.png" and * 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 * thus %d/%D would be ./ implicitly (but may need to be explicit
* in the command line) * in the command line)
* 4. i spot lots of kde .desktops use %m (i assume %M exists too). find
* out what it is - if not known - i guess assume %f/%F
* *
*/ */
if (fill && (desktop->exec_params))
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 (fill)
{ {
Ecore_DList *command; Ecore_DList *command;
char *p, *t, buf[PATH_MAX + 10]; char *p, *t, buf[PATH_MAX + 10];
int len = 0; int len = 0;
params = strdup(desktop->exec_params); if (!params) params = strdup("%F");
if (!params) goto error; if (!params) goto error;
command = ecore_dlist_new(); command = ecore_dlist_new();
if (!command) goto error; if (!command) goto error;
@ -921,6 +935,9 @@ ecore_desktop_get_command(Ecore_Desktop * desktop, Ecore_List * files, int fill)
} }
break; break;
case 'm': /* Deprecated mini icon, the spec says we can just drop it. */
break;
case 'v': /* Device field from .desktop file. */ case 'v': /* Device field from .desktop file. */
break; break;
@ -958,10 +975,9 @@ ecore_desktop_get_command(Ecore_Desktop * desktop, Ecore_List * files, int fill)
} }
ecore_list_destroy(command); ecore_list_destroy(command);
} }
else if (desktop->exec_params)
params = strdup(desktop->exec_params);
result = ecore_desktop_merge_command(desktop->exec, params); sub_result = ecore_desktop_merge_command(desktop->exec, params);
if (sub_result) ecore_list_append(result, sub_result);
error: error:
if (params) free(params); if (params) free(params);