- added default actions for each mime type, will be called on double
click
- added relative actions (actions that need a destination directory to
work)
- initial code for thumbnails and previews on the mime side :) (isnt
working yet)


SVN revision: 20459
This commit is contained in:
jlzapata 2006-02-14 19:39:39 +00:00 committed by jlzapata
parent 477a40e79b
commit bac975332a
7 changed files with 349 additions and 215 deletions

View File

@ -51,11 +51,8 @@ e_fm_file_new(const char *filename)
file->mtime = st.st_mtime;
file->ctime = st.st_ctime;
/* FIXME clean this for the new mime handler */
if (S_ISDIR(file->mode)){
if (S_ISDIR(file->mode))
file->type |= E_FM_FILE_TYPE_DIRECTORY;
//file->mime = "directory";
}
else if (S_ISREG(file->mode))
file->type = E_FM_FILE_TYPE_FILE;
else if (S_ISLNK(file->mode))
@ -66,27 +63,7 @@ e_fm_file_new(const char *filename)
if (file->name[0] == '.')
file->type |= E_FM_FILE_TYPE_HIDDEN;
file->preview_funcs = E_NEW(E_Fm_File_Preview_Function, 5);
file->preview_funcs[0] = e_fm_file_is_image;
file->preview_funcs[1] = e_fm_file_is_etheme;
file->preview_funcs[2] = e_fm_file_is_ebg;
file->preview_funcs[3] = e_fm_file_is_eap;
file->preview_funcs[4] = NULL;
/*if(!file->mime)
{
ext = strrchr(file->name, '.');
if (ext)
{
char *ext2;
ext = strdup(ext);
ext2 = ext;
for (; *ext2; ext2++) *ext2 = tolower(*ext2);
file->mime = ext;
}
else
file->mime = "unknown";
}*/
e_fm_mime_set(file);
D(("e_fm_file_new: %s\n", filename));
return file;
@ -172,15 +149,32 @@ e_fm_file_is_regular(E_Fm_File *file) /* TODO: find better name */
|| (file->type == E_FM_FILE_TYPE_SYMLINK));
}
EAPI int
e_fm_file_is_image(E_Fm_File *file)
{
/* We need to check if it is a filetype supported by evas.
* If it isn't supported by evas, we can't show it in the
* canvas.
*/
D(("e_fm_file_is_image: (%p)\n", file));
return e_fm_file_is_regular(file)
&&(e_fm_file_has_mime(file,"jpg")
|| e_fm_file_has_mime(file,"png"));
}
EAPI int
e_fm_file_has_mime(E_Fm_File *file, char* mime)
{
if (!file->mime) return 0;
D(("e_fm_file_has_mime: (%p) : %s\n", file,file->mime));
return (!strcasecmp(file->mime, mime));
D(("e_fm_file_has_mime: (%p) : %s\n", file,file->mime->name));
return (!strcasecmp(file->mime->name, mime));
}
/* this is pointless for the new model */
#if 0
EAPI int
e_fm_file_can_preview(E_Fm_File *file)
{
@ -198,21 +192,6 @@ e_fm_file_can_preview(E_Fm_File *file)
return 0;
}
EAPI int
e_fm_file_is_image(E_Fm_File *file)
{
/* We need to check if it is a filetype supported by evas.
* If it isn't supported by evas, we can't show it in the
* canvas.
*/
//D(("e_fm_file_is_image: (%p)\n", file));
return e_fm_file_is_regular(file)
&&(e_fm_file_has_mime(file,".jpg")
|| e_fm_file_has_mime(file,".jpeg")
|| e_fm_file_has_mime(file,".png"));
}
EAPI int
e_fm_file_is_etheme(E_Fm_File *file)
@ -284,7 +263,6 @@ e_fm_file_is_eap(E_Fm_File *file)
e_object_unref(E_OBJECT(app));
return 1;
}
EAPI int
e_fm_file_can_exec(E_Fm_File *file)
{
@ -398,43 +376,15 @@ 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)
{
Ecore_Exe *exe;
char app[PATH_MAX * 2];
if (!exec_with || !file) return 0;
/* FIXME: use the e app execution mechanisms where possible so we can
* collect error output
*/
snprintf(app, PATH_MAX * 2, "%s \"%s\"", exec_with, file->path);
exe = ecore_exe_run(app, NULL);
if (!exe)
{
e_error_dialog_show(_("Run Error"),
_("Enlightenment was unable to fork a child process:\n"
"\n"
"%s\n"
"\n"),
app);
return 0;
}
return 1;
}
#endif
/* local subsystem functions */
static void
_e_fm_file_free(E_Fm_File *file)
{
D(("_e_fm_file_free: (%p) (%s)\n", file, file->name));
free(file->preview_funcs);
if (file->path) free(file->path);
if (file->name) free(file->name);
///??? if (file->mime) free(file->mime);
free(file);
}

