Gtk4DotNet 5.4.0
See the version list below for details.
dotnet add package Gtk4DotNet --version 5.4.0
NuGet\Install-Package Gtk4DotNet -Version 5.4.0
<PackageReference Include="Gtk4DotNet" Version="5.4.0" />
paket add Gtk4DotNet --version 5.4.0
#r "nuget: Gtk4DotNet, 5.4.0"
// Install Gtk4DotNet as a Cake Addin
#addin nuget:?package=Gtk4DotNet&version=5.4.0
// Install Gtk4DotNet as a Cake Tool
#tool nuget:?package=Gtk4DotNet&version=5.4.0
Gtk4DotNet
.Net 8 bindings for GTK 4
Gtk4DotNet uses a functional declarative approach to GTK4 similar to REACT or Kotlin Compose:
return Application
.New("org.gtk.example")
.OnActivate(app =>
app
.NewWindow()
.Title("Hello Gtk👍")
.SideEffect(win => win
.Child(
Grid
.New()
.Attach(
Button
.NewWithLabel("Button 1")
.OnClicked(() => WriteLine("Button1 clicked")), 0, 0, 1, 1)
.Attach(
Button
.NewWithLabel("Button 2")
.OnClicked(() => WriteLine("Button2 clicked")), 1, 0, 1, 1)
.Attach(
Button
.NewWithLabel("Quit")
.OnClicked(() => win.CloseWindow()), 0, 1, 2, 1)))
.Show())
.Run(0, IntPtr.Zero);
}
You don't have to use window.ui XML files for describing the UI, instead declare the UI declarative with C#.
Contained in this Repo are samples how to use Gtk4DotNet. All examples of the official GTK4 are transformed to C# with Gtk4DotNet.
Prerequisites
Ubuntu
- sudo apt install libgtk-4-dev
if you want to use WebView (WebKitGTK):
- sudo apt install libwebkitgtk-6.0-dev
if you want to use GTK resources
- sudo apt install libglib2.0-dev-bin
Installation of GTK Schema
sudo install -D ./Test/org.gtk.example.gschema.xml /usr/share/glib-2.0/schemas/
sudo glib-compile-schemas /usr/share/glib-2.0/schemas/
Usage
Look at the sample programs (https://github.com/uriegel/Gtk4DotNet/tree/Main/Test)
Checking if memory is being freed
To check if GObjects are being freed, just run
Widget.AddWeakRef(() => Console.WriteLine("... is being freed));
If this object is finalized, then the callback will be called.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net8.0
- CsTools (>= 7.16.1)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Gtk4DotNet:
Package | Downloads |
---|---|
WebWindowNetCore.Linux
A C# Webview Application for Linux similar to Electron based on GTK WebKit |
|
Gtk4DotNet.FSharp
.NET 8 F# Bindings for GTK 4, functional declarative similar to REACT or Kotlin Compose |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
6.1.0 | 130 | 4/29/2024 |
6.0.0 | 96 | 4/27/2024 |
5.4.0 | 109 | 4/20/2024 |
5.3.11 | 88 | 4/20/2024 |
5.3.10 | 82 | 4/20/2024 |
5.3.9 | 95 | 4/19/2024 |
5.3.8 | 103 | 3/26/2024 |
5.3.7 | 118 | 3/13/2024 |
5.3.6 | 151 | 1/20/2024 |
5.3.5 | 87 | 1/20/2024 |
5.3.4 | 127 | 1/7/2024 |
5.3.3 | 121 | 1/3/2024 |
5.3.2 | 111 | 1/2/2024 |
5.3.1 | 96 | 1/2/2024 |
5.3.0 | 104 | 1/2/2024 |
5.2.0 | 114 | 12/22/2023 |
5.1.0 | 99 | 12/22/2023 |
5.0.0 | 159 | 12/14/2023 |
4.0.0 | 96 | 12/13/2023 |
3.4.0 | 99 | 12/10/2023 |
3.3.1 | 99 | 12/10/2023 |
3.3.0 | 89 | 12/10/2023 |
3.2.0 | 92 | 12/9/2023 |
3.1.1 | 96 | 12/9/2023 |
3.1.0 | 93 | 12/9/2023 |
3.0.0 | 110 | 12/9/2023 |
2.0.0 | 110 | 11/28/2023 |
1.4.0 | 151 | 11/17/2023 |
1.3.3 | 81 | 11/16/2023 |
1.3.2 | 100 | 11/16/2023 |
1.3.1 | 96 | 11/16/2023 |
1.3.0 | 105 | 11/16/2023 |
1.2.1 | 118 | 10/29/2023 |
1.2.0 | 113 | 10/22/2023 |
1.1.0 | 161 | 4/24/2023 |
1.0.0 | 140 | 4/23/2023 |
Now .NET 8 is target platform, using Railway oriented programming with Result instead of exceptions (GFile)