I've created both a HelloWorld example for Scala and a Calculator example for Kotlin. Due to the nature of Scala, it is impossible to write java-gi programs that follow proper Scala practices, as such I struggled to rewrite any examples except for HelloWorld. I may be able to write a wrapper library similar to the one for Swing in the future which would greatly improve Scala support.
Add Kotlin and Scala examples. #2
Thanks for the PR! Can you please change the calculator example so that it will replace the current Java version? I don't think it's really useful to have two calculator examples.
I'd really like a Scala example app that is a bit larger. Why is it impossible to write java-gi programs that follow Scala best practices? Is the Gtk API not suitable or is it something specific in java-gi?
I'll change the PR once I have access to my laptop. As for the second question, it is just due to the nature of GTK. Ideally, Scala programs should be immutable, non-nullable, and functional, however GTK was intended for mutable, nullable, and object-oriented programming languages. This conflict of interest makes it necessary to use Scala like it was Java or Vala which isn't how the language was intended to be used.
Thanks! I like the image viewer example a lot. It's small, and easy to understand.
I have a few review comments, nothing spectacular.
One question remains: Do you mind if I change the references to "org.poach3r" into "io.jwharm.javagi.examples" for consistency with the other examples, and credit you in the examples' README file instead?
@ -0,0 +1,28 @@
plugins {
Missing a closing "
@ -0,0 +1,28 @@
plugins {
kotlin("jvm") version "2.0.21"
}
Please add the application plugin & set the main class, so gradle run will work, and suppress the warning about unsafe access:
tasks.named<JavaExec>("run") {
jvmArgs("--enable-native-access=ALL-UNNAMED")
}
application {
mainClass.set("org.poach3r.MainKt")
}
@ -0,0 +1,185 @@
package io.jwharm.javagi.examples
Change this to Gtk.styleContextAddProviderForDisplay to prevent a deprecation warning about the StyleContext class.
@ -0,0 +5,4 @@
lazy val root = (project in file("."))
.settings(
name := "HelloWorldScala"
)
Please suppress the "unsafe native access" warning:
fork := true,
javaOptions += "--enable-native-access=ALL-UNNAMED"
@ -0,0 +7,4 @@
name := "HelloWorldScala"
)
libraryDependencies += "io.github.jwharm.javagi" % "gtk" % "0.11.0"
0.11.1
@ -0,0 +1,14 @@
ThisBuild / version := "0.1.0-SNAPSHOT"
Please suppress the "unsafe native access" warning:
fork := true,
javaOptions += "--enable-native-access=ALL-UNNAMED"
@ -0,0 +1,44 @@
import io.github.jwharm.javagi.base.GErrorException
I think it's okay. Can you remove the comment?
I'm unsure if Github notified you of this, however I updated my branch with your requests.
Thanks!
No due date set.
No dependencies set.
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?