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
<PackageReference Include="Majorsilence.Forms.Gtk4" Version="26.8.2" />
<PackageVersion Include="Majorsilence.Forms.Gtk4" Version="26.8.2" />
<PackageReference Include="Majorsilence.Forms.Gtk4" />
paket add Majorsilence.Forms.Gtk4 --version 26.8.2
#r "nuget: Majorsilence.Forms.Gtk4, 26.8.2"
#:package Majorsilence.Forms.Gtk4@26.8.2
#addin nuget:?package=Majorsilence.Forms.Gtk4&version=26.8.2
#tool nuget:?package=Majorsilence.Forms.Gtk4&version=26.8.2
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.Windowper top-levelForm, 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/Invokemarshal onto the GLib loop. - Clipboard text, multi-monitor
Screenenumeration. - Custom-chrome window move/resize drags via
Gdk.Toplevel.BeginMove/BeginResize. ShowDialoggets a real transient-for / modal window relationship.NativeControlHost— a realGtk.Widgetoverlaid inside an MF scene (INativeControlHostBackend). GTK 4 composites every widget into one render tree, so there is no airspace problem.WebBrowser/RadPdfViewer/RadRichTextEditor—IWebViewFactorybacked by WebKitGTK 6.0 (GirCore.WebKit-6.0): navigation events,ExecuteScriptAsync, and a JS→host script-message bridge. Needslibwebkitgtk-6.0installed at runtime (IsWebViewFunctionalisfalseotherwise).
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.Locationis a stored value the window manager may ignore, andPointToScreen/PointToClientassume it. Topmost,ShowInTaskbar,MaximumSizeround-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 (
OpenFileDialogetc.) 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.Headlessfor offscreen/CI rendering.
Links
Licensed under the MIT License.
| 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. 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. |
-
net10.0
- GirCore.Gtk-4.0 (>= 0.8.1)
- GirCore.WebKit-6.0 (>= 0.8.1)
- Majorsilence.Forms (>= 26.8.2)
- SkiaSharp (>= 3.119.4)
-
net8.0
- GirCore.Gtk-4.0 (>= 0.8.1)
- GirCore.WebKit-6.0 (>= 0.8.1)
- Majorsilence.Forms (>= 26.8.2)
- SkiaSharp (>= 3.119.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.