View File

@ -5,7 +5,6 @@
typedef struct _E_Fm_File E_Fm_File;
typedef struct _E_Fm_File_Attributes E_Fm_File_Attributes;
typedef int(*E_Fm_File_Preview_Function) (E_Fm_File*);
#define E_FM_FILE_TYPE_FILE (1 << 8)
#define E_FM_FILE_TYPE_DIRECTORY (1 << 9)
@ -51,7 +50,6 @@ struct _E_Fm_File
time_t mtime; /* time of last modification */
time_t ctime; /* time of last status change */
E_Fm_File_Preview_Function *preview_funcs; /* FIXME the preview should be part of mime.c */
};
EAPI E_Fm_File *e_fm_file_new (const char *filename);
@ -67,7 +65,6 @@ EAPI int e_fm_file_can_exec (E_Fm_File *file);
EAPI int e_fm_file_exec (E_Fm_File *file);
EAPI int e_fm_file_assoc_set (E_Fm_File *file, const char *assoc);
EAPI int e_fm_file_assoc_exec (E_Fm_File *file);
EAPI int e_fm_file_exec_with (E_Fm_File *file, char* exec_with);
EAPI int e_fm_file_has_mime (E_Fm_File *file, char* mime);
EAPI int e_fm_file_is_regular (E_Fm_File *file);
#endif

View File

@ -142,6 +142,8 @@ e_fm_icon_file_set(Evas_Object *obj, E_Fm_File *file)
sd->file = file;
file->icon_object = obj;
/* FIXME fix this */
#if 0
if (e_fm_file_can_preview(sd->file))
{
sd->thumb_path = e_thumb_file_get(sd->file->path);
@ -182,6 +184,7 @@ e_fm_icon_file_set(Evas_Object *obj, E_Fm_File *file)
}
}
else
#endif
{
_e_fm_icon_icon_mime_get(sd);
}
@ -521,6 +524,8 @@ _e_fm_icon_thumb_generate_cb(Evas_Object *obj, void *data)
sd = data;
/* FIXME fix this */
#if 0
if (e_fm_file_has_mime(sd->file,".eap") || (ecore_file_exists(sd->thumb_path)))
{
Evas_Coord icon_w, icon_h;
@ -550,6 +555,7 @@ _e_fm_icon_thumb_generate_cb(Evas_Object *obj, void *data)
edje_object_part_swallow(sd->icon_object, "icon_swallow",
sd->image_object);
}
#endif
}
static void

View File

