From ea90154e6138e8e023565bd0664dd23b99841030 Mon Sep 17 00:00:00 2001 From: Davide Andreoli Date: Sun, 8 Mar 2009 14:11:24 +0000 Subject: [PATCH] Show progress from the slave process in every efm windows. All the graphics need to be done! For now just a red rectangle, 5 labels and a really simple progress bar. ... (toma: ping) You can change the position of the info box from e_fwin.c line 329. A configuration will come soon.... The configuration will also let you choose on witch window you want to see the info box (every window, just on the source of copy operation, just on the dest or both) SVN revision: 39416 --- data/themes/default.edc | 148 +++++++++++++++++++++++++++++++ src/modules/fileman/Makefile.am | 2 +- src/modules/fileman/e_fwin.c | 125 +++++++++++++++++++++++++- src/modules/fileman/e_fwin.h | 3 +- src/modules/fileman/e_mod_main.c | 2 - 5 files changed, 275 insertions(+), 5 deletions(-) diff --git a/data/themes/default.edc b/data/themes/default.edc index 33c705281..001d2e633 100644 --- a/data/themes/default.edc +++ b/data/themes/default.edc @@ -11260,6 +11260,154 @@ collections { /* begin the collection of edje groups that are in this file */ } } } + group { name: "e/fileman/default/progress"; + min: 200 70; + parts { + part { name: "bg"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + rel1.offset: 3 3; + rel2.offset: -4 -4; + color: 255 0 0 200; + } + } + part { name: "gauge_bg"; + type: RECT; + mouse_events: 0; + description { state: "default" 0.0; + rel1.to: "bg"; + rel1.offset: 5 5; + rel2.to: "bg"; + rel2.relative: 0.0 1.0; + rel2.offset: 15 -7; + color: 155 155 155 200; + } + } + part { name: "e.gauge.bar"; + mouse_events: 0; + type: RECT; + description { state: "default" 0.0; + min: 10 0; + max: 10 110; + color: 255 255 255 255; + rel1 { + to: "gauge_bg"; + offset: 2 2; + } + rel2 { + to: "gauge_bg"; + offset: -3 -3; + } + } + dragable { + x: 0 0 0; + y: -1 1 0; + confine:"gauge_bg"; + } + } + part { name: "e.text.label1"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + align: 0.5 0.0; + rel1.to: "gauge_bg"; + rel1.relative: 1.0 0.0; + rel1.offset: 5 0; + rel2.to: "bg"; + color: 0 0 0 255; + text { + font: "Sans"; + size: 10; + min: 1 0; + align: 0.0 0.0; + text_class: "fileman_icon"; + } + } + } + part { name: "e.text.label2"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + align: 0.5 0.0; + rel1.to: "gauge_bg"; + rel1.relative: 1.0 0.2; + rel1.offset: 5 0; + rel2.to: "bg"; + color: 0 0 0 255; + text { + font: "Sans"; + size: 10; + min: 1 0; + align: 0.0 0.0; + text_class: "fileman_icon"; + } + } + } + part { name: "e.text.label3"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + align: 0.5 0.0; + rel1.to: "gauge_bg"; + rel1.relative: 1.0 0.4; + rel1.offset: 5 0; + rel2.to: "bg"; + color: 0 0 0 255; + text { + font: "Sans"; + size: 10; + min: 1 0; + align: 0.0 0.0; + text_class: "fileman_icon"; + } + } + } + part { name: "e.text.label4"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + align: 0.5 0.0; + rel1.to: "gauge_bg"; + rel1.relative: 1.0 0.6; + rel1.offset: 5 0; + rel2.to: "bg"; + color: 0 0 0 255; + text { + font: "Sans"; + size: 10; + min: 1 0; + align: 0.0 0.0; + text_class: "fileman_icon"; + } + } + } + part { name: "e.text.label5"; + type: TEXT; + mouse_events: 0; + scale: 1; + description { state: "default" 0.0; + align: 0.5 0.0; + rel1.to: "gauge_bg"; + rel1.relative: 1.0 0.8; + rel1.offset: 5 0; + rel2.to: "bg"; + color: 0 0 0 255; + text { + font: "Sans"; + size: 10; + min: 1 0; + align: 0.0 0.0; + text_class: "fileman_icon"; + } + } + } + } + } group { name: "e/fileman/default/scrollframe"; images { image: "inset_sunk.png" COMP; diff --git a/src/modules/fileman/Makefile.am b/src/modules/fileman/Makefile.am index 569c09c64..a46470c25 100644 --- a/src/modules/fileman/Makefile.am +++ b/src/modules/fileman/Makefile.am @@ -15,7 +15,7 @@ INCLUDES = -I. \ -I$(top_srcdir)/src/bin \ -I$(top_srcdir)/src/lib \ -I$(top_srcdir)/src/modules \ - @e_cflags@ + @e_cflags@ -Wall pkgdir = $(libdir)/enlightenment/modules/$(MODULE)/$(MODULE_ARCH) pkg_LTLIBRARIES = module.la module_la_SOURCES = e_mod_main.c \ diff --git a/src/modules/fileman/e_fwin.c b/src/modules/fileman/e_fwin.c index bf37f7301..7b6b60e85 100644 --- a/src/modules/fileman/e_fwin.c +++ b/src/modules/fileman/e_fwin.c @@ -28,6 +28,7 @@ struct _E_Fwin Evas_Object *scrollframe_obj; Evas_Object *fm_obj; Evas_Object *bg_obj; + Evas_Object *box_obj; E_Fwin_Apps_Dialog *fad; Evas_Object *under_obj; @@ -75,6 +76,8 @@ static void _e_fwin_cb_delete(E_Win *win); static void _e_fwin_cb_move(E_Win *win); static void _e_fwin_cb_resize(E_Win *win); static void _e_fwin_deleted(void *data, Evas_Object *obj, void *event_info); +static int _e_fwin_ipc_progress_data(void *data __UNUSED__, int type __UNUSED__, void *event); +static void _e_fwin_progress_update(E_Fwin *fwin, int slave_id, int percent, int seconds, size_t done, size_t total, char *src, char *dst); static const char *_e_fwin_custom_file_path_eval(E_Fwin *fwin, Efreet_Desktop *ef, const char *prev_path, const char *key); static void _e_fwin_changed(void *data, Evas_Object *obj, void *event_info); static void _e_fwin_selected(void *data, Evas_Object *obj, void *event_info); @@ -112,6 +115,7 @@ static int _e_fwin_dlg_cb_desk_list_sort(const void *data1, const void *data2); /* local subsystem globals */ static Eina_List *fwins = NULL; +static Ecore_Event_Handler *ipc = NULL; /* externally accessible functions */ EAPI int @@ -127,6 +131,7 @@ e_fwin_shutdown(void) { E_Fwin *fwin; + if (ipc) ecore_event_handler_del(ipc); //FIXME this is never called EINA_LIST_FREE(fwins, fwin) e_object_del(E_OBJECT(fwin)); @@ -311,6 +316,18 @@ e_fwin_zone_find(E_Zone *zone) return 0; } +EAPI void +e_fwin_progress_update_all(int slave_id, int percent, int seconds, size_t done, size_t total, char *src, char *dst) +{ + Eina_List *l; + E_Fwin *fwin; + + EINA_LIST_FOREACH(fwins, l, fwin) + _e_fwin_progress_update(fwin, slave_id, percent, seconds, done, total, src, dst); +} + +#define CONF_ALIGN_X 1.0 +#define CONF_ALIGN_Y 1.0 /* local subsystem functions */ static E_Fwin * _e_fwin_new(E_Container *con, const char *dev, const char *path) @@ -338,6 +355,12 @@ _e_fwin_new(E_Container *con, const char *dev, const char *path) evas_object_show(o); fwin->bg_obj = o; + o = evas_object_box_add(e_win_evas_get(fwin->win)); + evas_object_box_layout_set(o, evas_object_box_layout_vertical, NULL, NULL); + evas_object_box_align_set(o, CONF_ALIGN_X, CONF_ALIGN_Y); + evas_object_show(o); + fwin->box_obj = o; + o = e_fm2_add(e_win_evas_get(fwin->win)); fwin->fm_obj = o; _e_fwin_config_set(fwin); @@ -423,7 +446,10 @@ _e_fwin_new(E_Container *con, const char *dev, const char *path) fwin->win->border->internal_icon = eina_stringshare_add("system-file-manager"); } - + + if (!ipc) + ipc = ecore_event_handler_add(ECORE_IPC_EVENT_CLIENT_DATA, + _e_fwin_ipc_progress_data, NULL); return fwin; } @@ -523,6 +549,8 @@ _e_fwin_cb_resize(E_Win *win) _e_fwin_toolbar_resize(fwin); else evas_object_resize(fwin->scrollframe_obj, fwin->win->w, fwin->win->h); + if (fwin->box_obj) + evas_object_resize(fwin->box_obj, fwin->win->w, fwin->win->h); } else if (fwin->zone) evas_object_resize(fwin->scrollframe_obj, fwin->zone->w, fwin->zone->h); @@ -538,6 +566,101 @@ _e_fwin_deleted(void *data, Evas_Object *obj, void *event_info) e_object_del(E_OBJECT(fwin)); } +static int +_e_fwin_ipc_progress_data(void *data __UNUSED__, int type __UNUSED__, void *event) +{ + Ecore_Ipc_Event_Client_Data *e = event; + int percent, seconds; + size_t done, total; + char *src = NULL; + char *dst = NULL; + void *p; + + if (!(e->major == E_IPC_DOMAIN_FM && e->minor == E_FM_OP_PROGRESS)) + return 0; + if (!e->data) return 0; + + p = e->data; +#define UP(value, type) (value) = *(type *)p; p += sizeof(type) + UP(percent, int); + UP(seconds, int); + UP(done, size_t); + UP(total, size_t); +#undef UP + src = p; + dst = p + strlen(src) + 1; + //printf("%s:%s(%d) Progress from slave #%d:\n\t%d%% done,\n\t%d seconds left,\n\t%d done,\n\t%d total,\n\tsrc = %s,\n\tdst = %s.\n", __FILE__, __FUNCTION__, __LINE__, e->ref, percent, seconds, done, total, src, dst); + e_fwin_progress_update_all(e->ref, percent, seconds, done, total, src, dst); + + return 1; +} + +static void +_e_fwin_progress_update(E_Fwin *fwin, int slave_id, int percent, int seconds, size_t done, size_t total, char *src, char *dst) +{ + Evas_Object *o = NULL; + Eina_List *l; + char buf[PATH_MAX]; + char *dir; + int mw, mh, id; + + if (!fwin || !fwin->box_obj) return; + + // Search for existing progress object + EINA_LIST_FOREACH(evas_object_box_children_get(fwin->box_obj), l, o) + { + id = (int)evas_object_data_get(o, "e_fm_prog_id"); + if (id == slave_id) + break; + else + o = NULL; + } + + // Not found. Create a new one + if (!o) + { + o = edje_object_add(e_win_evas_get(fwin->win)); + e_theme_edje_object_set(o, "base/theme/fileman", + "e/fileman/default/progress"); + evas_object_data_set(o, "e_fm_prog_id", (void*)slave_id); + 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); + evas_object_show(o); + + // Append the element to the box + evas_object_box_append(fwin->box_obj, o); + evas_object_size_hint_align_set(o, CONF_ALIGN_X, CONF_ALIGN_Y); + } + + // Update element + edje_object_part_drag_size_set(o, "e.gauge.bar", 0.0, ((double)(percent)) / 100); + + snprintf(buf, PATH_MAX, "Progress from slave #%d", slave_id); + edje_object_part_text_set(o, "e.text.label1", buf); + snprintf(buf, PATH_MAX, _("Done %ld / %ld byte"), done, total); + edje_object_part_text_set(o, "e.text.label2", buf); + if (percent < 100) + snprintf(buf, PATH_MAX, _("Done %d%% - left %d sec"), percent, seconds); + else + snprintf(buf, PATH_MAX, _("Complete")); + edje_object_part_text_set(o, "e.text.label3", buf); + edje_object_part_text_set(o, "e.text.label4", ecore_file_file_get(src)); + dir = ecore_file_dir_get(dst); + edje_object_part_text_set(o, "e.text.label5", dir); + E_FREE(dir); + + evas_object_raise(fwin->box_obj); //TODO use layer?? + + if (percent == 100) //TODO delay hide by some seconds + { + // Delete the element + evas_object_box_remove(fwin->box_obj, o); + evas_object_del(o); + } +} + static const char * _e_fwin_custom_file_path_eval(E_Fwin *fwin, Efreet_Desktop *ef, const char *prev_path, const char *key) { diff --git a/src/modules/fileman/e_fwin.h b/src/modules/fileman/e_fwin.h index 1da1a74cd..5b0af39ad 100644 --- a/src/modules/fileman/e_fwin.h +++ b/src/modules/fileman/e_fwin.h @@ -15,6 +15,7 @@ EAPI void e_fwin_zone_shutdown (E_Zone *zone); EAPI void e_fwin_all_unsel (void *data); EAPI void e_fwin_reload_all (void); EAPI int e_fwin_zone_find (E_Zone *zone); - +EAPI void e_fwin_progress_update_all(int slave_id, int percent, int seconds, size_t done, size_t total, char *src, char *dst); + #endif #endif diff --git a/src/modules/fileman/e_mod_main.c b/src/modules/fileman/e_mod_main.c index 552bbcf8f..f5d3e82e0 100644 --- a/src/modules/fileman/e_mod_main.c +++ b/src/modules/fileman/e_mod_main.c @@ -99,7 +99,6 @@ e_modapi_init(E_Module *m) _e_mod_zone_add, NULL); /* FIXME: add system event for new zone creation, and on creation, add an fwin to the zone */ - e_fileman_dbus_init(); @@ -315,7 +314,6 @@ _e_mod_menu_generate(void *data, E_Menu *m) E_Menu_Item *mi; E_Volume *vol; const Eina_List *l; - char buf[PATH_MAX]; /* Home */ mi = e_menu_item_new(m);