Enlightenment CVS committal Author : jlzapata Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_fileman_mime.c e_fileman_mime.h e_fileman_smart.c e_fileman_smart.h Log Message: efm: - context menu (dragging with the right button) works - dragging from one efm window to another efm window pops up the context menu or calls the default relative action - menu item labels are filled with the correct text =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_mime.c,v retrieving revision 1.5 retrieving revision 1.6 diff -u -3 -r1.5 -r1.6 --- e_fileman_mime.c 16 Feb 2006 03:13:30 -0000 1.5 +++ e_fileman_mime.c 16 Feb 2006 17:06:37 -0000 1.6 @@ -63,7 +63,7 @@ * to define the command to execute there are several tokens like: * * %f => file input - * %d => current directory + * %h => hover file (might be the current directory, other file, whatever) * * * @@ -76,10 +76,12 @@ 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); +static char *_e_fm_mime_string_tokenizer(Evas_List *files, E_Fm_File *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 void _e_fm_mime_action_internal_copy_to(E_Fm_Smart_Data *data); +static void _e_fm_mime_action_internal_move_to(E_Fm_Smart_Data *data); static int init_count = 0; @@ -114,6 +116,22 @@ action->internal.function = &_e_fm_mime_action_internal_folder_open_other; actions = evas_list_append(actions,action); + action = E_NEW(E_Fm_Mime_Action,1); + action->name = strdup("_copy_to"); + action->label = strdup("Copy to %h"); + action->relative = 1; + action->is_internal = 1; + action->internal.function = &_e_fm_mime_action_internal_copy_to; + actions = evas_list_append(actions,action); + + action = E_NEW(E_Fm_Mime_Action,1); + action->name = strdup("_move_to"); + action->label = strdup("Move to %h"); + action->relative = 1; + action->is_internal = 1; + action->internal.function = &_e_fm_mime_action_internal_move_to; + actions = evas_list_append(actions,action); + /* actions */ /***********/ action = E_NEW(E_Fm_Mime_Action,1); @@ -151,6 +169,8 @@ root->label = strdup("Unkown File"); root->level = 0; entries = evas_list_append(entries,root); + _e_fm_mime_action_default_set(root, "_copy_to"); + _e_fm_mime_action_append(root, "_move_to"); /* data */ entry = E_NEW(E_Fm_Mime_Entry,1); entry->name = strdup("data"); @@ -267,13 +287,13 @@ if (files == NULL) return NULL; - file = (E_Fm_Mime_Entry *)files->data; + file = (E_Fm_File *)files->data; entry = file->mime; for (l = files->next; l; l = l->next) { E_Fm_Mime_Entry *eme; - file = (E_Fm_Mime_Entry *)l->data; + file = (E_Fm_File *)l->data; eme = file->mime; entry = _e_fm_mime_common(entry,eme); } @@ -318,7 +338,8 @@ file->mime = (E_Fm_Mime_Entry*)entries->data; } -E_Fm_Mime_Action * +#if 0 +EAPI E_Fm_Mime_Action * e_fm_mime_action_get_by_label(char *label) { Evas_List *l; @@ -332,6 +353,7 @@ } return action; } +#endif /* will call the command of an @action for the fileman_smart @sd */ EAPI int @@ -355,7 +377,6 @@ if (!exe) - { e_error_dialog_show(_("Run Error"), @@ -395,6 +416,15 @@ e_fm_mime_action_call(sd, action); } +EAPI char * +e_fm_mime_translate(E_Fm_Smart_Data *sd, char *istr) +{ + char *ostr; + + ostr = _e_fm_mime_string_tokenizer(sd->operation.files,sd->operation.hover, istr); + + return ostr; +} /* subsystem functions */ /***********************/ @@ -442,7 +472,7 @@ /* will translate %f,%d to file,dir respective */ static char* -_e_fm_mime_string_tokenizer(Evas_List *files, char *dir, char *istr) +_e_fm_mime_string_tokenizer(Evas_List *files, E_Fm_File *hover, char *istr) { char *buf; char *c; @@ -465,7 +495,7 @@ char *astr = NULL; if(*c == 'f') { - int i = 2; + int j = 2; char *f = NULL; astr = calloc(PATH_MAX,sizeof(char)); @@ -475,10 +505,14 @@ file = (E_Fm_File *)l->data; sprintf(astr,"%s %s",astr,file->path); - astr = realloc(astr,PATH_MAX*i); - i++; + astr = realloc(astr,PATH_MAX*j); + j++; } } + if(*c == 'h') + { + astr = strdup(hover->path); + } if(!astr) continue; if(bsize < i + strlen(astr)) @@ -534,7 +568,10 @@ if(!strcmp(action->name, action_name)) { /* overwrite the old default action */ - entry->action_default = action; + if(action->relative) + entry->action_default_relative = action; + else + entry->action_default = action; entry->actions = evas_list_append(entry->actions, action); break; } @@ -577,4 +614,14 @@ fileman = e_fileman_new_to_dir(e_container_current_get(e_manager_current_get()), file->path); e_fileman_show(fileman); } +static void +_e_fm_mime_action_internal_copy_to(E_Fm_Smart_Data *sd) +{ + printf("going to copy to %s\n", sd->operation.hover->path); +} +static void +_e_fm_mime_action_internal_move_to(E_Fm_Smart_Data *sd) +{ + printf("going to move to %s\n", sd->operation.hover->path); +} =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_mime.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- e_fileman_mime.h 16 Feb 2006 03:13:30 -0000 1.4 +++ e_fileman_mime.h 16 Feb 2006 17:06:37 -0000 1.5 @@ -62,7 +62,7 @@ EAPI void e_fm_mime_set(E_Fm_File *file); 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); +EAPI char *e_fm_mime_translate(E_Fm_Smart_Data *sd, char *istr); #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_smart.c,v retrieving revision 1.132 retrieving revision 1.133 diff -u -3 -r1.132 -r1.133 --- e_fileman_smart.c 16 Feb 2006 03:13:30 -0000 1.132 +++ e_fileman_smart.c 16 Feb 2006 17:06:37 -0000 1.133 @@ -186,6 +186,11 @@ static int _e_fm_init_assoc(E_Fm_Smart_Data *sd); +/* free functions */ +/******************/ +static void _e_fm_operation_menu_free(E_Fm_Smart_Data *sd); +static void _e_fm_operation_files_free(E_Fm_Smart_Data *sd); +static void _e_fm_operation_free(E_Fm_Smart_Data *sd); static Ecore_Event_Handler *e_fm_drag_mouse_up_handler = NULL; static Ecore_Event_Handler *e_fm_drag_mouse_move_handler = NULL; @@ -2206,12 +2211,10 @@ icon->sd->drag.y = ev->canvas.y; icon->sd->drag.icon_obj = icon; } - if (!icon->state.selected) { if (!evas_key_modifier_is_set(evas_key_modifier_get(icon->sd->evas), "Control")) _e_fm_selections_clear(icon->sd); - } } } @@ -2292,25 +2295,15 @@ _e_fm_selections_add(icon, evas_list_find_list(icon->sd->icons, icon)); } } - /* Free file list before recreating */ - while (icon->sd->operation.files) - { - E_Fm_File *file; - - file = icon->sd->operation.files->data; - icon->sd->operation.files = evas_list_remove_list( - icon->sd->operation.files, icon->sd->operation.files); - /* - * FIXME: should this be freed, it looks like we just need to free the list here? - * e_object_del(E_OBJECT(file)); - */ - } + /* free operation struct before recreating */ + _e_fm_operation_free(icon->sd); /* 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); + /* duplicate the selected files, to not free the selected ones directly */ + icon->sd->operation.files = evas_list_append(icon->sd->operation.files, e_fm_file_new(ic->file->path)); } /* get the overall mime entry for the selected files */ icon->sd->operation.hover = NULL; @@ -2326,7 +2319,7 @@ else if(icon->sd->drag.status == E_FILEMAN_DRAG_DONE) { printf("popping up the context menu\n"); - //_e_fm_menu_context_display(icon->sd, ev->output.x, ev->output.y, ev->timestamp); + _e_fm_menu_context_display(icon->sd, ev->output.x, ev->output.y, ev->timestamp); } break; @@ -3391,7 +3384,12 @@ /* check the position of every icon and compare the coords * until we find an icon below */ - sd->operation.hover = NULL; + + if(sd->operation.hover) + { + e_object_del(E_OBJECT(sd->operation.hover)); + sd->operation.hover = NULL; + } for (l = sd->icons; l; l = l->next) { E_Fm_Icon *icon; @@ -3405,7 +3403,13 @@ { icon->state.hover = 1; e_fm_icon_signal_emit(icon->icon_obj, "hover", ""); - sd->operation.hover = icon->file; + if(sd->operation.hover) + { + e_object_del(E_OBJECT(sd->operation.hover)); + sd->operation.hover = NULL; + } + sd->operation.hover = e_fm_file_new(icon->file->path); + } else { @@ -3420,6 +3424,9 @@ e_fm_icon_signal_emit(icon->icon_obj, "clicked", ""); } } + /* if we arent above any icon, the file is the dir itself */ + if(!sd->operation.hover) + sd->operation.hover = e_fm_file_new(sd->dir); } rect.x = 0; @@ -3547,9 +3554,8 @@ files = ev->data; if(files->num_files < 1) break; - - /* FIXME clean in a better way the list */ - sd->operation.files = NULL; + /* free the operation struct before recreating */ + _e_fm_operation_files_free(sd); i = 0; do { @@ -3810,15 +3816,19 @@ E_Fm_Mime_Action *action; E_Fm_Mime_Action *default_action; E_Fm_Mime_Entry *mime; + E_Fm_Menu_Item_Data *mid; int multiple = 0; - /* if we dont have any selection, how do we get here ? */ - if(!sd->selection.icons) + /* if we dont have any operation files, how do we get here ? */ + if(!sd->operation.files) return; /* to know if the action can be performed on multiple files */ if(sd->operation.files->next) multiple = 1; + /* to know if the action can be performed on multiple files */ + if(sd->operation.files->next) + multiple = 1; mn = e_menu_new(); e_menu_category_set(mn,"fileman/action"); @@ -3839,15 +3849,21 @@ mime = mime->parent; continue; } + if(action->relative) + continue; if(!action->multiple && multiple) { mime = mime->parent; continue; } + mid = E_NEW(E_Fm_Menu_Item_Data,1); + mid->action = action; + mid->sd = sd; + sd->operation.menu_item_data = evas_list_append(sd->operation.menu_item_data, mid); 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_callback_set(mi, _e_fm_menu_actions, mid); e_menu_item_icon_edje_set(mi, (char *)e_theme_edje_file_get("base/theme/fileman", "fileman/button/open"),"fileman/button/open"); @@ -3874,10 +3890,18 @@ /* if its the same as the default one, skip it */ if(action == default_action) continue; + if(action->relative) + continue; + + + mid = E_NEW(E_Fm_Menu_Item_Data,1); + mid->action = action; + mid->sd = sd; + sd->operation.menu_item_data = evas_list_append(sd->operation.menu_item_data, mid); 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_callback_set(mi, _e_fm_menu_actions, mid); e_menu_item_icon_edje_set(mi, (char *)e_theme_edje_file_get("base/theme/fileman", "fileman/button/open"),"fileman/button/open"); @@ -3935,7 +3959,7 @@ (char *)e_theme_edje_file_get("base/theme/fileman", "fileman/button/properties"), "fileman/button/properties"); - //sd->selection.icon->menu = mn; + sd->operation.menu = mn; if (!sd->win) return; @@ -3961,14 +3985,15 @@ E_Fm_Mime_Entry *mime; E_Fm_Mime_Action *action; E_Fm_Mime_Action *default_action; + E_Fm_Menu_Item_Data *mid; - /* if we dont have any selection, how do we get here ? */ - if(!sd->selection.icons) + /* if we dont have any operation files, how do we get here ? */ + if(!sd->operation.files) return; /* to know if the action can be performed on multiple files */ if(sd->operation.files->next) multiple = 1; - + mn = e_menu_new(); e_menu_category_set(mn,"fileman/action"); e_menu_category_data_set("fileman/action",sd); @@ -3993,9 +4018,14 @@ continue; } + mid = E_NEW(E_Fm_Menu_Item_Data,1); + mid->action = action; + mid->sd = sd; + sd->operation.menu_item_data = evas_list_append(sd->operation.menu_item_data, mid); + 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_label_set(mi, e_fm_mime_translate(sd, action->label)); + e_menu_item_callback_set(mi, _e_fm_menu_actions, mid); e_menu_item_icon_edje_set(mi, (char *)e_theme_edje_file_get("base/theme/fileman", "fileman/button/open"),"fileman/button/open"); @@ -4017,7 +4047,6 @@ actions = mime->actions; for(l = actions; l; l = l->next) { - action = (E_Fm_Mime_Action*)l->data; /* if its not relative skip it */ if(!action->relative) @@ -4028,9 +4057,15 @@ if(action == default_action) continue; + + mid = E_NEW(E_Fm_Menu_Item_Data,1); + mid->action = action; + mid->sd = sd; + sd->operation.menu_item_data = evas_list_append(sd->operation.menu_item_data, mid); + 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_label_set(mi, e_fm_mime_translate(sd, action->label)); + e_menu_item_callback_set(mi, _e_fm_menu_actions, mid); e_menu_item_icon_edje_set(mi, (char *)e_theme_edje_file_get("base/theme/fileman", "fileman/button/open"),"fileman/button/open"); @@ -4038,6 +4073,8 @@ mime = mime->parent; } while(mime); + sd->operation.menu = mn; + if (!sd->win) return; ecore_evas_geometry_get(sd->win->ecore_evas, &x, &y, &w, &h); @@ -4049,14 +4086,64 @@ 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; + E_Fm_Menu_Item_Data *mid; - sd = data; - /* search for the action clicked */ - action = e_fm_mime_action_get_by_label(mi->label); + mid = data; /* execute the action on the files */ - e_fm_mime_action_call(sd,action); + e_fm_mime_action_call(mid->sd,mid->action); +} + +static void +_e_fm_operation_from_selection(E_Fm_Smart_Data *sd) +{ + +} + +/* free functions */ +/******************/ +static void +_e_fm_operation_menu_free(E_Fm_Smart_Data *sd) +{ + if(sd->operation.menu) + e_object_del(E_OBJECT(sd->operation.menu)); + sd->operation.menu = NULL; + while(sd->operation.menu_item_data) + { + E_Fm_Menu_Item_Data *mid; + + mid = (E_Fm_Menu_Item_Data*)sd->operation.menu_item_data->data; + E_FREE(mid); + sd->operation.menu_item_data = evas_list_remove_list(sd->operation.menu_item_data, sd->operation.menu_item_data); + } +} + +static void +_e_fm_operation_files_free(E_Fm_Smart_Data *sd) +{ + while (sd->operation.files) + { + E_Fm_File *file; + + file = sd->operation.files->data; + sd->operation.files = evas_list_remove_list( + sd->operation.files, sd->operation.files); + /* also delete the file, its a copy of the selected or a new file + * in case of a drop + */ + e_object_del(E_OBJECT(file)); + } + /* also delete the menu associated with this operation */ + _e_fm_operation_menu_free(sd); +} + +static void +_e_fm_operation_free(E_Fm_Smart_Data *sd) +{ + if(sd->operation.hover) + { + e_object_del(E_OBJECT(sd->operation.hover)); + sd->operation.hover = NULL; + } + /* delete the files and the menu */ + _e_fm_operation_files_free(sd); } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_smart.h,v retrieving revision 1.20 retrieving revision 1.21 diff -u -3 -r1.20 -r1.21 --- e_fileman_smart.h 16 Feb 2006 03:13:30 -0000 1.20 +++ e_fileman_smart.h 16 Feb 2006 17:06:37 -0000 1.21 @@ -11,6 +11,8 @@ typedef struct _E_Fm_Fake_Mouse_Up_Info E_Fm_Fake_Mouse_Up_Info; typedef struct _E_Event_Fm_Reconfigure E_Event_Fm_Reconfigure; typedef struct _E_Event_Fm_Directory_Change E_Event_Fm_Directory_Change; +typedef struct _E_Fm_Menu_Item_Data E_Fm_Menu_Item_Data; + typedef struct _E_Fm_Assoc_App E_Fm_Assoc_App; typedef enum _E_Fm_Arrange E_Fm_Arrange; @@ -23,6 +25,14 @@ #ifndef E_FM_SMART_H #define E_FM_SMART_H +/* this is for passing the E_Fm_Mime_Action of a menu item and the E_Fm_Smart_Data + * in one struct for the menu item callback */ +struct _E_Fm_Menu_Item_Data +{ + E_Fm_Mime_Action *action; + E_Fm_Smart_Data *sd; +}; + struct _E_Fm_Config { int width; @@ -50,11 +60,9 @@ struct { unsigned char selected : 1; unsigned char hover : 1; - unsigned char visible : 1; /* FIXME what was it for?to stop comparing icon_obj to NULL */ + unsigned char visible : 1; /* to stop comparing icon_obj to NULL */ } state; - - E_Menu *menu; }; struct _E_Fm_Icon_CFData @@ -134,7 +142,7 @@ E_Fm_Dir_Metadata *meta; - Evas_Hash *mime_menu_hash; + Evas_Hash *mime_menu_hash; /* FIXME delete this */ char *dir; /* FIXME this could be actually a E_Fm_Dir */ DIR *dir2; @@ -215,6 +223,8 @@ Evas_List *files; /* list of E_Fm_Files */ E_Fm_File *hover; /* 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 */ + E_Menu *menu; /* the menu displayed for it (action/context) */ + Evas_List *menu_item_data; /* the data created for each callback, for free later */ } operation; /* the operating files, for wich we are going to make actions might be the selected files or the dropped files */ ------------------------------------------------------- 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 enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs