Enlightenment CVS committal Author : codewarrior Project : e17 Module : apps/e
Dir : e17/apps/e/src/bin Modified Files: e_apps.c e_apps.h e_eap_editor.c e_fileman_file.c e_fileman_file.h e_fileman_icon.c e_fileman_smart.c Log Message: - patch from mista (Efm) - allow eap image w/h to be changable. =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_apps.c,v retrieving revision 1.112 retrieving revision 1.113 diff -u -3 -r1.112 -r1.113 --- e_apps.c 13 Jan 2006 06:38:43 -0000 1.112 +++ e_apps.c 14 Jan 2006 21:05:43 -0000 1.113 @@ -72,6 +72,9 @@ static char *_e_apps_path_trash = NULL; static Evas_List *_e_apps_start_pending = NULL; +#define EAP_MIN_WIDTH 8 +#define EAP_MIN_HEIGHT 8 + #define EAP_EDC_TMPL \ "images {\n" \ " image: \"%s\" COMP;\n" \ @@ -234,6 +237,8 @@ /* no image for now */ a->image = NULL; + a->width = 0; + a->height = 0; /* record the path */ a->path = evas_stringshare_add(path); @@ -289,6 +294,13 @@ return a; } +EAPI void +e_app_image_size_set(E_App *a, int w, int h) +{ + a->width = w; + a->height = h; +} + EAPI int e_app_is_parent(E_App *parent, E_App *app) { @@ -1022,10 +1034,6 @@ eet_close(ef); } -/* - * We also need to fix startup-notify and wait-exit as they currently - * dont save too. - */ EAPI void e_app_fields_save(E_App *a) { @@ -1119,16 +1127,20 @@ iw = 0; ih = 0; evas_object_image_size_get(im, &iw, &ih); alpha = evas_object_image_alpha_get(im); + if(a->width <= EAP_MIN_WIDTH) + a->width = EAP_MIN_WIDTH; + if(a->height <= EAP_MIN_HEIGHT) + a->height = EAP_MIN_HEIGHT; if ((iw > 0) && (ih > 0)) { /* we need to change the sizes */ - ecore_evas_resize(buf, 48, 48); - evas_object_image_fill_set(im, 0, 0, 48, 48); - evas_object_resize(im, 48, 48); + ecore_evas_resize(buf, a->width, a->height); + evas_object_image_fill_set(im, 0, 0, a->width, a->height); + evas_object_resize(im, a->height, a->width); evas_object_move(im, 0, 0); evas_object_show(im); data = ecore_evas_buffer_pixels_get(buf); - eet_data_image_write(ef, "images/0", (void *)data, 48, 48, alpha, 1, 0, 0); + eet_data_image_write(ef, "images/0", (void *)data, a->width, a->height, alpha, 1, 0, 0); } } @@ -1320,7 +1332,13 @@ else ipart[0] = '\0'; if (a->image) - fprintf(out, EAP_EDC_TMPL, a->image, "48", "48", a->image); + { + if(a->width <= 0) + a->width = EAP_MIN_WIDTH; + if(a->height <= 0) + a->height = EAP_MIN_HEIGHT; + fprintf(out, EAP_EDC_TMPL, a->image, a->width, a->height, a->image); + } else fprintf(out, EAP_EDC_TMPL_EMPTY); fclose(out); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_apps.h,v retrieving revision 1.26 retrieving revision 1.27 diff -u -3 -r1.26 -r1.27 --- e_apps.h 15 Dec 2005 07:12:00 -0000 1.26 +++ e_apps.h 14 Jan 2006 21:05:43 -0000 1.27 @@ -63,6 +63,8 @@ unsigned char deleted : 1; /* this app's file is deleted from disk */ char *image; /* used when we're saving a image into the eap */ + int width; /* used for saving eap's image width in edje */ + int height; /* used for saving eap's image height in edje */ }; struct _E_App_Instance @@ -79,6 +81,7 @@ EAPI E_App *e_app_new (const char *path, int scan_subdirs); EAPI E_App *e_app_empty_new (const char *path); +EAPI void e_app_image_size_set (E_App *a, int w, int h); EAPI int e_app_is_parent (E_App *parent, E_App *app); EAPI int e_app_equals (E_App *app1, E_App *app2); EAPI void e_app_subdir_scan (E_App *a, int scan_subdirs); =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_eap_editor.c,v retrieving revision 1.20 retrieving revision 1.21 diff -u -3 -r1.20 -r1.21 --- e_eap_editor.c 7 Jan 2006 10:39:45 -0000 1.20 +++ e_eap_editor.c 14 Jan 2006 21:05:43 -0000 1.21 @@ -161,6 +161,10 @@ eap->startup_notify = cfdata->startup_notify; eap->wait_exit = cfdata->wait_exit; + /* FIXME: hardcoded until the eap editor provides fields to change it */ + eap->width = 128; + eap->height = 128; + e_app_fields_save(eap); return 1; @@ -213,6 +217,10 @@ if (cfdata->wrole) eap->win_role = evas_stringshare_add(cfdata->wrole); if (cfdata->iclass) eap->icon_class = evas_stringshare_add(cfdata->iclass); if (cfdata->path) eap->path = evas_stringshare_add(cfdata->path); + + /* FIXME: hardcoded until the eap editor provides fields to change it */ + eap->width = 128; + eap->height = 128; e_app_fields_save(eap); return 1; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_file.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -3 -r1.16 -r1.17 --- e_fileman_file.c 14 Jan 2006 14:53:29 -0000 1.16 +++ e_fileman_file.c 14 Jan 2006 21:05:43 -0000 1.17 @@ -74,13 +74,17 @@ if(!file->mime) { - ext = strrchr(file->name, '.'); - if (ext) - { - file->mime = ext; - } - else - file->mime = "unknown"; + 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"; } D(("e_fm_file_new: %s\n", filename)); return file; @@ -105,17 +109,17 @@ if (ecore_file_mv(file->path, path)) { - free(file->path); - file->path = strdup(path); - free(file->name); - file->name = strdup(name); - D(("e_fm_file_rename: ok (%p) (%s)\n", file, name)); - return 1; + free(file->path); + file->path = strdup(path); + free(file->name); + file->name = strdup(name); + D(("e_fm_file_rename: ok (%p) (%s)\n", file, name)); + return 1; } else { - D(("e_fm_file_rename: fail (%p) (%s)\n", file, name)); - return 0; + D(("e_fm_file_rename: fail (%p) (%s)\n", file, name)); + return 0; } } @@ -124,17 +128,17 @@ { if (ecore_file_recursive_rm(file->path)) { - free(file->path); - file->path = NULL; - free(file->name); - file->name = NULL; - D(("e_fm_file_delete: ok (%p) (%s)\n", file, file->name)); - return 1; + free(file->path); + file->path = NULL; + free(file->name); + file->name = NULL; + D(("e_fm_file_delete: ok (%p) (%s)\n", file, file->name)); + return 1; } else { - D(("e_fm_file_delete: fail (%p) (%s)\n", file, file->name)); - return 0; + D(("e_fm_file_delete: fail (%p) (%s)\n", file, file->name)); + return 0; } } @@ -145,20 +149,36 @@ if (ecore_file_cp(file->path, name)) { - free(file->path); - file->path = strdup(name); - free(file->name); - file->name = strdup(ecore_file_get_file(name)); - D(("e_fm_file_copy: ok (%p) (%s)\n", file, name)); - return 1; + free(file->path); + file->path = strdup(name); + free(file->name); + file->name = strdup(ecore_file_get_file(name)); + D(("e_fm_file_copy: ok (%p) (%s)\n", file, name)); + return 1; } else { - D(("e_fm_file_copy: fail (%p) (%s)\n", file, name)); - return 0; + D(("e_fm_file_copy: fail (%p) (%s)\n", file, name)); + return 0; } } +int +e_fm_file_is_regular(E_Fm_File *file) /* TODO: find better name */ +{ + return ((file->type == E_FM_FILE_TYPE_FILE) + || (file->type == E_FM_FILE_TYPE_SYMLINK)); +} + +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)); +} + EAPI int e_fm_file_can_preview(E_Fm_File *file) { @@ -167,11 +187,11 @@ D(("e_fm_file_can_preview: (%s) (%p)\n", file->name, file)); for (i = 0; file->preview_funcs[i]; i++) { - E_Fm_File_Preview_Function func; + E_Fm_File_Preview_Function func; - func = file->preview_funcs[i]; - if (func(file)) - return 1; + func = file->preview_funcs[i]; + if (func(file)) + return 1; } return 0; } @@ -183,31 +203,22 @@ * If it isn't supported by evas, we can't show it in the * 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; - - D(("e_fm_file_is_image: (%p)\n", file)); - return (!strcasecmp(ext, ".jpg")) || (!strcasecmp(ext, ".png")) || - (!strcasecmp(ext, ".jpeg")); + + //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) { 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")) + if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".edj")) return 0; val = 0; @@ -216,13 +227,13 @@ return 0; for (l = groups; l; l = l->next) - { - if (!strcmp(l->data, "widgets/border/default/border")) - { - val = 1; - break; - } - } + { + if (!strcmp(l->data, "widgets/border/default/border")) + { + val = 1; + break; + } + } edje_file_collection_list_free(groups); return val; } @@ -231,30 +242,24 @@ 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")) + if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".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; - } - } + { + if (!strcmp(l->data, "desktop/background")) + { + val = 1; + break; + } + } edje_file_collection_list_free(groups); return val; } @@ -262,23 +267,18 @@ EAPI 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; + E_App *app; - if (strcasecmp(ext, ".eap")) + if (!e_fm_file_is_regular(file) || !e_fm_file_has_mime(file,".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 0; + } e_object_unref(E_OBJECT(app)); return 1; } @@ -286,23 +286,17 @@ EAPI int e_fm_file_can_exec(E_Fm_File *file) { - char *ext; - - ext = strrchr(file->name, '.'); - if (ext) - { - if (!strcasecmp(ext, ".eap")) - { - D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name)); - return 1; - } - } + if (e_fm_file_has_mime(file,".eap")) + { + D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name)); + return 1; + } if (ecore_file_can_exec(file->path)) - { - D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name)); - return 1; - } + { + D(("e_fm_file_can_exec: true (%p) (%s)\n", file, file->name)); + return 1; + } D(("e_fm_file_can_exec: false (%p) (%s)\n", file, file->name)); return 0; @@ -312,40 +306,35 @@ e_fm_file_exec(E_Fm_File *file) { Ecore_Exe *exe; - char *ext; - ext = strrchr(file->name, '.'); - if (ext) - { - if (!strcasecmp(ext, ".eap")) - { - E_App *e_app; - Ecore_Exe *exe; - - e_app = e_app_new(file->path, 0); - - if (!e_app) return 0; - - exe = ecore_exe_run(e_app->exe, NULL); - if (exe) ecore_exe_free(exe); - e_object_unref(E_OBJECT(e_app)); - D(("e_fm_file_exec: eap (%p) (%s)\n", file, file->name)); - return 1; - } - } + if(e_fm_file_has_mime(file,".eap")) + { + E_App *e_app; + Ecore_Exe *exe; + + e_app = e_app_new(file->path, 0); + + if (!e_app) return 0; + + exe = ecore_exe_run(e_app->exe, NULL); + if (exe) ecore_exe_free(exe); + e_object_unref(E_OBJECT(e_app)); + D(("e_fm_file_exec: eap (%p) (%s)\n", file, file->name)); + return 1; + } exe = ecore_exe_run(file->path, NULL); if (!exe) - { - e_error_dialog_show(_("Run Error"), - _("Enlightenment was unable to fork a child process:\n" - "\n" - "%s\n" - "\n"), - file->path); - D(("e_fm_file_exec: fail (%p) (%s)\n", file, file->name)); - return 0; - } + { + e_error_dialog_show(_("Run Error"), + _("Enlightenment was unable to fork a child process:\n" + "\n" + "%s\n" + "\n"), + file->path); + D(("e_fm_file_exec: fail (%p) (%s)\n", file, file->name)); + return 0; + } /* E/app is the correct tag if the data is en E_App! ecore_exe_tag_set(exe, "E/app"); */ @@ -371,15 +360,12 @@ if (!assoc_apps) return 0; for (l = assoc_apps; l; l = l->next) - { - char *ext; - - assoc = l->data; - ext = strrchr(file->path, '.'); - if ((ext) && (!strcasecmp(ext, assoc->mime))) - break; - assoc = NULL; - } + { + assoc = l->data; + if (e_fm_file_has_mime(file,assoc->mime)) + break; + assoc = NULL; + } if (!assoc) return 0; @@ -387,16 +373,16 @@ 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); - D(("e_fm_assoc_exec: fail (%s)\n", app)); - return 0; - } + { + e_error_dialog_show(_("Run Error"), + _("Enlightenment was unable to fork a child process:\n" + "\n" + "%s\n" + "\n"), + app); + D(("e_fm_assoc_exec: fail (%s)\n", app)); + return 0; + } /* * ecore_exe_tag_set(exe, "E/app"); */ @@ -435,7 +421,7 @@ free(file->preview_funcs); if (file->path) free(file->path); if (file->name) free(file->name); - ///??? if (file->mime) free(file->mime); + ///??? if (file->mime) free(file->mime); free(file); } =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_file.h,v retrieving revision 1.4 retrieving revision 1.5 diff -u -3 -r1.4 -r1.5 --- e_fileman_file.h 6 Jan 2006 23:45:13 -0000 1.4 +++ e_fileman_file.h 14 Jan 2006 21:05:43 -0000 1.5 @@ -37,7 +37,7 @@ char *path; /* full name with path */ char *name; /* file name without parent directories */ - char *mime; /* mimetype (just the extension) */ + char *mime; /* mimetype (just the extension, beginning with dot) */ dev_t device; /* ID of device containing file */ ino_t inode; /* inode number */ @@ -67,8 +67,9 @@ 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_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 #endif =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_icon.c,v retrieving revision 1.27 retrieving revision 1.28 diff -u -3 -r1.27 -r1.28 --- e_fileman_icon.c 7 Jan 2006 17:54:31 -0000 1.27 +++ e_fileman_icon.c 14 Jan 2006 21:05:43 -0000 1.28 @@ -496,32 +496,22 @@ static void _e_fm_icon_icon_mime_get(E_Smart_Data *sd) { - sd->image_object = edje_object_add(sd->evas); - if (sd->file->type == E_FM_FILE_TYPE_DIRECTORY) - e_theme_edje_object_set(sd->image_object, "base/theme/fileman", - "icons/fileman/folder"); - else - { - char *ext; - - ext = strrchr(sd->file->name, '.'); - if (ext) - { - char part[PATH_MAX]; - char *ext2; - - ext = strdup(ext); - ext2 = ext; - for (; *ext2; ext2++) *ext2 = tolower(*ext2); - - snprintf(part, PATH_MAX, "icons/fileman/%s", (ext + 1)); - if (!e_theme_edje_object_set(sd->image_object, "base/theme/fileman", part)) + char part[PATH_MAX]; + + sd->image_object = edje_object_add(sd->evas); + + // since a mime is set with every creation of an E_Fm_File its existence isn“t checked here + if(sd->file->type == E_FM_FILE_TYPE_DIRECTORY) + e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/folder"); + + else if(e_fm_file_has_mime(sd->file,"unknown")) + e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/file"); + else + { + snprintf(part, PATH_MAX, "icons/fileman/%s", (sd->file->mime + 1)); + if (!e_theme_edje_object_set(sd->image_object, "base/theme/fileman", part)) e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/file"); - free(ext); - } - else - e_theme_edje_object_set(sd->image_object, "base/theme/fileman", "icons/fileman/file"); - } + } evas_object_show(sd->image_object); edje_extern_object_min_size_set(sd->image_object, sd->iw, sd->ih); edje_extern_object_max_size_set(sd->image_object, sd->iw, sd->ih); @@ -529,19 +519,16 @@ sd->image_object); } + + void _e_fm_icon_thumb_generate_cb(Evas_Object *obj, void *data) { E_Smart_Data *sd; - char *ext; sd = data; - ext = strrchr(sd->file->name, '.'); - if ((ext) && (strcasecmp(ext, ".eap"))) - ext = NULL; - - if ((ext) || (ecore_file_exists(sd->thumb_path))) + if (e_fm_file_has_mime(sd->file,".eap") || (ecore_file_exists(sd->thumb_path))) { Evas_Coord icon_w, icon_h; =================================================================== RCS file: /cvsroot/enlightenment/e17/apps/e/src/bin/e_fileman_smart.c,v retrieving revision 1.119 retrieving revision 1.120 diff -u -3 -r1.119 -r1.120 --- e_fileman_smart.c 7 Jan 2006 17:54:31 -0000 1.119 +++ e_fileman_smart.c 14 Jan 2006 21:05:44 -0000 1.120 @@ -1211,7 +1211,7 @@ e_widget_frametable_object_append(o, e_widget_label_add(evas, text), 0, 2, 1, 1, 1, 1, 1, 1); - snprintf(text, 512, "%s", "An Image"); + snprintf(text, 512, "%s", icon->file->mime); e_widget_frametable_object_append(o, e_widget_label_add(evas, text), 1, 2, 1, 1, 1, 1, 1, 1); @@ -2120,7 +2120,7 @@ if(icon->sd->win) icon->sd->drag.start = 0; - if (!strcmp(icon->file->name, ".")) return; + if (!strcmp(icon->file->name, ".")) return; /* this case cant happen!? */ if (!strcmp(icon->file->name, "..")) { @@ -2215,7 +2215,7 @@ for (l = icon->sd->conf.main->apps; l; l = l->next) { assoc = l->data; - if (strcmp(icon->file->mime, assoc->mime) == 0) + if (e_fm_file_has_mime(icon->file, assoc->mime)) { mi = e_menu_item_new(mo); ------------------------------------------------------- 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://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs