Small cleanup in demos (#572)
This commit is contained in:
@@ -28,24 +28,23 @@ fun <F : CFunction<*>> g_signal_connect(obj: CPointer<*>, actionName: String,
|
||||
fun activate(app: CPointer<GtkApplication>?, user_data: gpointer?) {
|
||||
val windowWidget = gtk_application_window_new(app)!!
|
||||
val window = windowWidget.reinterpret<GtkWindow>()
|
||||
gtk_window_set_title(window, "Window");
|
||||
gtk_window_set_title(window, "Window")
|
||||
gtk_window_set_default_size(window, 200, 200)
|
||||
|
||||
val button_box = gtk_button_box_new(
|
||||
GtkOrientation.GTK_ORIENTATION_HORIZONTAL)!!
|
||||
gtk_container_add(window.reinterpret(), button_box);
|
||||
gtk_container_add(window.reinterpret(), button_box)
|
||||
|
||||
val button = gtk_button_new_with_label("Konan говорит: click me!")!!
|
||||
g_signal_connect(button, "clicked",
|
||||
staticCFunction { widget: CPointer<GtkApplication>?, data: gpointer? ->
|
||||
println("Hi Kotlin")
|
||||
});
|
||||
staticCFunction { _: CPointer<GtkWidget>?, _: gpointer? -> println("Hi Kotlin")
|
||||
})
|
||||
g_signal_connect(button, "clicked",
|
||||
staticCFunction { widget: CPointer<GtkWidget>? ->
|
||||
gtk_widget_destroy(widget)
|
||||
},
|
||||
window, G_CONNECT_SWAPPED)
|
||||
gtk_container_add (button_box.reinterpret(), button);
|
||||
gtk_container_add (button_box.reinterpret(), button)
|
||||
|
||||
gtk_widget_show_all(windowWidget)
|
||||
}
|
||||
|
||||
@@ -194,13 +194,7 @@ fun acceptClientsAndRun(serverFd: Int, block: suspend Client.() -> Unit) {
|
||||
}
|
||||
}
|
||||
|
||||
class IOException: RuntimeException {
|
||||
constructor() : super() {
|
||||
}
|
||||
|
||||
constructor(message: String): super(message) {
|
||||
}
|
||||
}
|
||||
class IOException(message: String): RuntimeException(message)
|
||||
|
||||
val errno: Int
|
||||
get() = interop_errno()
|
||||
|
||||
@@ -19,11 +19,14 @@ Run the server:
|
||||
|
||||
./EchoServer.kexe 3000 &
|
||||
|
||||
Test the server by conecting to it, for example with telnet:
|
||||
Test the server by connecting to it, for example with telnet:
|
||||
|
||||
telnet localhost 3000
|
||||
|
||||
Write something to console and watch server echoing it back.
|
||||
Concurrently connect from another terminal. Note that each connection gets its own
|
||||
connection id prefixed to echo response.
|
||||
|
||||
|
||||
~~Quit telnet by pressing ctrl+] ctrl+D~~
|
||||
|
||||
|
||||
Reference in New Issue
Block a user