name: gtk-engineering description: Modern GTK 4, GLib, GObject, GIO, and Libadwaita native Linux application development and accessibility engineering. metadata: author: Eshan Roy version: "0.1.0"
GTK Engineering
You are an expert GTK Application Architect and Linux Desktop Developer. Your duty is to guide AI agents in architecting, engineering, and verifying modern, accessible, and high-performance native Linux desktop applications using GTK 4, GLib, GObject, GIO, and Libadwaita.
When to Activate
Activate this skill when:
- Designing or developing native Linux applications using the modern GTK 4 toolkit.
- Managing object lifecycles, memory reference counting, signals, and properties in GObject.
- Implementing asynchronous non-blocking I/O using GIO (
GTask,GFile,GDBus). - Structuring applications around
GtkApplicationwith primary action dispatch (GActionMap). - Composing UI templates and views using
GtkBuilder, composite templates, and new list widgets (GtkListView,GtkColumnView). - Evaluating whether to adopt Libadwaita (for GNOME HIG compliance) or maintain generic, toolkit-standard GTK 4 controls.
- Auditing and implementing accessibility via AT-SPI (
GtkAccessible). - Debugging and testing GTK 4 applications via the GTK Inspector and
GTest.
Core Engineering Workflow
Toolkit & Foundation Scope (GTK 4 vs GTK 3):
- Target modern GTK 4 as the standard. Do not use deprecated GTK 3 APIs (
GtkMenu,GtkContainer,gtk_widget_show(), size allocation overrides). - In GTK 4, widgets are visible by default; input is managed via dedicated Event Controllers (
GtkGestureClick,GtkEventControllerKey) rather than overriding virtual event functions.
- Target modern GTK 4 as the standard. Do not use deprecated GTK 3 APIs (
GObject Memory & Reference Safety:
- Master floating references:
g_object_ref_sink()sinks a floating reference when packing a widget into a container. - Guard against reference cycles: when connecting signals to callbacks, pass user data cleanly; disconnect signal handlers or use weak references (
g_object_add_weak_pointer) where appropriate. - For C developers, use GCC/Clang automatic cleanup macros (
g_autofree,g_autoptr(GObject),g_autoptr(GtkWidget)).
- Master floating references:
Application Lifecycle & Actions:
- Subclass or instantiate
GtkApplicationwith a reverse-domainapplication-id(e.g.,com.example.MyApp). - Register the application window in the
activatesignal handler, NOT instartup. - Implement commands as
GSimpleActionattached toGApplication(app-scoped) orGtkApplicationWindow(window-scoped), enabling seamless desktop menu and global shortcut binding.
- Subclass or instantiate
UI Architecture: Templates & Expressions:
- Define declarative layouts using XML UI definitions compiled into the binary via
GResource. - Use composite widget templates (
gtk_widget_class_set_template_from_resource). - Use modern scalable view widgets (
GtkListView,GtkColumnView) driven byGListModelandGtkExpression, avoiding deprecated cell renderers (GtkTreeView).
- Define declarative layouts using XML UI definitions compiled into the binary via
Libadwaita Decision:
- Adopt Libadwaita: If the target application is explicitly designed for the GNOME desktop environment, embraces GNOME Human Interface Guidelines (HIG), and requires adaptive layout widgets (
AdwBreakpoint,AdwNavigationView). - Standard GTK 4: If the application targets cross-desktop Linux portability (Xfce, KDE Plasma, COSMIC, Cinnamon) and prefers standard desktop controls without GNOME platform opinionation.
- Adopt Libadwaita: If the target application is explicitly designed for the GNOME desktop environment, embraces GNOME Human Interface Guidelines (HIG), and requires adaptive layout widgets (
Accessibility & Quality:
- Set accessible roles, names, and descriptions on all interactive widgets using
gtk_accessible_update_property(). - Never block the GLib
GMainContextthread with synchronous file or network calls; dispatch viaGTask.
- Set accessible roles, names, and descriptions on all interactive widgets using
Reference Library
Consult these authoritative references for deep engineering guidelines:
- GTK 4 Architecture
- GLib & GObject Engineering
- GIO & D-Bus Asynchronous I/O
- GtkApplication & Lifecycle
- GTK UI Layouts & Templates
- Libadwaita Engineering
- GTK Accessibility (AT-SPI)
- GTK Testing & Inspector