@ -52,6 +52,10 @@
* 3. by file contents (if a dir is full of mp3, might be an audio dir)
*
*
* previews and thumbnails
* =======================
* a thumbnail can be done for example on images,videos,or any graphical file
* but a preview is for example that when you are over an audio file it starts playing
*
* actions
* =======
@ -68,9 +72,15 @@
#include "e.h"
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 E_Fm_Mime_Entry *_e_fm_mime_common(E_Fm_Mime_Entry *e1, E_Fm_Mime_Entry *e2);
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 void _e_fm_mime_action_default_set(E_Fm_Mime_Entry *entry, char *action_name);
static char *_e_fm_mime_string_tokenizer(Evas_List *files, char *dir, char *istr);
/* definitions of the internal actions */
static void _e_fm_mime_action_internal_folder_open(E_Fm_Smart_Data *data);
static void _e_fm_mime_action_internal_folder_open_other(E_Fm_Smart_Data *data);
static int init_count = 0;
static Evas_List *entries = NULL;
@ -88,6 +98,21 @@ e_fm_mime_init(void)
if(init_count)
return 1;
/* internal actions */
/********************/
action = E_NEW(E_Fm_Mime_Action,1);
action->name = strdup("_folder_open");
action->label = strdup("Open the Folder");
action->is_internal = 1;
action->internal.function = &_e_fm_mime_action_internal_folder_open;
actions = evas_list_append(actions,action);
action = E_NEW(E_Fm_Mime_Action,1);
action->name = strdup("_folder_open_other");
action->label = strdup("Open the Folder in other Window");
action->is_internal = 1;
action->internal.function = &_e_fm_mime_action_internal_folder_open_other;
actions = evas_list_append(actions,action);
/* actions */
/***********/
@ -98,6 +123,13 @@ e_fm_mime_init(void)
action->multiple = 1;
actions = evas_list_append(actions,action);
action = E_NEW(E_Fm_Mime_Action,1);
action->name = strdup("exhibit_view");
action->label = strdup("View with Exhibit");
action->cmd = strdup("exhibit %f");
action->multiple = 0;
actions = evas_list_append(actions,action);
action = E_NEW(E_Fm_Mime_Action,1);
action->name = strdup("xmms_enqueue");
action->label = strdup("Add to XMMS Queue");
@ -134,7 +166,9 @@ e_fm_mime_init(void)
entry->label = strdup("Image File");
entry->parent = l1;
entry->level = 2;
_e_fm_mime_action_append(entry, "gimp_edit");
entries = evas_list_append(entries,entry);
_e_fm_mime_action_default_set(entry, "gimp_edit");
_e_fm_mime_action_append(entry, "exhibit_view");
l2 = entry;
{
/* jpg */
@ -162,6 +196,7 @@ e_fm_mime_init(void)
entry->label = strdup("Audio File");
entry->parent = l1;
entry->level = 2;
entries = evas_list_append(entries,entry);
_e_fm_mime_action_append(entry, "xmms_play");
_e_fm_mime_action_append(entry, "xmms_enqueue");
l2 = entry;
@ -202,6 +237,8 @@ e_fm_mime_init(void)
entry->parent = root;
entry->level = 1;
entries = evas_list_append(entries,entry);
_e_fm_mime_action_default_set(entry, "_folder_open");
_e_fm_mime_action_append(entry, "_folder_open_other");
l1 = entry;
@ -216,62 +253,26 @@ e_fm_mime_shutdwon(void)
init_count--;
}
/* returns the shortest root for both entries @e1 and @e2
* FIXME can be implemented faster?
*/
E_Fm_Mime_Entry *
e_fm_mime_common(E_Fm_Mime_Entry *e1, E_Fm_Mime_Entry *e2)
{
E_Fm_Mime_Entry *tmp;
int i;
int count;
/* take the lowest on the tree */
/* set the e1 upper, e2 lower */
if(e1->level > e2->level)
{
count = e1->level - e2->level;
tmp = e1;
e1 = e2;
e2 = tmp;
}
else
count = e2->level - e1-> level;
/* first equal levels */
for(i = 0; i < count; i++)
{
e2 = e2->parent;
}
/* get up on the tree until we find the same parent */
for(i = e1->level; i >= 0; i--)
{
if(!strcmp(e1->name,e2->name))
return e1;
e1 = e1->parent;
e2 = e2->parent;
}
/* this should never happen */
return NULL;
}
/* returns the shortest root of a list of mime entries @mis
/* returns the shortest root mime for a list of @files
* FIXME can be implemented faster? delete the list while iterating
*/
E_Fm_Mime_Entry *
e_fm_mime_list(Evas_List *mis)
e_fm_mime_get_from_list(Evas_List *files)
{
E_Fm_File *file;
E_Fm_Mime_Entry *entry;
Evas_List *l;
entry = (E_Fm_Mime_Entry *)mis->data;
for(l = mis->next; l; l = l->next)
file = (E_Fm_Mime_Entry *)files->data;
entry = file->mime;
for(l = files->next; l; l = l->next)
{
E_Fm_Mime_Entry *eme;
eme = (E_Fm_Mime_Entry *)l->data;
entry = e_fm_mime_common(entry,eme);
file = (E_Fm_Mime_Entry *)l->data;
eme = file->mime;
entry = _e_fm_mime_common(entry,eme);
}
return entry;
}
@ -329,9 +330,9 @@ e_fm_mime_action_get_by_label(char *label)
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)
/* will call the command of an @action for the fileman_smart @sd */
EAPI int
e_fm_mime_action_call(E_Fm_Smart_Data *sd, E_Fm_Mime_Action *action)
{
Ecore_Exe *exe;
char *command;
@ -339,28 +340,106 @@ e_fm_mime_action_call(Evas_List *files, E_Fm_Mime_Action *action)
/* 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)
if(action->is_internal)
{
e_error_dialog_show(_("Run Error"),
action->internal.function(sd);
}
else
{
command = _e_fm_mime_string_tokenizer(sd->operation.files,sd->operation.dir,action->cmd);
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 0;
}
}
return 1;
}
EAPI int
e_fm_mime_action_default_call(E_Fm_Smart_Data *sd)
{
E_Fm_Mime_Entry *mime;
E_Fm_Mime_Action *action;
mime = sd->operation.mime;
do
{
action = mime->action_default;
if(!action)
{
mime = mime->parent;
continue;
}
/* if we reach here we have an action */
break;
} while(mime);
if(!action)
return;
e_fm_mime_action_call(sd, action);
}
/* subsystem functions */
/***********************/
/* returns the shortest root for both entries @e1 and @e2
* FIXME can be implemented faster?
*/
static E_Fm_Mime_Entry *
_e_fm_mime_common(E_Fm_Mime_Entry *e1, E_Fm_Mime_Entry *e2)
{
E_Fm_Mime_Entry *tmp;
int i;
int count;
/* take the lowest on the tree */
/* set the e1 upper, e2 lower */
if(e1->level > e2->level)
{
count = e1->level - e2->level;
tmp = e1;
e1 = e2;
e2 = tmp;
}
else
count = e2->level - e1-> level;
/* first equal levels */
for(i = 0; i < count; i++)
{
e2 = e2->parent;
}
/* get up on the tree until we find the same parent */
for(i = e1->level; i >= 0; i--)
{
if(!strcmp(e1->name,e2->name))
return e1;
e1 = e1->parent;
e2 = e2->parent;
}
/* this should never happen */
return NULL;
}
/* will translate %f,%d to file,dir respective */
static char*
_e_fm_mime_action_tokenizer(Evas_List *files, E_Fm_Mime_Action *action)
_e_fm_mime_string_tokenizer(Evas_List *files, char *dir, char *istr)
{
char *buf;
char *c;
@ -371,7 +450,7 @@ _e_fm_mime_action_tokenizer(Evas_List *files, E_Fm_Mime_Action *action)
bsize = PATH_MAX;
i = 0;
trans = 0;
for(c = action->cmd; *c; c++)
for(c = istr; *c; c++)
{
if( i > bsize - 1)
{
@ -439,6 +518,26 @@ _e_fm_mime_action_append(E_Fm_Mime_Entry *entry, char *action_name)
}
}
static void
_e_fm_mime_action_default_set(E_Fm_Mime_Entry *entry, char *action_name)
{
Evas_List *l;
for(l = actions; l; l = l->next)
{
E_Fm_Mime_Action *action;
action = (E_Fm_Mime_Action *)l->data;
if(!strcmp(action->name, action_name))
{
/* overwrite the old default action */
entry->action_default = action;
entry->actions = evas_list_append(entry->actions, action);
break;
}
}
}
static char *
_e_fm_mime_suffix_get(char *filename)
{
@ -453,3 +552,26 @@ _e_fm_mime_suffix_get(char *filename)
}
return NULL;
}
static void
_e_fm_mime_action_internal_folder_open(E_Fm_Smart_Data *sd)
{
E_Fm_File *file;
file = sd->operation.files->data;
e_fm_dir_set(sd->object, file->path);
}
static void
_e_fm_mime_action_internal_folder_open_other(E_Fm_Smart_Data *sd)
{
E_Fileman *fileman;
E_Fm_File *file;
file = sd->operation.files->data;
fileman = e_fileman_new_to_dir(e_container_current_get(e_manager_current_get()), file->path);
e_fileman_show(fileman);
}

