From 7f92258ee43d5b3df322dace94f323087e1cfc09 Mon Sep 17 00:00:00 2001 From: "Carsten Haitzler (Rasterman)" Date: Sun, 29 Dec 2013 14:59:57 +0900 Subject: [PATCH] terminology - make wp display more than basic img formats (edj, scale etc.) --- src/bin/Makefile.am | 4 +-- src/bin/extns.c | 41 +++++++++++++++++++++++ src/bin/extns.h | 44 +++---------------------- src/bin/options_wallpaper.c | 65 +++++++++++++++++++++++++------------ 4 files changed, 92 insertions(+), 62 deletions(-) create mode 100644 src/bin/extns.c diff --git a/src/bin/Makefile.am b/src/bin/Makefile.am index 03320937..46ba0e9b 100644 --- a/src/bin/Makefile.am +++ b/src/bin/Makefile.am @@ -45,7 +45,7 @@ utf8.c utf8.h \ win.c win.h \ utils.c utils.h \ dbus.c dbus.h \ -extns.h \ +extns.c extns.h \ app_server.c app_server.h \ app_server_eet.c app_server_eet.h @@ -87,7 +87,7 @@ tyq_LDADD = tycat_SOURCES = \ tycat.c \ -extns.h +extns.c extns.h tycat_CPPFLAGS = -I. \ -DPACKAGE_BIN_DIR=\"$(bindir)\" -DPACKAGE_LIB_DIR=\"$(libdir)\" \ diff --git a/src/bin/extns.c b/src/bin/extns.c new file mode 100644 index 00000000..b830589c --- /dev/null +++ b/src/bin/extns.c @@ -0,0 +1,41 @@ +#include + +const char *extn_img[] = +{ + ".png", ".jpg", ".jpeg", ".jpe", ".jfif", ".tif", ".tiff", ".gif", ".thm", + ".bmp", ".ico", ".ppm", ".pgm", ".pbm", ".pnm", ".xpm", ".psd", ".wbmp", + ".cur", ".xcf", ".xcf.gz", ".arw", ".cr2", ".crw", ".dcr", ".dng", ".k25", + ".kdc", ".erf", ".mrw", ".nef", ".nrf", ".nrw", ".orf", ".raw", ".rw2", + ".pef", ".raf", ".sr2", ".srf", ".x3f", ".webp", ".ppt", ".pptx", ".odp", + NULL +}; + +const char *extn_scale[] = +{ + ".svg", ".svgz", ".svg.gz", ".ps", ".ps.gz", ".pdf", + NULL +}; + +const char *extn_edj[] = +{ + ".edj", + NULL +}; + +const char *extn_mov[] = +{ + ".asf", ".avi", ".bdm", ".bdmv", ".clpi", ".cpi", ".dv", ".fla", ".flv", + ".m1v", ".m2t", ".m2v", ".m4v", ".mkv", ".mov", ".mp2", ".mp2ts", ".mp4", + ".mpe", ".mpeg", ".mpg", ".mpl", ".mpls", ".mts", ".mxf", ".nut", ".nuv", + ".ogg", ".ogm", ".ogv", ".qt", ".rm", ".rmj", ".rmm", ".rms", ".rmvb", + ".rmx", ".rv", ".swf", ".ts", ".weba", ".webm", ".wmv", ".3g2", ".3gp", + ".3gp2", ".3gpp", ".3gpp2", ".3p2", ".264", + ".mp3", ".aac", ".wav", + NULL +}; + +const char *extn_aud[] = +{ + ".mp3", ".aac", ".wav", + NULL +}; diff --git a/src/bin/extns.h b/src/bin/extns.h index 04f62bb6..8f67644c 100644 --- a/src/bin/extns.h +++ b/src/bin/extns.h @@ -1,39 +1,5 @@ -static const char *extn_img[] = -{ - ".png", ".jpg", ".jpeg", ".jpe", ".jfif", ".tif", ".tiff", ".gif", ".thm", - ".bmp", ".ico", ".ppm", ".pgm", ".pbm", ".pnm", ".xpm", ".psd", ".wbmp", - ".cur", ".xcf", ".xcf.gz", ".arw", ".cr2", ".crw", ".dcr", ".dng", ".k25", - ".kdc", ".erf", ".mrw", ".nef", ".nrf", ".nrw", ".orf", ".raw", ".rw2", - ".pef", ".raf", ".sr2", ".srf", ".x3f", ".webp", ".ppt", ".pptx", ".odp", - NULL -}; - -static const char *extn_scale[] = -{ - ".svg", ".svgz", ".svg.gz", ".ps", ".ps.gz", ".pdf", - NULL -}; - -static const char *extn_edj[] = -{ - ".edj", - NULL -}; - -static const char *extn_mov[] = -{ - ".asf", ".avi", ".bdm", ".bdmv", ".clpi", ".cpi", ".dv", ".fla", ".flv", - ".m1v", ".m2t", ".m2v", ".m4v", ".mkv", ".mov", ".mp2", ".mp2ts", ".mp4", - ".mpe", ".mpeg", ".mpg", ".mpl", ".mpls", ".mts", ".mxf", ".nut", ".nuv", - ".ogg", ".ogm", ".ogv", ".qt", ".rm", ".rmj", ".rmm", ".rms", ".rmvb", - ".rmx", ".rv", ".swf", ".ts", ".weba", ".webm", ".wmv", ".3g2", ".3gp", - ".3gp2", ".3gpp", ".3gpp2", ".3p2", ".264", - ".mp3", ".aac", ".wav", - NULL -}; - -static const char *extn_aud[] = -{ - ".mp3", ".aac", ".wav", - NULL -}; +extern const char *extn_img[]; +extern const char *extn_scale[]; +extern const char *extn_edj[]; +extern const char *extn_mov[]; +extern const char *extn_aud[]; diff --git a/src/bin/options_wallpaper.c b/src/bin/options_wallpaper.c index 4d7acd6b..df168c91 100644 --- a/src/bin/options_wallpaper.c +++ b/src/bin/options_wallpaper.c @@ -57,7 +57,18 @@ _grid_content_get(void *data, Evas_Object *obj, const char *part) { if (item->path) { - return media_add(obj, item->path, config, MEDIA_THUMB, TYPE_IMG); + int len0, len = strlen(item->path); + int i, ret = 0; + + for (i = 0; extn_edj[i]; i++) + { + len0 = strlen(extn_edj[i]); + if ((len > len0) && + (!strcasecmp(&(item->path[len - len0]), extn_edj[i]))) + return media_add(obj, item->path, config, + MEDIA_BG, &ret); + } + return media_add(obj, item->path, config, MEDIA_THUMB, &ret); } else { @@ -83,7 +94,7 @@ _item_selected(void *data, Evas_Object *obj EINA_UNUSED, void *event EINA_UNUSED if (!config) return; if (!item->path) { - //no background + // no background eina_stringshare_del(config->background); config->background = NULL; config_save(config, NULL); @@ -272,8 +283,8 @@ static Eina_List* _rec_read_directorys(Eina_List *list, char *root_path, Evas_Object *term) { Eina_List *childs = ecore_file_ls(root_path); - char *file_name, *ext; - int i; + char *file_name; + int i, j, len, len0; char path[PATH_MAX]; Background_Item *item; @@ -281,20 +292,32 @@ _rec_read_directorys(Eina_List *list, char *root_path, Evas_Object *term) EINA_LIST_FREE(childs, file_name) { snprintf(path, PATH_MAX, "%s/%s", root_path, file_name); - ext = strchr(file_name, '.'); - if ((!ecore_file_is_dir(path)) && (file_name[0] != '.') && (ext)) + len = strlen(file_name); + if ((!ecore_file_is_dir(path)) && (file_name[0] != '.')) { - for (i = 0; extn_img[i]; i++) + const char **extns[5] = + { extn_img, extn_scale, extn_edj, extn_mov, NULL }; + + for (j = 0; extns[j]; j++) { - if (strcasecmp(extn_img[i], ext)) continue; - item = calloc(1, sizeof(Background_Item)); - if (item) + const char **ex = extns[j]; + + for (i = 0; ex[i]; i++) { - item->path = eina_stringshare_add(path); - item->term = term; - list = eina_list_append(list, item); + len0 = strlen(ex[i]); + if ((len > len0) && + (!strcasecmp(&(file_name[len - len0]), ex[i]))) + { + item = calloc(1, sizeof(Background_Item)); + if (item) + { + item->path = eina_stringshare_add(path); + item->term = term; + list = eina_list_append(list, item); + } + break; + } } - break; } } else @@ -324,22 +347,22 @@ _read_directorys(Evas_Object *term) free(item); } } - //first of all append the None !! + // first of all append the None !! item = calloc(1, sizeof(Background_Item)); item->path = NULL; item->term = term; backgroundlist = eina_list_append(backgroundlist, item); - //append the standart directory - snprintf(path, sizeof(path), "%s/backgrounds/", elm_app_data_dir_get()); + // append the standard directory + snprintf(path, sizeof(path), "%s/backgrounds", elm_app_data_dir_get()); backgroundlist = _rec_read_directorys(backgroundlist, path, term); - //append the Home background directory if this directory exists + // append the Home background directory if this directory exists home_dir = getenv("HOME"); - if(home_dir) + if (home_dir) { - snprintf(path, sizeof(path), "%s/.e/e/backgrounds/", home_dir); + snprintf(path, sizeof(path), "%s/.e/e/backgrounds", home_dir); backgroundlist = _rec_read_directorys(backgroundlist, path, term); } - //Now append all the directorys which are stored + // Now append all the directorys which are stored EINA_LIST_FOREACH(config->wallpaper_paths, node, path_iterate) { backgroundlist = _rec_read_directorys(backgroundlist, path_iterate, term);