Gtk4DotNet 1.3.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Gtk4DotNet --version 1.3.2
NuGet\Install-Package Gtk4DotNet -Version 1.3.2
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="1.3.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Gtk4DotNet --version 1.3.2
#r "nuget: Gtk4DotNet, 1.3.2"
#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.
// Install Gtk4DotNet as a Cake Addin
#addin nuget:?package=Gtk4DotNet&version=1.3.2

// Install Gtk4DotNet as a Cake Tool
#tool nuget:?package=Gtk4DotNet&version=1.3.2

Gtk4DotNet

.Net 6 bindings for GTK 4

Mostly functional approach like this:

using GtkDotNet;

using LinqTools;

return Application.Run("org.gtk.example", app =>
    Application
        .NewWindow(app)
        .SideEffect(win => win.SetTitle("Hello Gtk👍"))
        .SideEffect(win => win.SetChild(
            Grid
                .New()
                .SideEffect(g => g.Attach(
                    Button
                        .NewWithLabel("Button 1")
                        .SideEffect(btn => btn.SignalConnect("clicked", clicked))
                    , 0, 0, 1, 1))
                .SideEffect(g => g.Attach(
                    Button
                        .NewWithLabel("Button 2")
                        .SideEffect(btn => btn.SignalConnect("clicked", clicked))
                    , 1, 0, 1, 1))
                .SideEffect(g => g.Attach(
                    Button
                        .NewWithLabel("Quit")
                        .SideEffect(btn => btn.SignalConnect("clicked", () => win.Close()))
                    , 0, 1, 2, 1))
        ))
        .Show());

void clicked() => Console.WriteLine("Clicked button");    

Prerequisites

Ubuntu

  • sudo apt install libgtk-4-dev

for use with WebView only:

  • sudo apt install libwebkitgtk-6.0-dev

Installation of GTK Schema

    sudo install -D 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)

Checking if memory is being freed

To check if GObjects are being freed, just run

GObject.AddWeakRef(obj, (_, obj) => 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 net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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 106 4/29/2024
6.0.0 93 4/27/2024
5.4.0 107 4/20/2024
5.3.11 87 4/20/2024
5.3.10 81 4/20/2024
5.3.9 93 4/19/2024
5.3.8 101 3/26/2024
5.3.7 117 3/13/2024
5.3.6 149 1/20/2024
5.3.5 86 1/20/2024
5.3.4 126 1/7/2024
5.3.3 120 1/3/2024
5.3.2 110 1/2/2024
5.3.1 95 1/2/2024
5.3.0 103 1/2/2024
5.2.0 113 12/22/2023
5.1.0 98 12/22/2023
5.0.0 154 12/14/2023
4.0.0 94 12/13/2023
3.4.0 97 12/10/2023
3.3.1 98 12/10/2023
3.3.0 88 12/10/2023
3.2.0 91 12/9/2023
3.1.1 95 12/9/2023
3.1.0 92 12/9/2023
3.0.0 108 12/9/2023
2.0.0 108 11/28/2023
1.4.0 149 11/17/2023
1.3.3 80 11/16/2023
1.3.2 99 11/16/2023
1.3.1 95 11/16/2023
1.3.0 104 11/16/2023
1.2.1 117 10/29/2023
1.2.0 112 10/22/2023
1.1.0 160 4/24/2023
1.0.0 139 4/23/2023

Beginning...