forked from speedie/spmenu
generate cache by default, don't load cache if we're not also generating cache
This commit is contained in:
parent
563806f2d1
commit
5ae0fc4eea
|
@ -64,7 +64,7 @@ spmenu.imagewidth: 86
|
||||||
spmenu.imageheight: 86
|
spmenu.imageheight: 86
|
||||||
spmenu.imagegaps: 0
|
spmenu.imagegaps: 0
|
||||||
spmenu.imageposition: 0
|
spmenu.imageposition: 0
|
||||||
spmenu.generatecache: 0
|
spmenu.generatecache: 1
|
||||||
spmenu.mode: 0
|
spmenu.mode: 0
|
||||||
spmenu.fast: 0
|
spmenu.fast: 0
|
||||||
spmenu.hidematchcount: 0
|
spmenu.hidematchcount: 0
|
||||||
|
|
12
libs/img.c
12
libs/img.c
|
@ -190,7 +190,7 @@ loadimagecache(const char *file, int *width, int *height)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* try find image from cache first */
|
/* try find image from cache first */
|
||||||
if(!(xdg_cache = getenv("XDG_CACHE_HOME"))) {
|
if(!(xdg_cache = getenv("XDG_CACHE_HOME")) && generatecache) {
|
||||||
if(!(home = getenv("HOME")) && (pw = getpwuid(getuid())))
|
if(!(home = getenv("HOME")) && (pw = getpwuid(getuid())))
|
||||||
home = pw->pw_dir;
|
home = pw->pw_dir;
|
||||||
if(!home) {
|
if(!home) {
|
||||||
|
@ -221,9 +221,9 @@ loadimagecache(const char *file, int *width, int *height)
|
||||||
sprintf(&md5[i*2], "%02x", (unsigned int)digest[i]);
|
sprintf(&md5[i*2], "%02x", (unsigned int)digest[i]);
|
||||||
|
|
||||||
/* path for cached thumbnail */
|
/* path for cached thumbnail */
|
||||||
if (xdg_cache)
|
if (xdg_cache && generatecache)
|
||||||
slen = snprintf(NULL, 0, "%s/thumbnails/%s/%s.png", xdg_cache, dsize, md5)+1;
|
slen = snprintf(NULL, 0, "%s/thumbnails/%s/%s.png", xdg_cache, dsize, md5)+1;
|
||||||
else
|
else if (generatecache)
|
||||||
slen = snprintf(NULL, 0, "%s/.thumbnails/%s/%s.png", home, dsize, md5)+1;
|
slen = snprintf(NULL, 0, "%s/.thumbnails/%s/%s.png", home, dsize, md5)+1;
|
||||||
|
|
||||||
if(!(buf = malloc(slen))) {
|
if(!(buf = malloc(slen))) {
|
||||||
|
@ -231,12 +231,12 @@ loadimagecache(const char *file, int *width, int *height)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (xdg_cache)
|
if (xdg_cache && generatecache)
|
||||||
sprintf(buf, "%s/thumbnails/%s/%s.png", xdg_cache, dsize, md5);
|
sprintf(buf, "%s/thumbnails/%s/%s.png", xdg_cache, dsize, md5);
|
||||||
else
|
else if (generatecache)
|
||||||
sprintf(buf, "%s/.thumbnails/%s/%s.png", home, dsize, md5);
|
sprintf(buf, "%s/.thumbnails/%s/%s.png", home, dsize, md5);
|
||||||
|
|
||||||
loadimage(buf, width, height);
|
if (generatecache) loadimage(buf, width, height);
|
||||||
|
|
||||||
if (image && *width < imagewidth && *height < imageheight) {
|
if (image && *width < imagewidth && *height < imageheight) {
|
||||||
imlib_free_image();
|
imlib_free_image();
|
||||||
|
|
|
@ -8,6 +8,7 @@ static void cleanupimage(void);
|
||||||
static void drawimage(void);
|
static void drawimage(void);
|
||||||
static void rotateimage(void);
|
static void rotateimage(void);
|
||||||
static void flipimage(void);
|
static void flipimage(void);
|
||||||
|
static void loadimage(const char *file, int *width, int *height);
|
||||||
static void loadimagecache(const char *file, int *width, int *height);
|
static void loadimagecache(const char *file, int *width, int *height);
|
||||||
static void resizetoimageheight(int imageheight);
|
static void resizetoimageheight(int imageheight);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ static int imagewidth = 86; /* Default image width */
|
||||||
static int imageheight = 86; /* Default image height */
|
static int imageheight = 86; /* Default image height */
|
||||||
static int imagegaps = 0; /* Image gaps */
|
static int imagegaps = 0; /* Image gaps */
|
||||||
static int imageposition = 0; /* Image position (0: Top, 1: Bottom, 2: Center, 3: Top center) */
|
static int imageposition = 0; /* Image position (0: Top, 1: Bottom, 2: Center, 3: Top center) */
|
||||||
static int generatecache = 0; /* Generate image cache by default */
|
static int generatecache = 1; /* Generate image cache by default */
|
||||||
|
|
||||||
/* Mode options */
|
/* Mode options */
|
||||||
static int mode = 0; /* Mode to start speedwm in (0: Normal mode, 1: Insert mode) */
|
static int mode = 0; /* Mode to start speedwm in (0: Normal mode, 1: Insert mode) */
|
||||||
|
|
Loading…
Reference in a new issue