Composite template support for Vala, Rust, Python + "Custom Widget" demo #823
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is my attempt to get composite templates working for the other langs.
I say attempt, because it doesn't actually work. There are a lot of reasons, and it boils down to that this probably would require approaching the external previewers completely different.
The main remaining/blocking issue is the fact that the class names need to be counted up to avoid collisions. but Python, Vala and Rust expect the class name to match exactly what's in the demo while the current GJS demo doesn't seem to mind the mismatch.
I worked around that for Python by getting the gtype name from the Workbench API, but for the others this is much more complicated due to the fact that it needs to be compiled. I'm not sure how to get the modified class name in there. Maybe we need to just not add a number to it for those two and restart the previewer every time.
The Python code currently launches once. After that it doesn't anymore, since it tries to re-register the object. Modification would probably be needed to always count up on launch, not just when the XML changes, or the previewer would just also need to be restarted every time. In that case we should just get rid of the number for all external demos and restart the previewer on every launch if templates are involved.
Another issue is that the Vala/Rust code would need to modify the internal state of the previewer to set the "target", but since they are linked in as shared objects there's no easy way to communicate back here.
And I needed to change how the dummy target is handled, replacing it just with an empty box so that the Python and Vala previewers don't crash trying to initialize it's signal handlers. Weirdly this kinda breaks Blueprint, it's trying to display the internal previewer now for non-JS demos. But maybe that's not related.