Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/indoorvivants/scala-native-gtk-bindings

Scala Native bindings To Gtk4 C API
https://github.com/indoorvivants/scala-native-gtk-bindings

bindings gtk gtk4 scala scala-native scala3

Last synced: 2 months ago
JSON representation

Scala Native bindings To Gtk4 C API

Awesome Lists containing this project

README

        

# Gtk4 bindings for Scala 3 Native

## Installation

Make sure you have Gtk4 installed:

1. On MacOS, do `brew install gtk4`
2. On Debian-based Linux systems, you can do `sudo apt install libgtk-4-dev`

You can check the installation by running `pkg-config --cflags gtk4` - it should succeed.

The bindings are published to Maven central, with gtk4 specifically being available at the following coordinates:

[![Maven Central](https://img.shields.io/maven-central/v/com.indoorvivants.gnome/gtk4_native0.4_3.svg?label=Maven%20Central)](https://search.maven.org/artifact/com.indoorvivants.gnome/gtk4_native0.4_3/)

```
com.indoorvivants.gnome::gtk4:: // Scala CLI/Mill format
"com.indoorvivants.gnome" %%% "gtk4" % "" // SBT format
```

## Usage

This repository contains a very small app you can run.

```bash
$ pkg-config --cflags gtk4 | xargs -n1 > compilationFlags
$ pkg-config --libs gtk4 | xargs -n1 > linkingFlags

$ scala-cli run ./examples/src/main/scala/example.scala --native --native-compile @$PWD/compilationFlags --native-linking @$PWD/linkingFlags --dep com.indoorvivants.gnome::gtk4::0.0.4 # or change the version to latest
```

Bindings generated using [sn-bindgen](https://sn-bindgen.indoorvivants.com/)

![GtkBindingsDemo](https://user-images.githubusercontent.com/1052965/217792578-a4faa191-053b-48a7-aa2a-207709690fa1.gif)