Created
October 23, 2019 10:48
-
-
Save kavan-mevada/4ecca633c15024304f4019c81ac1457a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package sample | |
import glibresources.* | |
import kotlinx.cinterop.* | |
import libgtk3.* | |
import libgtk3.G_APPLICATION_FLAGS_NONE | |
var builder: CPointer<GtkBuilder>? = null | |
fun incrementProgressBar() { | |
println("Inside thread ... ") | |
g_idle_add(staticCFunction { _: CPointer<GtkApplication> -> | |
println("Thread compsadasdasdleted...") | |
println(builder) | |
return@staticCFunction FALSE | |
}.reinterpret(), null) | |
println("Thread completed...") | |
} | |
@ExperimentalUnsignedTypes | |
fun main(args: Array<String>) { | |
glibresources_get_resource() | |
val app = gtk_application_new("org.gtk.example", G_APPLICATION_FLAGS_NONE) | |
builder = gtk_builder_new() | |
gtk_builder_set_application(builder?.reinterpret(), app?.reinterpret()) | |
memScoped { | |
val argc = alloc<IntVar>().apply { value = args.size } | |
val argv = alloc<CPointerVar<CPointerVar<ByteVar>>>().apply { | |
value = args.map { it.cstr.ptr }.toCValues().ptr | |
} | |
gtk_init(argc.ptr, argv.ptr) | |
} | |
if(gtk_builder_add_from_resource(builder, "/org/gtk/example/layout/simple.ui", null) == 1u){ | |
val mainWindow = gtk_builder_get_object(builder, "window")?.reinterpret<GtkWidget>() | |
libgtk3.g_signal_connect_object(mainWindow, "destroy", staticCFunction { _: CPointer<GtkApplication> -> | |
gtk_main_quit() }.reinterpret(), null, 0u) | |
g_thread_new(null , staticCFunction(::incrementProgressBar).reinterpret(), null) | |
gtk_main() | |
gtk_widget_show_all(mainWindow?.reinterpret()) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment