├── .gitignore ├── .gradle ├── 5.6.3 │ ├── executionHistory │ │ ├── executionHistory.bin │ │ └── executionHistory.lock │ ├── fileChanges │ │ └── last-build.bin │ ├── fileHashes │ │ ├── fileHashes.bin │ │ └── fileHashes.lock │ └── gc.properties ├── buildOutputCleanup │ ├── buildOutputCleanup.lock │ ├── cache.properties │ └── outputFiles.bin └── vcs-1 │ └── gc.properties ├── .idea ├── codeStyles │ ├── Project.xml │ └── codeStyleConfig.xml ├── gradle.xml ├── misc.xml ├── modules.xml └── workspace.xml ├── README.md ├── application-screenshot.png ├── build.gradle ├── build └── g_resources │ ├── glibresources.a │ ├── glibresources.c │ ├── glibresources.gresource.xml │ ├── glibresources.h │ ├── glibresources.o │ ├── layout │ └── main.ui │ └── raw │ ├── cloudy.png │ ├── partly_cloudy.png │ ├── rain.png │ ├── rain_light.png │ └── sunny.png ├── builder-screenshot.png ├── gradle.properties ├── gradle └── wrapper │ └── gradle-wrapper.properties ├── settings.gradle └── src ├── linuxMain ├── kotlin │ └── sample │ │ ├── CUrl.kt │ │ ├── GtkHelpers │ │ └── Application.kt │ │ ├── GtkThreads.kt │ │ ├── JsonExtension.kt │ │ ├── SampleLinux.kt │ │ ├── SharedPreferences │ │ └── IO.kt │ │ └── WeatherAPI.kt └── resources │ ├── layout │ ├── main.ui │ ├── main.ui~ │ └── menu.ui │ └── raw │ ├── cloudy.png │ ├── partly_cloudy.png │ ├── rain.png │ ├── rain_light.png │ ├── rain_s_sunny.png │ ├── sleet.png │ ├── snow.png │ ├── sunny.png │ └── thunderstorms.png └── nativeInterop └── cinterop └── libgtk3.def /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | build 3 | .gradle 4 | -------------------------------------------------------------------------------- /.gradle/5.6.3/executionHistory/executionHistory.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/.gradle/5.6.3/executionHistory/executionHistory.bin -------------------------------------------------------------------------------- /.gradle/5.6.3/executionHistory/executionHistory.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/.gradle/5.6.3/executionHistory/executionHistory.lock -------------------------------------------------------------------------------- /.gradle/5.6.3/fileChanges/last-build.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gradle/5.6.3/fileHashes/fileHashes.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/.gradle/5.6.3/fileHashes/fileHashes.bin -------------------------------------------------------------------------------- /.gradle/5.6.3/fileHashes/fileHashes.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/.gradle/5.6.3/fileHashes/fileHashes.lock -------------------------------------------------------------------------------- /.gradle/5.6.3/gc.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/.gradle/5.6.3/gc.properties -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/buildOutputCleanup.lock: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/.gradle/buildOutputCleanup/buildOutputCleanup.lock -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/cache.properties: -------------------------------------------------------------------------------- 1 | #Sat Nov 02 19:00:58 IST 2019 2 | gradle.version=5.6.3 3 | -------------------------------------------------------------------------------- /.gradle/buildOutputCleanup/outputFiles.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/.gradle/buildOutputCleanup/outputFiles.bin -------------------------------------------------------------------------------- /.gradle/vcs-1/gc.properties: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/.gradle/vcs-1/gc.properties -------------------------------------------------------------------------------- /.idea/codeStyles/Project.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | 7 | 9 | 10 | -------------------------------------------------------------------------------- /.idea/codeStyles/codeStyleConfig.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/gradle.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 21 | 22 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 1572699100434 164 | 168 | 169 | 170 | 171 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # kotlin-native-gtk-linux 2 | Sample IntelliJ project for GTK+3 using Kotlin/Native 3 | 4 | To build use ../gradlew assemble. Do not forget to install GTK3. See bellow. 5 | 6 | > **Info:** Work of Kotlin Gtk library in progress.. 7 | 8 | #### GTK3 Install 9 | 10 | on Debian flavours of Linux 11 | 12 | sudo apt-get install libgtk-3-dev 13 | 14 | on Fedora 15 | 16 | sudo dnf install gtk3-devel 17 | 18 | 19 | If error occures shows missing file libtinfo.so.5 20 | 21 | > **Solution:** Put "libtinfo.so.5" file to /lib64 (for 64bit) or /lib (for 32bit) folder 22 | 23 | > **Note:** For fedora users file will be found in libncurses5-32bit-6.1-16.1.x86_64.rpm. For debian users file is in libncurses5-dev package. 24 | 25 | #### Application Screenshot 26 | 27 | ![ScreenShot of Application](https://raw.githubusercontent.com/kavanmevada/kotlin-native-gtk-linux/master/application-screenshot.png) 28 | 29 | 30 | ## Info 31 | 32 | Install GNOME Builder to edit layout file (builder.ui) 33 | 34 | ![ScreenShot of GNOME Builder](https://raw.githubusercontent.com/kavanmevada/kotlin-native-gtk-linux/master/builder-screenshot.png) 35 | 36 | -------------------------------------------------------------------------------- /application-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/application-screenshot.png -------------------------------------------------------------------------------- /build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'org.jetbrains.kotlin.multiplatform' version '1.3.50' 3 | } 4 | repositories { 5 | mavenCentral() 6 | } 7 | kotlin { 8 | // For ARM, should be changed to iosArm32 or iosArm64 9 | // For Linux, should be changed to e.g. linuxX64 10 | // For MacOS, should be changed to e.g. macosX64 11 | // For Windows, should be changed to e.g. mingwX64 12 | linuxX64("linux") { 13 | binaries { 14 | executable { 15 | // Change to specify fully qualified name of your application's entry point: 16 | entryPoint = 'sample.main' 17 | // Specify command-line arguments, if necessary: 18 | runTask?.args('') 19 | } 20 | } 21 | } 22 | sourceSets { 23 | // Note: To enable common source sets please comment out 'kotlin.import.noCommonSourceSets' property 24 | // in gradle.properties file and re-import your project in IDE. 25 | linuxMain { 26 | } 27 | linuxTest { 28 | } 29 | } 30 | } 31 | 32 | // Use the following Gradle tasks to run your application: 33 | // :runReleaseExecutableLinux - without debug symbols 34 | // :runDebugExecutableLinux - with debug symbols 35 | 36 | build { 37 | 38 | //Generate Resource File 39 | mkdir("$buildDir/g_resources/") 40 | ext.outputFile = file("$buildDir/g_resources/glibresources.gresource.xml") 41 | outputFile.text = "" 42 | outputFile.text += "\n" 43 | 44 | 45 | //kotlin.linuxX64("linux").compilations.main.freeCompilerArgs = mutableListOf("-include-binary", "$buildDir/libui.a") 46 | 47 | 48 | 49 | kotlin.linuxX64("linux").compilations.main { 50 | cinterops { 51 | libgtk3 52 | } 53 | } 54 | 55 | kotlin.sourceSets.linuxMain.resources.srcDirs.each { src -> 56 | 57 | outputFile.text += "\n " 58 | fileTree("${src.path}/layout").filter { it.name.endsWith('.ui') }.files.each { file -> 59 | outputFile.text += "\n layout/${file.name}" 60 | 61 | copy { 62 | from file.path 63 | into "$buildDir/g_resources/layout" 64 | } 65 | } 66 | outputFile.text += "\n " 67 | 68 | 69 | outputFile.text += "\n " 70 | fileTree("${src.path}/raw").filter { it.isFile() }.files.each { file -> 71 | outputFile.text += "\n raw/${file.name}" 72 | 73 | copy { 74 | from file.path 75 | into "$buildDir/g_resources/raw" 76 | } 77 | } 78 | outputFile.text += "\n " 79 | } 80 | 81 | outputFile.text += "\n" 82 | 83 | 84 | 85 | 86 | exec { 87 | workingDir "$buildDir/g_resources" 88 | executable 'glib-compile-resources' args "glibresources.gresource.xml", "--generate-source", "--target=glibresources.c" 89 | } 90 | 91 | exec { 92 | workingDir "$buildDir/g_resources" 93 | executable 'glib-compile-resources' args "glibresources.gresource.xml", "--generate-header", "--target=glibresources.h" 94 | } 95 | 96 | 97 | exec { 98 | workingDir "$buildDir/g_resources" 99 | executable 'bash' args '-c', 'sed -i -e "s:gio.h>:gio.h>\\n#include \\"glibresources.h\\":" glibresources.c' 100 | } 101 | 102 | 103 | exec { 104 | workingDir "$buildDir/g_resources" 105 | executable 'gcc' args '-c', "-I$buildDir/g_resources", '-c', "-I/usr/include/glib-2.0", '-c', "-I/usr/lib64/glib-2.0/include", 'glibresources.c', '-o', 'glibresources.o' 106 | } 107 | 108 | 109 | exec { 110 | workingDir "$buildDir/g_resources" 111 | executable 'ar' args 'rcs', 'glibresources.a', 'glibresources.o' 112 | } 113 | } -------------------------------------------------------------------------------- /build/g_resources/glibresources.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/build/g_resources/glibresources.a -------------------------------------------------------------------------------- /build/g_resources/glibresources.gresource.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | layout/main.ui 5 | layout/menu.ui 6 | 7 | 8 | raw/partly_cloudy.png 9 | raw/rain.png 10 | raw/rain_light.png 11 | raw/cloudy.png 12 | raw/sunny.png 13 | raw/snow.png 14 | raw/thunderstorms.png 15 | raw/rain_s_sunny.png 16 | raw/sleet.png 17 | 18 | -------------------------------------------------------------------------------- /build/g_resources/glibresources.h: -------------------------------------------------------------------------------- 1 | #ifndef __RESOURCE_glibresources_H__ 2 | #define __RESOURCE_glibresources_H__ 3 | 4 | #include 5 | 6 | extern GResource *glibresources_get_resource (void); 7 | #endif 8 | -------------------------------------------------------------------------------- /build/g_resources/glibresources.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/build/g_resources/glibresources.o -------------------------------------------------------------------------------- /build/g_resources/layout/main.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | 18 8 | 9 | 10 | 11 | 12 | 13 | True 14 | False 15 | vertical 16 | 17 | 18 | True 19 | False 20 | center 21 | 22 | 23 | True 24 | True 25 | True 26 | center 27 | London 28 | 29 | 30 | False 31 | True 32 | 0 33 | 34 | 35 | 36 | 37 | True 38 | False 39 | go-down-symbolic 40 | 41 | 42 | False 43 | True 44 | 1 45 | 46 | 47 | 48 | 49 | False 50 | True 51 | 0 52 | 53 | 54 | 55 | 56 | True 57 | False 58 | 34 59 | center 60 | 61 | 62 | 63 | 64 | 65 | 66 | False 67 | True 68 | 1 69 | 70 | 71 | 72 | 73 | True 74 | False 75 | center 76 | center 77 | 16 78 | 79 | 80 | 81 | 82 | 83 | 84 | False 85 | True 86 | 2 87 | 88 | 89 | 90 | 91 | True 92 | False 93 | 94 | 95 | False 96 | True 97 | 4 98 | 3 99 | 100 | 101 | 102 | 103 | True 104 | False 105 | 106 | 107 | False 108 | True 109 | 4 110 | 4 111 | 112 | 113 | 114 | 115 | 578 116 | True 117 | True 118 | center 119 | center 120 | 68 121 | 34 122 | True 123 | True 124 | never 125 | never 126 | True 127 | 128 | 129 | True 130 | False 131 | center 132 | center 133 | none 134 | 135 | 136 | True 137 | False 138 | center 139 | center 140 | 8 141 | 8 142 | 16 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | False 177 | False 178 | 5 179 | 180 | 181 | 182 | 183 | 184 | 185 | False 186 | start 187 | 8 188 | Add Location 189 | False 190 | True 191 | True 192 | dialog 193 | False 194 | window 195 | 196 | 197 | 198 | 199 | 200 | False 201 | start 202 | vertical 203 | 2 204 | 205 | 206 | False 207 | 18 208 | end 209 | 210 | 211 | gtk-add 212 | True 213 | True 214 | True 215 | True 216 | 217 | 218 | True 219 | True 220 | 0 221 | 222 | 223 | 224 | 225 | False 226 | False 227 | 0 228 | 229 | 230 | 231 | 232 | True 233 | False 234 | vertical 235 | 236 | 237 | True 238 | False 239 | start 240 | Search 241 | 242 | 243 | False 244 | True 245 | 0 246 | 247 | 248 | 249 | 250 | True 251 | True 252 | 8 253 | none 254 | 255 | 256 | False 257 | True 258 | 1 259 | 260 | 261 | 262 | 263 | False 264 | True 265 | 1 266 | 267 | 268 | 269 | 270 | 271 | 272 | False 273 | 8 274 | button1 275 | 276 | 277 | True 278 | False 279 | vertical 280 | 4 281 | 282 | 283 | True 284 | True 285 | True 286 | Add New 287 | 288 | 289 | False 290 | True 291 | 2 292 | 293 | 294 | 295 | 296 | 297 | 298 | -------------------------------------------------------------------------------- /build/g_resources/raw/cloudy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/build/g_resources/raw/cloudy.png -------------------------------------------------------------------------------- /build/g_resources/raw/partly_cloudy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/build/g_resources/raw/partly_cloudy.png -------------------------------------------------------------------------------- /build/g_resources/raw/rain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/build/g_resources/raw/rain.png -------------------------------------------------------------------------------- /build/g_resources/raw/rain_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/build/g_resources/raw/rain_light.png -------------------------------------------------------------------------------- /build/g_resources/raw/sunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/build/g_resources/raw/sunny.png -------------------------------------------------------------------------------- /builder-screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/builder-screenshot.png -------------------------------------------------------------------------------- /gradle.properties: -------------------------------------------------------------------------------- 1 | kotlin.code.style=official 2 | kotlin.import.noCommonSourceSets=true -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.3-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists -------------------------------------------------------------------------------- /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'weather' 2 | 3 | -------------------------------------------------------------------------------- /src/linuxMain/kotlin/sample/CUrl.kt: -------------------------------------------------------------------------------- 1 | package sample 2 | 3 | import kotlinx.cinterop.* 4 | import libgtk3.* 5 | import platform.posix.* 6 | 7 | 8 | fun curl_read_all_content(url: String) : String? { 9 | initRuntimeIfNeeded() 10 | 11 | val memory = StringBuilder() 12 | curl_global_init(CURL_GLOBAL_ALL) 13 | val curl = curl_easy_init() 14 | curl_easy_setopt(curl, CURLOPT_URL, url) 15 | 16 | curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, staticCFunction { 17 | contents: CPointer?, size: size_t, nmemb: size_t, userp : COpaquePointer? -> 18 | initRuntimeIfNeeded() 19 | val mem = userp?.asStableRef()?.get() 20 | mem?.append(contents?.toKString()) 21 | return@staticCFunction size * nmemb 22 | }) 23 | 24 | curl_easy_setopt(curl, CURLOPT_WRITEDATA, StableRef.create(memory).asCPointer()) 25 | curl_easy_setopt(curl, CURLOPT_USERAGENT, "libcurl-agent/1.0") 26 | 27 | val error = curl_easy_perform(curl) 28 | curl_easy_cleanup(curl) 29 | curl_global_cleanup() 30 | 31 | return if (error==0u) memory.toString() else null 32 | } 33 | 34 | 35 | fun CPointer?.connect(name: String,function: () -> Unit) { 36 | g_signal_connect_data(this, name, staticCFunction { pointer: COpaquePointer?, data: gpointer? -> 37 | data?.asStableRef<() -> Unit>()?.get()?.let { it() } 38 | null as COpaquePointer? 39 | }.reinterpret(), StableRef.create(function).asCPointer(), null, 0U) 40 | } 41 | 42 | fun CPointer?.connect(name: String, function: () -> Unit) = this?.reinterpret().connect(name, function) 43 | 44 | fun GtkStringList(vararg array: String): CPointer? { 45 | val store = gtk_list_store_new (1, G_TYPE_STRING) 46 | 47 | memScoped { 48 | val iter = alloc() 49 | array.forEach { 50 | gtk_list_store_append (store, iter.ptr) 51 | gtk_list_store_set (store, iter.ptr, 0, it, -1) 52 | } 53 | } 54 | return store 55 | } -------------------------------------------------------------------------------- /src/linuxMain/kotlin/sample/GtkHelpers/Application.kt: -------------------------------------------------------------------------------- 1 | package sample.GtkHelpers 2 | 3 | import kotlinx.cinterop.* 4 | import libgtk3.* 5 | import platform.posix.exit 6 | 7 | 8 | 9 | abstract class Application(id: String, gApplicationFlagsNone: GApplicationFlags) { 10 | 11 | var builder: CPointer? = null 12 | var application: CPointer? = null 13 | val application_id = id 14 | 15 | abstract fun onActivate(app: CPointer) 16 | 17 | init { 18 | glibresources_get_resource() 19 | gtk_application_new(application_id, gApplicationFlagsNone)?.let { application = it } 20 | g_signal_connect_data(application?.reinterpret(), "activate", staticCFunction { app: CPointer, data: COpaquePointer? -> 21 | data?.asStableRef<(CPointer) -> Unit>()?.get()?.let { it(app) } 22 | null as COpaquePointer? 23 | }.reinterpret(), StableRef.create(::onActivate).asCPointer(), null, 0u) 24 | } 25 | 26 | fun run(args: Array) { 27 | memScoped { 28 | val status = g_application_run(application?.reinterpret(), args.size, args.map { it.cstr.ptr }.toCValues()) 29 | g_object_unref(application) 30 | 31 | exit(status) 32 | } 33 | } 34 | 35 | fun setContentView(templatePath: String) { 36 | builder = gtk_builder_new_from_resource(templatePath) 37 | val builderObjs = gtk_builder_get_objects(builder) 38 | 39 | val length = g_slist_length(builderObjs?.reinterpret()).toInt() 40 | (0 .. length).forEach { 41 | val element = g_slist_nth_data(builderObjs?.reinterpret(), it.toUInt()) 42 | if (gtk_widget_get_name(element?.reinterpret())?.toKString() == "GtkWindow") { 43 | gtk_application_add_window(application, element?.reinterpret()) 44 | gtk_widget_show(element?.reinterpret()) 45 | } 46 | } 47 | 48 | } 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /src/linuxMain/kotlin/sample/GtkThreads.kt: -------------------------------------------------------------------------------- 1 | package sample 2 | 3 | import kotlinx.cinterop.* 4 | import libgtk3.gdk_threads_add_idle 5 | import platform.posix.* 6 | import kotlin.native.concurrent.freeze 7 | 8 | 9 | fun createThread(f0 : () -> Unit) : pthread_t { 10 | val thread_id = memScoped { alloc() } 11 | pthread_create(thread_id.ptr, null, staticCFunction { pointer: COpaquePointer? -> 12 | initRuntimeIfNeeded() 13 | pointer?.asStableRef<() -> Unit>()?.get()?.invoke() 14 | 15 | null as COpaquePointer? 16 | }.reinterpret(), StableRef.create(f0.freeze()).asCPointer()) 17 | return thread_id.value 18 | } 19 | 20 | fun pthread_t.after(func: (id: pthread_t, value: COpaquePointer?) -> Unit) { 21 | val result = memScoped { alloc() }.apply { 22 | pthread_join(this@after, this.ptr) 23 | }.value 24 | func(this@after, result) 25 | } 26 | 27 | val pthread_t.isrunning get() = (pthread_kill(this, 0) == 0) 28 | val pthread_t.cancel get() = pthread_cancel(this) 29 | 30 | fun pthread_t.await() : COpaquePointer? { 31 | return memScoped { alloc() }.apply { 32 | platform.posix.pthread_join(this@await, this.ptr) 33 | }.value 34 | } 35 | 36 | 37 | fun gtk_ideal(f0 : () -> Unit) { 38 | gdk_threads_add_idle(staticCFunction { pointer: COpaquePointer? -> 39 | pointer?.asStableRef<() -> Unit>()?.get()?.invoke() 40 | 41 | null as COpaquePointer? 42 | }.reinterpret(), StableRef.create(f0.freeze()).asCPointer()) 43 | } 44 | -------------------------------------------------------------------------------- /src/linuxMain/kotlin/sample/JsonExtension.kt: -------------------------------------------------------------------------------- 1 | package sample 2 | 3 | 4 | import kotlinx.cinterop.* 5 | import libgtk3.* 6 | 7 | 8 | fun JSON(string: String): CPointer? { 9 | val parser = json_parser_new() 10 | val bool = json_parser_load_from_data(parser, string, string.length.convert(), null) 11 | return json_parser_get_root(parser) 12 | } 13 | 14 | 15 | 16 | fun CPointer?.get() = json_node_get_parent(this) 17 | 18 | fun CPointer?.asArray() = json_node_get_array(this) 19 | fun CPointer?.asObject() = json_node_get_object(this) 20 | 21 | 22 | 23 | 24 | fun CPointer?.forEachObjets(func: (CPointer) -> Unit) { 25 | val arraySize = json_array_get_length(this).toUInt() 26 | var i = 0u 27 | while (i < arraySize) { 28 | json_array_get_object_element(this, i)?.let { func(it) } 29 | i++ 30 | } 31 | } 32 | 33 | 34 | 35 | 36 | fun CPointer.getObject(index: Int) = json_array_get_object_element(this, index.toUInt()) 37 | fun CPointer.getArray(index: Int) = json_array_get_array_element(this, index.toUInt()) 38 | 39 | fun CPointer.getObject(key: String) = json_object_get_object_member(this, key) 40 | fun CPointer.getArray(key: String) = json_object_get_array_member(this, key) 41 | 42 | fun CPointer.getInt(key: String) = json_object_get_int_member(this, key).toInt() 43 | fun CPointer.getDouble(key: String) = json_object_get_double_member(this, key).toDouble() 44 | fun CPointer.getString(key: String) = json_object_get_string_member(this, key)?.toKString() 45 | fun CPointer.getBoolean(key: String) = json_object_get_boolean_member(this, key) == TRUE -------------------------------------------------------------------------------- /src/linuxMain/kotlin/sample/SampleLinux.kt: -------------------------------------------------------------------------------- 1 | package sample 2 | 3 | import kotlinx.cinterop.* 4 | import libgtk3.* 5 | import platform.posix.* 6 | import sample.GtkHelpers.Application 7 | import sample.SharedPreferences.getSharedPreferences 8 | 9 | 10 | class SampleLinux(s: String, gApplicationFlagsNone: GApplicationFlags) : Application(s, gApplicationFlagsNone) { 11 | 12 | override fun onActivate(app: CPointer) { 13 | setContentView("/org/gtk/example/layout/main.ui") 14 | 15 | 16 | val window = gtk_application_get_active_window(application) 17 | gtk_window_set_title(window, "Weather") 18 | 19 | 20 | 21 | val preferences = getSharedPreferences() 22 | 23 | 24 | val currentSelected = "London" 25 | 26 | val location_list = gtk_builder_get_object(builder, "location_list") 27 | gtk_model_button_new().apply { 28 | g_object_set (this?.reinterpret(), "text", currentSelected, NULL); 29 | gtk_container_add(location_list?.reinterpret(), this) 30 | gtk_widget_show(this) 31 | } 32 | 33 | 34 | val location_btn = gtk_builder_get_object(builder, "button1")?.reinterpret() 35 | location_btn.connect("clicked") { 36 | println("damini") 37 | val popover = gtk_builder_get_object(builder, "location_menu") 38 | val dialog = gtk_builder_get_object(builder, "add_location_dialog") 39 | gtk_builder_get_object(builder, "add_new").apply { 40 | connect("clicked") { 41 | gtk_widget_show(dialog?.reinterpret()) 42 | } 43 | 44 | val editView = gtk_builder_get_object(builder, "find_location") 45 | val completion = gtk_entry_completion_new (); 46 | gtk_entry_set_completion (editView?.reinterpret(), completion) 47 | g_object_unref (completion) 48 | 49 | 50 | val add_btn = gtk_builder_get_object(builder, "add_btn") 51 | add_btn.connect("clicked") { 52 | gtk_entry_get_text(editView?.reinterpret())?.toKString()?.let { 53 | setLocation(builder, it) 54 | } 55 | } 56 | 57 | 58 | 59 | editView.connect("changed") { 60 | val entry_text = gtk_entry_get_text(editView?.reinterpret())?.toKString() 61 | createThread { 62 | val result = curl_read_all_content("https://www.metaweather.com/api/location/search/?query=$entry_text") 63 | 64 | //val completion_model = GtkStringList("Entry1", "Entry2", "Entry3", "Entry1", "Entry2", "Entry3") 65 | 66 | val completion_model = gtk_list_store_new (1, G_TYPE_STRING) 67 | memScoped { 68 | val iter = alloc() 69 | JSON(result!!).asArray().forEachObjets { 70 | gtk_list_store_append(completion_model, iter.ptr) 71 | gtk_list_store_set(completion_model, iter.ptr, 0, it.getString("title"), -1) 72 | } 73 | } 74 | 75 | gtk_ideal { 76 | gtk_entry_completion_set_model (completion, completion_model?.reinterpret()); 77 | g_object_unref (completion_model); 78 | gtk_entry_completion_set_text_column(completion, 0) 79 | } 80 | } 81 | } 82 | setLocation(builder, "London") 83 | } 84 | 85 | gtk_widget_show(popover?.reinterpret()) 86 | gtk_widget_set_visible(popover?.reinterpret(), TRUE) 87 | } 88 | 89 | 90 | } 91 | 92 | 93 | 94 | 95 | fun setLocation(builder: CPointer?, place: String) { 96 | createThread { 97 | val woeid = WeatherAPI.queryLocation(place) 98 | val weekForcast = WeatherAPI.getWeatherInfo(woeid.get(0).woeid) 99 | 100 | val todayInfo = weekForcast.get(0) 101 | 102 | gtk_ideal { 103 | gtk_label_set_text(gtk_builder_get_object(builder, "the_temp")?.reinterpret(), "${todayInfo.currentTemp.toInt()}°") 104 | gtk_label_set_text(gtk_builder_get_object(builder, "day_place")?.reinterpret(), "${todayInfo.dayOfWeek} - ${woeid.get(0).name}") 105 | gtk_label_set_text(gtk_builder_get_object(builder, "weather_state_name")?.reinterpret(), "${todayInfo.weatherState}") 106 | gtk_label_set_text(gtk_builder_get_object(builder, "more_detailed")?.reinterpret(), "High: ${todayInfo.maxTemp.toInt()}° Low: ${todayInfo.minTemp.toInt()}° Precip: 0%") 107 | 108 | 109 | val weekGridView = gtk_builder_get_object(builder, "week_detail_grid") 110 | weekForcast.drop(1).forEachIndexed { index, dayInfo -> 111 | gtk_grid_attach(weekGridView?.reinterpret(), createElement(dayInfo.dayOfWeek.substring(0,3), dayInfo.weatherStateAbbr, dayInfo.maxTemp.toInt().toString(), dayInfo.minTemp.toInt().toString())?.reinterpret(), index, 0, 1, 1) 112 | } 113 | gtk_widget_show_all(weekGridView?.reinterpret()) 114 | 115 | //val settings = g_settings_new ("org.gtk.Demo") 116 | //g_settings_set(settings, "current", place) 117 | //g_settings_set_string(settings, "current", place) 118 | } 119 | } 120 | } 121 | 122 | 123 | 124 | } 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | /** Main Method **/ 133 | fun main(args: Array) { 134 | SampleLinux("com.gtk.example", G_APPLICATION_FLAGS_NONE).run(args) 135 | } -------------------------------------------------------------------------------- /src/linuxMain/kotlin/sample/SharedPreferences/IO.kt: -------------------------------------------------------------------------------- 1 | package sample.SharedPreferences 2 | 3 | import kotlinx.cinterop.* 4 | import libgtk3.g_get_home_dir 5 | import platform.posix.* 6 | import sample.GtkHelpers.Application 7 | 8 | 9 | fun Application.getSharedPreferences(name: String = "test.txt"): Int { 10 | val home = g_get_home_dir()?.toKString() 11 | val path = "$home/.var/app/$application_id/$name" 12 | val fd = open(path, O_RDWR or O_CREAT) 13 | 14 | 15 | 16 | 17 | readline(fd) 18 | 19 | appendline(path, "key4", "value4") 20 | 21 | 22 | //appendline(path, "lmnopqrst") 23 | 24 | 25 | 26 | // memScoped { 27 | // println(contentSize) 28 | // val bytes = allocArray(contentSize) 29 | // val content = read(fd, bytes, contentSize.convert()) 30 | // } 31 | 32 | 33 | 34 | 35 | 36 | return fd 37 | 38 | } 39 | 40 | 41 | fun readline(fd: Int) { 42 | val buffer = nativeHeap.allocArray(1) 43 | 44 | var bytesRead: ssize_t = 0 45 | while (read(fd, buffer + bytesRead, 1.convert()) > 0) { bytesRead += 1 } 46 | 47 | 48 | //Read lines 49 | val map = hashMapOf() 50 | buffer.readBytes(bytesRead.convert()).toKString().split("\n").dropLast(1).forEach { 51 | it.split("=").let { 52 | map[it.first()] = it.last() 53 | } 54 | } 55 | 56 | println(map) 57 | 58 | 59 | // while (bytes.value != 10) { 60 | // read(fd, bytes.ptr, 1uL) 61 | // if (bytes.value != 10) builder.append(bytes.value.toChar()) 62 | // } 63 | } 64 | 65 | fun appendline(path: String, key: String, value: String){ 66 | val fd = open(path, O_RDWR or O_APPEND or O_CREAT) 67 | write(fd, "$key=$value".cstr, ((key+value).length+1).convert()) 68 | } 69 | 70 | -------------------------------------------------------------------------------- /src/linuxMain/kotlin/sample/WeatherAPI.kt: -------------------------------------------------------------------------------- 1 | package sample 2 | 3 | import kotlinx.cinterop.CPointer 4 | import kotlinx.cinterop.reinterpret 5 | import libgtk3.* 6 | 7 | object WeatherAPI { 8 | 9 | data class Place(val name: String,val woeid: Int) 10 | data class WeatherInfo( 11 | val currentTemp: Double, 12 | val maxTemp: Double, 13 | val minTemp: Double, 14 | val weatherState: String, 15 | val weatherStateAbbr: String, 16 | val windSpeed: Double, 17 | val humidity: Double, 18 | val dayOfWeek: String 19 | ) 20 | 21 | fun queryLocation(placeName: String): ArrayList { 22 | val hashMap = arrayListOf() 23 | curl_read_all_content("https://www.metaweather.com/api/location/search/?query=$placeName")?.let { jsonString -> 24 | JSON(jsonString).asArray()?.forEachObjets { 25 | val place = it.getString("title")!! 26 | val woeid = it.getInt("woeid") 27 | hashMap.add(Place(placeName, woeid)) 28 | } 29 | } 30 | return hashMap 31 | } 32 | 33 | fun getWeatherInfo(woeid: Int): ArrayList { 34 | val infoArray = arrayListOf() 35 | 36 | curl_read_all_content( "https://www.metaweather.com/api/location/$woeid/")?.let { jsonString -> 37 | JSON(jsonString).asObject()?.getArray("consolidated_weather").forEachObjets { 38 | val currentTemp= it.getDouble("the_temp") 39 | val maxTemp = it.getDouble("max_temp") 40 | val minTemp = it.getDouble("min_temp") 41 | val weatherState = it.getString("weather_state_name") 42 | val weatherStateAbbr = it.getString("weather_state_abbr") 43 | val windSpeed = it.getDouble("wind_speed") 44 | val humidity = it.getDouble("humidity") 45 | val dayOfWeek = it.getString("applicable_date")?.getWeekDay() 46 | 47 | infoArray.add( WeatherInfo(currentTemp, maxTemp, minTemp, weatherState ?: "", weatherStateAbbr ?: "", windSpeed, humidity, dayOfWeek ?: "") ) 48 | } 49 | } 50 | return infoArray 51 | } 52 | 53 | } 54 | 55 | 56 | /* Universal Extionsion */ 57 | fun String.getWeekDay(): String? { 58 | val dayOfWeek = g_date_time_get_day_of_week( 59 | g_date_time_new_local( 60 | substring(0, 4).toInt(), 61 | substring(5, 7).toInt(), 62 | substring(8, 10).toInt(), 63 | 0, 0, 0.0 64 | ) 65 | ) 66 | return when(dayOfWeek) { 67 | 1 -> "Monday" 68 | 2 -> "Tuesday" 69 | 3 -> "Wednesday" 70 | 4 -> "Thursday" 71 | 5 -> "Friday" 72 | 6 -> "Saturday" 73 | 7 -> "Sunday" 74 | else -> null 75 | } 76 | } 77 | 78 | 79 | fun createElement(weekDay: String, state: String, maxT: String, minT: String): CPointer? { 80 | 81 | val gtkGrid = gtk_grid_new() 82 | gtk_widget_set_margin_left(gtkGrid?.reinterpret(), 16) 83 | gtk_widget_set_margin_right(gtkGrid?.reinterpret(), 16) 84 | gtk_widget_set_margin_top(gtkGrid?.reinterpret(), 8) 85 | gtk_widget_set_margin_bottom(gtkGrid?.reinterpret(), 8) 86 | gtk_grid_set_row_spacing(gtkGrid?.reinterpret(), 4) 87 | 88 | val dayLabel = gtk_label_new(weekDay) 89 | gtk_grid_attach(gtkGrid?.reinterpret(), dayLabel, 0, 0,1, 1) 90 | 91 | 92 | val icon = when(state) { 93 | "sl" -> "sleet" 94 | "lc" -> "partly_cloudy" 95 | "hc" -> "cloudy" 96 | "c" -> "sunny" 97 | "sn" -> "snow" 98 | "t" -> "thunderstorms" 99 | "hr" -> "rain" 100 | "lr" -> "rain_light" 101 | "s" -> "rain_s_sunny" 102 | "h" -> "snow" 103 | else -> null 104 | } 105 | 106 | val pixbuf = gtk_image_new_from_resource("/org/gtk/example/raw/$icon.png") 107 | gtk_grid_attach(gtkGrid?.reinterpret(), pixbuf?.reinterpret(), 0, 1,1, 1) 108 | 109 | val dayMaxMin = gtk_label_new("$maxT° $minT°") 110 | gtk_grid_attach(gtkGrid?.reinterpret(), dayMaxMin, 0, 2,1, 1) 111 | 112 | return gtkGrid 113 | } -------------------------------------------------------------------------------- /src/linuxMain/resources/layout/main.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | 18 8 | 9 | 10 | 11 | 12 | 13 | True 14 | False 15 | vertical 16 | 17 | 18 | True 19 | False 20 | center 21 | 22 | 23 | True 24 | True 25 | True 26 | center 27 | London 28 | 29 | 30 | False 31 | True 32 | 0 33 | 34 | 35 | 36 | 37 | True 38 | False 39 | go-down-symbolic 40 | 41 | 42 | False 43 | True 44 | 1 45 | 46 | 47 | 48 | 49 | False 50 | True 51 | 0 52 | 53 | 54 | 55 | 56 | True 57 | False 58 | 34 59 | center 60 | 61 | 62 | 63 | 64 | 65 | 66 | False 67 | True 68 | 1 69 | 70 | 71 | 72 | 73 | True 74 | False 75 | center 76 | center 77 | 16 78 | 79 | 80 | 81 | 82 | 83 | 84 | False 85 | True 86 | 2 87 | 88 | 89 | 90 | 91 | True 92 | False 93 | 94 | 95 | False 96 | True 97 | 4 98 | 3 99 | 100 | 101 | 102 | 103 | True 104 | False 105 | 106 | 107 | False 108 | True 109 | 4 110 | 4 111 | 112 | 113 | 114 | 115 | 578 116 | True 117 | True 118 | center 119 | center 120 | 68 121 | 34 122 | True 123 | True 124 | never 125 | never 126 | True 127 | 128 | 129 | True 130 | False 131 | center 132 | center 133 | none 134 | 135 | 136 | True 137 | False 138 | center 139 | center 140 | 8 141 | 8 142 | 16 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | False 177 | False 178 | 5 179 | 180 | 181 | 182 | 183 | 184 | 185 | False 186 | start 187 | 8 188 | Add Location 189 | False 190 | True 191 | True 192 | dialog 193 | False 194 | window 195 | 196 | 197 | 198 | 199 | 200 | False 201 | start 202 | vertical 203 | 2 204 | 205 | 206 | False 207 | 18 208 | end 209 | 210 | 211 | gtk-add 212 | True 213 | True 214 | True 215 | True 216 | 217 | 218 | True 219 | True 220 | 0 221 | 222 | 223 | 224 | 225 | False 226 | False 227 | 0 228 | 229 | 230 | 231 | 232 | True 233 | False 234 | vertical 235 | 236 | 237 | True 238 | False 239 | start 240 | Search 241 | 242 | 243 | False 244 | True 245 | 0 246 | 247 | 248 | 249 | 250 | True 251 | True 252 | 8 253 | none 254 | 255 | 256 | False 257 | True 258 | 1 259 | 260 | 261 | 262 | 263 | False 264 | True 265 | 1 266 | 267 | 268 | 269 | 270 | 271 | 272 | False 273 | 8 274 | button1 275 | 276 | 277 | True 278 | False 279 | vertical 280 | 4 281 | 282 | 283 | True 284 | True 285 | True 286 | Add New 287 | 288 | 289 | False 290 | True 291 | 2 292 | 293 | 294 | 295 | 296 | 297 | 298 | -------------------------------------------------------------------------------- /src/linuxMain/resources/layout/main.ui~: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | False 7 | 18 8 | 9 | 10 | 11 | 12 | 13 | True 14 | False 15 | vertical 16 | 17 | 18 | True 19 | False 20 | center 21 | 22 | 23 | True 24 | True 25 | True 26 | center 27 | London 28 | 29 | 30 | False 31 | True 32 | 0 33 | 34 | 35 | 36 | 37 | True 38 | False 39 | go-down-symbolic 40 | 41 | 42 | False 43 | True 44 | 1 45 | 46 | 47 | 48 | 49 | False 50 | True 51 | 0 52 | 53 | 54 | 55 | 56 | True 57 | False 58 | 34 59 | center 60 | 61 | 62 | 63 | 64 | 65 | 66 | False 67 | True 68 | 1 69 | 70 | 71 | 72 | 73 | True 74 | False 75 | center 76 | center 77 | 16 78 | 79 | 80 | 81 | 82 | 83 | 84 | False 85 | True 86 | 2 87 | 88 | 89 | 90 | 91 | True 92 | False 93 | 94 | 95 | False 96 | True 97 | 4 98 | 3 99 | 100 | 101 | 102 | 103 | True 104 | False 105 | 106 | 107 | False 108 | True 109 | 4 110 | 4 111 | 112 | 113 | 114 | 115 | 578 116 | True 117 | True 118 | center 119 | center 120 | 68 121 | 34 122 | True 123 | True 124 | never 125 | never 126 | True 127 | 128 | 129 | True 130 | False 131 | center 132 | center 133 | none 134 | 135 | 136 | True 137 | False 138 | center 139 | center 140 | 8 141 | 8 142 | 16 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | False 177 | False 178 | 5 179 | 180 | 181 | 182 | 183 | 184 | 185 | False 186 | start 187 | 8 188 | Add Location 189 | True 190 | True 191 | dialog 192 | window 193 | 194 | 195 | 196 | 197 | 198 | False 199 | start 200 | vertical 201 | 2 202 | 203 | 204 | False 205 | 18 206 | end 207 | 208 | 209 | gtk-add 210 | True 211 | True 212 | True 213 | True 214 | 215 | 216 | True 217 | True 218 | 0 219 | 220 | 221 | 222 | 223 | False 224 | False 225 | 0 226 | 227 | 228 | 229 | 230 | True 231 | False 232 | vertical 233 | 234 | 235 | True 236 | False 237 | start 238 | Search 239 | 240 | 241 | False 242 | True 243 | 0 244 | 245 | 246 | 247 | 248 | True 249 | True 250 | 8 251 | none 252 | 253 | 254 | False 255 | True 256 | 1 257 | 258 | 259 | 260 | 261 | False 262 | True 263 | 1 264 | 265 | 266 | 267 | 268 | 269 | 270 | False 271 | 8 272 | button1 273 | 274 | 275 | True 276 | False 277 | vertical 278 | 4 279 | 280 | 281 | True 282 | True 283 | True 284 | Add New 285 | 286 | 287 | False 288 | True 289 | 2 290 | 291 | 292 | 293 | 294 | 295 | 296 | -------------------------------------------------------------------------------- /src/linuxMain/resources/layout/menu.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | John 14 | Doe 15 | 25 16 | This is the John Doe row 17 | 18 | 19 | Mary 20 | Unknown 21 | 50 22 | This is the Mary Unknown row 23 | 24 | 25 | 26 | 27 | Builder demo 28 | gtk3-demo 29 | 30 | 31 | 32 | 33 | 34 | 250 35 | 440 36 | Builder 37 | 38 | 39 | 1 40 | 41 | 42 | 1 43 | 44 | 45 | The menubar 46 | 47 | 48 | 49 | 50 | 1 51 | _File 52 | 1 53 | 54 | 55 | 56 | 57 | 1 58 | _New 59 | 1 60 | 61 | 62 | 63 | 64 | 1 65 | _Open 66 | 1 67 | 68 | 69 | 70 | 71 | 1 72 | _Save 73 | 1 74 | 75 | 76 | 77 | 78 | 1 79 | Save _As 80 | 1 81 | 82 | 83 | 84 | 85 | 86 | 1 87 | 88 | 89 | 90 | 91 | 1 92 | _Quit 93 | 1 94 | win.quit 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 1 104 | _Edit 105 | 1 106 | 107 | 108 | 109 | 110 | 1 111 | _Copy 112 | 1 113 | 114 | 115 | 116 | 117 | 1 118 | _Cut 119 | 1 120 | 121 | 122 | 123 | 124 | 1 125 | _Paste 126 | 1 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 1 136 | _Help 137 | 1 138 | 139 | 140 | 141 | 142 | 1 143 | _Help 144 | 1 145 | win.help 146 | 147 | 148 | 149 | 150 | 1 151 | _About 152 | 1 153 | win.about 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 0 163 | 164 | 165 | 166 | 167 | 1 168 | 169 | 170 | The toolbar 171 | 172 | 173 | 174 | 175 | 1 176 | New 177 | Create a new file 178 | document-new 179 | 180 | 181 | 182 | 183 | 1 184 | Open 185 | Open a file 186 | document-open 187 | 188 | 189 | 190 | 191 | 1 192 | Save 193 | Save a file 194 | document-save 195 | 1 196 | 197 | 198 | 199 | 200 | 1 201 | 202 | 203 | 204 | 205 | 1 206 | Copy 207 | Copy selected object into the clipboard 208 | edit-copy 209 | 210 | 211 | 212 | 213 | 1 214 | Cut 215 | Cut selected object into the clipboard 216 | edit-cut 217 | 218 | 219 | 220 | 221 | 1 222 | Paste 223 | Paste object from the clipboard 224 | edit-paste 225 | 226 | 227 | 228 | 229 | 0 230 | 1 231 | 232 | 233 | 234 | 235 | in 236 | 1 237 | 238 | 239 | 1 240 | liststore1 241 | 3 242 | 243 | 244 | Name list 245 | 246 | A list of person with name, surname and age columns 247 | 248 | 249 | 250 | 251 | 252 | Name 253 | 254 | 255 | 256 | 0 257 | 258 | 259 | 260 | 261 | 262 | 263 | Surname 264 | 265 | 266 | 267 | 1 268 | 269 | 270 | 271 | 272 | 273 | 274 | Age 275 | 276 | 277 | 278 | 2 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 2 288 | 1 289 | 290 | 291 | 292 | 293 | 1 294 | 295 | 296 | 3 297 | 0 298 | 299 | 300 | 301 | 302 | 303 | 304 | 305 | -------------------------------------------------------------------------------- /src/linuxMain/resources/raw/cloudy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/src/linuxMain/resources/raw/cloudy.png -------------------------------------------------------------------------------- /src/linuxMain/resources/raw/partly_cloudy.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/src/linuxMain/resources/raw/partly_cloudy.png -------------------------------------------------------------------------------- /src/linuxMain/resources/raw/rain.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/src/linuxMain/resources/raw/rain.png -------------------------------------------------------------------------------- /src/linuxMain/resources/raw/rain_light.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/src/linuxMain/resources/raw/rain_light.png -------------------------------------------------------------------------------- /src/linuxMain/resources/raw/rain_s_sunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/src/linuxMain/resources/raw/rain_s_sunny.png -------------------------------------------------------------------------------- /src/linuxMain/resources/raw/sleet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/src/linuxMain/resources/raw/sleet.png -------------------------------------------------------------------------------- /src/linuxMain/resources/raw/snow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/src/linuxMain/resources/raw/snow.png -------------------------------------------------------------------------------- /src/linuxMain/resources/raw/sunny.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/src/linuxMain/resources/raw/sunny.png -------------------------------------------------------------------------------- /src/linuxMain/resources/raw/thunderstorms.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kavan-mevada/kotlin-native-gtk-linux/c854ea4b6ad1746624eed524b91979efa2c9d322/src/linuxMain/resources/raw/thunderstorms.png -------------------------------------------------------------------------------- /src/nativeInterop/cinterop/libgtk3.def: -------------------------------------------------------------------------------- 1 | headers = "glibresources.h" "curl.h" "json-glib/json-glib.h" "gtk/gtk.h" 2 | compilerOpts ="-Ibuild/g_resources" "-I/usr/include/glib-2.0" "-I/usr/lib64/glib-2.0/include" "-I/usr/include/pango-1.0" "-I/usr/include/harfbuzz" "-I/usr/include/cairo" "-I/usr/include/gdk-pixbuf-2.0" "-I/usr/include/atk-1.0" "-I/usr/include/json-glib-1.0" "-I/usr/include/gtk-3.0/gtk" "-I/usr/include/gtk-3.0" "-I/usr/include/curl" 3 | staticLibraries = glibresources.a 4 | libraryPaths = build/g_resources 5 | linkerOpts.linux = -L/usr/lib64 -L/usr/lib/x86_64-linux-gnu -lglib-2.0 -lgdk-3 -lgtk-3 -lgio-2.0 -lgobject-2.0 -ljson-glib-1.0 -lcurl 6 | 7 | 8 | --- 9 | 10 | /// Required dependencies 11 | /// glib2-devel - [ for command glib-compile-resources ] 12 | /// ncurses-compat-libs 13 | /// libcurl-devel 14 | /// gtk3-devel 15 | /// json-glib-devel --------------------------------------------------------------------------------