Enlightenment CVS committal
Author : jlzapata
Project : e17
Module : apps/e
Dir : e17/apps/e/src/bin
Modified Files:
e_fileman_file.c e_fileman_mime.c e_fileman_mime.h
e_fileman_smart.c
Log Message:
efm:
- actions working, for test cases it only has: "edit with gimp",
"play with xmms" and "enqueue on xmms". test it :)
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_file.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -3 -r1.19 -r1.20
--- e_fileman_file.c 14 Feb 2006 00:40:57 -0000 1.19
+++ e_fileman_file.c 14 Feb 2006 02:32:13 -0000 1.20
@@ -398,6 +398,8 @@
return 1;
}
+
+/* FIXME get rid of this */
EAPI int
e_fm_file_exec_with(E_Fm_File *file, char* exec_with)
{
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_mime.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- e_fileman_mime.c 14 Feb 2006 00:40:57 -0000 1.1
+++ e_fileman_mime.c 14 Feb 2006 02:32:14 -0000 1.2
@@ -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 @@
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)
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_mime.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- e_fileman_mime.h 14 Feb 2006 00:40:57 -0000 1.1
+++ e_fileman_mime.h 14 Feb 2006 02:32:14 -0000 1.2
@@ -32,12 +32,13 @@
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
===================================================================
RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_smart.c,v
retrieving revision 1.128
retrieving revision 1.129
diff -u -3 -r1.128 -r1.129
--- e_fileman_smart.c 14 Feb 2006 00:40:57 -0000 1.128
+++ e_fileman_smart.c 14 Feb 2006 02:32:14 -0000 1.129
@@ -3893,22 +3893,27 @@
;
}
+/* 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);
}
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=103432&bid=230486&dat=121642
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs