Repository
Current version released
2 years ago
Deno GI
Deno port of Gnome libraries (such as Gtk).
Early Stage and Unstable
Usage
You must specify --allow-ffi
and --unstable
flags to run your program.
deno run --unstable --allow-ffi <file>
Loading a library
Import libraries from gir.deno.dev
to load them.
Loading Gtk:
import Gtk from "https://gir.deno.dev/Gtk-4.0";
Creating Objects
Objects are initialized using creation functions or javascript constructors.
Creating a GtkButton:
const button = Gtk.Button.newWithLabel("Click Me!");
or
const button = new Gtk.Button({ label: "Click Me!" });
Signals
Signals are connected using on
method.
Connecting clicked
signal to a button:
button.on("clicked", () => {
console.log("Clicked");
});
Example
import Gtk from "https://gir.deno.dev/Gtk-4.0";
const app = new Gtk.Application();
app.on("activate", () => {
const win = new Gtk.ApplicationWindow({ application: app });
const contentArea = new Gtk.Box();
const label = new Gtk.Label({ label: "Hello World!" });
contentArea.append(label);
win.setChild(contentArea);
win.show();
});
app.run([]);
See more examples on examples folder.
Dependencies
Deno GI depends on gobject-introspection
.
Fedora
dnf install gobject-introspection
Ubuntu
apt install gobject-introspection
Arch
pacman -S gobject-introspection
macOS
brew install gobject-introspection
Windows
- Install MSYS2.
- Add
C:\msys64\mingw64\bin
to system path. - Run in msys shell:
pacman -S mingw-w64-x86_64-gobject-introspection
Additional libraries such as gtk4
and libadwaita
are used in examples.
Their installation process is the same as gobject-introspection
.