View File

@ -6,6 +6,17 @@
typedef struct _E_Fm_Mime_Entry E_Fm_Mime_Entry;
typedef struct _E_Fm_Mime_Action E_Fm_Mime_Action;
typedef int (*E_Fm_Mime_Thumbnail_Function) (E_Fm_File*);
typedef int (*E_Fm_Mime_Preview_Function) (E_Fm_File*);
#if 0
file->preview_funcs = E_NEW(E_Fm_File_Preview_Function, 5);
file->preview_funcs[0] = e_fm_file_is_image;
file->preview_funcs[1] = e_fm_file_is_etheme;
file->preview_funcs[2] = e_fm_file_is_ebg;
file->preview_funcs[3] = e_fm_file_is_eap;
file->preview_funcs[4] = NULL;
#endif
#else
#ifndef E_FILEMAN_MIME_H
@ -14,14 +25,20 @@ typedef struct _E_Fm_Mime_Action E_Fm_Mime_Action;
struct _E_Fm_Mime_Entry
{
char *name;
char *label;
int level; /* the level on the three for easy search/comparsion */
E_Fm_Mime_Entry *parent;
Evas_List *actions;
char *name;
char *label;
int level; /* the level on the three for easy search/comparsion */
E_Fm_Mime_Entry *parent;
E_Fm_Mime_Action *action_default; /* the default action also exists on the actions list */
Evas_List *actions;
/* the autodetect features */
char *suffix;
int type;
char *suffix;
int type;
/* to thumbnail this file type */
E_Fm_Mime_Thumbnail_Function preview;
/* to preview this file type */
E_Fm_Mime_Preview_Function thumbnail;
};
struct _E_Fm_Mime_Action
@ -29,15 +46,21 @@ struct _E_Fm_Mime_Action
char *name;
char *label;
char *cmd;
int multiple; /* support for multiple files at once */
unsigned char multiple : 1; /* support for multiple files at once */
unsigned char is_internal : 1; /* if its internal cant be modified */
unsigned char relative : 1; /* if the action MUST be realitve to a dir */
struct
{
void (*function)(E_Fm_Smart_Data *sd);
} internal;
};
EAPI int e_fm_mime_init(void);
EAPI void e_fm_mime_shutdwon(void);
EAPI E_Fm_Mime_Entry *e_fm_mime_get_from_list(Evas_List *files);
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 int e_fm_mime_action_call(E_Fm_Smart_Data *sd, E_Fm_Mime_Action *action);
EAPI int e_fm_mime_action_default_call(E_Fm_Smart_Data *sd);
EAPI E_Fm_Mime_Action *e_fm_mime_action_get_by_label(char *label);

