MiniTreeSwitcher

Discuss and share scripts and script files...
Post Reply
highend
Posts: 13309
Joined: 06 Feb 2011 00:33

MiniTreeSwitcher

Post by highend »

Switching mini trees is currently a bit limited in XY so I wrote a replacement script.

It allows you to save the current mini tree, switch to stored ones and delete either a single one or (nuke) all. It also contains a link to the original mini tree context menu as the last option.

If you want to switch on / off the mini tree you can do it either via the context menu (two clicks) or e.g. by invoking the script with a parameter.
For a CTB (custom toolbar button):
On right-click:

Code: Select all

::load "MiniTreeSwitcher", "_Switch mini tree state";
The current loaded mini tree is marked with a star icon.

It's a self modifying script and I hope it's foolproof enough to not destroy it's content by itself :)

If you need to transfer your saved trees from an older version to the latest one, copy
everything that's between these two comments in the old file:

Code: Select all

// begin_entries
// end_entries
and paste it in between these comments in the new file. These comments are required, DO NOT REMOVE
them (nor duplicate ofc)!

A screenshot:
Unbenannt.png
Unbenannt.png (21.08 KiB) Viewed 6052 times
Current version:
v0.3
MiniTreeSwitcher_v0.3.zip
(1.35 KiB) Downloaded 378 times
Old versions:
MiniTreeSwitcher_v0.1.zip
(1.19 KiB) Downloaded 216 times
MiniTreeSwitcher_v0.2.zip
(1.31 KiB) Downloaded 200 times
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: MiniTreeSwitcher

Post by klownboy »

Cool highend. It works right out of the box. I haven't used minitree all that much, but with this script I'll start. This capability probably should be built-in to XY. Before bed last night I had tried the initial version you posted under wishes and that one gave me an error message about not finding the "ini" file. It was not written to <xyscripts>. I see in this version you modify the script itself to store the Mini-Tree information in lieu of using an ini file.

Could you add the MiniTree right click context menu to your script context menu? It would make it much more convenient to edit the minitree before saving it as a new one. With that, we could then remove the original XY MiniTree button from the toolbar and replace it with your MiniTreeSwitcher.

Code: Select all

"MiniTree Context Menu|:minitree" button minitree, 2;
Edit: Actually in addition to the context menu, it would also be valuable to have the Mini Tree cid #489 on MiniTreeSwitcher which actually cycles the mini tree on and off. Also necessary to eliminate the need for having XY's built-in Mini Tree. If we were using a CTB, it might be better to set the CTB's right click as "cycle Mini Tree on and off" since that's something we really don't want to have to click 2 times to accomplish. For those who don't want to assign cycle on and off to the right-click, it might be wise to have the cycle capability directly on the MiniTreeSwitcher menu itself.

Thanks,
Ken
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13309
Joined: 06 Feb 2011 00:33

Re: MiniTreeSwitcher

Post by highend »

Hi Ken,

I've added the context menu and (but only as a hidden script) a "_Switch mini tree state" that can be called by e.g. right clicking on a CTB.

I don't want to clutter the popupmenu with too many entries (apart from the stored tree entries) so I didn't include it directly. Can't see the reason to switch the mini tree to the normal view so often (that it can't be done by using two instead of one click) :)

I hope that's ok...
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: MiniTreeSwitcher

Post by klownboy »

Thanks highend, there's one drawback on using the script itself for saving the "trees" or any info in general. The trees are gone on update. I didn't delete my old already modified version with my new mini trees. So it was just a matter of cut and pasting the old tree info between "// begin_entries" and "// end_entries". That won't be a problem obviously for those that haven't used version 0.1. No problem on not including the cycle minitree though it is 3 clicks to cycle in lieu of 2 on the left clickmenu :) unless I include it as the right click, which I probably will anyway.
Thanks again,
Ken
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: MiniTreeSwitcher

Post by klownboy »

Is there anyway to "get" the current state of the "tree" (i.e., mini or normal). It would be slick to be able to reflect the tree state of the CTB in the script as Don does in the built-in mini tree. If possible, it would then only be a matter of using CTBstate and a different icon small tree/large tree depending on the mini vs normal? I do have the expanded or large tree icon from somewhere. I'm not sure where it came from because I don't see it available from the customized menu listing.
I could use getkey for Minitree value of 0/1 in the XY's ini file but the ini has to be saved first using 'savesettings 1" to be valid or up-to-date.

