Majorsilence.Forms.Gtk4 26.8.2

dotnet add package Majorsilence.Forms.Gtk4 --version 26.8.2
                    
NuGet\Install-Package Majorsilence.Forms.Gtk4 -Version 26.8.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="Majorsilence.Forms.Gtk4" Version="26.8.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Majorsilence.Forms.Gtk4" Version="26.8.2" />
                    
Directory.Packages.props
<PackageReference Include="Majorsilence.Forms.Gtk4" />
                    
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 Majorsilence.Forms.Gtk4 --version 26.8.2
                    
#r "nuget: Majorsilence.Forms.Gtk4, 26.8.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.
#:package Majorsilence.Forms.Gtk4@26.8.2
                    
#: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=Majorsilence.Forms.Gtk4&version=26.8.2
                    
Install as a Cake Addin
#tool nuget:?package=Majorsilence.Forms.Gtk4&version=26.8.2
                    
Install as a Cake Tool

Majorsilence.Forms.Gtk4

A GTK 4 platform backend for Majorsilence.Forms, built on the gir.core bindings.

Majorsilence.Forms does all of its own drawing with SkiaSharp; this backend is only the host — it creates a real Gtk.Window, runs the GLib main loop, delivers input, and presents the Skia surface through a Gtk.DrawingArea.

Install

dotnet add package Majorsilence.Forms
dotnet add package Majorsilence.Forms.Gtk4

You also need GTK 4 installed on the machine (libgtk-4-1 on Debian/Ubuntu, gtk4 on Fedora/Arch, brew install gtk4 on macOS, the GTK runtime on Windows). For WebBrowser / the webview-backed compat controls, also install WebKitGTK 6.0 (libwebkitgtk-6.0-4 on Debian/Ubuntu, webkitgtk6.0 on Fedora, webkitgtk on Arch).

Use it

Unlike the default (Avalonia) backend, the GTK 4 backend is selected explicitly:

using Majorsilence.Forms;
using Majorsilence.Forms.Gtk4;

Gtk4Application.Use ();                 // installs Gtk4PlatformBackend
Application.Run (new MainForm ());      // GLib main loop

What works

  • Real Gtk.Window per top-level Form, borderless windows for popups (menus, combo dropdowns).
  • Skia frame rendered straight into a Cairo image surface each paint.
  • Mouse (click / move / wheel), keyboard, and typed-text input via GTK event controllers.
  • GLib timers back Majorsilence.Forms.Timer; Post/Invoke marshal onto the GLib loop.
  • Clipboard text, multi-monitor Screen enumeration.
  • Custom-chrome window move/resize drags via Gdk.Toplevel.BeginMove/BeginResize.
  • ShowDialog gets a real transient-for / modal window relationship.
  • NativeControlHost — a real Gtk.Widget overlaid inside an MF scene (INativeControlHostBackend). GTK 4 composites every widget into one render tree, so there is no airspace problem.
  • WebBrowser / RadPdfViewer / RadRichTextEditor — IWebViewFactory backed by WebKitGTK 6.0 (GirCore.WebKit-6.0): navigation events, ExecuteScriptAsync, and a JS→host script-message bridge. Needs libwebkitgtk-6.0 installed at runtime (IsWebViewFunctional is false otherwise).

Embed in a host GTK app

The reverse direction — an existing Gtk.Application that wants to use MF objects as its own:

using Majorsilence.Forms.Gtk4;

// MF Control  → GTK widget
Gtk.Widget widget = myMfControl.ToGtkWidget ();          // or: new MajorsilenceFormsPresenter { Content = myMfControl }
someGtkBox.Append (widget);

// MF Form → Gtk.Window (created eagerly in the Form's constructor)
Gtk.Window window = myForm.ToGtkWindow ();
window.SetTransientFor (hostWindow);
window.Present ();

MajorsilenceFormsPresenter exposes a Widget property rather than deriving from a GTK widget (gir.core's GObject subclassing needs an extra integration package and a type-registration call). See samples/EmbeddingGtk4.

Known limits (v1)

  • No screen-position control. GTK 4 removed client-side positioning of top-levels, so Form.Location is a stored value the window manager may ignore, and PointToScreen/PointToClient assume it.
  • Topmost, ShowInTaskbar, MaximumSize round-trip as properties but GTK 4 has no API to enforce them.
  • Window icons come from a themed icon name in GTK 4, so SetIcon(byte[]) is a no-op.
  • File pickers (OpenFileDialog etc.) return empty — the compat dialogs fall back, as on Headless.
  • Fractional display scaling uses the integer scale factor GTK reports (1 or 2); text is slightly soft at 1.25×/1.5× until fractional-scale support lands.
  • Runs only where a display server (X11/Wayland) is available — use Majorsilence.Forms.Headless for offscreen/CI rendering.

Licensed under the MIT License.

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 is compatible.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
26.8.2 0 10/6/2026
26.8.1 6 10/5/2026
26.8.0 53 10/3/2026
26.7.0 48 10/3/2026
26.6.0 47 10/2/2026
26.5.0 40 10/1/2026
26.4.0 76 9/29/2026
26.3.0 96 9/25/2026
26.2.0 90 9/23/2026
26.1.0 100 9/21/2026
26.0.52 101 9/12/2026