View File

@ -168,8 +168,10 @@ static int _e_fm_dir_meta_save(E_Fm_Smart_Data *sd);
static void _e_fm_dir_meta_fill(E_Fm_Dir_Metadata *m, E_Fm_Smart_Data *sd);
static void _e_fm_menu_action_display(E_Fm_Smart_Data *sd, Evas_Coord dx, Evas_Coord dy, unsigned int timestamp);
static void _e_fm_menu_context_display(E_Fm_Smart_Data *sd, Evas_Coord dx, Evas_Coord dy, unsigned int timestamp);
static void _e_fm_menu_actions(void *data, E_Menu *m, E_Menu_Item *mi);
static void _e_fm_menu_default(void *data, E_Menu *m, E_Menu_Item *mi);
static int _e_fm_init_assoc(E_Fm_Smart_Data *sd);
@ -906,6 +908,8 @@ _e_fm_file_delete(E_Fm_Icon *icon)
_e_fm_file_free(icon);
}
/* FIXME delete this */
static void
_e_fm_file_menu_open(void *data, E_Menu *m, E_Menu_Item *mi)
{
@ -914,27 +918,6 @@ _e_fm_file_menu_open(void *data, E_Menu *m, E_Menu_Item *mi)
Evas_List *l;
icon = data;
for (l = icon->sd->conf.main->apps; l; l = l->next)
{
assoc = l->data;
if(!strcmp(assoc->app,mi->label)){
e_fm_file_exec_with(icon->file, assoc->app);
return;
}
}
switch (icon->file->type)
{
case E_FM_FILE_TYPE_DIRECTORY:
_e_fm_dir_set(icon->sd, icon->file->path);
break;
case E_FM_FILE_TYPE_FILE:
if ((!e_fm_file_assoc_exec(icon->file) && (e_fm_file_can_exec(icon->file))))
e_fm_file_exec(icon->file);
break;
default:
break;
}
}
static void
@ -1527,6 +1510,7 @@ _e_fm_dir_set(E_Fm_Smart_Data *sd, const char *dir)
icon->file = e_fm_file_new(path);
icon->file->mode = 0040000;
icon->file->type = E_FM_FILE_TYPE_DIRECTORY;
e_fm_mime_set(icon->file);
icon->icon_obj = e_fm_icon_add(sd->evas);
icon->sd = sd;
e_fm_icon_file_set(icon->icon_obj, icon->file);
@ -1780,7 +1764,6 @@ _e_fm_selections_clear(E_Fm_Smart_Data *sd)
sd->selection.band.files = evas_list_free(sd->selection.band.files);
sd->selection.current.file = NULL;
sd->selection.current.ptr = NULL;
sd->selection.mime = NULL;
}
static void
@ -1792,7 +1775,6 @@ _e_fm_selections_add(E_Fm_Icon *icon, Evas_List *icon_ptr)
e_fm_icon_signal_emit(icon->icon_obj, "clicked", "");
icon->sd->selection.icons = evas_list_append(icon->sd->selection.icons, icon);
icon->state.selected = 1;
icon->sd->selection.mime = NULL;
}
static void
@ -1808,8 +1790,6 @@ _e_fm_selections_del(E_Fm_Icon *icon)
icon->sd->selection.current.file = icon->sd->selection.icons->data;
}
icon->state.selected = 0;
icon->sd->selection.mime = NULL;
}
static void
@ -2165,6 +2145,20 @@ _e_fm_icon_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info
if (ev->button == 1)
{
/* double click = default mime action */
if(ev->flags == EVAS_BUTTON_DOUBLE_CLICK)
{
icon->sd->operation.files = NULL;
_e_fm_selections_clear(icon->sd);
_e_fm_selections_add(icon, evas_list_find_list(icon->sd->icons, icon));
icon->sd->operation.dir = icon->sd->dir;
icon->sd->operation.files = evas_list_append(icon->sd->operation.files, icon->file);
icon->sd->operation.mime = icon->file->mime;
e_fm_mime_action_default_call(icon->sd);
}
#if 0
if (icon->file->type == E_FM_FILE_TYPE_DIRECTORY && (ev->flags == EVAS_BUTTON_DOUBLE_CLICK))
{
char *fullname;
@ -2203,10 +2197,11 @@ _e_fm_icon_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info
return;
}
if ((!e_fm_file_assoc_exec(icon->file)) &&
/*if ((!e_fm_file_assoc_exec(icon->file)) &&
(e_fm_file_can_exec(icon->file)))
e_fm_file_exec(icon->file);
e_fm_file_exec(icon->file);*/
}
#endif
else
{
if(icon->sd->is_selector && icon->file->type == E_FM_FILE_TYPE_FILE)
@ -2262,6 +2257,7 @@ _e_fm_icon_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
E_Fm_Icon *icon;
Evas_Event_Mouse_Up *ev;
Evas_List *l;
Evas_List *mimes = NULL;
ev = event_info;
icon = data;
@ -2318,7 +2314,19 @@ _e_fm_icon_mouse_up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
/* the xdnd_drop will handle this case */
if(icon->sd->drag.doing)
break;
/* FIXME if it isnt null free the list */
icon->sd->operation.files = NULL;
/* set the operation files equal to the selected icons */
for(l = icon->sd->selection.icons; l; l = l->next)
{
E_Fm_Icon *ic;
ic = (E_Fm_Icon *)l->data;
icon->sd->operation.files = evas_list_append(icon->sd->operation.files, ic->file);
}
/* get the overall mime entry for the selected files */
icon->sd->operation.dir = icon->sd->dir;
icon->sd->operation.mime = e_fm_mime_get_from_list(icon->sd->operation.files);
_e_fm_menu_action_display(icon->sd, ev->output.x, ev->output.y, ev->timestamp);
break;
@ -3068,9 +3076,9 @@ _e_fm_icon_run(E_Fm_Smart_Data *sd)
return;
}
if ((!e_fm_file_assoc_exec(icon->file)) &&
/*if ((!e_fm_file_assoc_exec(icon->file)) &&
(e_fm_file_can_exec(icon->file)))
e_fm_file_exec(icon->file);
e_fm_file_exec(icon->file);*/
}
}
}
@ -3249,14 +3257,19 @@ _e_fm_xdnd_enter_cb(void *data, int type, void *event)
if (ev->win != sd->win->evas_win) return 1;
/*if (ev->win == sd->drag->evas_win)
{
e_fm_icon_signal_emit(icon->icon_obj, "default", "");
}*/
/*if(evas_object_visible_get(sd->drag.icon_obj->icon_obj))
evas_object_hide(sd->drag.icon_obj->icon_obj);*/
if (ev->win == sd->win->evas_win)
{
if(sd->drag.doing)
{
//e_fm_icon_signal_emit(icon->icon_obj, "default", "");
}
else
{
/* split the data from the drop and
* create E_Fm_Files for all the uris */
}
}
return 1;
}
@ -3436,6 +3449,7 @@ _e_fm_xdnd_drop_cb(void *data, int type, void *event)
sd->drag.doing = 0;
sd->drag.start = 0;
}
/* if we drop over another efm window */
else
{
printf("outside drop\n");
@ -3702,7 +3716,8 @@ _e_fm_dir_meta_fill(E_Fm_Dir_Metadata *m, E_Fm_Smart_Data *sd)
}
/* displays the action menu for a list of selected files
* on the coordinate @dx, @dy relative to the sd window
* on the coordinate @dx, @dy relative to the @sd window
* for the list of @files relative to a directory @dir
*/
static void
@ -3714,9 +3729,9 @@ _e_fm_menu_action_display(E_Fm_Smart_Data *sd, Evas_Coord dx, Evas_Coord dy, uns
int x, y, w, h;
E_Fm_Assoc_App *assoc;
E_Fm_Icon *icon_clicked; // ?
Evas_List *l,*actions,*mimes = NULL;
E_Fm_Mime_Action *action;
E_Fm_Mime_Action *default_action;
E_Fm_Mime_Entry *mime;
int multiple = 0;
@ -3725,11 +3740,9 @@ _e_fm_menu_action_display(E_Fm_Smart_Data *sd, Evas_Coord dx, Evas_Coord dy, uns
if(!sd->selection.icons)
return;
/* to know if the action can be performed on multiple files */
if(sd->selection.icons->next)
if(sd->operation.files->next)
multiple = 1;
// icon_clicked = sd->selection.current.file;
mn = e_menu_new();
e_menu_category_set(mn,"fileman/action");
e_menu_category_data_set("fileman/action",sd->selection.icons);
@ -3791,28 +3804,53 @@ _e_fm_menu_action_display(E_Fm_Smart_Data *sd, Evas_Coord dx, Evas_Coord dy, uns
"fileman/button/open");
#endif
/* get the overall mime entry for the selected files */
for(l = sd->selection.icons; l; l = l->next)
{
E_Fm_Icon *icon;
E_Fm_Mime_Entry *entry;
icon = (E_Fm_Icon *)l->data;
mimes = evas_list_append(mimes, icon->file->mime);
}
mime = sd->selection.mime = e_fm_mime_list(mimes);
mime = sd->operation.mime;
printf("mime for selection %s\n", mime->name);
/* the default action */
do
{
action = mime->action_default;
if(!action)
{
mime = mime->parent;
continue;
}
if(!action->multiple && multiple)
{
mime = mime->parent;
continue;
}
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, _(action->label));
e_menu_item_callback_set(mi, _e_fm_menu_actions, sd);
e_menu_item_icon_edje_set(mi, (char *)e_theme_edje_file_get("base/theme/fileman",
"fileman/button/properties"),"fileman/button/properties");
mi = e_menu_item_new(mn);
e_menu_item_separator_set(mi, 1);
default_action = action;
break;
} while(mime);
/* the other possible actions */
mime = sd->operation.mime;
do
{
printf("mime %s\n", mime->name);
actions = mime->actions;
for(l = actions; l; l = l->next)
{
E_Fm_Mime_Action *action;
action = (E_Fm_Mime_Action*)l->data;
if(!action->multiple && multiple)
continue;
/* if its the same as the default one, skip it */
if(action == default_action)
continue;
mi = e_menu_item_new(mn);
e_menu_item_label_set(mi, _(action->label));
e_menu_item_callback_set(mi, _e_fm_menu_actions, sd);
@ -3821,7 +3859,7 @@ _e_fm_menu_action_display(E_Fm_Smart_Data *sd, Evas_Coord dx, Evas_Coord dy, uns
}
mime = mime->parent;
}while(mime);
} while(mime);
mi = e_menu_item_new(mn);
e_menu_item_separator_set(mi, 1);
@ -3905,15 +3943,6 @@ _e_fm_menu_actions(void *data, E_Menu *m, E_Menu_Item *mi)
sd = data;
/* search for the action clicked */
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)
{
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);
e_fm_mime_action_call(sd,action);
}

View File

@ -115,7 +115,7 @@ struct _E_Fm_Smart_Data
Evas_Hash *mime_menu_hash;
char *dir;
char *dir; /* FIXME this could be actually a E_Fm_Dir */
DIR *dir2;
double timer_int;
@ -172,7 +172,6 @@ struct _E_Fm_Smart_Data
struct {
Evas_List *icons; /* list of E_Fm_Icons selected */
E_Fm_Mime_Entry *mime; /* the computed mime for all the selected icons */
struct {
E_Fm_Icon *file; /* FIXME should be called icon! */
@ -189,7 +188,15 @@ struct _E_Fm_Smart_Data
band;
}
selection;
selection; /* the selected icons */
struct {
Evas_List *files; /* list of E_Fm_Files */
E_Fm_File *dir; /* the file of the relative directory for operations */
E_Fm_Mime_Entry *mime; /* overall mime for all the icons we are going to operate wirh */
}
operation; /* the operating files, for wich we are going to make actions
might be the selected files or the dropped files */
struct {
E_Config_DD *main_edd;