Enlightenment CVS committal Author : codewarrior Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_fileman.c e_fileman_file.c e_fileman_file.h e_fileman_icon.c e_fileman_smart.c e_thumb.c Log Message: - modularize e_fm_file thumb determination scheme - add thumb functions for: * e17 themes (thanks Chady) * e17 bg files * eap * jpg/png - add scrolling support (must be calculated, currently is absolute) =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman.c,v retrieving revision 1.12 retrieving revision 1.13 diff -u -3 -r1.12 -r1.13 --- e_fileman.c 22 Oct 2005 02:07:39 -0000 1.12 +++ e_fileman.c 22 Oct 2005 17:02:37 -0000 1.13 @@ -19,8 +19,9 @@ #endif static void _e_fileman_vscrollbar_drag_cb(Evas_Object *object, double value, void *data); -static void _e_fileman_reconf_cb(void *data, int type, void *event); -static void _e_fileman_dir_change_cb(void *data, int type, void *event); +static int _e_fileman_reconf_cb(void *data, int type, void *event); +static int _e_fileman_dir_change_cb(void *data, int type, void *event); +static int _e_fileman_mouse_wheel_cb(void *data, int type, void *event); static void _e_fileman_resize_cb(E_Win *win); static void _e_fileman_delete_cb(E_Win *win); static void _e_fileman_vscrollbar_show_cb(void *data, Evas_Object *obj, void *ev); @@ -100,6 +101,11 @@ _e_fileman_dir_change_cb, fileman)); + fileman->event_handlers = evas_list_append(fileman->event_handlers, + ecore_event_handler_add(ECORE_X_EVENT_MOUSE_WHEEL, + _e_fileman_mouse_wheel_cb, + fileman)); + evas_event_thaw(fileman->evas); D(("e_fileman_new: ok\n")); @@ -194,7 +200,7 @@ e_fm_scroll_vertical(fileman->smart, value); } -static void +static int _e_fileman_reconf_cb(void *data, int type, void *event) { E_Event_Fm_Reconfigure *ev; @@ -222,10 +228,11 @@ D(("e_fileman_reconf_cb: hide (%p)\n", fileman)); edje_object_part_unswallow(fileman->main, fileman->vscrollbar); evas_object_hide(fileman->vscrollbar); - } + } + return 1; } -static void +static int _e_fileman_dir_change_cb(void *data, int type, void *event) { E_Event_Fm_Directory_Change *ev; @@ -239,6 +246,38 @@ D(("_e_fileman_dir_change_cb:\n")); e_scrollbar_value_set(fileman->vscrollbar, 0.0); + return 1; +} + +static int +_e_fileman_mouse_wheel_cb(void *data, int type, void *event) +{ + Ecore_X_Event_Mouse_Wheel *ev; + E_Fileman *fileman; + double pos; + + ev = event; + fileman = data; + + pos = e_scrollbar_value_get(fileman->vscrollbar); + + if(ev->z < 0) + { + pos -= 0.05; + if(pos < 0.0) + pos = 0.0; + } + + if(ev->z > 0) + { + pos += 0.05; + if(pos > 1.0) + pos = 1.0; + } + + e_scrollbar_value_set(fileman->vscrollbar, pos); + e_fm_scroll_vertical(fileman->smart, pos); + return 1; } static void =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_file.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -3 -r1.2 -r1.3 --- e_fileman_file.c 21 Oct 2005 09:52:46 -0000 1.2 +++ e_fileman_file.c 22 Oct 2005 17:02:37 -0000 1.3 @@ -53,6 +53,12 @@ if (file->name[0] == '.') file->type |= E_FM_FILE_TYPE_HIDDEN; + file->preview_funcs = E_NEW(E_Fm_File_Preview_Function, 4); + 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; + D(("e_fm_file_new: %s\n", filename)); return file; @@ -131,6 +137,22 @@ } int +e_fm_file_can_preview(E_Fm_File *file) +{ + int i; + + D(("e_fm_file_can_preview: (%s) (%p)\n", file->name, file)); + for (i = 0; i < sizeof(file->preview_funcs); i++) + { + E_Fm_File_Preview_Function func; + func = file->preview_funcs[i]; + if(func(file)) + return 1; + } + return 0; +} + +int e_fm_file_is_image(E_Fm_File *file) { /* We need to check if it is a filetype supported by evas. @@ -138,15 +160,99 @@ * canvas. */ char *ext; + + if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0; + + ext = strrchr(file->name, '.'); + if (!ext) return 0; - if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0; + D(("e_fm_file_is_image: (%p)\n", file)); + return (!strcasecmp(ext, ".jpg")) || (!strcasecmp(ext, ".png")) + || (!strcasecmp(ext, ".jpeg")); +} +int +e_fm_file_is_etheme(E_Fm_File *file) +{ + int val; + char *ext; + Evas_List *groups, *l; + + if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0; + ext = strrchr(file->name, '.'); if (!ext) return 0; - D(("e_fm_file_is_image: (%p)\n", file)); - return (!strcasecmp(ext, ".jpg")) || (!strcasecmp(ext, ".png")) - || (!strcasecmp(ext, ".jpeg")) || (!strcasecmp(ext, ".eap")); + if(strcasecmp(ext, ".edj")) + return 0; + + val = 0; + groups = edje_file_collection_list(file->path); + if(!groups) + return 0; + + for (l = groups; l; l = l->next) + if(!strcmp(l->data, "widgets/border/default/border")) + { + val = 1; + break; + } + edje_file_collection_list_free(groups); + return val; +} + +int +e_fm_file_is_ebg(E_Fm_File *file) +{ + int val; + char *ext; + Evas_List *groups, *l; + + if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0; + + ext = strrchr(file->name, '.'); + if (!ext) return 0; + + if(strcasecmp(ext, ".edj")) + return 0; + + val = 0; + groups = edje_file_collection_list(file->path); + if(!groups) + return 0; + + for (l = groups; l; l = l->next) + if(!strcmp(l->data, "desktop/background")) + { + val = 1; + break; + } + edje_file_collection_list_free(groups); + return val; +} + +int +e_fm_file_is_eap(E_Fm_File *file) +{ + char *ext; + E_App *app; + + if ((file->type != E_FM_FILE_TYPE_FILE) && (file->type != E_FM_FILE_TYPE_SYMLINK)) return 0; + + ext = strrchr(file->name, '.'); + if (!ext) return 0; + + if(strcasecmp(ext, ".eap")) + return 0; + + app = e_app_new(file->path, 0); + if(!app) + { + e_object_unref(E_OBJECT(app)); + return 0; + } + e_object_unref(E_OBJECT(app)); + return 1; } int @@ -226,6 +332,7 @@ _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); free(file); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_file.h,v retrieving revision 1.1 retrieving revision 1.2 diff -u -3 -r1.1 -r1.2 --- e_fileman_file.h 20 Oct 2005 13:08:51 -0000 1.1 +++ e_fileman_file.h 22 Oct 2005 17:02:37 -0000 1.2 @@ -5,6 +5,7 @@ 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) @@ -48,16 +49,22 @@ time_t atime; /* time of last access */ time_t mtime; /* time of last modification */ time_t ctime; /* time of last status change */ + + E_Fm_File_Preview_Function *preview_funcs; }; -EAPI E_Fm_File *e_fm_file_new (const char *filename); -EAPI int e_fm_file_rename (E_Fm_File *file, const char *name); -EAPI int e_fm_file_delete (E_Fm_File *file); -EAPI int e_fm_file_copy (E_Fm_File *file, const char *name); -EAPI int e_fm_file_is_image (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 E_Fm_File *e_fm_file_new (const char *filename); +EAPI int e_fm_file_rename (E_Fm_File *file, const char *name); +EAPI int e_fm_file_delete (E_Fm_File *file); +EAPI int e_fm_file_copy (E_Fm_File *file, const char *name); +EAPI int e_fm_file_can_preview (E_Fm_File *file); +EAPI int e_fm_file_is_image (E_Fm_File *file); +EAPI int e_fm_file_is_etheme (E_Fm_File *file); +EAPI int e_fm_file_is_ebg (E_Fm_File *file); +EAPI int e_fm_file_is_eap (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); #endif #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_icon.c,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- e_fileman_icon.c 21 Oct 2005 09:52:46 -0000 1.4 +++ e_fileman_icon.c 22 Oct 2005 17:02:37 -0000 1.5 @@ -333,7 +333,7 @@ "fileman/icon"); evas_object_smart_member_add(sd->icon_object, obj); - if (e_fm_file_is_image(sd->file)) + if (e_fm_file_can_preview(sd->file)) { sd->thumb_path = e_thumb_file_get(sd->file->path); if (e_thumb_exists(sd->file->path)) =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_smart.c,v retrieving revision 1.45 retrieving revision 1.46 diff -u -3 -r1.45 -r1.46 --- e_fileman_smart.c 22 Oct 2005 02:11:51 -0000 1.45 +++ e_fileman_smart.c 22 Oct 2005 17:02:37 -0000 1.46 @@ -903,6 +903,7 @@ static void _e_fm_icon_prop_fill_data(E_Fm_Icon_CFData *cfdata) { + /*- BASIC -*/ if((cfdata->icon->file->mode & (S_IWUSR|S_IWGRP|S_IWOTH))) cfdata->protect = 0; else @@ -915,6 +916,9 @@ cfdata->readwrite = 1; else if(!(cfdata->icon->file->mode & (S_IRGRP|S_IROTH|S_IWGRP|S_IWOTH))) cfdata->readwrite = 2; + + /*- ADVANCED -*/ +// if((cfdata->icon->file->mode & } static void * =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_thumb.c,v retrieving revision 1.7 retrieving revision 1.8 diff -u -3 -r1.7 -r1.8 --- e_thumb.c 21 Oct 2005 09:52:46 -0000 1.7 +++ e_thumb.c 22 Oct 2005 17:02:37 -0000 1.8 @@ -84,6 +84,151 @@ return 0; } +int * +_e_thumb_image_create(char *file, Evas_Coord w, Evas_Coord h, int *ww, int *hh, int *alpha, Evas_Object **im, Ecore_Evas **buf) +{ + Evas *evasbuf; + int size, iw, ih; + + *buf = ecore_evas_buffer_new(1, 1); + evasbuf = ecore_evas_get(*buf); + *im = evas_object_image_add(evasbuf); + evas_object_image_file_set(*im, file, NULL); + iw = 0; ih = 0; + evas_object_image_size_get(*im, &iw, &ih); + *alpha = evas_object_image_alpha_get(im); + if ((iw > 0) && (ih > 0)) + { + *ww = w; + *hh = (w * ih) / iw; + if (*hh > h) + { + *hh = h; + *ww = (h * iw) / ih; + } + ecore_evas_resize(*buf, *ww, *hh); + evas_object_image_fill_set(*im, 0, 0, *ww, *hh); + evas_object_resize(*im, *ww, *hh); + evas_object_move(*im, 0, 0); + evas_object_show(*im); + + return ecore_evas_buffer_pixels_get(*buf); + } + return NULL; +} + +/* thumbnail an e17 background and return pixel data */ +int * +_e_thumb_ebg_create(char *file, Evas_Coord w, Evas_Coord h, int *ww, int *hh, int *alpha, Evas_Object **im, Ecore_Evas **buf) +{ + Evas *evasbuf; + Evas_Object *wallpaper; + int *pixels; + + *ww = 640; + *hh = 480; + *alpha = 0; + + w = 640; + h = 480; + + *buf = ecore_evas_buffer_new(w, h); + evasbuf = ecore_evas_get(*buf); + + wallpaper = edje_object_add(evasbuf); + + + edje_object_file_set(wallpaper, file, "desktop/background"); + + /* wallpaper */ + evas_object_move(wallpaper, 0, 0); + evas_object_resize(wallpaper, w, h); + + evas_object_show(wallpaper); + + pixels = ecore_evas_buffer_pixels_get(*buf); + + evas_object_del(wallpaper); + return pixels; +} + +/* thumbnail an e17 theme and return pixel data */ +int * +_e_thumb_etheme_create(char *file, Evas_Coord w, Evas_Coord h, int *ww, int *hh, int *alpha, Evas_Object **im, Ecore_Evas **buf) +{ + Evas *evasbuf; + Evas_Object *wallpaper, *window, *clock, *start, **pager; + int *pixels; + + *ww = 640; + *hh = 480; + *alpha = 0; + + w = 640; + h = 480; + + *buf = ecore_evas_buffer_new(w, h); + evasbuf = ecore_evas_get(*buf); + + wallpaper = edje_object_add(evasbuf); + window = edje_object_add(evasbuf); + clock = edje_object_add(evasbuf); + start = edje_object_add(evasbuf); + pager = E_NEW(Evas_Object*, 3); + pager[0] = edje_object_add(evasbuf); + pager[1] = edje_object_add(evasbuf); + pager[2] = edje_object_add(evasbuf); + + edje_object_file_set(wallpaper, file, "desktop/background"); + edje_object_file_set(window, file, "widgets/border/default/border"); + edje_object_file_set(clock, file, "modules/clock/main"); + edje_object_file_set(clock, file, "modules/clock/main"); + edje_object_file_set(start, file, "modules/start/main"); + edje_object_file_set(pager[0], file, "modules/pager/main"); + edje_object_file_set(pager[1], file, "modules/pager/desk"); + edje_object_file_set(pager[2], file, "modules/pager/window"); + edje_object_part_text_set(window, "title_text", file); + edje_object_part_swallow(pager[0], "items", pager[1]); + edje_object_part_swallow(pager[1], "items", pager[2]); + + /* wallpaper */ + evas_object_move(wallpaper, 0, 0); + evas_object_resize(wallpaper, w, h); + /* main window */ + evas_object_move(window, (w * 0.1), (h * 0.05)); + evas_object_resize(window, w * 0.8, h * 0.75); + /* clock */ + evas_object_move(clock, (w * 0.9), (h * 0.9)); + evas_object_resize(clock, w * 0.1, h * 0.1); + /* start */ + evas_object_move(start, (w * 0.9), (h * 0.9)); + evas_object_resize(start, w * 0.1, h * 0.1); + /* pager */ + evas_object_move(pager[0], (w * 0.3), (h * 0.9)); + evas_object_resize(pager[0], w * 0.1, h * 0.1); + + evas_object_show(wallpaper); + evas_object_show(window); + evas_object_show(clock); + evas_object_show(start); + evas_object_show(pager[0]); + evas_object_show(pager[1]); + evas_object_show(pager[2]); + + pixels = ecore_evas_buffer_pixels_get(*buf); + + evas_object_del(wallpaper); + evas_object_del(window); + evas_object_del(clock); + evas_object_del(start); + evas_object_del(pager[0]); + evas_object_del(pager[1]); + evas_object_del(pager[2]); + free(pager); + + return pixels; +} + /* create and save a thumb to disk */ int e_thumb_create(char *file, Evas_Coord w, Evas_Coord h) @@ -111,14 +256,20 @@ return -1; } - buf = ecore_evas_buffer_new(1, 1); - evasbuf = ecore_evas_get(buf); - im = evas_object_image_add(evasbuf); - evas_object_image_file_set(im, file, NULL); - iw = 0; ih = 0; - evas_object_image_size_get(im, &iw, &ih); - alpha = evas_object_image_alpha_get(im); - if ((iw > 0) && (ih > 0)) + if(ext) + { + if(!strcasecmp(ext, ".edj")) + { + /* for now, this function does both the bg and theme previews */ + data = _e_thumb_etheme_create(file, w, h, &ww, &hh, &alpha, &im, &buf); + } + else + data = _e_thumb_image_create(file, w, h, &ww, &hh, &alpha, &im, &buf); + } + else + data = _e_thumb_image_create(file, w, h, &ww, &hh, &alpha, &im, &buf); + + if (data) { ef = eet_open(thumbpath, EET_FILE_MODE_WRITE); if (!ef) @@ -129,19 +280,6 @@ return -1; } free(thumbpath); - - ww = w; - hh = (w * ih) / iw; - if (hh > h) - { - hh = h; - ww = (h * iw) / ih; - } - ecore_evas_resize(buf, ww, hh); - evas_object_image_fill_set(im, 0, 0, ww, hh); - evas_object_resize(im, ww, hh); - evas_object_show(im); - data = ecore_evas_buffer_pixels_get(buf); eet_write(ef, "/thumbnail/orig_path", file, strlen(file), 1); if ((size = eet_data_image_write(ef, "/thumbnail/data", ------------------------------------------------------- This SF.Net email is sponsored by the JBoss Inc. Get Certified Today * Register for a JBoss Training Course Free Certification Exam for All Training Attendees Through End of 2005 Visit http://www.jboss.com/services/certification for more information _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs