forked from enlightenment/enlightenment
efm:
- actions working, for test cases it only has: "edit with gimp", "play with xmms" and "enqueue on xmms". test it :) SVN revision: 20448
This commit is contained in:
parent
c98217f129
commit
a8094c9329
|
@ -398,6 +398,8 @@ e_fm_file_assoc_exec(E_Fm_File *file)
|
|||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* FIXME get rid of this */
|
||||
EAPI int
|
||||
e_fm_file_exec_with(E_Fm_File *file, char* exec_with)
|
||||
{
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
|
||||
static char * _e_fm_mime_suffix_get(char *filename);
|
||||
static void _e_fm_mime_action_append(E_Fm_Mime_Entry *entry, char *action_name);
|
||||
static char *_e_fm_mime_action_tokenizer(Evas_List *files, E_Fm_Mime_Action *action);
|
||||
|
||||
static int init_count = 0;
|
||||
static Evas_List *entries = NULL;
|
||||
|
@ -313,16 +314,112 @@ e_fm_mime_set(E_Fm_File *file)
|
|||
file->mime = (E_Fm_Mime_Entry*)entries->data;
|
||||
}
|
||||
|
||||
/* will call the command of an @action for the list of @files */
|
||||
void
|
||||
E_Fm_Mime_Action *
|
||||
e_fm_mime_action_get_by_label(char *label)
|
||||
{
|
||||
Evas_List *l;
|
||||
E_Fm_Mime_Action *action = NULL;
|
||||
|
||||
for(l = actions; l; l = l->next)
|
||||
{
|
||||
action = (E_Fm_Mime_Action*)l->data;
|
||||
if(!strcmp(label,action->label))
|
||||
break;
|
||||
}
|
||||
return action;
|
||||
}
|
||||
|
||||
/* will call the command of an @action for the list of E_Fm_Files @files */
|
||||
int
|
||||
e_fm_mime_action_call(Evas_List *files, E_Fm_Mime_Action *action)
|
||||
{
|
||||
printf("executing\n");
|
||||
Ecore_Exe *exe;
|
||||
char *command;
|
||||
|
||||
/* FIXME: use the e app execution mechanisms where possible so we can
|
||||
* collect error output
|
||||
*/
|
||||
command = _e_fm_mime_action_tokenizer(files,action);
|
||||
printf("going to execute %s\n", command);
|
||||
exe = ecore_exe_run(command, NULL);
|
||||
|
||||
if (!exe)
|
||||
{
|
||||
e_error_dialog_show(_("Run Error"),
|
||||
_("Enlightenment was unable to fork a child process:\n"
|
||||
"\n"
|
||||
"%s\n"
|
||||
"\n"),
|
||||
command);
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/* subsystem functions */
|
||||
/***********************/
|
||||
static char*
|
||||
_e_fm_mime_action_tokenizer(Evas_List *files, E_Fm_Mime_Action *action)
|
||||
{
|
||||
char *buf;
|
||||
char *c;
|
||||
int i, bsize,trans;
|
||||
Evas_List *l;
|
||||
|
||||
buf = calloc(PATH_MAX,sizeof(char));
|
||||
bsize = PATH_MAX;
|
||||
i = 0;
|
||||
trans = 0;
|
||||
for(c = action->cmd; *c; c++)
|
||||
{
|
||||
if( i > bsize - 1)
|
||||
{
|
||||
bsize += PATH_MAX;
|
||||
buf = realloc(buf,bsize);
|
||||
}
|
||||
if(trans)
|
||||
{
|
||||
char *astr = NULL;
|
||||
if(*c == 'f')
|
||||
{
|
||||
int i = 2;
|
||||
char *f = NULL;
|
||||
|
||||
astr = calloc(PATH_MAX,sizeof(char));
|
||||
for(l = files; l; l = l->next)
|
||||
{
|
||||
E_Fm_File *file;
|
||||
|
||||
file = (E_Fm_File *)l->data;
|
||||
sprintf(astr,"%s %s",astr,file->path);
|
||||
astr = realloc(astr,PATH_MAX*i);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if(!astr)
|
||||
continue;
|
||||
if(bsize < i + strlen(astr))
|
||||
{
|
||||
bsize += strlen(astr) + 1;
|
||||
buf = realloc(buf,bsize);
|
||||
}
|
||||
buf[i-1] = '\0';
|
||||
sprintf(buf, "%s%s", buf, astr);
|
||||
i += strlen(astr) - 1;
|
||||
trans = 0;
|
||||
free(astr);
|
||||
continue;
|
||||
}
|
||||
if(*c == '%')
|
||||
trans = 1;
|
||||
else
|
||||
buf[i] = *c;
|
||||
i++;
|
||||
}
|
||||
return buf;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_e_fm_mime_action_append(E_Fm_Mime_Entry *entry, char *action_name)
|
||||
|
|
|
@ -32,12 +32,13 @@ struct _E_Fm_Mime_Action
|
|||
int multiple; /* support for multiple files at once */
|
||||
};
|
||||
|
||||
EAPI int e_fm_mime_init(void);
|
||||
EAPI void e_fm_mime_shutdwon(void);
|
||||
EAPI void e_fm_mime_set(E_Fm_File *file);
|
||||
EAPI void e_fm_mime_action_call(Evas_List *files, E_Fm_Mime_Action *action);
|
||||
EAPI E_Fm_Mime_Entry *e_fm_mime_common(E_Fm_Mime_Entry *e1, E_Fm_Mime_Entry *e2);
|
||||
EAPI E_Fm_Mime_Entry *e_fm_mime_list(Evas_List *mis);
|
||||
EAPI int e_fm_mime_init(void);
|
||||
EAPI void e_fm_mime_shutdwon(void);
|
||||
EAPI void e_fm_mime_set(E_Fm_File *file);
|
||||
EAPI int e_fm_mime_action_call(Evas_List *files, E_Fm_Mime_Action *action);
|
||||
EAPI E_Fm_Mime_Entry *e_fm_mime_common(E_Fm_Mime_Entry *e1, E_Fm_Mime_Entry *e2);
|
||||
EAPI E_Fm_Mime_Entry *e_fm_mime_list(Evas_List *mis);
|
||||
EAPI E_Fm_Mime_Action *e_fm_mime_action_get_by_label(char *label);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3893,22 +3893,27 @@ _e_fm_menu_context_display(E_Fm_Smart_Data *sd, Evas_Coord dx, Evas_Coord dy, un
|
|||
;
|
||||
}
|
||||
|
||||
/* callback when a mime action is clicked on the actions menu */
|
||||
static void
|
||||
_e_fm_menu_actions(void *data, E_Menu *m, E_Menu_Item *mi)
|
||||
{
|
||||
E_Fm_Smart_Data *sd;
|
||||
E_Fm_Mime_Action *action;
|
||||
Evas_List *l;
|
||||
Evas_List *files = NULL;
|
||||
|
||||
sd = data;
|
||||
/* search for the action clicked */
|
||||
for(l = sd->selection.mime; l; l = l->next)
|
||||
action = e_fm_mime_action_get_by_label(mi->label);
|
||||
/* get the list of files selected */
|
||||
for(l = sd->selection.icons; l; l = l->next)
|
||||
{
|
||||
action = (E_Fm_Mime_Action*)l->data;
|
||||
if(!strcmp(action->label,mi->label))
|
||||
break;
|
||||
E_Fm_Icon *icon;
|
||||
|
||||
icon = (E_Fm_Icon *)l->data;
|
||||
files = evas_list_append(files,icon->file);
|
||||
}
|
||||
/* execute the action on the files */
|
||||
|
||||
e_fm_mime_action_call(files,action);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue