Re: Icons with relative paths - status report

2022-07-19 Thread spike
Within Leo, header icons are only used by the default status icon, a few UI commands, the 'todo' plugin, the 'declutter' feature, and a handful of unused functions in editCommands. All live references are limited to only four files: commands/editCommands.py core/leoCommands.py plugins/qt_tree.py pl

Re: Icons with relative paths

2022-07-18 Thread spike
Since we need an argument to distinguish between document and theme relative paths, I'm using the absence of that argument to set legacy mode. For absolute paths it doesn't make any difference. I just need to test for absolute or relative. The devil is, of course, in the details. I keep overthinki

Re: Icons with relative paths

2022-07-18 Thread tbp1...@gmail.com
You can add a new parameter to the method call, say use_legacy = True. Then all existing code will work as always with the default value of use_legacy. You add a new code branch for when use_legacy is False so you can get what you want in that case. Tests for file existence will work with re

Re: Icons with relative paths

2022-07-18 Thread spike
I can kludge it, but it introduces some subtle but potentially nasty bugs. It really needs to be fixed properly in the next major update. I suppose adding a 'pathType' parameter to insertIconFromFile would work. If the parameter is missing then it uses legacy mode and issues a deprecation warn

Re: Icons with relative paths

2022-07-18 Thread tbp1...@gmail.com
I'm all in favor of improving features, but please find a way to make them continue to work with existing code. It seems to me that the easiest way to go about this would be to make the code fall back to a document or outline-relative path if it can't find the icon files in the other standard

Re: Icons with relative paths

2022-07-18 Thread spike
g.os_path_exists works with relative paths but c.editCommands.insertIconFromFile forces relative paths to be relative to the Leo theme directory. Document relative paths are rejected. Running the following command from Leo's Python Console tab fails: c.editCommands.insertIconFromFile('./icons/

Re: Icons with relative paths

2022-07-18 Thread tbp1...@gmail.com
Typically, either you write code and try different paths depending on whether your file is in one place or another, or a Leo method does the same thing for you, in which case you need to know where Leo is going to look. For example, in the part of the Cheatsheet you mention: fn = g.os_

Re: Icons with relative paths

2022-07-17 Thread FĂ©lix
Thanks for the examples spike, but you replied to me only instead of reply all, so your examples are not showing in the thread. Here is the example spike provided: (see attachments) On the other hand, i've looked at the 'unknownattributes' of the nodes, and indeed the paths provided for the ic

Re: Icons with relative paths

2022-07-17 Thread Edward K. Ream
On Sat, Jul 16, 2022 at 9:50 PM Robert-Felix wrote: Leo uses relative paths for most stuff so moving the leo file and your > 'project' or 'resources' folder to accompany it along should keep > everything working fine. whatever you had going on... > Leo's path expressions

Re: Icons with relative paths

2022-07-16 Thread Robert-Felix
it does use relative paths... I mean Leo uses relative paths for most stuff so moving the leo file and your 'project' or 'resources' folder to accompany it along should keep everything working fine. whatever you had going on... if the leo file is in the folder, like most people use it, and @files

Icons with relative paths

2022-07-16 Thread spike
I have a .leo file that has a companion folder containing custom icons. Leo doesn't seem to support relative paths, so moving the .leo file and its companion folder breaks all of the icons in the file. On top of that, if Leo can't find an icon then there is no visual indication that something i