chore: perform more actions in the builder stage for simpleDialog
This commit is contained in:
parent
98cc37405a
commit
e14294fdd6
|
@ -78,30 +78,25 @@ object GtkEnvBackend : EnvBackend {
|
||||||
.message(title)
|
.message(title)
|
||||||
.detail(markup)
|
.detail(markup)
|
||||||
.modal(true)
|
.modal(true)
|
||||||
.build()
|
|
||||||
when {
|
when {
|
||||||
cancel == null -> {
|
cancel == null -> dialog.buttons(arrayOf(I18n["ok"]))
|
||||||
dialog.setButtons(arrayOf(I18n["ok"]))
|
.defaultButton(0)
|
||||||
dialog.defaultButton = 0
|
.cancelButton(-1)
|
||||||
dialog.cancelButton = -1
|
ok == null -> dialog.buttons(arrayOf("Cancel"))
|
||||||
}
|
.defaultButton(-1)
|
||||||
ok == null -> {
|
.cancelButton(0)
|
||||||
dialog.setButtons(arrayOf("Cancel"))
|
else -> dialog.buttons(arrayOf("OK", "Cancel"))
|
||||||
dialog.defaultButton = -1
|
.defaultButton(0)
|
||||||
dialog.cancelButton = 0
|
.cancelButton(1)
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
dialog.setButtons(arrayOf("OK", "Cancel"))
|
|
||||||
dialog.defaultButton = 0
|
|
||||||
dialog.cancelButton = 1
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
dialog.choose(parent, Cancellable()) { _, res, _ ->
|
dialog.build().apply {
|
||||||
val result = dialog.chooseFinish(res)
|
choose(parent, Cancellable()) { _, res, _ ->
|
||||||
val cancelIdx = dialog.cancelButton
|
val result = chooseFinish(res)
|
||||||
val defaultIdx = dialog.defaultButton
|
val cancelIdx = cancelButton
|
||||||
if (result == cancelIdx) cancel?.run()
|
val defaultIdx = defaultButton
|
||||||
if (result == defaultIdx) ok?.run()
|
if (result == cancelIdx) cancel?.run()
|
||||||
|
if (result == defaultIdx) ok?.run()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue