#include <limits.h> /* for PATH_MAX */
#include <sys/types.h>
#include <sys/stat.h>
+#include <time.h> /* for time() */
#define __USE_GNU /* for strcasestr */
#include <string.h> /* for making ftw.h happy */
#include "mmcache.h"
#include "mmcat.h"
#include "mmui.h"
+#include "mmui_context.h"
extern pnd_conf_handle g_conf;
extern unsigned char g_pvwcache;
}
// set up target filename to copy
snprintf ( buffer, PATH_MAX, "%s/%s/%s.png", cacheoutpath, cache_path, app -> unique_id );
- pnd_log ( pndn_debug, "Found free space to cache preview to here: %s", buffer );
+ pnd_log ( pndn_debug, "Found free space to cache preview to here: %s", buffer );
if ( ! pnd_filecopy ( filepath, buffer ) ) {
- pnd_log ( pndn_error, "ERROR: Copying preview from %s to %s", filepath, buffer );
+ pnd_log ( pndn_error, "ERROR: Copying preview from %s to %s", filepath, buffer );
}
} else {
pnd_log ( pndn_warning, "WARN: Couldn't find a device to cache preview to.\n" );
sprintf ( ovrfile, "%s/%s.png", iconpath, app -> unique_id );
+ // making sure the file is at least a few seconds old, to help avoid race condition
struct stat statbuf;
- if ( stat ( ovrfile, &statbuf ) == 0 ) {
+ // *** commented out this stat() 'race test' since it buggers up icon loading at boot, if using .desktop instead of .pnd scanning..
+ if ( stat ( ovrfile, &statbuf ) == 0 /*&& time ( NULL ) - statbuf.st_mtime > 5*/ ) { // race with pndnotifyd
buflen = statbuf.st_size;
if ( ( iconbuf = malloc ( statbuf.st_size ) ) ) {
int fd = open ( ovrfile, O_RDONLY );
s = scaled;
}
+ // scale for tiny?
+ SDL_Surface *scaled_tiny = SDL_ConvertSurface ( s, s -> format, s -> flags );
+ extern ui_context_t ui_display_context;
+ scaled_tiny = ui_scale_image ( scaled_tiny, -1 , ui_display_context.text_height );
+
// add to cache
c = (mm_cache_t*) malloc ( sizeof(mm_cache_t) );
bzero ( c, sizeof(mm_cache_t) );
strncpy ( c -> uniqueid, app -> unique_id, 1000 );
c -> i = s;
+ c -> itiny = scaled_tiny;
return ( 1 );
}