*/}}
Browse Source

UDF embedded thumbnail priority

YimingWu 7 months ago
parent
commit
e3a35a720b
4 changed files with 18 additions and 0 deletions
  1. 3 0
      la_data.c
  2. 1 0
      la_data.h
  3. 1 0
      la_interface.h
  4. 13 0
      resources/la_operators.c

+ 3 - 0
la_data.c

@@ -3625,6 +3625,9 @@ void laSaveAlongside(laManagedSaveProp* parent, char* path){
     if(!msp){ msp=memAcquireSimple(sizeof(laManagedSaveProp)); lstAppendItem(&parent->SaveAlongside, msp); }
     strSafeSet(&msp->Path, path);
 }
+void laSetThumbnailProp(char* path){
+    strSafeSet(&MAIN.ThumbnailProp,path);
+}
 void laClearSaveProp(){
     laManagedSaveProp* m; while(m=lstPopItem(&MAIN.ManagedSaveProps)) {
         laManagedSaveProp* ma; while(ma=lstPopItem(&m->SaveAlongside)){ strSafeDestroy(&ma->Path); memFree(ma); }

+ 1 - 0
la_data.h

@@ -984,6 +984,7 @@ int laPackUDF(laUDF *udf, int UseInstanceList, int DoBackup);
 
 laManagedSaveProp* laSaveProp(char* path);
 void laSaveAlongside(laManagedSaveProp* parent, char* path);
+void laSetThumbnailProp(char* path);
 void laClearSaveProp();
 
 int laRegisterModifications(int ReturnIfAnyMod, int ReturnIfAnyEmpty, int* rempty, int RegisterToUDF);

+ 1 - 0
la_interface.h

@@ -448,6 +448,7 @@ STRUCTURE(LA){
     //laHash256 CustomCommandHash;
     laSafeString* SignalFilter;
     laListHandle CustomSignals;
+    laSafeString* ThumbnailProp;
 
     laListHandle ExtraExtensions;
     laListHandle ExtraPreferencePaths;

+ 13 - 0
resources/la_operators.c

@@ -409,6 +409,19 @@ void la_FileBrowserGetFullPath(laFileBrowser *fb,char* buf){
     strcat(buf, fb->FileName);
 }
 void la_FileBrowserRefreshThumbnail(laFileBrowser* fb){
+    if(MAIN.ThumbnailProp && fb->Active && fb->Active->Type==LA_FILETYPE_UDF){
+        char* prop=SSTR(MAIN.ThumbnailProp); if(prop[0]){
+            char fbuf[2048];la_FileBrowserGetFullPath(fb,fbuf);
+            FILE* fpudf=fopen(fbuf,"rb"); if(fpudf){
+                void* data=0; size_t size=0;
+                if(laExtractQuickRaw(fpudf,prop,&data,&size)){
+                    tnsRefreshImage(fb->Thumbnail,data);
+                    fclose(fpudf); return;
+                }
+                fclose(fpudf);
+            }
+        }
+    }
 #ifdef __linux__
     char buf[2048]="file://"; char md5[128];
     la_FileBrowserGetFullPath(fb,buf+strlen(buf));