From d115dd1b4ec2381d0f6a0785e766cc2de11c807f Mon Sep 17 00:00:00 2001 From: Davide Andreoli Date: Fri, 10 Apr 2009 22:02:32 +0000 Subject: [PATCH] * e_fwin.c : Make some cleaning here. Whitespaces + functions grouped better. No changes to code made. Still need to rename some functions in a more standard way. SVN revision: 39950 --- src/modules/fileman/e_fwin.c | 1426 +++++++++++++++++----------------- 1 file changed, 719 insertions(+), 707 deletions(-) diff --git a/src/modules/fileman/e_fwin.c b/src/modules/fileman/e_fwin.c index 35ce46768..07a33fc15 100644 --- a/src/modules/fileman/e_fwin.c +++ b/src/modules/fileman/e_fwin.c @@ -22,7 +22,7 @@ typedef struct _E_Fwin_Apps_Dialog E_Fwin_Apps_Dialog; struct _E_Fwin { E_Object e_obj_inherit; - + E_Win *win; E_Zone *zone; Evas_Object *scrollframe_obj; @@ -35,7 +35,7 @@ struct _E_Fwin struct { Evas_Coord x, y, max_x, max_y, w, h; } fm_pan, fm_pan_last; - + const char *wallpaper_file; const char *overlay_file; const char *scrollframe_file; @@ -69,7 +69,7 @@ typedef enum E_FWIN_EXEC_DESKTOP } E_Fwin_Exec_Type; -/* local subsystem functions */ +/* local subsystem prototypes */ static E_Fwin *_e_fwin_new(E_Container *con, const char *dev, const char *path); static void _e_fwin_free(E_Fwin *fwin); static void _e_fwin_cb_delete(E_Win *win); @@ -204,11 +204,11 @@ e_fwin_zone_new(E_Zone *zone, const char *dev, const char *path) { E_Fwin *fwin; Evas_Object *o; - + fwin = E_OBJECT_ALLOC(E_Fwin, E_FWIN_TYPE, _e_fwin_free); if (!fwin) return; fwin->zone = zone; - + /* Add Event Handler for zone move/resize & del */ fwin->zone_handler = ecore_event_handler_add(E_EVENT_ZONE_MOVE_RESIZE, @@ -216,14 +216,14 @@ e_fwin_zone_new(E_Zone *zone, const char *dev, const char *path) fwin->zone_del_handler = ecore_event_handler_add(E_EVENT_ZONE_DEL, _e_fwin_zone_del, fwin); - + /* Trap the mouse_down on zone so we can unselect */ evas_object_event_callback_add(zone->bg_event_object, EVAS_CALLBACK_MOUSE_DOWN, _e_fwin_zone_cb_mouse_down, fwin); - + fwins = eina_list_append(fwins, fwin); - + o = e_fm2_add(zone->container->bg_evas); fwin->fm_obj = o; _e_fwin_config_set(fwin); @@ -242,7 +242,7 @@ e_fwin_zone_new(E_Zone *zone, const char *dev, const char *path) e_fm2_icon_menu_end_extend_callback_set(o, _e_fwin_menu_extend, fwin); e_fm2_underlay_hide(o); evas_object_show(o); - + o = e_scrollframe_add(zone->container->bg_evas); ecore_x_icccm_state_set(zone->container->bg_win, ECORE_X_WINDOW_STATE_HINT_NORMAL); e_drop_xdnd_register_set(zone->container->bg_win, 1); @@ -276,7 +276,7 @@ e_fwin_zone_new(E_Zone *zone, const char *dev, const char *path) evas_object_show(o); e_fm2_window_object_set(fwin->fm_obj, E_OBJECT(fwin->zone)); - + evas_object_focus_set(fwin->fm_obj, 1); e_fm2_path_set(fwin->fm_obj, dev, path); @@ -286,7 +286,7 @@ EAPI void e_fwin_all_unsel(void *data) { E_Fwin *fwin; - + fwin = data; E_OBJECT_CHECK(fwin); E_OBJECT_TYPE_CHECK(fwin, E_FWIN_TYPE); @@ -297,8 +297,8 @@ EAPI void e_fwin_zone_shutdown(E_Zone *zone) { Eina_List *f; - E_Fwin *win; - + E_Fwin *win; + EINA_LIST_FOREACH(fwins, f, win) { if (win->zone != zone) continue; @@ -365,124 +365,13 @@ e_fwin_zone_find(E_Zone *zone) } -/* e_fm_op_registry */ -static void -_e_fwin_op_registry_listener_cb(void *data, const E_Fm2_Op_Registry_Entry *ere) -{ - Evas_Object *o = data; - char buf[PATH_MAX]; - char *total; - - // Update element - edje_object_part_drag_size_set(o, "e.gauge.bar", ((double)(ere->percent)) / 100, 1.0); - - total = e_util_size_string_get(ere->total); - switch (ere->op) - { - case E_FM_OP_COPY: - edje_object_signal_emit(o, "e,action,icon,copy", "e"); - if (ere->finished) - snprintf(buf, sizeof(buf), "Copy of %s done", total); - else - snprintf(buf, sizeof(buf), "Copying %s (eta: %d sec)", total, ere->eta); - break; - case E_FM_OP_MOVE: - edje_object_signal_emit(o, "e,action,icon,move", "e"); - if (ere->finished) - snprintf(buf, sizeof(buf), "Move of %s done", total); - else - snprintf(buf, sizeof(buf), "Moving %s (eta: %d sec)", total, ere->eta); - break; - case E_FM_OP_REMOVE: - edje_object_signal_emit(o, "e,action,icon,delete", "e"); - if (ere->finished) - snprintf(buf, sizeof(buf), "Delete done"); - else - snprintf(buf, sizeof(buf), "Deleting files..."); - break; - default: - edje_object_signal_emit(o, "e,action,icon,unknow", "e"); - snprintf(buf, sizeof(buf), "Unknow operation from slave %d", ere->id); - break; - } - edje_object_part_text_set(o, "e.text.label1", buf); - - if (ere->needs_attention) - edje_object_signal_emit(o, "e,action,set,need_attention", "e"); - else - edje_object_signal_emit(o, "e,action,set,normal", "e"); - - E_FREE(total); -} - -static int -_e_fwin_op_registry_free_data_delayed(void *data) -{ - evas_object_del((Evas_Object*)data); - return ECORE_CALLBACK_CANCEL; -} - -static void -_e_fwin_op_registry_free_data(void *data) -{ - ecore_timer_add(5.0, _e_fwin_op_registry_free_data_delayed, data); -} - -static int -_e_fwin_op_registry_entry_add_cb(void *data, int type, void *event) -{ - E_Fm2_Op_Registry_Entry *ere = (E_Fm2_Op_Registry_Entry *)event; - E_Fwin *fwin = data; - Evas_Object *o; - int mw, mh; - - if (!(ere->op == E_FM_OP_COPY || ere->op == E_FM_OP_MOVE || - ere->op == E_FM_OP_REMOVE)) - return ECORE_CALLBACK_RENEW; - - o = edje_object_add(e_win_evas_get(fwin->win)); - e_theme_edje_object_set(o, "base/theme/fileman", - "e/fileman/default/progress"); - edje_object_size_min_get(o, &mw, &mh); - evas_object_resize(o, mw * e_scale, mh * e_scale); - //evas_object_event_callback_add(o, EVAS_CALLBACK_CHANGED_SIZE_HINTS, - // _size_hint_changed_cb, NULL); - - //Update the element - _e_fwin_op_registry_listener_cb(o, ere); - - // Append the element to the box - edje_object_part_box_append(e_scrollframe_edje_object_get(fwin->scrollframe_obj), - "e.box.operations", o); - evas_object_size_hint_align_set(o, 1.0, 1.0); //FIXME this should be theme-configurable - evas_object_show(o); - - //Listen to progress changes - e_fm2_op_registry_entry_listener_add(ere, _e_fwin_op_registry_listener_cb, - o, _e_fwin_op_registry_free_data); - - return ECORE_CALLBACK_RENEW; -} - -static void -_e_fwin_op_registry_entry_iter(E_Fwin *fwin) -{ - Eina_Iterator *itr; - E_Fm2_Op_Registry_Entry *ere; - - itr = e_fm2_op_registry_iterator_new(); - EINA_ITERATOR_FOREACH(itr, ere) - _e_fwin_op_registry_entry_add_cb(fwin, 0, ere); - eina_iterator_free(itr); -} - /* local subsystem functions */ static E_Fwin * _e_fwin_new(E_Container *con, const char *dev, const char *path) { E_Fwin *fwin; Evas_Object *o; - + fwin = E_OBJECT_ALLOC(E_Fwin, E_FWIN_TYPE, _e_fwin_free); if (!fwin) return NULL; fwin->win = e_win_new(con); @@ -508,7 +397,7 @@ _e_fwin_new(E_Container *con, const char *dev, const char *path) _e_fwin_config_set(fwin); e_fm2_view_flags_set(o, E_FM2_VIEW_DIR_CUSTOM); evas_object_event_callback_add(o, EVAS_CALLBACK_KEY_DOWN, _e_fwin_cb_key_down, fwin); - + evas_object_smart_callback_add(o, "dir_changed", _e_fwin_changed, fwin); evas_object_smart_callback_add(o, "dir_deleted", @@ -520,7 +409,7 @@ _e_fwin_new(E_Container *con, const char *dev, const char *path) e_fm2_icon_menu_start_extend_callback_set(o, _e_fwin_cb_menu_extend_start, fwin); e_fm2_icon_menu_end_extend_callback_set(o, _e_fwin_menu_extend, fwin); evas_object_show(o); - + o = e_scrollframe_add(e_win_evas_get(fwin->win)); /* FIXME: this theme object will have more versions and options later * for things like swallowing widgets/buttons ot providing them - a @@ -561,22 +450,22 @@ _e_fwin_new(E_Container *con, const char *dev, const char *path) edje_object_part_swallow(fwin->bg_obj, "e.swallow.bg", o); evas_object_pass_events_set(o, 1); fwin->under_obj = o; - + o = edje_object_add(e_win_evas_get(fwin->win)); edje_object_part_swallow(e_scrollframe_edje_object_get(fwin->scrollframe_obj), "e.swallow.overlay", o); evas_object_pass_events_set(o, 1); fwin->over_obj = o; - + e_fm2_window_object_set(fwin->fm_obj, E_OBJECT(fwin->win)); - + evas_object_focus_set(fwin->fm_obj, 1); e_fm2_path_set(fwin->fm_obj, dev, path); - + e_win_name_class_set(fwin->win, "E", "e_fwin"); - + _e_fwin_window_title_set(fwin); - + e_win_size_min_set(fwin->win, 24, 24); e_win_resize(fwin->win, 280 * e_scale, 200 * e_scale); e_win_show(fwin->win); @@ -612,7 +501,7 @@ _e_fwin_free(E_Fwin *fwin) EVAS_CALLBACK_MOUSE_DOWN, _e_fwin_zone_cb_mouse_down); } - + if (fwin->zone_handler) ecore_event_handler_del(fwin->zone_handler); if (fwin->zone_del_handler) @@ -635,11 +524,396 @@ _e_fwin_free(E_Fwin *fwin) free(fwin); } +static const char * +_e_fwin_custom_file_path_eval(E_Fwin *fwin, Efreet_Desktop *ef, const char *prev_path, const char *key) +{ + char buf[PATH_MAX]; + const char *res, *ret = NULL; + + /* get a X-something custom tage from the .desktop for the dir */ + res = eina_hash_find(ef->x, key); + /* free the old path */ + if (prev_path) eina_stringshare_del(prev_path); + /* if there was no key found - return NULL */ + if (!res) return NULL; + + /* it's a full path */ + if (res[0] == '/') + ret = eina_stringshare_add(res); + /* relative path to the dir */ + else + { + snprintf(buf, sizeof(buf), "%s/%s", e_fm2_real_path_get(fwin->fm_obj), res); + ret = eina_stringshare_add(buf); + } + return ret; +} + +static Eina_List* +_e_fwin_suggested_apps_list_get(Eina_List *files, Eina_List **mime_list) +{ + E_Fm2_Icon_Info *ici; + const char *f = NULL; + char *mime; + Eina_Hash *mimes = NULL; + Eina_List *mlist = NULL, *apps = NULL, *ret = NULL, *l; + Efreet_Desktop *desk = NULL; + + /* 1. build hash of mimetypes */ + EINA_LIST_FOREACH(files, l, ici) + if (!((ici->link) && (ici->mount))) + { + if (_e_fwin_file_is_exec(ici) == E_FWIN_EXEC_NONE) + { + if (ici->link) + f = efreet_mime_globs_type_get(ici->link); + if (!mimes) + mimes = eina_hash_string_superfast_new(NULL); + eina_hash_del(mimes, ici->link ? f : ici->mime, (void *)1); + eina_hash_direct_add(mimes, ici->link ? f : ici->mime, (void *)1); + } + } + if (!mimes) return NULL; + + /* 2. add apps to a list so its a unique app list */ + eina_hash_foreach(mimes, _e_fwin_cb_hash_foreach, &mlist); + eina_hash_free(mimes); + + /* 3. for each mimetype list apps that handle it */ + EINA_LIST_FOREACH(mlist, l, mime) + apps = eina_list_merge(apps, efreet_util_desktop_mime_list(mime)); + + /* 4. create a new list without duplicates */ + EINA_LIST_FOREACH(apps, l, desk) + if (!eina_list_data_find(ret, desk)) + ret = eina_list_append(ret, desk); + + if (apps) apps = eina_list_free(apps); + + if (mime_list) + *mime_list = mlist; + else + if (mlist) mlist = eina_list_free(mlist); + + return ret; +} + + +static void +_e_fwin_desktop_run(Efreet_Desktop *desktop, E_Fwin *fwin) +{ + char pcwd[4096], buf[4096]; + Eina_List *selected, *l, *files = NULL; + E_Fm2_Icon_Info *ici; + char *file; + + selected = e_fm2_selected_list_get(fwin->fm_obj); + if (!selected) return; + + getcwd(pcwd, sizeof(pcwd)); + chdir(e_fm2_real_path_get(fwin->fm_obj)); + + EINA_LIST_FOREACH(selected, l, ici) + { + E_Fwin_Exec_Type ext; + + /* this snprintf is silly - but it's here in case i really do + * need to provide full paths (seems silly since we chdir + * into the dir) + */ + buf[0] = 0; + ext = _e_fwin_file_is_exec(ici); + if (ext == E_FWIN_EXEC_NONE) + { + if (!((ici->link) && (ici->mount))) + { + if (ici->link) + { + if (!S_ISDIR(ici->statinfo.st_mode)) + snprintf(buf, sizeof(buf), "%s", ici->file); + } + else + { + if (!S_ISDIR(ici->statinfo.st_mode)) + snprintf(buf, sizeof(buf), "%s", ici->file); + } + } + } + else + _e_fwin_file_exec(fwin, ici, ext); + if (buf[0] != 0) + { + if (ici->mime && desktop) + e_exehist_mime_desktop_add(ici->mime, desktop); + files = eina_list_append(files, strdup(ici->file)); + } + } + eina_list_free(selected); + + if (fwin->win && desktop) + e_exec(fwin->win->border->zone, desktop, NULL, files, "fwin"); + else if (fwin->zone && desktop) + e_exec(fwin->zone, desktop, NULL, files, "fwin"); + + EINA_LIST_FREE(files, file) + free(file); + + chdir(pcwd); +} + +static Eina_Bool +_e_fwin_cb_hash_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data __UNUSED__, void *fdata) +{ + Eina_List **mlist; + + mlist = fdata; + *mlist = eina_list_append(*mlist, key); + return 1; +} + +static E_Fwin_Exec_Type +_e_fwin_file_is_exec(E_Fm2_Icon_Info *ici) +{ + /* special file or dir - can't exec anyway */ + if ((S_ISCHR(ici->statinfo.st_mode)) || + (S_ISBLK(ici->statinfo.st_mode)) || + (S_ISFIFO(ici->statinfo.st_mode)) || + (S_ISSOCK(ici->statinfo.st_mode))) + return E_FWIN_EXEC_NONE; + /* it is executable */ + if ((ici->statinfo.st_mode & S_IXOTH) || + ((getgid() == ici->statinfo.st_gid) && + (ici->statinfo.st_mode & S_IXGRP)) || + ((getuid() == ici->statinfo.st_uid) && + (ici->statinfo.st_mode & S_IXUSR))) + { + /* no mimetype */ + if (!ici->mime) + return E_FWIN_EXEC_DIRECT; + /* mimetype */ + else + { + /* FIXME: - this could be config */ + if (!strcmp(ici->mime, "application/x-desktop")) + return E_FWIN_EXEC_DESKTOP; + else if ((!strcmp(ici->mime, "application/x-sh")) || + (!strcmp(ici->mime, "application/x-shellscript")) || + (!strcmp(ici->mime, "application/x-csh")) || + (!strcmp(ici->mime, "application/x-perl")) || + (!strcmp(ici->mime, "application/x-shar")) || + (!strcmp(ici->mime, "text/x-csh")) || + (!strcmp(ici->mime, "text/x-python")) || + (!strcmp(ici->mime, "text/x-sh")) + ) + { + return E_FWIN_EXEC_DIRECT; + } + } + } + else + { + /* mimetype */ + if (ici->mime) + { + /* FIXME: - this could be config */ + if (!strcmp(ici->mime, "application/x-desktop")) + return E_FWIN_EXEC_DESKTOP; + else if ((!strcmp(ici->mime, "application/x-sh")) || + (!strcmp(ici->mime, "application/x-shellscript")) || + (!strcmp(ici->mime, "text/x-sh")) + ) + { + return E_FWIN_EXEC_TERMINAL_SH; + } + } + else if ((e_util_glob_match(ici->file, "*.desktop")) || + (e_util_glob_match(ici->file, "*.kdelink")) + ) + { + return E_FWIN_EXEC_DESKTOP; + } + else if (e_util_glob_match(ici->file, "*.run")) + return E_FWIN_EXEC_TERMINAL_SH; + } + return E_FWIN_EXEC_NONE; +} + +static void +_e_fwin_file_exec(E_Fwin *fwin, E_Fm2_Icon_Info *ici, E_Fwin_Exec_Type ext) +{ + char buf[4096]; + Efreet_Desktop *desktop; + + /* FIXME: execute file ici with either a terminal, the shell, or directly + * or open the .desktop and exec it */ + switch (ext) + { + case E_FWIN_EXEC_NONE: + break; + case E_FWIN_EXEC_DIRECT: + if (fwin->win) + e_exec(fwin->win->border->zone, NULL, ici->file, NULL, "fwin"); + else if (fwin->zone) + e_exec(fwin->zone, NULL, ici->file, NULL, "fwin"); + break; + case E_FWIN_EXEC_SH: + snprintf(buf, sizeof(buf), "/bin/sh %s", e_util_filename_escape(ici->file)); + if (fwin->win) + e_exec(fwin->win->border->zone, NULL, buf, NULL, NULL); + else if (fwin->zone) + e_exec(fwin->zone, NULL, buf, NULL, NULL); + break; + case E_FWIN_EXEC_TERMINAL_DIRECT: + snprintf(buf, sizeof(buf), "%s %s", e_config->exebuf_term_cmd, e_util_filename_escape(ici->file)); + if (fwin->win) + e_exec(fwin->win->border->zone, NULL, buf, NULL, NULL); + else if (fwin->zone) + e_exec(fwin->zone, NULL, buf, NULL, NULL); + break; + case E_FWIN_EXEC_TERMINAL_SH: + snprintf(buf, sizeof(buf), "%s /bin/sh %s", e_config->exebuf_term_cmd, e_util_filename_escape(ici->file)); + if (fwin->win) + e_exec(fwin->win->border->zone, NULL, buf, NULL, NULL); + else if (fwin->zone) + e_exec(fwin->zone, NULL, buf, NULL, NULL); + break; + case E_FWIN_EXEC_DESKTOP: + snprintf(buf, sizeof(buf), "%s/%s", e_fm2_real_path_get(fwin->fm_obj), ici->file); + desktop = efreet_desktop_new(buf); + if (desktop) + { + if (fwin->win) + e_exec(fwin->win->border->zone, desktop, NULL, NULL, NULL); + else if (fwin->zone) + e_exec(fwin->zone, desktop, NULL, NULL, NULL); + efreet_desktop_free(desktop); + } + break; + default: + break; + } +} + +static void +_e_fwin_config_set(E_Fwin *fwin) +{ + E_Fm2_Config fmc; + + memset(&fmc, 0, sizeof(E_Fm2_Config)); + if (!fwin->zone) + { +#if 0 + fmc.view.mode = E_FM2_VIEW_MODE_LIST; + fmc.icon.list.w = 24 * e_scale; + fmc.icon.list.h = 24 * e_scale; + fmc.icon.fixed.w = 1; + fmc.icon.fixed.h = 1; +#else + fmc.view.mode = fileman_config->view.mode; + fmc.icon.icon.w = fileman_config->icon.icon.w * e_scale; + fmc.icon.icon.h = fileman_config->icon.icon.h * e_scale; + fmc.icon.fixed.w = 0; + fmc.icon.fixed.h = 0; +#endif + fmc.view.open_dirs_in_place = fileman_config->view.open_dirs_in_place; + } + else + { +#if 0 + fmc.view.mode = E_FM2_VIEW_MODE_LIST; + fmc.icon.list.w = 24 * e_scale; + fmc.icon.list.h = 24 * e_scale; + fmc.icon.fixed.w = 1; + fmc.icon.fixed.h = 1; +#else + fmc.view.mode = E_FM2_VIEW_MODE_CUSTOM_ICONS; + fmc.icon.icon.w = fileman_config->icon.icon.w * e_scale; + fmc.icon.icon.h = fileman_config->icon.icon.h * e_scale; + fmc.icon.fixed.w = 0; + fmc.icon.fixed.h = 0; +#endif + + fmc.view.open_dirs_in_place = 0; + fmc.view.fit_custom_pos = 1; + } + + fmc.view.selector = 0; + fmc.view.single_click = fileman_config->view.single_click; + fmc.view.no_subdir_jump = 0; + fmc.icon.extension.show = fileman_config->icon.extension.show; + fmc.list.sort.no_case = fileman_config->list.sort.no_case; + fmc.list.sort.dirs.first = fileman_config->list.sort.dirs.first; + fmc.list.sort.dirs.last = fileman_config->list.sort.dirs.last; + fmc.selection.single = fileman_config->selection.single; + fmc.selection.windows_modifiers = fileman_config->selection.windows_modifiers; + e_fm2_config_set(fwin->fm_obj, &fmc); +} + +static void +_e_fwin_window_title_set(E_Fwin *fwin) +{ + char buf[4096]; + const char *file; + + if (!fwin) return; + if (fwin->zone) return; //safety + + if (fileman_config->view.show_full_path) + file = e_fm2_real_path_get(fwin->fm_obj); + else + file = ecore_file_file_get(e_fm2_real_path_get(fwin->fm_obj)); + + if (file) + { + snprintf(buf, sizeof(buf), "%s", file); + e_win_title_set(fwin->win, buf); + } +} + +static void +_e_fwin_toolbar_resize(E_Fwin *fwin) +{ + int x, y, w, h; + + e_toolbar_position_calc(fwin->tbar); + w = fwin->win->w; + h = fwin->win->h; + switch (fwin->tbar->gadcon->orient) + { + case E_GADCON_ORIENT_TOP: + x = 0; + y = fwin->tbar->h; + h = (h - fwin->tbar->h); + break; + case E_GADCON_ORIENT_BOTTOM: + x = 0; + y = 0; + h = (h - fwin->tbar->h); + break; + case E_GADCON_ORIENT_LEFT: + x = (fwin->tbar->x + fwin->tbar->w); + y = 0; + w = (w - fwin->tbar->w); + break; + case E_GADCON_ORIENT_RIGHT: + x = 0; + y = 0; + w = (fwin->win->w - fwin->tbar->w); + break; + default: + return; + } + evas_object_move(fwin->scrollframe_obj, x, y); + evas_object_resize(fwin->scrollframe_obj, w, h); +} + + +/* fwin callbacks */ static void _e_fwin_cb_delete(E_Win *win) { E_Fwin *fwin; - + if (!win) return; //safety fwin = win->data; e_object_del(E_OBJECT(fwin)); @@ -707,92 +981,18 @@ static void _e_fwin_deleted(void *data, Evas_Object *obj, void *event_info) { E_Fwin *fwin; - + fwin = data; e_object_del(E_OBJECT(fwin)); } -static const char * -_e_fwin_custom_file_path_eval(E_Fwin *fwin, Efreet_Desktop *ef, const char *prev_path, const char *key) -{ - char buf[PATH_MAX]; - const char *res, *ret = NULL; - - /* get a X-something custom tage from the .desktop for the dir */ - res = eina_hash_find(ef->x, key); - /* free the old path */ - if (prev_path) eina_stringshare_del(prev_path); - /* if there was no key found - return NULL */ - if (!res) return NULL; - - /* it's a full path */ - if (res[0] == '/') - ret = eina_stringshare_add(res); - /* relative path to the dir */ - else - { - snprintf(buf, sizeof(buf), "%s/%s", e_fm2_real_path_get(fwin->fm_obj), res); - ret = eina_stringshare_add(buf); - } - return ret; -} - -static Eina_List* -_e_fwin_suggested_apps_list_get(Eina_List *files, Eina_List **mime_list) -{ - E_Fm2_Icon_Info *ici; - const char *f = NULL; - char *mime; - Eina_Hash *mimes = NULL; - Eina_List *mlist = NULL, *apps = NULL, *ret = NULL, *l; - Efreet_Desktop *desk = NULL; - - /* 1. build hash of mimetypes */ - EINA_LIST_FOREACH(files, l, ici) - if (!((ici->link) && (ici->mount))) - { - if (_e_fwin_file_is_exec(ici) == E_FWIN_EXEC_NONE) - { - if (ici->link) - f = efreet_mime_globs_type_get(ici->link); - if (!mimes) - mimes = eina_hash_string_superfast_new(NULL); - eina_hash_del(mimes, ici->link ? f : ici->mime, (void *)1); - eina_hash_direct_add(mimes, ici->link ? f : ici->mime, (void *)1); - } - } - if (!mimes) return NULL; - - /* 2. add apps to a list so its a unique app list */ - eina_hash_foreach(mimes, _e_fwin_cb_hash_foreach, &mlist); - eina_hash_free(mimes); - - /* 3. for each mimetype list apps that handle it */ - EINA_LIST_FOREACH(mlist, l, mime) - apps = eina_list_merge(apps, efreet_util_desktop_mime_list(mime)); - - /* 4. create a new list without duplicates */ - EINA_LIST_FOREACH(apps, l, desk) - if (!eina_list_data_find(ret, desk)) - ret = eina_list_append(ret, desk); - - if (apps) apps = eina_list_free(apps); - - if (mime_list) - *mime_list = mlist; - else - if (mlist) mlist = eina_list_free(mlist); - - return ret; -} - static void _e_fwin_changed(void *data, Evas_Object *obj, void *event_info) { E_Fwin *fwin; Efreet_Desktop *ef; char buf[PATH_MAX]; - + fwin = data; if (!fwin) return; //safety @@ -851,7 +1051,7 @@ _e_fwin_changed(void *data, Evas_Object *obj, void *event_info) e_fm2_custom_theme_set(obj, fwin->theme_file); else e_fm2_custom_theme_set(obj, NULL); - + if (fwin->zone) return; _e_fwin_window_title_set(fwin); } @@ -861,7 +1061,7 @@ _e_fwin_selected(void *data, Evas_Object *obj, void *event_info) { E_Fwin *fwin; Eina_List *selected; - + fwin = data; selected = e_fm2_selected_list_get(fwin->fm_obj); if (!selected) return; @@ -874,7 +1074,7 @@ _e_fwin_selection_change(void *data, Evas_Object *obj, void *event_info) { Eina_List *l; E_Fwin *fwin; - + fwin = data; for (l = fwins; l; l = l->next) { @@ -883,35 +1083,16 @@ _e_fwin_selection_change(void *data, Evas_Object *obj, void *event_info) } } -static void -_e_fwin_menu_extend(void *data, Evas_Object *obj, E_Menu *m, E_Fm2_Icon_Info *info) +static void +_e_fwin_cb_all_change(void *data, Evas_Object *obj) { - E_Fwin *fwin; - E_Menu_Item *mi; - - fwin = data; - if (e_fm2_has_parent_get(obj)) - { - mi = e_menu_item_new(m); - e_menu_item_separator_set(mi, 1); + E_Fwin_Apps_Dialog *fad; + Efreet_Desktop *desktop = NULL; - mi = e_menu_item_new(m); - e_menu_item_label_set(mi, _("Go to Parent Directory")); - e_menu_item_icon_edje_set(mi, - e_theme_edje_file_get("base/theme/fileman", - "e/fileman/default/button/parent"), - "e/fileman/default/button/parent"); - e_menu_item_callback_set(mi, _e_fwin_parent, obj); - } - /* FIXME: if info != null then check mime type and offer options based - * on that - */ -} - -static void -_e_fwin_parent(void *data, E_Menu *m, E_Menu_Item *mi) -{ - e_fm2_parent_go(data); + fad = data; + desktop = efreet_util_desktop_file_id_find(fad->app2); + if ((desktop) && (desktop->exec)) + e_widget_entry_text_set(fad->o_entry, desktop->exec); } static void @@ -919,7 +1100,7 @@ _e_fwin_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info) { Evas_Event_Key_Down *ev; E_Fwin *fwin; - + fwin = data; ev = event_info; @@ -948,6 +1129,90 @@ _e_fwin_cb_key_down(void *data, Evas *e, Evas_Object *obj, void *event_info) } } + +/* fwin zone callbacks */ +static void +_e_fwin_zone_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) +{ + E_Fwin *fwin; + + fwin = data; + if (!fwin) return; + e_fwin_all_unsel(fwin); +} + +static int +_e_fwin_zone_move_resize(void *data, int type, void *event) +{ + E_Event_Zone_Move_Resize *ev; + E_Fwin *fwin; + + if (type != E_EVENT_ZONE_MOVE_RESIZE) return 1; + fwin = data; + ev = event; + if (!fwin) return 1; + if (fwin->zone != ev->zone) return 1; + if (fwin->bg_obj) + { + evas_object_move(fwin->bg_obj, ev->zone->x, ev->zone->y); + evas_object_resize(fwin->bg_obj, ev->zone->w, ev->zone->h); + } + if (fwin->scrollframe_obj) + { + evas_object_move(fwin->scrollframe_obj, ev->zone->x, ev->zone->y); + evas_object_resize(fwin->scrollframe_obj, ev->zone->w, ev->zone->h); + } + return 1; +} + +static int +_e_fwin_zone_del(void *data, int type, void *event) +{ + E_Event_Zone_Del *ev; + E_Fwin *fwin; + + if (type != E_EVENT_ZONE_DEL) return 1; + fwin = data; + ev = event; + if (!fwin) return 1; + if (fwin->zone != ev->zone) return 1; + e_object_del(E_OBJECT(fwin)); + return 1; +} + + +/* fm menu extend */ +static void +_e_fwin_menu_extend(void *data, Evas_Object *obj, E_Menu *m, E_Fm2_Icon_Info *info) +{ + E_Fwin *fwin; + E_Menu_Item *mi; + + fwin = data; + if (e_fm2_has_parent_get(obj)) + { + mi = e_menu_item_new(m); + e_menu_item_separator_set(mi, 1); + + mi = e_menu_item_new(m); + e_menu_item_label_set(mi, _("Go to Parent Directory")); + e_menu_item_icon_edje_set(mi, + e_theme_edje_file_get("base/theme/fileman", + "e/fileman/default/button/parent"), + "e/fileman/default/button/parent"); + e_menu_item_callback_set(mi, _e_fwin_parent, obj); + } + /* FIXME: if info != null then check mime type and offer options based + * on that + */ +} + +static void +_e_fwin_parent(void *data, E_Menu *m, E_Menu_Item *mi) +{ + e_fm2_parent_go(data); +} + static void _e_fwin_cb_menu_open_fast(void *data, E_Menu *m, E_Menu_Item *mi) { @@ -1042,7 +1307,7 @@ _e_fwin_cb_menu_open_with(void *data, E_Menu *m, E_Menu_Item *mi) { E_Fwin *fwin; Eina_List *selected = NULL; - + fwin = data; selected = e_fm2_selected_list_get(fwin->fm_obj); if (!selected) return; @@ -1050,293 +1315,8 @@ _e_fwin_cb_menu_open_with(void *data, E_Menu *m, E_Menu_Item *mi) eina_list_free(selected); } -static void -_e_fwin_cb_all_change(void *data, Evas_Object *obj) -{ - E_Fwin_Apps_Dialog *fad; - Efreet_Desktop *desktop = NULL; - - fad = data; - desktop = efreet_util_desktop_file_id_find(fad->app2); - if ((desktop) && (desktop->exec)) - e_widget_entry_text_set(fad->o_entry, desktop->exec); -} - -static void -_e_fwin_cb_exec_cmd_changed(void *data, void *data2) -{ - E_Fwin_Apps_Dialog *fad = NULL; - Efreet_Desktop *desktop = NULL; - - if (!(fad = data)) return; - - if (fad->app2) - desktop = efreet_util_desktop_file_id_find(fad->app2); - - if (!desktop) return; - if (!strcmp(desktop->exec, fad->exec_cmd)) return; - - eina_stringshare_del(fad->app2); - if (fad->o_all) e_widget_ilist_unselect(fad->o_all); -} - - -static void -_e_fwin_desktop_run(Efreet_Desktop *desktop, E_Fwin *fwin) -{ - char pcwd[4096], buf[4096]; - Eina_List *selected, *l, *files = NULL; - E_Fm2_Icon_Info *ici; - char *file; - - selected = e_fm2_selected_list_get(fwin->fm_obj); - if (!selected) return; - - getcwd(pcwd, sizeof(pcwd)); - chdir(e_fm2_real_path_get(fwin->fm_obj)); - - EINA_LIST_FOREACH(selected, l, ici) - { - E_Fwin_Exec_Type ext; - - /* this snprintf is silly - but it's here in case i really do - * need to provide full paths (seems silly since we chdir - * into the dir) - */ - buf[0] = 0; - ext = _e_fwin_file_is_exec(ici); - if (ext == E_FWIN_EXEC_NONE) - { - if (!((ici->link) && (ici->mount))) - { - if (ici->link) - { - if (!S_ISDIR(ici->statinfo.st_mode)) - snprintf(buf, sizeof(buf), "%s", ici->file); - } - else - { - if (!S_ISDIR(ici->statinfo.st_mode)) - snprintf(buf, sizeof(buf), "%s", ici->file); - } - } - } - else - _e_fwin_file_exec(fwin, ici, ext); - if (buf[0] != 0) - { - if (ici->mime && desktop) - e_exehist_mime_desktop_add(ici->mime, desktop); - files = eina_list_append(files, strdup(ici->file)); - } - } - eina_list_free(selected); - - if (fwin->win && desktop) - e_exec(fwin->win->border->zone, desktop, NULL, files, "fwin"); - else if (fwin->zone && desktop) - e_exec(fwin->zone, desktop, NULL, files, "fwin"); - - EINA_LIST_FREE(files, file) - free(file); - - chdir(pcwd); -} - -static void -_e_fwin_cb_open(void *data, E_Dialog *dia) -{ - E_Fwin_Apps_Dialog *fad; - Efreet_Desktop *desktop = NULL; - - fad = data; - if (fad->app2) - desktop = efreet_util_desktop_file_id_find(fad->app2); - - if ((!desktop) && (!fad->exec_cmd)) return; - - // Create a fake .desktop for custom command. - if (!desktop) - { - desktop = efreet_desktop_empty_new(""); - if (strchr(fad->exec_cmd, '%')) - { - desktop->exec = strdup(fad->exec_cmd); - } - else - { - desktop->exec = malloc(strlen(fad->exec_cmd) + 4); - if (desktop->exec) - snprintf(desktop->exec, strlen(fad->exec_cmd) + 4, "%s %%U", fad->exec_cmd); - } - } - - if ((desktop) || (strcmp(fad->exec_cmd, ""))) - _e_fwin_desktop_run(desktop,fad->fwin); - - // Free fake .desktop - if (!strcmp(fad->exec_cmd, "")) - efreet_desktop_free(desktop); - - e_object_del(E_OBJECT(fad->dia)); -} - -static void -_e_fwin_cb_close(void *data, E_Dialog *dia) -{ - E_Fwin_Apps_Dialog *fad; - - fad = data; - e_object_del(E_OBJECT(fad->dia)); -} - -static void -_e_fwin_cb_dialog_free(void *obj) -{ - E_Dialog *dia; - E_Fwin_Apps_Dialog *fad; - - dia = (E_Dialog *)obj; - fad = dia->data; - eina_stringshare_del(fad->app2); - E_FREE(fad->exec_cmd); - fad->fwin->fad = NULL; - E_FREE(fad); -} - -static Eina_Bool -_e_fwin_cb_hash_foreach(const Eina_Hash *hash __UNUSED__, const void *key, void *data __UNUSED__, void *fdata) -{ - Eina_List **mlist; - - mlist = fdata; - *mlist = eina_list_append(*mlist, key); - return 1; -} - -static E_Fwin_Exec_Type -_e_fwin_file_is_exec(E_Fm2_Icon_Info *ici) -{ - /* special file or dir - can't exec anyway */ - if ((S_ISCHR(ici->statinfo.st_mode)) || - (S_ISBLK(ici->statinfo.st_mode)) || - (S_ISFIFO(ici->statinfo.st_mode)) || - (S_ISSOCK(ici->statinfo.st_mode))) - return E_FWIN_EXEC_NONE; - /* it is executable */ - if ((ici->statinfo.st_mode & S_IXOTH) || - ((getgid() == ici->statinfo.st_gid) && - (ici->statinfo.st_mode & S_IXGRP)) || - ((getuid() == ici->statinfo.st_uid) && - (ici->statinfo.st_mode & S_IXUSR))) - { - /* no mimetype */ - if (!ici->mime) - return E_FWIN_EXEC_DIRECT; - /* mimetype */ - else - { - /* FIXME: - this could be config */ - if (!strcmp(ici->mime, "application/x-desktop")) - return E_FWIN_EXEC_DESKTOP; - else if ((!strcmp(ici->mime, "application/x-sh")) || - (!strcmp(ici->mime, "application/x-shellscript")) || - (!strcmp(ici->mime, "application/x-csh")) || - (!strcmp(ici->mime, "application/x-perl")) || - (!strcmp(ici->mime, "application/x-shar")) || - (!strcmp(ici->mime, "text/x-csh")) || - (!strcmp(ici->mime, "text/x-python")) || - (!strcmp(ici->mime, "text/x-sh")) - ) - { - return E_FWIN_EXEC_DIRECT; - } - } - } - else - { - /* mimetype */ - if (ici->mime) - { - /* FIXME: - this could be config */ - if (!strcmp(ici->mime, "application/x-desktop")) - return E_FWIN_EXEC_DESKTOP; - else if ((!strcmp(ici->mime, "application/x-sh")) || - (!strcmp(ici->mime, "application/x-shellscript")) || - (!strcmp(ici->mime, "text/x-sh")) - ) - { - return E_FWIN_EXEC_TERMINAL_SH; - } - } - else if ((e_util_glob_match(ici->file, "*.desktop")) || - (e_util_glob_match(ici->file, "*.kdelink")) - ) - { - return E_FWIN_EXEC_DESKTOP; - } - else if (e_util_glob_match(ici->file, "*.run")) - return E_FWIN_EXEC_TERMINAL_SH; - } - return E_FWIN_EXEC_NONE; -} - -static void -_e_fwin_file_exec(E_Fwin *fwin, E_Fm2_Icon_Info *ici, E_Fwin_Exec_Type ext) -{ - char buf[4096]; - Efreet_Desktop *desktop; - - /* FIXME: execute file ici with either a terminal, the shell, or directly - * or open the .desktop and exec it */ - switch (ext) - { - case E_FWIN_EXEC_NONE: - break; - case E_FWIN_EXEC_DIRECT: - if (fwin->win) - e_exec(fwin->win->border->zone, NULL, ici->file, NULL, "fwin"); - else if (fwin->zone) - e_exec(fwin->zone, NULL, ici->file, NULL, "fwin"); - break; - case E_FWIN_EXEC_SH: - snprintf(buf, sizeof(buf), "/bin/sh %s", e_util_filename_escape(ici->file)); - if (fwin->win) - e_exec(fwin->win->border->zone, NULL, buf, NULL, NULL); - else if (fwin->zone) - e_exec(fwin->zone, NULL, buf, NULL, NULL); - break; - case E_FWIN_EXEC_TERMINAL_DIRECT: - snprintf(buf, sizeof(buf), "%s %s", e_config->exebuf_term_cmd, e_util_filename_escape(ici->file)); - if (fwin->win) - e_exec(fwin->win->border->zone, NULL, buf, NULL, NULL); - else if (fwin->zone) - e_exec(fwin->zone, NULL, buf, NULL, NULL); - break; - case E_FWIN_EXEC_TERMINAL_SH: - snprintf(buf, sizeof(buf), "%s /bin/sh %s", e_config->exebuf_term_cmd, e_util_filename_escape(ici->file)); - if (fwin->win) - e_exec(fwin->win->border->zone, NULL, buf, NULL, NULL); - else if (fwin->zone) - e_exec(fwin->zone, NULL, buf, NULL, NULL); - break; - case E_FWIN_EXEC_DESKTOP: - snprintf(buf, sizeof(buf), "%s/%s", e_fm2_real_path_get(fwin->fm_obj), ici->file); - desktop = efreet_desktop_new(buf); - if (desktop) - { - if (fwin->win) - e_exec(fwin->win->border->zone, desktop, NULL, NULL, NULL); - else if (fwin->zone) - e_exec(fwin->zone, desktop, NULL, NULL, NULL); - efreet_desktop_free(desktop); - } - break; - default: - break; - } -} +/* 'open with' dialog*/ static void _e_fwin_file_open_dialog(E_Fwin *fwin, Eina_List *files, int always) { @@ -1720,11 +1700,116 @@ _e_fwin_file_open_dialog(E_Fwin *fwin, Eina_List *files, int always) e_dialog_border_icon_set(dia, "preferences-applications"); } +static int +_e_fwin_dlg_cb_desk_sort(const void *p1, const void *p2) +{ + Efreet_Desktop *d1, *d2; + + d1 = (Efreet_Desktop *)p1; + d2 = (Efreet_Desktop *)p2; + + if (!d1->name) return 1; + if (!d2->name) return -1; + return strcmp(d1->name, d2->name); +} + +static int +_e_fwin_dlg_cb_desk_list_sort(const void *data1, const void *data2) +{ + const Efreet_Desktop *d1, *d2; + + if (!(d1 = data1)) return 1; + if (!(d2 = data2)) return -1; + return strcmp(d1->name, d2->name); +} + +static void +_e_fwin_cb_exec_cmd_changed(void *data, void *data2) +{ + E_Fwin_Apps_Dialog *fad = NULL; + Efreet_Desktop *desktop = NULL; + + if (!(fad = data)) return; + + if (fad->app2) + desktop = efreet_util_desktop_file_id_find(fad->app2); + + if (!desktop) return; + if (!strcmp(desktop->exec, fad->exec_cmd)) return; + + eina_stringshare_del(fad->app2); + if (fad->o_all) e_widget_ilist_unselect(fad->o_all); +} + + +static void +_e_fwin_cb_open(void *data, E_Dialog *dia) +{ + E_Fwin_Apps_Dialog *fad; + Efreet_Desktop *desktop = NULL; + + fad = data; + if (fad->app2) + desktop = efreet_util_desktop_file_id_find(fad->app2); + + if ((!desktop) && (!fad->exec_cmd)) return; + + // Create a fake .desktop for custom command. + if (!desktop) + { + desktop = efreet_desktop_empty_new(""); + if (strchr(fad->exec_cmd, '%')) + { + desktop->exec = strdup(fad->exec_cmd); + } + else + { + desktop->exec = malloc(strlen(fad->exec_cmd) + 4); + if (desktop->exec) + snprintf(desktop->exec, strlen(fad->exec_cmd) + 4, "%s %%U", fad->exec_cmd); + } + } + + if ((desktop) || (strcmp(fad->exec_cmd, ""))) + _e_fwin_desktop_run(desktop,fad->fwin); + + // Free fake .desktop + if (!strcmp(fad->exec_cmd, "")) + efreet_desktop_free(desktop); + + e_object_del(E_OBJECT(fad->dia)); +} + +static void +_e_fwin_cb_close(void *data, E_Dialog *dia) +{ + E_Fwin_Apps_Dialog *fad; + + fad = data; + e_object_del(E_OBJECT(fad->dia)); +} + +static void +_e_fwin_cb_dialog_free(void *obj) +{ + E_Dialog *dia; + E_Fwin_Apps_Dialog *fad; + + dia = (E_Dialog *)obj; + fad = dia->data; + eina_stringshare_del(fad->app2); + E_FREE(fad->exec_cmd); + fad->fwin->fad = NULL; + E_FREE(fad); +} + + +/* scrolling ability */ static void _e_fwin_pan_set(Evas_Object *obj, Evas_Coord x, Evas_Coord y) { E_Fwin *fwin; - + fwin = evas_object_data_get(obj, "fwin"); e_fm2_pan_set(obj, x, y); if (x > fwin->fm_pan.max_x) x = fwin->fm_pan.max_x; @@ -1740,7 +1825,7 @@ static void _e_fwin_pan_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) { E_Fwin *fwin; - + fwin = evas_object_data_get(obj, "fwin"); e_fm2_pan_get(obj, x, y); fwin->fm_pan.x = *x; @@ -1751,7 +1836,7 @@ static void _e_fwin_pan_max_get(Evas_Object *obj, Evas_Coord *x, Evas_Coord *y) { E_Fwin *fwin; - + fwin = evas_object_data_get(obj, "fwin"); e_fm2_pan_max_get(obj, x, y); fwin->fm_pan.max_x = *x; @@ -1763,7 +1848,7 @@ static void _e_fwin_pan_child_size_get(Evas_Object *obj, Evas_Coord *w, Evas_Coord *h) { E_Fwin *fwin; - + fwin = evas_object_data_get(obj, "fwin"); e_fm2_pan_child_size_get(obj, w, h); fwin->fm_pan.w = *w; @@ -1775,7 +1860,7 @@ static void _e_fwin_pan_scroll_update(E_Fwin *fwin) { Edje_Message_Int_Set *msg; - + if ((fwin->fm_pan.x == fwin->fm_pan_last.x) && (fwin->fm_pan.y == fwin->fm_pan_last.y) && (fwin->fm_pan.max_x == fwin->fm_pan_last.max_x) && @@ -1809,187 +1894,114 @@ _e_fwin_pan_scroll_update(E_Fwin *fwin) fwin->fm_pan_last.h = fwin->fm_pan.h; } -static void -_e_fwin_zone_cb_mouse_down(void *data, Evas *evas, Evas_Object *obj, void *event_info) + +/* e_fm_op_registry */ +static void +_e_fwin_op_registry_listener_cb(void *data, const E_Fm2_Op_Registry_Entry *ere) { - E_Fwin *fwin; - - fwin = data; - if (!fwin) return; - e_fwin_all_unsel(fwin); -} + Evas_Object *o = data; + char buf[PATH_MAX]; + char *total; -static int -_e_fwin_zone_move_resize(void *data, int type, void *event) -{ - E_Event_Zone_Move_Resize *ev; - E_Fwin *fwin; - - if (type != E_EVENT_ZONE_MOVE_RESIZE) return 1; - fwin = data; - ev = event; - if (!fwin) return 1; - if (fwin->zone != ev->zone) return 1; - if (fwin->bg_obj) - { - evas_object_move(fwin->bg_obj, ev->zone->x, ev->zone->y); - evas_object_resize(fwin->bg_obj, ev->zone->w, ev->zone->h); - } - if (fwin->scrollframe_obj) - { - evas_object_move(fwin->scrollframe_obj, ev->zone->x, ev->zone->y); - evas_object_resize(fwin->scrollframe_obj, ev->zone->w, ev->zone->h); - } - return 1; -} + // Update element + edje_object_part_drag_size_set(o, "e.gauge.bar", ((double)(ere->percent)) / 100, 1.0); -static int -_e_fwin_zone_del(void *data, int type, void *event) -{ - E_Event_Zone_Del *ev; - E_Fwin *fwin; - - if (type != E_EVENT_ZONE_DEL) return 1; - fwin = data; - ev = event; - if (!fwin) return 1; - if (fwin->zone != ev->zone) return 1; - e_object_del(E_OBJECT(fwin)); - return 1; -} - -static void -_e_fwin_config_set(E_Fwin *fwin) -{ - E_Fm2_Config fmc; - - memset(&fmc, 0, sizeof(E_Fm2_Config)); - if (!fwin->zone) - { -#if 0 - fmc.view.mode = E_FM2_VIEW_MODE_LIST; - fmc.icon.list.w = 24 * e_scale; - fmc.icon.list.h = 24 * e_scale; - fmc.icon.fixed.w = 1; - fmc.icon.fixed.h = 1; -#else - fmc.view.mode = fileman_config->view.mode; - fmc.icon.icon.w = fileman_config->icon.icon.w * e_scale; - fmc.icon.icon.h = fileman_config->icon.icon.h * e_scale; - fmc.icon.fixed.w = 0; - fmc.icon.fixed.h = 0; -#endif - fmc.view.open_dirs_in_place = fileman_config->view.open_dirs_in_place; - } - else - { -#if 0 - fmc.view.mode = E_FM2_VIEW_MODE_LIST; - fmc.icon.list.w = 24 * e_scale; - fmc.icon.list.h = 24 * e_scale; - fmc.icon.fixed.w = 1; - fmc.icon.fixed.h = 1; -#else - fmc.view.mode = E_FM2_VIEW_MODE_CUSTOM_ICONS; - fmc.icon.icon.w = fileman_config->icon.icon.w * e_scale; - fmc.icon.icon.h = fileman_config->icon.icon.h * e_scale; - fmc.icon.fixed.w = 0; - fmc.icon.fixed.h = 0; -#endif - - fmc.view.open_dirs_in_place = 0; - fmc.view.fit_custom_pos = 1; - } - - fmc.view.selector = 0; - fmc.view.single_click = fileman_config->view.single_click; - fmc.view.no_subdir_jump = 0; - fmc.icon.extension.show = fileman_config->icon.extension.show; - fmc.list.sort.no_case = fileman_config->list.sort.no_case; - fmc.list.sort.dirs.first = fileman_config->list.sort.dirs.first; - fmc.list.sort.dirs.last = fileman_config->list.sort.dirs.last; - fmc.selection.single = fileman_config->selection.single; - fmc.selection.windows_modifiers = fileman_config->selection.windows_modifiers; - e_fm2_config_set(fwin->fm_obj, &fmc); -} - -static void -_e_fwin_window_title_set(E_Fwin *fwin) -{ - char buf[4096]; - const char *file; - - if (!fwin) return; - if (fwin->zone) return; //safety - - if (fileman_config->view.show_full_path) - file = e_fm2_real_path_get(fwin->fm_obj); - else - file = ecore_file_file_get(e_fm2_real_path_get(fwin->fm_obj)); - - if (file) - { - snprintf(buf, sizeof(buf), "%s", file); - e_win_title_set(fwin->win, buf); - } -} - -static void -_e_fwin_toolbar_resize(E_Fwin *fwin) -{ - int x, y, w, h; - - e_toolbar_position_calc(fwin->tbar); - w = fwin->win->w; - h = fwin->win->h; - switch (fwin->tbar->gadcon->orient) - { - case E_GADCON_ORIENT_TOP: - x = 0; - y = fwin->tbar->h; - h = (h - fwin->tbar->h); - break; - case E_GADCON_ORIENT_BOTTOM: - x = 0; - y = 0; - h = (h - fwin->tbar->h); - break; - case E_GADCON_ORIENT_LEFT: - x = (fwin->tbar->x + fwin->tbar->w); - y = 0; - w = (w - fwin->tbar->w); - break; - case E_GADCON_ORIENT_RIGHT: - x = 0; - y = 0; - w = (fwin->win->w - fwin->tbar->w); - break; + total = e_util_size_string_get(ere->total); + switch (ere->op) + { + case E_FM_OP_COPY: + edje_object_signal_emit(o, "e,action,icon,copy", "e"); + if (ere->finished) + snprintf(buf, sizeof(buf), "Copy of %s done", total); + else + snprintf(buf, sizeof(buf), "Copying %s (eta: %d sec)", total, ere->eta); + break; + case E_FM_OP_MOVE: + edje_object_signal_emit(o, "e,action,icon,move", "e"); + if (ere->finished) + snprintf(buf, sizeof(buf), "Move of %s done", total); + else + snprintf(buf, sizeof(buf), "Moving %s (eta: %d sec)", total, ere->eta); + break; + case E_FM_OP_REMOVE: + edje_object_signal_emit(o, "e,action,icon,delete", "e"); + if (ere->finished) + snprintf(buf, sizeof(buf), "Delete done"); + else + snprintf(buf, sizeof(buf), "Deleting files..."); + break; default: - return; - } - evas_object_move(fwin->scrollframe_obj, x, y); - evas_object_resize(fwin->scrollframe_obj, w, h); + edje_object_signal_emit(o, "e,action,icon,unknow", "e"); + snprintf(buf, sizeof(buf), "Unknow operation from slave %d", ere->id); + break; + } + edje_object_part_text_set(o, "e.text.label1", buf); + + if (ere->needs_attention) + edje_object_signal_emit(o, "e,action,set,need_attention", "e"); + else + edje_object_signal_emit(o, "e,action,set,normal", "e"); + + E_FREE(total); } -static int -_e_fwin_dlg_cb_desk_sort(const void *p1, const void *p2) +static int +_e_fwin_op_registry_free_data_delayed(void *data) { - Efreet_Desktop *d1, *d2; - - d1 = (Efreet_Desktop *)p1; - d2 = (Efreet_Desktop *)p2; - - if (!d1->name) return 1; - if (!d2->name) return -1; - return strcmp(d1->name, d2->name); + evas_object_del((Evas_Object*)data); + return ECORE_CALLBACK_CANCEL; } -static int -_e_fwin_dlg_cb_desk_list_sort(const void *data1, const void *data2) +static void +_e_fwin_op_registry_free_data(void *data) { - const Efreet_Desktop *d1, *d2; - - if (!(d1 = data1)) return 1; - if (!(d2 = data2)) return -1; - return strcmp(d1->name, d2->name); + ecore_timer_add(5.0, _e_fwin_op_registry_free_data_delayed, data); +} + +static int +_e_fwin_op_registry_entry_add_cb(void *data, int type, void *event) +{ + E_Fm2_Op_Registry_Entry *ere = (E_Fm2_Op_Registry_Entry *)event; + E_Fwin *fwin = data; + Evas_Object *o; + int mw, mh; + + if (!(ere->op == E_FM_OP_COPY || ere->op == E_FM_OP_MOVE || + ere->op == E_FM_OP_REMOVE)) + return ECORE_CALLBACK_RENEW; + + o = edje_object_add(e_win_evas_get(fwin->win)); + e_theme_edje_object_set(o, "base/theme/fileman", + "e/fileman/default/progress"); + edje_object_size_min_get(o, &mw, &mh); + evas_object_resize(o, mw * e_scale, mh * e_scale); + //evas_object_event_callback_add(o, EVAS_CALLBACK_CHANGED_SIZE_HINTS, + // _size_hint_changed_cb, NULL); + + //Update the element + _e_fwin_op_registry_listener_cb(o, ere); + + // Append the element to the box + edje_object_part_box_append(e_scrollframe_edje_object_get(fwin->scrollframe_obj), + "e.box.operations", o); + evas_object_size_hint_align_set(o, 1.0, 1.0); //FIXME this should be theme-configurable + evas_object_show(o); + + //Listen to progress changes + e_fm2_op_registry_entry_listener_add(ere, _e_fwin_op_registry_listener_cb, + o, _e_fwin_op_registry_free_data); + + return ECORE_CALLBACK_RENEW; +} + +static void +_e_fwin_op_registry_entry_iter(E_Fwin *fwin) +{ + Eina_Iterator *itr; + E_Fm2_Op_Registry_Entry *ere; + + itr = e_fm2_op_registry_iterator_new(); + EINA_ITERATOR_FOREACH(itr, ere) + _e_fwin_op_registry_entry_add_cb(fwin, 0, ere); + eina_iterator_free(itr); }