From 6746e42037f5aa867d077ab745e304aa89dad419 Mon Sep 17 00:00:00 2001 From: Andreas Tennert Date: Sun, 10 Jan 2021 18:11:14 +0100 Subject: [PATCH] refactor: distribute 'stuff' --- .../atennert/lcarsde/statusbar/StatusBar.kt | 2 + .../configuration/readConfiguration.kt | 5 +- .../atennert/lcarsde/statusbar/constants.kt | 8 ++ .../lcarsde/statusbar/executeCommand.kt | 28 ++++++ .../statusbar/extensions/gtkExtentions.kt | 20 ++++ .../statusbar/extensions/stringExtensions.kt | 35 +++++++ .../de/atennert/lcarsde/statusbar/readFile.kt | 20 ++++ .../de/atennert/lcarsde/statusbar/stuff.kt | 95 ------------------- .../lcarsde/statusbar/widgets/AudioWidget.kt | 5 +- .../statusbar/widgets/BatteryWidget.kt | 2 +- .../lcarsde/statusbar/widgets/ButtonWidget.kt | 4 +- .../statusbar/widgets/CpuUsageWidget.kt | 23 ++--- .../lcarsde/statusbar/widgets/EmptyWidget.kt | 2 +- .../statusbar/widgets/EthernetWidget.kt | 2 +- .../statusbar/widgets/RadarGraphWidget.kt | 2 +- .../statusbar/widgets/StardateWidget.kt | 2 +- .../statusbar/widgets/StatusFillerWidget.kt | 2 +- .../lcarsde/statusbar/widgets/TextWidget.kt | 2 +- .../lcarsde/statusbar/widgets/WifiWidget.kt | 3 +- src/nativeMain/kotlin/main.kt | 7 +- 20 files changed, 146 insertions(+), 123 deletions(-) create mode 100644 src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/constants.kt create mode 100644 src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/executeCommand.kt create mode 100644 src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/extensions/gtkExtentions.kt create mode 100644 src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/extensions/stringExtensions.kt create mode 100644 src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/readFile.kt delete mode 100644 src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/stuff.kt diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/StatusBar.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/StatusBar.kt index a29beb6..0466b29 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/StatusBar.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/StatusBar.kt @@ -2,6 +2,8 @@ package de.atennert.lcarsde.statusbar import de.atennert.lcarsde.statusbar.configuration.WidgetConfiguration import de.atennert.lcarsde.statusbar.configuration.readConfiguration +import de.atennert.lcarsde.statusbar.extensions.gSignalConnect +import de.atennert.lcarsde.statusbar.extensions.setStyling import de.atennert.lcarsde.statusbar.widgets.EmptyWidget import de.atennert.lcarsde.statusbar.widgets.StatusFillerWidget import de.atennert.lcarsde.statusbar.widgets.StatusWidget diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/configuration/readConfiguration.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/configuration/readConfiguration.kt index ac64751..c445222 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/configuration/readConfiguration.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/configuration/readConfiguration.kt @@ -1,9 +1,8 @@ package de.atennert.lcarsde.statusbar.configuration -import de.atennert.lcarsde.statusbar.toKString -import de.atennert.lcarsde.statusbar.toUByteArray +import de.atennert.lcarsde.statusbar.extensions.toKString +import de.atennert.lcarsde.statusbar.extensions.toUByteArray import kotlinx.cinterop.* -import kotlinx.cinterop.toKString import platform.posix.F_OK import platform.posix.access import platform.posix.getenv diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/constants.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/constants.kt new file mode 100644 index 0000000..c1c8b62 --- /dev/null +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/constants.kt @@ -0,0 +1,8 @@ +package de.atennert.lcarsde.statusbar + +const val CELL_SIZE = 40 +const val GAP_SIZE = 8 + +const val LCARSDE_STATUS_BAR = "LCARSDE_STATUS_BAR" + +const val STYLE_PATH = "/usr/share/lcarsde/status-bar/style.css" diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/executeCommand.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/executeCommand.kt new file mode 100644 index 0000000..37a5613 --- /dev/null +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/executeCommand.kt @@ -0,0 +1,28 @@ +package de.atennert.lcarsde.statusbar + +import kotlinx.cinterop.* +import statusbar.* + +fun executeCommand(command: String) { + val commandParts = command.split(' ') + + val byteArgs = commandParts.map { it.encodeToByteArray().pin() } + val convertedArgs = nativeHeap.allocArrayOfPointersTo(byteArgs.map { it.addressOf(0).pointed }) + when (fork()) { + -1 -> return + 0 -> { + if (setsid() == -1) { + perror("setsid failed") + exit(1) + } + + if (execvp(commandParts[0], convertedArgs) == -1) { + perror("execvp failed") + exit(1) + } + + exit(0) + } + } + byteArgs.map { it.unpin() } +} diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/extensions/gtkExtentions.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/extensions/gtkExtentions.kt new file mode 100644 index 0000000..24d894a --- /dev/null +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/extensions/gtkExtentions.kt @@ -0,0 +1,20 @@ +package de.atennert.lcarsde.statusbar.extensions + +import kotlinx.cinterop.CFunction +import kotlinx.cinterop.CPointer +import kotlinx.cinterop.reinterpret +import statusbar.* + +fun > gSignalConnect(obj: CPointer<*>, actionName: String, action: CPointer, + data: gpointer? = null, connect_flags: GConnectFlags = 0u) { + g_signal_connect_data(obj.reinterpret(), actionName, action.reinterpret(), data, + destroy_data = null, connect_flags = connect_flags) +} + +fun CPointer.setStyling(cssProvider: CPointer, vararg classes: String) { + val styleContext = gtk_widget_get_style_context(this) + for (cls in classes) { + gtk_style_context_add_class(styleContext, cls) + } + gtk_style_context_add_provider(styleContext, cssProvider.reinterpret(), GTK_STYLE_PROVIDER_PRIORITY_USER) +} diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/extensions/stringExtensions.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/extensions/stringExtensions.kt new file mode 100644 index 0000000..2870d62 --- /dev/null +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/extensions/stringExtensions.kt @@ -0,0 +1,35 @@ +package de.atennert.lcarsde.statusbar.extensions + +import kotlinx.cinterop.* +import kotlinx.cinterop.toKString + +/** Convert string to byte array as used in X properties */ +fun String.toUByteArray(): UByteArray { + return this.encodeToByteArray().asUByteArray() +} + +/** convert this ubyte array pointer to a string */ +fun CPointer.toKString(): String { + val byteString = mutableListOf() + var i = 0 + + while (true) { + val value = this[i] + if (value.convert() == 0) { + break + } + + byteString.add(value.convert()) + i++ + } + return byteString.toByteArray().toKString() +} + +/** convert this ubyte array pointer to a string */ +fun CPointer?.toKString(): String = this?.toKString() ?: "" + +/** print a float with a certain amount of places */ +fun Float.print(places: Int): String { + val flString = this.toString().split('.', limit = 2) + return "${flString[0]}.${flString[1].take(places)}" +} diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/readFile.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/readFile.kt new file mode 100644 index 0000000..b47ebc7 --- /dev/null +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/readFile.kt @@ -0,0 +1,20 @@ +package de.atennert.lcarsde.statusbar + +import kotlinx.cinterop.addressOf +import kotlinx.cinterop.toKString +import kotlinx.cinterop.usePinned + +fun readFile(path: String): String? { + platform.posix.fopen(path, "r")?. let { fp -> + var s = "" + val buf = ByteArray(1000) + buf.usePinned { + while (platform.posix.fgets(it.addressOf(0), 1000, fp) != null) { + s += it.get().toKString() + } + } + platform.posix.fclose(fp) + return s.trim() + } + return null +} diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/stuff.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/stuff.kt deleted file mode 100644 index 929574e..0000000 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/stuff.kt +++ /dev/null @@ -1,95 +0,0 @@ -package de.atennert.lcarsde.statusbar - -import kotlinx.cinterop.* -import statusbar.* - -const val CELL_SIZE = 40 -const val GAP_SIZE = 8 - -const val LCARSDE_STATUS_BAR = "LCARSDE_STATUS_BAR" - -const val STYLE_PATH = "/usr/share/lcarsde/status-bar/style.css" - -fun > gSignalConnect(obj: CPointer<*>, actionName: String, action: CPointer, - data: gpointer? = null, connect_flags: GConnectFlags = 0u) { - g_signal_connect_data(obj.reinterpret(), actionName, action.reinterpret(), data, - destroy_data = null, connect_flags = connect_flags) -} - -fun CPointer.setStyling(cssProvider: CPointer, vararg classes: String) { - val styleContext = gtk_widget_get_style_context(this) - for (cls in classes) { - gtk_style_context_add_class(styleContext, cls) - } - gtk_style_context_add_provider(styleContext, cssProvider.reinterpret(), GTK_STYLE_PROVIDER_PRIORITY_USER) -} - -/** Convert string to byte array as used in X properties */ -fun String.toUByteArray(): UByteArray { - return this.encodeToByteArray().asUByteArray() -} - -/** convert this ubyte array pointer to a string */ -fun CPointer.toKString(): String { - val byteString = mutableListOf() - var i = 0 - - while (true) { - val value = this[i] - if (value.convert() == 0) { - break - } - - byteString.add(value.convert()) - i++ - } - return byteString.toByteArray().toKString() -} - -/** convert this ubyte array pointer to a string */ -fun CPointer?.toKString(): String = this?.toKString() ?: "" - -/** print a float with a certain amount of places */ -fun Float.print(places: Int): String { - val flString = this.toString().split('.', limit = 2) - return "${flString[0]}.${flString[1].take(places)}" -} - -fun readFile(path: String): String? { - platform.posix.fopen(path, "r")?. let { fp -> - var s = "" - val buf = ByteArray(1000) - buf.usePinned { - while (platform.posix.fgets(it.addressOf(0), 1000, fp) != null) { - s += it.get().toKString() - } - } - platform.posix.fclose(fp) - return s.trim() - } - return null -} - -fun executeCommand(command: String) { - val commandParts = command.split(' ') - - val byteArgs = commandParts.map { it.encodeToByteArray().pin() } - val convertedArgs = nativeHeap.allocArrayOfPointersTo(byteArgs.map { it.addressOf(0).pointed }) - when (fork()) { - -1 -> return - 0 -> { - if (setsid() == -1) { - perror("setsid failed") - exit(1) - } - - if (execvp(commandParts[0], convertedArgs) == -1) { - perror("execvp failed") - exit(1) - } - - exit(0) - } - } - byteArgs.map { it.unpin() } -} diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/AudioWidget.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/AudioWidget.kt index bfb698b..2cd26a6 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/AudioWidget.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/AudioWidget.kt @@ -1,7 +1,10 @@ package de.atennert.lcarsde.statusbar.widgets -import de.atennert.lcarsde.statusbar.* +import de.atennert.lcarsde.statusbar.CELL_SIZE +import de.atennert.lcarsde.statusbar.GAP_SIZE import de.atennert.lcarsde.statusbar.configuration.WidgetConfiguration +import de.atennert.lcarsde.statusbar.executeCommand +import de.atennert.lcarsde.statusbar.extensions.gSignalConnect import kotlinx.cinterop.* import statusbar.* diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/BatteryWidget.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/BatteryWidget.kt index b56b22b..ccf3362 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/BatteryWidget.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/BatteryWidget.kt @@ -1,7 +1,7 @@ package de.atennert.lcarsde.statusbar.widgets import de.atennert.lcarsde.statusbar.configuration.WidgetConfiguration -import de.atennert.lcarsde.statusbar.gSignalConnect +import de.atennert.lcarsde.statusbar.extensions.gSignalConnect import de.atennert.lcarsde.statusbar.readFile import kotlinx.cinterop.* import statusbar.* diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/ButtonWidget.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/ButtonWidget.kt index 98687b5..95acc87 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/ButtonWidget.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/ButtonWidget.kt @@ -2,8 +2,8 @@ package de.atennert.lcarsde.statusbar.widgets import de.atennert.lcarsde.statusbar.configuration.WidgetConfiguration import de.atennert.lcarsde.statusbar.executeCommand -import de.atennert.lcarsde.statusbar.gSignalConnect -import de.atennert.lcarsde.statusbar.setStyling +import de.atennert.lcarsde.statusbar.extensions.gSignalConnect +import de.atennert.lcarsde.statusbar.extensions.setStyling import kotlinx.cinterop.* import statusbar.* diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/CpuUsageWidget.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/CpuUsageWidget.kt index 1215d94..794926e 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/CpuUsageWidget.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/CpuUsageWidget.kt @@ -6,8 +6,8 @@ import kotlinx.cinterop.CPointer import statusbar.GtkCssProvider import statusbar.cairo_t -class CpuUsageWidget(widgetConfiguration: WidgetConfiguration, cssProvider: CPointer) - : RadarGraphWidget(widgetConfiguration, cssProvider, 500, 100) { +class CpuUsageWidget(widgetConfiguration: WidgetConfiguration, cssProvider: CPointer) : + RadarGraphWidget(widgetConfiguration, cssProvider, 500, 100) { private val attentionFreq = 60 private val warningFreq = 80 @@ -37,14 +37,14 @@ class CpuUsageWidget(widgetConfiguration: WidgetConfiguration, cssProvider: CPoi private fun getCpuUtilization(): List { val statData = readFile("/proc/stat")?.lines() ?: return emptyList() val cpuData = statData - .filter { it.startsWith("cpu") } - .drop(1) - .map { - it.trim() - .split(' ') - .drop(1) - .map(String::toFloat) - } + .filter { it.startsWith("cpu") } + .drop(1) + .map { + it.trim() + .split(' ') + .drop(1) + .map(String::toFloat) + } val idlesTotals = cpuData.map { Pair(it[3] + it[4], it.sum()) } val deltas = if (lastIdlesTotals.isEmpty()) { @@ -54,7 +54,8 @@ class CpuUsageWidget(widgetConfiguration: WidgetConfiguration, cssProvider: CPoi } lastIdlesTotals = idlesTotals - return deltas.map { (idle, total) -> try { + return deltas.map { (idle, total) -> + try { 100 * (1.0 - idle / total) } catch (e: ArithmeticException) { 100 * (1.0 - idle / 0.001) diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/EmptyWidget.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/EmptyWidget.kt index fca354a..be619af 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/EmptyWidget.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/EmptyWidget.kt @@ -1,7 +1,7 @@ package de.atennert.lcarsde.statusbar.widgets import de.atennert.lcarsde.statusbar.configuration.WidgetConfiguration -import de.atennert.lcarsde.statusbar.setStyling +import de.atennert.lcarsde.statusbar.extensions.setStyling import kotlinx.cinterop.CPointer import statusbar.GtkCssProvider import statusbar.gtk_label_new diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/EthernetWidget.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/EthernetWidget.kt index 73128f7..b5483bb 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/EthernetWidget.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/EthernetWidget.kt @@ -1,7 +1,7 @@ package de.atennert.lcarsde.statusbar.widgets import de.atennert.lcarsde.statusbar.configuration.WidgetConfiguration -import de.atennert.lcarsde.statusbar.gSignalConnect +import de.atennert.lcarsde.statusbar.extensions.gSignalConnect import de.atennert.lcarsde.statusbar.readFile import kotlinx.cinterop.* import statusbar.* diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/RadarGraphWidget.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/RadarGraphWidget.kt index 4546c79..590564e 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/RadarGraphWidget.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/RadarGraphWidget.kt @@ -1,7 +1,7 @@ package de.atennert.lcarsde.statusbar.widgets import de.atennert.lcarsde.statusbar.configuration.WidgetConfiguration -import de.atennert.lcarsde.statusbar.gSignalConnect +import de.atennert.lcarsde.statusbar.extensions.gSignalConnect import kotlinx.cinterop.* import statusbar.* import kotlin.math.PI diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/StardateWidget.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/StardateWidget.kt index 4e9303e..a865953 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/StardateWidget.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/StardateWidget.kt @@ -1,7 +1,7 @@ package de.atennert.lcarsde.statusbar.widgets import de.atennert.lcarsde.statusbar.configuration.WidgetConfiguration -import de.atennert.lcarsde.statusbar.print +import de.atennert.lcarsde.statusbar.extensions.print import kotlinx.cinterop.CPointer import statusbar.* diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/StatusFillerWidget.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/StatusFillerWidget.kt index 319ff56..051d7c8 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/StatusFillerWidget.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/StatusFillerWidget.kt @@ -1,7 +1,7 @@ package de.atennert.lcarsde.statusbar.widgets import de.atennert.lcarsde.statusbar.configuration.WidgetConfiguration -import de.atennert.lcarsde.statusbar.setStyling +import de.atennert.lcarsde.statusbar.extensions.setStyling import kotlinx.cinterop.CPointer import kotlinx.cinterop.reinterpret import statusbar.* diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/TextWidget.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/TextWidget.kt index f115073..7bd9d3c 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/TextWidget.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/TextWidget.kt @@ -1,7 +1,7 @@ package de.atennert.lcarsde.statusbar.widgets import de.atennert.lcarsde.statusbar.configuration.WidgetConfiguration -import de.atennert.lcarsde.statusbar.gSignalConnect +import de.atennert.lcarsde.statusbar.extensions.gSignalConnect import kotlinx.cinterop.* import statusbar.* diff --git a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/WifiWidget.kt b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/WifiWidget.kt index b1107c4..f353be1 100644 --- a/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/WifiWidget.kt +++ b/src/nativeMain/kotlin/de/atennert/lcarsde/statusbar/widgets/WifiWidget.kt @@ -1,12 +1,11 @@ package de.atennert.lcarsde.statusbar.widgets import de.atennert.lcarsde.statusbar.configuration.WidgetConfiguration -import de.atennert.lcarsde.statusbar.gSignalConnect +import de.atennert.lcarsde.statusbar.extensions.gSignalConnect import de.atennert.lcarsde.statusbar.readFile import kotlinx.cinterop.* import statusbar.* import kotlin.math.PI -import kotlin.math.max class WifiWidget(widgetConfiguration: WidgetConfiguration, cssProvider: CPointer) : StatusWidget(widgetConfiguration, cssProvider, 1000) { diff --git a/src/nativeMain/kotlin/main.kt b/src/nativeMain/kotlin/main.kt index 360130c..b81381e 100644 --- a/src/nativeMain/kotlin/main.kt +++ b/src/nativeMain/kotlin/main.kt @@ -1,11 +1,14 @@ import de.atennert.lcarsde.statusbar.StatusBar -import de.atennert.lcarsde.statusbar.gSignalConnect +import de.atennert.lcarsde.statusbar.extensions.gSignalConnect import kotlinx.cinterop.cValue import kotlinx.cinterop.cValuesOf import kotlinx.cinterop.staticCFunction import kotlinx.coroutines.delay import kotlinx.coroutines.runBlocking -import statusbar.* +import statusbar.gtk_events_pending +import statusbar.gtk_init +import statusbar.gtk_main_iteration +import statusbar.gtk_widget_show_all var stop = false