I would like to create a plugin to run some QA and highlight certain nodes in EditView. I already have my Python QA; now, I would like to make the plugin.
I need functions from Reporter to draw things on EditView, but I also need to show a Vanilla Window to choose and run QA. What is the best method to do that?
Make a plugin to display things in EditView, and another one to set preferences of first one ?
You don’t need to be a reporter plugin to draw in Edit View, it’s just more convenient that way as you don’t have to set up the View menu item and the drawing callback hooks yourself.
Inversely, you can also use Vanilla from a reporter plugin.
However, the distinction between the different plugin types will be less relevant going forward. Starting with Glyphs 3.2, you can have multiple different plugins in a single .glyphsPlugin bundle. We will publish more details on that soon.
So I would choose a .glyphsPlugin bundle, put a reporter plugin in there, and call the Vanilla functions from the reporter plugin. If the Vanilla-part of the plugin does not fit into the reporter, add a separate general plugin into the same .glyphPlugin bundle and have the two talk to each other.
How to do this exactly is difficult to tell without knowing more about your plugins features and needs.
Then it might be easier with a general plugin. You need your own menu item. if that is clicked, you show your window and add a drawing callback. And when the window is closed, you remove it again.
The easiest would be to check existing plugins. The python version of speepunk has an always on window.
And after thinking about it, doing a reporter might actually be the better option. There are willActivate() and willDeactivate() callback. There you can show/hide your window. But make sure that you only have one window.
Now, I’m experiencing something very peculiar. After adding these two methods and running GlyphsApp, the app still bounces (even when this plugin is removed), and I can only open it in Plugin Disabled mode.
The only way to make it work as before is:
Remove all plugins manually from the Plugins folder.
Do not add the @objc.python_method to methods that the ObjectiveC part of the app needs to access. That decorator is only needed to methods that are only used within the plugin (and some helper methods for the python wrapper).
@HugoJ did you have a look at my Skedge plugin? It is quite similar to what you want, no? It has a window which is always open when the plugin is active, and it draws into the edit view.
One thing from Skedge which you don’t need is the execution of the window code all the time, that is specific to Skedge, as it is supposed to render the user’s code. But you can see an example how to inject the drawing callback.
That would work for now, until the updated architecture is live, that Florian was talking about.
@Mark Of course, I know it
It’s not too far from what I’m trying to achieve, but as Georg explained, it’s easier to show a window from a Reporter Plugin than to add a drawing callback in a General Plugin.
@GeorgSeifert I have another question. Is it possible to run a part of the code not when the application starts, but after a font has been loaded?
I’m using Font.userData to store the data I use in my plugin, and since the plugin is loaded before fonts, I can’t access this data.