6

GitHub - hristogochev/tray-gtk: Easily build GTK-3 status icons with Kotlin

 1 year ago
source link: https://github.com/hristogochev/tray-gtk
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

tray-gtk

Easily build GTK-3 status icons with Kotlin.

Usage

To use this library, add jitpack to your project's repositories:

maven { url = URI("https://jitpack.io") }

And then add the following dependency to your build.gradle.kts file:

implementation("com.github.hristogochev:tray-gtk:0.1.0")

Or if you want to use the most up to date commit version:

implementation("com.github.hristogochev:tray-gtk:master-SNAPSHOT")

Example

Preview

trayIcon(
    imagePath = "/path/to/tray/icon/image",
    visible = true,
    title = "GTK Tray Icon",
    tooltip = "GTK Tray Icon"
) {
    menu {
        item(
            text = "GTK Tray",
            enabled = false,
            imagePath = "/path/to/tray/menu/image"
        )
        separator()
        item(text = "Click me!") {
            action {
                println("Yey!")
            }
        }
        separator()
        checkbox(text = "Enable") {
            action {
                text = if (it) "Disable" else "Enable"
                println("Currently enabled: $it")
            }
        }
        separator()
        submenu(text = "Submenu") {
            item(text = "Hello")
            separator()
            item(text = "How")
            separator()
            item(text = "Are")
            separator()
            item(text = "You")
        }
        separator()
        item(text = "Exit") {
            action {
                exitProcess(0)
            }
        }
    }
}

Notes

  • Keeps an internal reference to all created tray icons in order to avoid garbage collection of GTK structs.

Building with ProGuard

When building with ProGuard make sure to add these to your proguard-rules.pro file

-keep class com.sun.jna.** { *; }
-keep class * implements com.sun.jna.** { *; }

License

Licensed under Apache-2.0 license.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK