Repository
Current version released
4 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
Loading a library is done by calling require function.
Loading Gtk:
import * as gi from "https://deno.land/x/deno_gi/mod.ts";
const Gtk = gi.require("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 * as gi from "https://deno.land/x/deno_gi/mod.ts";
const Gtk = gi.require("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.present();
});
app.run();See more examples on examples folder.
Dependencies
Deno GI depends on gobject-introspection.
Fedora
dnf install gobject-introspectionUbuntu
apt install gobject-introspectionArch
pacman -S gobject-introspectionmacOS
brew install gobject-introspectionWindows
- Install MSYS2.
- Add
C:\msys64\mingw64\binto system path. - Run in msys shell:
pacman -S mingw-w64-x86_64-gobject-introspectionAdditional libraries such as gtk4 and libadwaita are used in
examples. Their installation process is the same as
gobject-introspection.