1
7
Fork
You've already forked examples
2

Add Kotlin and Scala examples. #2

Merged
poach3r merged 5 commits from main into main 2024年12月20日 23:04:14 +01:00
poach3r commented 2024年12月10日 15:47:59 +01:00 (Migrated from github.com)
Copy link

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.

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](https://index.scala-lang.org/scala/scala-swing) in the future which would greatly improve Scala support.
jwharm commented 2024年12月11日 22:33:08 +01:00 (Migrated from github.com)
Copy link

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?

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?
poach3r commented 2024年12月12日 01:05:47 +01:00 (Migrated from github.com)
Copy link

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.

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.
jwharm (Migrated from github.com) requested changes 2024年12月13日 22:40:47 +01:00
jwharm (Migrated from github.com) left a comment
Copy link

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?

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 {
jwharm (Migrated from github.com) commented 2024年12月13日 22:00:32 +01:00
Copy link

Missing a closing "

Missing a closing `"`
@ -0,0 +1,28 @@
plugins {
kotlin("jvm") version "2.0.21"
}
jwharm (Migrated from github.com) commented 2024年12月13日 22:15:37 +01:00
Copy link

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")
}
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
jwharm (Migrated from github.com) commented 2024年12月13日 22:16:45 +01:00
Copy link

Change this to Gtk.styleContextAddProviderForDisplay to prevent a deprecation warning about the StyleContext class.

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"
)
jwharm (Migrated from github.com) commented 2024年12月13日 22:25:04 +01:00
Copy link

Please suppress the "unsafe native access" warning:

 fork := true,
 javaOptions += "--enable-native-access=ALL-UNNAMED"
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"
jwharm (Migrated from github.com) commented 2024年12月13日 22:25:19 +01:00
Copy link

0.11.1

0.11.1
@ -0,0 +1,14 @@
ThisBuild / version := "0.1.0-SNAPSHOT"
jwharm (Migrated from github.com) commented 2024年12月13日 22:26:13 +01:00
Copy link

Please suppress the "unsafe native access" warning:

 fork := true,
 javaOptions += "--enable-native-access=ALL-UNNAMED"
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
jwharm (Migrated from github.com) commented 2024年12月13日 22:33:58 +01:00
Copy link

I think it's okay. Can you remove the comment?

I think it's okay. Can you remove the comment?
poach3r commented 2024年12月19日 12:39:27 +01:00 (Migrated from github.com)
Copy link

I'm unsure if Github notified you of this, however I updated my branch with your requests.

I'm unsure if Github notified you of this, however I updated my branch with your requests.
jwharm commented 2024年12月20日 23:08:22 +01:00 (Migrated from github.com)
Copy link

Thanks!

Thanks!
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
java-gi/examples!2
Reference in a new issue
java-gi/examples
No description provided.
Delete branch "main"

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?