vbsteven / gtk-kotlin-native

This project is no longer actively maintained and my attention has moved to the community project gtk-kn
https://gitlab.com/gtk-kn/gtk-kn
MIT License
22 stars 0 forks source link

Build failure on Ubuntu 22.04 with gtk 4.6.6 #2

Closed maroc81 closed 1 year ago

maroc81 commented 1 year ago

Building on Ubuntu 22.04 with gtk 4.6.6 fails with the error

e: gtk-kotlin-native/gtk-bindings/src/nativeMain/kotlin/bindings/gtk/CheckButton.kt: (25, 17): Unresolved reference: gtk_check_button_get_child

e: gtk-kotlin-native/gtk-bindings/src/nativeMain/kotlin/bindings/gtk/CheckButton.kt: (26, 22): Unresolved reference: gtk_check_button_set_child

It looks like those interfaces were added in version 4.8: https://docs.gtk.org/gtk4/method.CheckButton.get_child.html

For now I edited CheckButton.kt to return null and changed the setter to just "Unit".

vbsteven commented 1 year ago

Yes indeed, I did the initial manual wrapping effort based on the versions that I have installed on my development machine running Arch so it is tailored to fairly recent versions. I assume the libadwaita bindings are going to have similar issues since Ubuntu 22.04 does not have libadwaita 1.2 yet.

Be aware that this repository is mainly a proof of concept to validate the possibility of Kotlin/Native GTK bindings.

I'm working with some others on a new iteration of all this, where we skip the manual bindings in favor of generating them automatically from the GIR files (GObject Introspection), this will also handle library versioning better. We are aiming for the Kotlin/Native equivalent of gtk-rs. It's not published yet but hopefully we will have something soon.

In the meantime, feel free to experiment and log any issues or feature requests. I'm keeping a close eye on the issues here so we can incorporate them into the new project.

vbsteven commented 1 year ago

BTW, if you manage to get it to build nicely on Ubuntu 22.04 I am open to create an ubuntu-22-04 branch for it and mention it in the readme. I would prefer that that branch has the unsupported methods/properties/classes removed instead of returning null.

maroc81 commented 1 year ago

Sounds great! I'll keep an eye out for the GIR bindings.

You are correct in that I also cannot build the adwaita bindings since Ubuntu 22.04 uses version 1.1 and a number of classes were introduced in 1.2.

I would say not to worry about Ubuntu 22.04 and focus on GIR bindings. Is that repo published yet?

vbsteven commented 1 year ago

Alright.

The new repo is not published yet. The current state is that we have PoC's ready for all the parts and we are currently rewriting them properly and moving them under a single gtk-kn umbrella project.

We are aiming to open up the repository once we have the full chain gir parser -> processor -> binding generator -> library up and running in a clean workable state. At that point this repository will be archived and and updated with references pointing to the new one.

May I ask how your experience has been trying out this repository (if you have) and what your intended use case is?

Any other questions/remarks/features/concerns are always welcome. Either here, via email (available via my website on my GH profile), @vbsteven on the Kotlin Slack or @stevenvanbael:matrix.org on Matrix.

maroc81 commented 1 year ago

I saw your reddit post a couple of months ago and I was just now getting a chance to try out your work. I've been looking at various libraries that provide the gtk-kotlin bindings. My goal is to write cross-platform GUI applications that have a small footprint and are easy to write and maintain.

I have written several applications using TornadoFX (although I'm slowly transitioning away from it to JavaFX + a new extension library I'm working on). It satisfies the easy to write and maintain part but being JVM based is heavy on memory usage and install size.

Kotlin + gtk seems to be the best combination to get a full featured application with a small footprint and small code base. The only downside is that many useful libraries are JVM based or everything else but C/Kotlin.

vbsteven commented 1 year ago

Yes, the biggest challenge for Kotlin Native right now is the library ecosystem but I have the impression it is steadily improving because it is riding the Kotlin multiplatform wave. More and more libraries are adding kotlin multiplatform support and some of them are adding native linux/windows/macos support along with that.

Interesting that you mention TornadoFX. I actually started hacking on these bindings in december after some frustration with JavaFX/TornadoFX (the large binary sizes, requiring a JVM, slow/sluggishness among other things).

I liked the development speed of TornadoFX and its use of JavaFX property binding and I think we can achieve something similar for GTK and Kotlin because the gobject signal and property system is similar.

The gtk-kn project is progressing nicely, we have the gir parser done and we are at the point of implementing the bindings generator. The resulting bindings will look and behave very similar to the manual bindings from this repository so converting any code you might already have shouldn't be that much work. We're also working on a solution for the library versioning problem from this issue based on the Kotlin @OptIn mechanism with some promising results.

From the first tests, it looks like we can achieve a cross platform Kotlin + GTK application within a 500kb linux binary (and shared system or flatpak gnome libs ofcourse).

I expect we will be able to open up the repository within the next few weeks. We have a matrix channel as well now: https://matrix.to/#/#gtk-kn:matrix.org

maroc81 commented 1 year ago

Yes, TornadoFX really demonstrates the power of the kotlin language to streamline GUI application development. It's a shame that it is more or less abandoned now. However, TornadoFX turned into a new framework not just an extension to JavaFX and it had to use some less than ideal (IMO) code tricks to make it so streamlined. It also hides a lot of JavaFX details "behind the scenes" so when you need to step outside of what it provides you end up back at JavaFX docs and learning the JavaFX way to do things. The library I'm working on tries to balance streamlining the code while staying in the JavaFX realm.

I am seeing more kotlin native libraries as well but there is a long way to go. Until then, I'll use gtk-kn where I can, and JavaFX everywhere else. I also have a few Qt based apps that I could port to gtk but not sure if its worth it just yet.

vbsteven commented 1 year ago

For me gtk-kn is part of a bigger project. The primary goal of gtk-kn is to provide idiomatic Kotlin OO bindings for GTK (and the gir-generator for other libraries). Trying to stay close to the original GTK API with some additional syntactic sugar/quality of life extensions on top to abstract the low-level C/pointer handling and make it feel more like Kotlin.

I'm hoping that by building gtk-kn we can boost the KN ecosystem a bit and gather more developer interest for building KN libraries and wrappers to existing native libraries.

On top of that, I am thinking about and currently scoping out an additional desktop app framework based on gtk-kn. The ideal framework that I have in mind is something similar to UIKit for iOS and pre-compose Android. With an equivalent to UIKit UIViewController or Android Activity/Fragment as the high level building blocks which can handle lifecycles, coroutine scopes, navigation, etc. These high level building blocks would then use GTK Widgets (from gtk-kn) as the view layer. It also sounds very similar to what TornadoFX is/was to JavaFX.

vbsteven commented 1 year ago

I'm closing this now that we have opened up the gtk-kn repository.

https://gitlab.com/gtk-kn/gtk-kn