-
-
Notifications
You must be signed in to change notification settings - Fork 90
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Composite template support for Vala, Rust, Python + "Custom Widget" demo #823
base: main
Are you sure you want to change the base?
Conversation
Some solution ideas we had:
Edit: |
Thanks for sharing your work and documenting.
That's because I implemented a hack. Lines 24 to 32 in 35a3a70
If that means closing and reopening the preview window then it's probably a no go If the goal is to avoid connecting signals manually and using
The idea is to add a new API. In Workbench first, as experimental and upstream relevant bits into GJS/Vala/Rust/PyGObject/... Regarding composite widgets, if we can make it work that'd be great.
|
Ah shame, that makes unregistering impossible then, shame. If we also don't want to restart then we have to come up with another solution. For Python we could probably monkey-patch Gtk.Template, but for the other two it wouldn't be so simple... |
I wonder if there could be a way to restart the previewer in a seamless way. This would be useful for all bindings as we could get rid of our complicated GModule setup. Something GDK surfaces? |
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.