diff --git a/build.gradle.kts b/build.gradle.kts index ecea4fe..7ef8e81 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -17,7 +17,7 @@ val jbAnnotationsVersion by extra("24.0.1") val lwjglVersion by extra("3.3.2") val imguiVersion by extra("1.86.10") // launcher-gtk -val javagiVersion by extra("0.6.0") +val javagiVersion by extra("0.6.1") val flavorProp: String by extra(prop("flavor", "custom")) if (!setOf("custom", "maven", "fat", "windows", "linux", "macos").contains(flavorProp)) throw IllegalStateException("Unsupported flavor: $flavorProp") diff --git a/launcher-gtk/build.gradle.kts b/launcher-gtk/build.gradle.kts index 5c20bc7..8cabde0 100644 --- a/launcher-gtk/build.gradle.kts +++ b/launcher-gtk/build.gradle.kts @@ -20,6 +20,7 @@ repositories { maven("https://jitpack.io") { content { includeGroup("com.github.jwharm.java-gi") + includeGroup("com.github.jwharm") } } } diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/KEntry.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/KEntry.kt index defb4a3..5698704 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/KEntry.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/control/KEntry.kt @@ -1,5 +1,6 @@ package io.gitlab.jfronny.inceptum.gtk.control +import io.gitlab.jfronny.inceptum.gtk.util.kText import org.gnome.gtk.Entry import java.util.function.Consumer @@ -7,7 +8,7 @@ class KEntry(value: String? = ""): Entry() { private val onChange = ArrayList>() init { - text = value ?: "" + kText = value ?: "" onChanged { onChange.forEach { it.accept(text) } } } diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/util/UIExt.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/util/UIExt.kt index 8fd7536..7465271 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/util/UIExt.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/util/UIExt.kt @@ -2,6 +2,8 @@ package io.gitlab.jfronny.inceptum.gtk.util import io.gitlab.jfronny.inceptum.gtk.control.ILabel import org.gnome.adw.ActionRow +import org.gnome.gtk.Entry +import org.gnome.gtk.EntryBuffer import org.gnome.gtk.Label import org.gnome.gtk.MessageDialog import org.gnome.gtk.Widget @@ -31,4 +33,14 @@ var MessageDialog.markup: String set(value) { setMarkup(value) } get() = throw NotImplementedError() -fun ActionRow.fixSubtitle() = ILabel.theme(firstChild!!.lastChild!!.prevSibling!!.lastChild as Label, ILabel.Mode.SUBTITLE) \ No newline at end of file +fun ActionRow.fixSubtitle() = ILabel.theme(firstChild!!.lastChild!!.prevSibling!!.lastChild as Label, ILabel.Mode.SUBTITLE) + +// Work around a segfault with empty entries +var Entry.kText: String? + get() = text + set(value) { + if (value == "") buffer.clear() + else text = value + } + +fun EntryBuffer.clear() = deleteText(0, length) \ No newline at end of file diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/create/NewInstanceWindow.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/create/NewInstanceWindow.kt index bc52ccb..4a21d48 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/create/NewInstanceWindow.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/create/NewInstanceWindow.kt @@ -10,6 +10,7 @@ import io.gitlab.jfronny.inceptum.gtk.control.KEntry import io.gitlab.jfronny.inceptum.gtk.control.assistant.KAssistant import io.gitlab.jfronny.inceptum.gtk.schedule import io.gitlab.jfronny.inceptum.gtk.util.I18n +import io.gitlab.jfronny.inceptum.gtk.util.kText import io.gitlab.jfronny.inceptum.gtk.util.toTypedArray import io.gitlab.jfronny.inceptum.gtk.window.dialog.ProcessStateWatcherDialog import io.gitlab.jfronny.inceptum.launcher.api.FabricMetaApi @@ -103,7 +104,7 @@ class NewInstanceWindow(app: Application) : KAssistant(app) { append(entry) onOpen { name = InstanceNameTool.getDefaultName(gameVersion!!.id, useFabric) - entry.text = name + entry.kText = name } setComplete(true) diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/dialog/StringInputDialog.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/dialog/StringInputDialog.kt index 98fe1b8..f7f6be0 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/dialog/StringInputDialog.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/dialog/StringInputDialog.kt @@ -1,5 +1,6 @@ package io.gitlab.jfronny.inceptum.gtk.window.dialog +import io.gitlab.jfronny.inceptum.gtk.util.kText import org.gnome.gtk.* class StringInputDialog(parent: Window?, flags: DialogFlags, type: MessageType, buttons: ButtonsType, message: String, value: String) : MessageDialog(parent, flags, type, buttons, message) { @@ -7,7 +8,7 @@ class StringInputDialog(parent: Window?, flags: DialogFlags, type: MessageType, init { (messageArea as Box).append(entry) - entry.text = value + entry.kText = value } val input: String get() = entry.text diff --git a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/GeneralTab.kt b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/GeneralTab.kt index 75ee020..d46a6c3 100644 --- a/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/GeneralTab.kt +++ b/launcher-gtk/src/main/kotlin/io/gitlab/jfronny/inceptum/gtk/window/settings/instance/GeneralTab.kt @@ -8,10 +8,7 @@ import io.gitlab.jfronny.inceptum.common.MetaHolder import io.gitlab.jfronny.inceptum.common.Utils import io.gitlab.jfronny.inceptum.gtk.control.ILabel import io.gitlab.jfronny.inceptum.gtk.control.settings.SectionedSettingsTab -import io.gitlab.jfronny.inceptum.gtk.util.I18n -import io.gitlab.jfronny.inceptum.gtk.util.Memory -import io.gitlab.jfronny.inceptum.gtk.util.markup -import io.gitlab.jfronny.inceptum.gtk.util.toTypedArray +import io.gitlab.jfronny.inceptum.gtk.util.* import io.gitlab.jfronny.inceptum.launcher.api.FabricMetaApi import io.gitlab.jfronny.inceptum.launcher.api.McApi import io.gitlab.jfronny.inceptum.launcher.system.instance.InstanceList @@ -150,7 +147,7 @@ class GeneralTab(window: InstanceSettingsWindow) : SectionedSettingsTab if (responseId == ResponseType.ACCEPT.value) { val file = dialog.file!!.path - if (file != null) entry.text = file + if (file != null) entry.kText = file } } dialog.show()