I'm set some custom fields and custom icons to my files in WFX plugin.
On data change I modify custom field value (returned by FsContentGetValue) and custom icon handle (returned by FsExtractCustomIcon in TheIcon), then call cm_rereadsource.
The field is updated and the icon is not. If I try to exit plugin and enter it back, the file has proper (updated) icon.
Is this default TC behaviour or another my mistake?
WFX custom icons update
Moderators: Hacker, petermad, Stefan2, white
- Korney San
- Junior Member
- Posts: 19
- Joined: 2011-10-13, 11:42 UTC
- Location: Belarus, Gomel
WFX custom icons update
Praemonitus praemunitus
Korney San
TC caches the icons and does not always request them from plugin. I met with this problem too, and worked it around by changing the modification date of the file entry and then calling cm_rereadsource.
TC caches the icons and does not always request them from plugin. I met with this problem too, and worked it around by changing the modification date of the file entry and then calling cm_rereadsource.
Flint's Homepage: Full TC Russification Package, VirtualDisk, NTFS Links, NoClose Replacer, and other stuff!
Using TC 11.03 / Win10 x64
Using TC 11.03 / Win10 x64
Korney San, AFAIK TC doesn't ask for icons on refresh until you re-enter current folder. Also TC remembers pair <RemoteName, icon> (returned by you from FsExtractCustomIcon) in cache and doesn't change icon in cache if you return same RemoteName, so you should return another RemoteName in order to change icon. You may return any strings, not only filenames.
E.g. if you have a file \indicator and it may take 4 different icons indicating different modes, you may return \indicator/0, \indicator/1, \indicator/2 etc. in RemoteName so TC will show previously cached icons.
E.g. if you have a file \indicator and it may take 4 different icons indicating different modes, you may return \indicator/0, \indicator/1, \indicator/2 etc. in RemoteName so TC will show previously cached icons.
- ghisler(Author)
- Site Admin
- Posts: 50840
- Joined: 2003-02-04, 09:46 UTC
- Location: Switzerland
- Contact:
MVV is right, TC uses the name returned by FsExtractCustomIcon to cache the icon. So if for example all .txt files have the same icon, you should return the same name to save memory (TC has to cache the icon only once then).
Author of Total Commander
https://www.ghisler.com
https://www.ghisler.com
- Korney San
- Junior Member
- Posts: 19
- Joined: 2011-10-13, 11:42 UTC
- Location: Belarus, Gomel
Mmm, I need to update the state of file (i. e. icon) once per minute.
Here is a piece of code of FsExtractCustomIcon:
Icons were not updated with it.
I change code as
but icons are not updating yet.
What shall I do else?
P.S. I decide to leave files their native icons and make another field to display state of file, if I cannot solve this problem.
Here is a piece of code of FsExtractCustomIcon:
Code: Select all
st:=ParseTagXML('state', s);
case StrToIntDef(st, -1) of
0, 1:
begin
TheIcon := CustomIcons[icPaused].Handle;
StrCopy(RemoteName, CustomIcons[icPaused].Name);
Result := FS_ICON_EXTRACTED;
end;
2:
begin
sv:=ParseTagXML('saveto', s);
if FileExists(sv) then
begin
TheIcon := CustomIcons[icCompleted].Handle;
StrCopy(RemoteName, CustomIcons[icCompleted].Name);
Result := FS_ICON_EXTRACTED;
end
else
begin
TheIcon := CustomIcons[icCompletedNoFile].Handle;
StrCopy(RemoteName, CustomIcons[icCompletedNoFile].Name);
Result := FS_ICON_EXTRACTED;
end;
end;
3:
begin
TheIcon := CustomIcons[icDownloading].Handle;
StrCopy(RemoteName, CustomIcons[icDownloading].Name);
Result := FS_ICON_EXTRACTED;
end;
4, 5:
begin
TheIcon := CustomIcons[icError].Handle;
StrCopy(RemoteName, CustomIcons[icError].Name);
Result := FS_ICON_EXTRACTED;
end;
6:
begin
TheIcon := CustomIcons[icQueue].Handle;
StrCopy(RemoteName, CustomIcons[icQueue].Name);
Result := FS_ICON_EXTRACTED;
end;
else
begin
TheIcon := CustomIcons[icMain].Handle;
StrCopy(RemoteName, CustomIcons[icMain].Name);
Result := FS_ICON_EXTRACTED;
end;
end;
I change code as
Code: Select all
...
0, 1:
begin
TheIcon := CustomIcons[icPaused].Handle;
//StrCopy(RemoteName, CustomIcons[icPaused].Name);
StrLCat(RemoteName, '/', MAX_PATH-1);
StrLCat(RemoteName, CustomIcons[icPaused].Name, MAX_PATH-1);
Result := FS_ICON_EXTRACTED;
end;
...
3:
begin
TheIcon := CustomIcons[icDownloading].Handle;
//StrCopy(RemoteName, CustomIcons[icDownloading].Name);
StrLCat(RemoteName, '/', MAX_PATH-1);
StrLCat(RemoteName, CustomIcons[icDownloading].Name, MAX_PATH-1);
Result := FS_ICON_EXTRACTED;
end;
...
6:
begin
TheIcon := CustomIcons[icQueue].Handle;
//StrCopy(RemoteName, CustomIcons[icQueue].Name);
StrLCat(RemoteName, '/', MAX_PATH-1);
StrLCat(RemoteName, CustomIcons[icQueue].Name, MAX_PATH-1);
Result := FS_ICON_EXTRACTED;
end;
What shall I do else?
P.S. I decide to leave files their native icons and make another field to display state of file, if I cannot solve this problem.
Praemonitus praemunitus