[TxMt] Re: Registering images for dialogs
doob at me.com
Thu Jul 14 19:33:53 UTC 2016
On 2016-07-14 13:52, Allan Odgaard wrote:
> The idea with the image registration is that you register a dictionary
> with /name/ → /path/ pairs and in your pop-up description you use the
> symbolic names.
> The advantage of this is that we will only create one |NSImage| per path
> and the popup menu definition can be simpler, i.e. using |symbol|
> instead of |/Users/«name»/Library/Application
> bundle».tmbundle/Support/symbol.pdf| for every single menu item.
I find it hard to see how that's simpler. Rather I think it's more
complicated, because you need to:
1. Make a separate call to the dialog command. This is not documented,
at least not in the documentation for the popup Ruby method. The tests
don't t even do this and in general look outdated. There's also no Ruby
interface for this, as far as I can see. Well actually, the "complete"
method does document the ":images" option to be a hash of image names to
paths but it doesn't use that option at all, adding even more to the
2. Setup the mapping of a symbolic name to a path
3. There also seems to be a risk of having conflicting names between
different bundles and possible the application itself
When it comes to efficiency the register command already caches the
NSImage objects using NSImage.setName/imageNamed, as far as I can see.
So if the popup command just contained the same code as the register
command the problem would be solved :). It would also make the dialog
command simpler because the register command could be removed.
The only reason I see why a register command would be useful is to be
able to call it once to register the images. But it's not possible to
automatically run a command only once, as far as I know. Commands don't
have state (unless you want to read/write to a file) so you can't check
if you already registered the images.
(sorry for the rant).
More information about the textmate