Issues subclassing Widget in clojure #316
Labels
No labels
bug
dependencies
documentation
duplicate
enhancement
github_actions
good first issue
help wanted
invalid
java
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
java-gi/java-gi#316
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Hello,
I've been messing around with this library in clojure for a little bit now. I've really enjoyed it -- thanks for your work on this! It's been mostly smooth sailing so far, but I just ran into a bit of a roadblock. I'm not sure what level of clojure support you're aiming for, but I did notice https://github.com/jwharm/java-gi/issues/136 so I figured it would be worth asking about.
I'm having issues subclassing Widget related things in this project. I first noticed this after trying to override
Widget.snapshot()to play around with GSK. I tried to use clojure'sproxyto make my instance, but this caused a crash.Here's a simplified example to illustrate what I've been seeing. You should be able to paste this into a clojure 1.12 REPL to test it out.
Not much going on here, we're just making a bare-bones application and putting in an anonymous subclass of
Buttonthat overridestoString().When running it, I'm seeing an error like this in stdout:
If you swap the
Buttonproxy out for a regular instance (i.e. replacing(proxy [Button] []...)with(Button.)), the window should open up fine.A few additional notes:
Widgetinstead ofButton, I get a similar error, but the "Unsupported property type" isString [].proxyfunction withWidget's parent classes. I notice any obvious problems creating them fromGObjects orInitiallyUnowneds.Buttonsubclass and a.toString()override works fine in Java, so it seems safe to say that this has something to do with how clojure is creating the object.I'm not quite sure what to make of all this, but hopefully some of it is useful information...
Using the
gen-classfunction might be an option, but I haven't tested that out yet... I believe it would complicate using these libraries from the REPL, which wouldn't be ideal.Thanks for testing java-gi with clojure! I wanted to try this, but I don't have experience with Clojure. So your feedback is really helpful!
The error means that Java-GI found a get/set method pair and tried to register them as a GObject property. The error message clearly needs to be improved, and shouldn't be fatal. I will try to reproduce and fix the issue.
By the way, I'd appreciate any recommendations you have, to make the API more suitable for Clojure.
The error happens specifically with classes created by the
proxyfunction in Clojure. I've reproduced the issue, and will fix it in the next release. Thanks again for reporting.Thank you for the fix! As for the overall experience with the API in clojure, I don't think I have any suggestions at the moment.
The only other thing I've run into in the examples so far that hasn't been smooth is the GtkTemplate stuff -- annotations are a bit of a pain in clojure/java interop. Honestly I don't think it's a big deal though, it doesn't seem to me like you'd get much out of templates with less OO style programs -- just using GTKBuilder directly feels simpler/cleaner here IMO.
Ok, good to know. Thanks for the feedback!