custom icons beside files ?

Please check the FAQ (https://www.xyplorer.com/faq.php) before posting a question...
Post Reply
CookieMonster

custom icons beside files ?

Post by CookieMonster »

I would like to place a custom icon beside a file when it has been read or watched or semi-read etc. Is it possible to place custom icons beside file names ?

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: custom icons beside files ?

Post by highend »

Nope
One of my scripts helped you out? Please donate via Paypal

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: custom icons beside files ?

Post by SkyFrontier »

Well... I was about to suggest setting labels or tags for that same task, which I used in the past for marking most used files, but intrigued with XY being NOT able to set custom icons via script, and being off for a big while, decided to give Help a chance - and found seticons().

If you're open to a bit of sacrifice on PFA comfort due to its current implementation, later I may have something posted here.

Base solution:

Code: Select all

*.*> $label = report("{Label}", "<curitem>"); $label2 = report("{Tags}", "<curitem>"); if($label2 <= "3") { tag "Green"; } elseif($label2 > "3" && $label2 <= "6") { tag "Orange"; } elseif($label2 > "6") { tag "Red"; };  if($label2 == "") { tag "1", , 1, 1; } elseif($label2 != "") { $label2++; tag "$label2", , 1, 1; }; run """<curitem>""";
Last edited by SkyFrontier on 12 Mar 2017 17:00, edited 1 time in total.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: custom icons beside files ?

Post by highend »

And after a while you have hundreds / thousands of entries in the CFI. I didn't test if you can slow down XY with enough
entries but seriously, who wants to clean up that mess (when e.g. files are deleted), etc.? :)
One of my scripts helped you out? Please donate via Paypal

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: custom icons beside files ?

Post by SkyFrontier »

Hello, highend!

Well... I guess a one-for-all solution, leaving the user with the micromanagement for specific cases (regarding which icon should be applied for each and every marked file) DO IS an acceptable scenario, here, despite your valid consideration.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

CookieMonster

Re: custom icons beside files ?

Post by CookieMonster »

SkyFrontier wrote:Well... I was about to suggest setting labels or tags for that same task, which I used in the past for marking most used files, but intrigued with XY being NOT able to set custom icons via script, and being off for a big while, decided to give Help a chance - and found seticons().

If you're open to a bit of sacrifice on PFA comfort due to its current implementation, later I may have something posted here.

Base solution:

Code: Select all

*.*> $label = report("{Label}", "<curitem>"); $label2 = report("{Tags}", "<curitem>"); if($label2 <= "3") { tag "Green"; } elseif($label2 > "3" && $label2 <= "6") { tag "Orange"; } elseif($label2 > "6") { tag "Red"; };  if($label2 == "") { tag "1", , 1, 1; } elseif($label2 != "") { $label2++; tag "$label2", , 1, 1; }; run """<curitem>""";
I assume I run the script on a folder ? If so I get an error at this line;

Code: Select all

*.*> $label = report("{Label}", "<curitem>");
Maybe I'm not clear on how to use this script ? :)

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: custom icons beside files ?

Post by SkyFrontier »

Uh, sorry...

This is a PFA entry, which should be put on top(per) position, favored over other PFA definitions you'll have for *anything else* (it's the price to pay, as I told, but with enough patience and care this can be managed by un-setting it when a session is over).

As it is it'll color files with some pretty basic color-coding based on number of executions - everything needs customization on your side.

For the OP, I'm finding it difficult to spot a way to retrieve current custom icons definitions - not implemented, AFAICT, so smart fine tuning will be a tad difficult. But it's a progress towards a solution, IMHO.

EDIT: oh, there's a return for current defs...
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: custom icons beside files ?

Post by SkyFrontier »

@highend:
Perhaps PFA may not be populated... but CFI list will surely be a nightmare with what I'm learning here now. :roll:
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: custom icons beside files ?

Post by highend »

I had some fun stress testing seticons(). 1000 files with a random pool of ~50 icons -> XYplorer just quit. Without any error message.
Ofc this will not be the case here, it's only about setting one file icon at a time.

Cleaning up isn't probably not that hard, at least with a script. A regexmatches() + a bit of string manipulation + a final seticons()
but ofc this had to be done manually from time to time...

But one should not forget that you probably need to create each and every state together with the document type in a new icon
when there is no way to add an extra item column (which custom columns would be perfect for)
One of my scripts helped you out? Please donate via Paypal

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: custom icons beside files ?

Post by SkyFrontier »

highend wrote:I had some fun stress testing seticons(). 1000 files with a random pool of ~50 icons -> XYplorer just quit. Without any error message.
Ofc this will not be the case here, it's only about setting one file icon at a time.

Cleaning up isn't probably not that hard, at least with a script. A regexmatches() + a bit of string manipulation + a final seticons()
but ofc this had to be done manually from time to time...

Anyway seticons() isn't the way to go, highend.
It seems to not support individual files' definitions, only generic 'per drive/extension/folder' ones. Also, for my concept to work it should be able to retrieve currently defined icon apart of any new definition, which it seems to be incapable of.

@CookieM:

Bad news: the posted method is your only way to go for the moment. Let us know if any refinements are necessary, as said the mentioned one may need customization. Extra hint: tags 'green', 'orange' and 'red' are default terms you may have modified on your installment and for which XY hasn't tools for me to guess, so any adjustments are your call here too.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: custom icons beside files ?

Post by highend »

It seems to not support individual files' definitions, only generic 'per drive/extension/folder' ones
Mh? Look at this:
cfi.png
cfi.png (57.4 KiB) Viewed 1591 times
One of my scripts helped you out? Please donate via Paypal

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: custom icons beside files ?

Post by SkyFrontier »

highend wrote:
It seems to not support individual files' definitions, only generic 'per drive/extension/folder' ones
Mh? Look at this:
...
In my quick tests I could only change icons for externsions, not for individual files. Thanks for the tip, will bother later!
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

CookieMonster

Re: custom icons beside files ?

Post by CookieMonster »

I can only color files, no icons to files can be added.

SkyFrontier
Posts: 2341
Joined: 04 Jan 2010 14:27
Location: Pasárgada (eu vou!)

Re: custom icons beside files ?

Post by SkyFrontier »

CookieMonster wrote:I can only color files, no icons to files can be added.
For the time being. Since highend pointed there is a way to add unique icons to unique files, I'll come up with something later (today, I hope - have to manage another something here, sorry) - not smart as the 'tags' method, but better than nothing (my idea is to swap icons based on other factors, 'tags' perhaps, since I currently don't know a way to retrieve a CFI, but you may not need these).

@highend: feel free to develop this, since I'm not familiar with seticons and... really have to go, now.
New User's Ref. Guide and Quick Setup Guide can help a bit! Check XYplorer Resources Index for many useful links!
Want a new XYperience? XY MOD - surfYnXoard
-coz' the aim of computing is to free us to LIVE...

highend
Posts: 13313
Joined: 06 Feb 2011 00:33
Location: Win Server 2022 @100%

Re: custom icons beside files ?

Post by highend »

I don't think that trying to do that with a PFA entry is the right way...
Why not?
It can only support "full" states (fully read, fully watched, etc.) reliable. The op wants
"half-read" as well. You can't just count the number of execution times to say: Ok,
movie watched two times, now it has reached the full state...

So... With additional states a possible solution is to use a popupmenu that let's you
select it's state.

The following script assumes your icons are in "<xyicons>\states"
and use this format:

Code: Select all

0.25 [<extension>].ico
0.50 [<extension>].ico
0.75 [<extension>].ico
1.00 [<extension>].ico
While <extensions> represents a file extension like "txt, mp3, etc."
So one of the four entries could look like this
0.50 [doc].ico
Translated -> Half read status

The script adds, deletes or replaces such a CFI entry according to: if the entry
does not exist yet, "reset" was used / file doesn't exist anymore or a different entry
from one of the four above is chosen

Every 10th execution of any of these methods invokes a cleaning process that deletes
all active! single file definitions for which the file doesn't exist anymore. This value
is adjustable ($clearEvery)

Code: Select all

    perm $P_CFI_ClearCounter;

    $clearEvery = 10;
    $iconDir = "<xyicons>\states";
    $states = "0.25|0.50|0.75|1.00|-|reset";
    $state = popupmenu($states);
    $ext = gpc(<curitem>, "ext");

    if !($state) { status "No state selected, aborted!", "8B4513", "stop"; end 1==1; }
    switch ($state) {
        case "0.25": $icon = "$iconDir\0.25 [$ext].ico"; break;
        case "0.50": $icon = "$iconDir\0.50 [$ext].ico"; break;
        case "0.75": $icon = "$iconDir\0.75 [$ext].ico"; break;
        case "1.00": $icon = "$iconDir\1.00 [$ext].ico"; break;
        default: $icon = "";
    }
    // Check if the icon exists
    if ($icon && exists($icon) != 1) { status "Selected icon does not exist, no icon set!", "8B4513", "stop"; end 1==1; }

    $curCFIs = seticons();
    $index = gettokenindex("+<curitem>>*", $curCFIs, <crlf>, "iw");

    if (!$index && $state UnLikeI "reset") { seticons("+<curitem>>$icon"); } // Not in $index and "reset" wasn't selected -> Add it
    elseif ($state LikeI "reset") { seticons(gettoken($curCFIs, $index, <crlf>), "d"); } // Delete CFI entry
    else { seticons("+<curitem>>$icon", "r", $index); } // Replace CFI entry

    $P_CFI_ClearCounter++;
    if ($P_CFI_ClearCounter >= $clearEvery) {
        $matches = regexmatches($curCFIs, "^\+([A-Z]:|\\\\).*?(?=\r?\n)", <crlf>);

        $definitions = "";
        foreach($match, $matches, <crlf>, "e") {
            if (exists(regexreplace($match, "(^\+|>.+$)")) == 1) { continue; }
            $definitions = $definitions . $match . <crlf>;
        }
        seticons($definitions, "d");
    }
Setting
Configuration | Refresh, Icons, History | Scripting | Remember permanent variables
should be activated
One of my scripts helped you out? Please donate via Paypal

Post Reply