Edit: I suppose if there was no fool proof method to determine the tree state I could always insert cbtstate and ctbicon statements in the right click to show the current full tree icon or normal state, but obviously that doesn't work right if you cycle the tree state with the right click.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13309
Joined: 06 Feb 2011 00:33

Re: MiniTreeSwitcher

Post by highend »

Yeah, there is no update mechanism but I don't intend to update it often *g*

Btw, there is a foolproof way to get the state:

Code: Select all

text get("#489");
1 = mini tree
0 = no mini tree

Does that help?
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: MiniTreeSwitcher

Post by klownboy »

Sure that helps. :oops: Sorry, I even looked through the help and I didn't notice the "get" cid for mini tree. I tested it and it does return a valid up-to-date index without a save so Don must get that from XY memory because it's right when the XY ini file is wrong (i.e., before a safe) which is the case for most of the get cid returns. When I get a chance I may fiddle with my personal version (of your script) to up date the icon when the state is changed.
Thanks highend.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13309
Joined: 06 Feb 2011 00:33

Re: MiniTreeSwitcher

Post by highend »

v0.3 is online.

It seems self("file") does return only the basename of the script in some cases (at least it did so in v0.2 when used in subscripts). I'm now initializing the value in the "_Initialize" section and export it via a global var. So far this works flawlessly. I can't reproduce it with a simple demo script (just two sections) so I won't file a bug report for now (but it's still a bit fishy...).

A hint how to import currently saved trees into the new version is in the first post.
One of my scripts helped you out? Please donate via Paypal

xpa
Posts: 5
Joined: 14 Oct 2014 23:04

Re: MiniTreeSwitcher

Post by xpa »

That is so useful, thanks!
I'm also impressed by how easy it is to improve on XYplorer... wow.
I checked SO MANY explorer application replacements and none of them support such feature.

Now its possible to have multiple favorites "views" with a complete folder tree.
for example, you can have multiple views of folders with information in a folder-tree structure: like "favorites pdfs" or "pictures" or "work documents" all with sub-folders and all sorted to folder-trees.

It is so convenient that i'm really stunned no app supports it! until now.

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: MiniTreeSwitcher

Post by klownboy »

highend wrote:It seems self("file") does return only the basename of the script in some cases
That's probably why your initial posted script in the "Wishes" Discussion area didn't work for me. I received errors stating, the ini file could not be found. I was curious why, but it was beyond bedtime and when I awoke low and behold a new script. :)
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13309
Joined: 06 Feb 2011 00:33

Re: MiniTreeSwitcher

Post by highend »

Did I really use subscripts in that script? Can't remember and I already deleted it. Maybe I should invest some time to create a script that is able to reproduce this faulty behavior so that Don can fix it...
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: MiniTreeSwitcher

Post by klownboy »

Hey highend, no I don't believe there were subscripts. I sent the script to you with some comments. In stepping through the script it appears the variable $iniFile is made but the ini file itself is not, so there's nothing to read.
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

highend
Posts: 13309
Joined: 06 Feb 2011 00:33

Re: MiniTreeSwitcher

Post by highend »

Hi Ken,

yeah, I see. I wouldn't just create a file without checking if does not already exist.

So a better approach would have been:

Code: Select all

    $iniFile = replace(self("file"), "xys", "ini");
    if (!exists($iniFile)) { new($iniFile); }
    $iniFileContent = readfile($iniFile);
This would have worked as expected but hey, there is a new script in place so forget about the old one *g*
One of my scripts helped you out? Please donate via Paypal

klownboy
Posts: 4139
Joined: 28 Feb 2012 19:27

Re: MiniTreeSwitcher

Post by klownboy »

Yes, if it doesn't exist, create it. You didn't want to overwrite the file if it exists.

Your latest version works great. I made the minor changes I mentioned such that the CTB icon reflects the state (i.e., small tree / large tree). Works great regardless of where the state is changed, in the main menu, context menu, or via a right click. No more reason for the built-in MiniTree CTB...it's gone from my toolbar. :) :whistle:
Thanks :appl:
Windows 11, 22H2 Build 22621.1555 at 100% 2560x1440

Lusayalumino
Posts: 90
Joined: 13 Aug 2018 07:16
Location: USA

Re: MiniTreeSwitcher

Post by Lusayalumino »

What an absolutely tremendous script... thanks so much for posting this. Massive improvement in my mini tree efficiency, and it allows me to remove two toolbar buttons and replace with one. :tup:
XYPlorer, Great Form -- Awesome Function

Post Reply