Gtk4DotNet 6.5.4-beta5

This is a prerelease version of Gtk4DotNet.
There is a newer version of this package available.
See the version list below for details.
dotnet add package Gtk4DotNet --version 6.5.4-beta5
                    
NuGet\Install-Package Gtk4DotNet -Version 6.5.4-beta5
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Gtk4DotNet" Version="6.5.4-beta5" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Gtk4DotNet" Version="6.5.4-beta5" />
                    
Directory.Packages.props
<PackageReference Include="Gtk4DotNet" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Gtk4DotNet --version 6.5.4-beta5
                    
#r "nuget: Gtk4DotNet, 6.5.4-beta5"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Gtk4DotNet@6.5.4-beta5
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Gtk4DotNet&version=6.5.4-beta5&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Gtk4DotNet&version=6.5.4-beta5&prerelease
                    
Install as a Cake Tool

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

Necessary only depending on the version of Linux

if you want to use WebView (WebKitGTK) on Ubuntu 22.04:

  • sudo apt install libwebkitgtk-6.0-dev

With LibAdwaita

  • sudo apt install libadwaita-1-dev

Gtk4

  • sudo apt install libgtk-4-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 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.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (3)

Showing the top 3 NuGet packages that depend on Gtk4DotNet:

Package Downloads
WebWindowNetCore

A C# Webview Application for Windows and Linux similar to Electron based on WebView2 (Windows) and GTK WebKit (Linux)

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
7.0.65-beta-65 135 5/17/2025
7.0.64-beta-64 115 5/17/2025
7.0.63-beta-63 148 5/16/2025
7.0.62-beta-62 191 5/16/2025
7.0.61-beta-61 222 5/14/2025
7.0.60-beta-60 228 5/12/2025
7.0.59-beta-59 196 5/12/2025
7.0.58-beta-58 150 4/18/2025
7.0.57-beta-57 202 4/14/2025
7.0.56-beta-56 138 4/13/2025
7.0.55-beta-55 140 4/13/2025
7.0.54-beta-54 136 4/12/2025
7.0.53-beta-53 143 4/12/2025
7.0.52-beta-52 97 4/12/2025
7.0.51-beta-51 134 4/11/2025
7.0.50-beta-50 167 4/10/2025
7.0.49-beta-49 165 4/10/2025
7.0.48-beta-48 161 4/10/2025
7.0.47-beta-47 163 4/10/2025
7.0.46-beta-46 160 4/10/2025
7.0.45-beta-45 153 4/9/2025
7.0.44-beta-44 172 4/8/2025
7.0.43-beta-43 157 4/8/2025
7.0.42-beta-42 162 4/7/2025
7.0.41-beta-41 156 4/6/2025
7.0.40-beta-40 131 4/6/2025
7.0.39-beta-39 105 4/5/2025
7.0.38-beta-38 100 4/5/2025
7.0.37-beta-37 87 4/5/2025
7.0.36-beta-36 167 4/3/2025
7.0.35-beta-35 158 4/3/2025
7.0.34-beta-34 155 4/3/2025
7.0.33-beta-33 161 4/2/2025
7.0.32-beta-32 162 4/1/2025
7.0.31-beta-31 163 4/1/2025
7.0.30-beta-30 165 3/31/2025
7.0.29-beta-29 157 3/31/2025
7.0.28-beta-28 149 3/30/2025
7.0.27-beta-27 473 3/24/2025
7.0.26-beta-26 461 3/24/2025
7.0.25-beta-25 409 3/24/2025
7.0.24-beta-24 412 3/24/2025
7.0.23-beta-23 265 3/23/2025
7.0.22-beta-22 75 3/22/2025
7.0.21-beta-21 73 3/22/2025
7.0.20-beta-20 92 3/21/2025
7.0.19-beta-19 135 3/21/2025
7.0.18-beta-18 150 3/20/2025
7.0.17-beta-17 141 3/20/2025
7.0.16-beta-16 152 3/19/2025
7.0.15-beta-15 142 3/18/2025
7.0.14-beta-14 146 3/18/2025
7.0.13-beta-13 142 3/18/2025
7.0.12-beta-12 152 3/17/2025
7.0.11-beta-11 151 3/16/2025
7.0.10-beta-10 85 3/14/2025
7.0.9-beta-9 99 3/14/2025
7.0.8-beta-8 118 3/14/2025
7.0.7-beta-7 97 3/2/2025
7.0.6-beta-6 134 2/26/2025
7.0.5-beta-5 107 2/25/2025
7.0.4-beta-4 110 2/24/2025
7.0.3-beta-3 108 2/24/2025
7.0.2-beta-2 102 2/24/2025
7.0.1-beta-1 92 2/24/2025
7.0.0-beta-0 108 2/23/2025
6.8.1 242 2/15/2025
6.8.0 118 2/15/2025
6.7.1 197 2/8/2025
6.7.0 131 2/8/2025
6.6.1 115 2/8/2025
6.6.0 195 2/3/2025
6.5.6 132 2/2/2025
6.5.5 200 9/7/2024
6.5.4 262 8/31/2024
6.5.4-beta6 115 8/31/2024
6.5.4-beta5 116 8/31/2024
6.5.4-beta4 105 8/31/2024
6.5.4-beta3 114 8/31/2024
6.5.3 314 8/23/2024
6.5.3-beta3 110 8/31/2024
6.5.3-beta2 115 8/31/2024
6.5.3-beta1 107 8/31/2024
6.5.2 169 8/19/2024
6.5.1 152 8/19/2024
6.5.0 161 8/18/2024
6.4.0 169 8/13/2024
6.3.0 157 8/12/2024
6.2.1 182 8/11/2024
6.2.0 150 8/11/2024
6.1.3 168 8/10/2024
6.1.2 157 8/9/2024
6.1.1 147 8/9/2024
6.1.0 340 4/29/2024
6.0.0 155 4/27/2024
5.4.0 188 4/20/2024
5.3.11 154 4/20/2024
5.3.10 144 4/20/2024
5.3.9 165 4/19/2024
5.3.8 169 3/26/2024
5.3.7 164 3/13/2024
5.3.6 232 1/20/2024
5.3.5 160 1/20/2024
5.3.4 210 1/7/2024
5.3.3 186 1/3/2024
5.3.2 183 1/2/2024
5.3.1 165 1/2/2024
5.3.0 169 1/2/2024
5.2.0 188 12/22/2023
5.1.0 162 12/22/2023
5.0.0 249 12/14/2023
4.0.0 160 12/13/2023
3.4.0 158 12/10/2023
3.3.1 165 12/10/2023
3.3.0 145 12/10/2023
3.2.0 154 12/9/2023
3.1.1 153 12/9/2023
3.1.0 154 12/9/2023
3.0.0 179 12/9/2023
2.0.0 156 11/28/2023
1.4.0 224 11/17/2023
1.3.3 124 11/16/2023
1.3.2 150 11/16/2023
1.3.1 143 11/16/2023
1.3.0 157 11/16/2023
1.2.1 170 10/29/2023
1.2.0 163 10/22/2023
1.1.0 246 4/24/2023
1.0.0 215 4/23/2023

BackgroundColor in WebKit