Enlightenment CVS committal Author : kwo Project : e16 Module : e
Dir : e16/e/src Modified Files: menus-misc.c Log Message: Simplify image extension check. =================================================================== RCS file: /cvs/e/e16/e/src/menus-misc.c,v retrieving revision 1.48 retrieving revision 1.49 diff -u -3 -r1.48 -r1.49 --- menus-misc.c 10 May 2008 23:29:01 -0000 1.48 +++ menus-misc.c 16 Jun 2008 21:24:02 -0000 1.49 @@ -39,6 +39,7 @@ static Menu *MenuCreateFromDirectory(const char *name, Menu * parent, MenuStyle * ms, const char *dir); +static int _ext_is_imagetype(const char *ext); static MenuItem * MenuItemCreateFromBackground(const char *bgid, const char *file) @@ -172,6 +173,7 @@ ext = fileext(ss); if (S_ISDIR(st.st_mode)) { + /* Submenu */ Esnprintf(s, sizeof(s), "%s/%s:%s", dir, list[i], MenuGetName(m)); mm = MenuCreateFromDirectory(s, m, NULL, ss); mi = MenuItemCreate(list[i], NULL, NULL, mm); @@ -179,33 +181,22 @@ if (f) fprintf(f, "DIR %s\n", list[i]); } -/* that's it - people are stupid and have executable images and just */ -/* don't get it - so I'm disablign this to save people from their own */ -/* stupidity */ -/* else if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) - * { - * mi = MenuItemCreate(list[i], NULL, ss, NULL); - * MenuAddItem(m, mi); - * if (f) - * fprintf(f, "EXE %s\n", list[i]); - * } - */ - else if ((!strcmp(ext, "jpg")) || (!strcmp(ext, "JPG")) - || (!strcmp(ext, "jpeg")) || (!strcmp(ext, "Jpeg")) - || (!strcmp(ext, "JPEG")) || (!strcmp(ext, "Jpg")) - || (!strcmp(ext, "gif")) || (!strcmp(ext, "Gif")) - || (!strcmp(ext, "GIF")) || (!strcmp(ext, "png")) - || (!strcmp(ext, "Png")) || (!strcmp(ext, "PNG")) - || (!strcmp(ext, "tif")) || (!strcmp(ext, "Tif")) - || (!strcmp(ext, "TIFF")) || (!strcmp(ext, "tiff")) - || (!strcmp(ext, "Tiff")) || (!strcmp(ext, "TIFF")) - || (!strcmp(ext, "xpm")) || (!strcmp(ext, "Xpm")) - || (!strcmp(ext, "XPM")) || (!strcmp(ext, "ppm")) - || (!strcmp(ext, "PPM")) || (!strcmp(ext, "pgm")) - || (!strcmp(ext, "PGM")) || (!strcmp(ext, "pnm")) - || (!strcmp(ext, "PNM")) || (!strcmp(ext, "bmp")) - || (!strcmp(ext, "Bmp")) || (!strcmp(ext, "BMP"))) +#if 0 + else if (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)) { + /* Executable */ + /* that's it - people are stupid and have executable images and just */ + /* don't get it - so I'm disablign this to save people from their own */ + /* stupidity */ + mi = MenuItemCreate(list[i], NULL, ss, NULL); + MenuAddItem(m, mi); + if (f) + fprintf(f, "EXE %s\n", list[i]); + } +#endif + else if (_ext_is_imagetype(ext)) + { + /* Background */ char s3[512]; int aa, bb, cc; @@ -848,4 +839,20 @@ } return m; +} + +static int +_ext_is_imagetype(const char *ext) +{ + static const char *const exts[] = { + "jpg", "jpeg", "gif", "png", "tif", "tiff", + "xpm", "ppm", "pgm", "pnm", "bmp", NULL + }; + int i; + + for (i = 0; exts[i]; i++) + if (!strcasecmp(exts[i], ext)) + return 1; + + return 0; } ------------------------------------------------------------------------- Check out the new SourceForge.net Marketplace. It's the best place to buy or sell services for just about anything Open Source. http://sourceforge.net/services/buy/index.php _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs