From f390941fd6a0871a26ba151432c772f37442b06c Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Fri, 25 Jul 2025 12:46:41 -0500 Subject: [PATCH] gtk-ng: move debug property to window --- src/apprt/gtk-ng/class/debug_warning.zig | 28 ----------------------- src/apprt/gtk-ng/class/window.zig | 28 +++++++++++++++++++++++ src/apprt/gtk-ng/ui/1.2/debug-warning.blp | 1 - src/apprt/gtk-ng/ui/1.3/debug-warning.blp | 2 +- src/apprt/gtk-ng/ui/1.5/window.blp | 4 +++- 5 files changed, 32 insertions(+), 31 deletions(-) diff --git a/src/apprt/gtk-ng/class/debug_warning.zig b/src/apprt/gtk-ng/class/debug_warning.zig index 9d90c5d4a..edda6659b 100644 --- a/src/apprt/gtk-ng/class/debug_warning.zig +++ b/src/apprt/gtk-ng/class/debug_warning.zig @@ -21,29 +21,6 @@ pub const DebugWarning = extern struct { .parent_class = &Class.parent, }); - pub const properties = struct { - pub const debug = struct { - pub const name = "debug"; - const impl = gobject.ext.defineProperty( - name, - Self, - bool, - .{ - .nick = "Debug", - .blurb = "True if runtime safety checks are enabled.", - .default = build_config.is_debug, - .accessor = gobject.ext.typedAccessor(Self, bool, .{ - .getter = struct { - pub fn getter(_: *DebugWarning) bool { - return build_config.is_debug; - } - }.getter, - }), - }, - ); - }; - }; - fn init(self: *Self, _: *Class) callconv(.c) void { gtk.Widget.initTemplate(self.as(gtk.Widget)); } @@ -68,11 +45,6 @@ pub const DebugWarning = extern struct { .name = "debug-warning", }), ); - - // Properties - gobject.ext.registerProperties(class, &.{ - properties.debug.impl, - }); } pub const as = C.Class.as; diff --git a/src/apprt/gtk-ng/class/window.zig b/src/apprt/gtk-ng/class/window.zig index 757d5a798..1f717a5cf 100644 --- a/src/apprt/gtk-ng/class/window.zig +++ b/src/apprt/gtk-ng/class/window.zig @@ -26,6 +26,29 @@ pub const Window = extern struct { .private = .{ .Type = Private, .offset = &Private.offset }, }); + pub const properties = struct { + pub const debug = struct { + pub const name = "debug"; + const impl = gobject.ext.defineProperty( + name, + Self, + bool, + .{ + .nick = "Debug", + .blurb = "True if runtime safety checks are enabled.", + .default = build_config.is_debug, + .accessor = gobject.ext.typedAccessor(Self, bool, .{ + .getter = struct { + pub fn getter(_: *Window) bool { + return build_config.is_debug; + } + }.getter, + }), + }, + ); + }; + }; + const Private = struct { /// The surface in the view. surface: *Surface = undefined, @@ -106,6 +129,11 @@ pub const Window = extern struct { }), ); + // Properties + gobject.ext.registerProperties(class, &.{ + properties.debug.impl, + }); + // Bindings class.bindTemplateChildPrivate("surface", .{}); diff --git a/src/apprt/gtk-ng/ui/1.2/debug-warning.blp b/src/apprt/gtk-ng/ui/1.2/debug-warning.blp index 02c3a5a0b..34411ce90 100644 --- a/src/apprt/gtk-ng/ui/1.2/debug-warning.blp +++ b/src/apprt/gtk-ng/ui/1.2/debug-warning.blp @@ -5,7 +5,6 @@ template $GhosttyDebugWarning: Gtk.Box { Gtk.Label { label: _("⚠️ You're running a debug build of Ghostty! Performance will be degraded."); - visible: bind template.debug; margin-top: 10; margin-bottom: 10; } diff --git a/src/apprt/gtk-ng/ui/1.3/debug-warning.blp b/src/apprt/gtk-ng/ui/1.3/debug-warning.blp index 0f82a5f88..ad7246a80 100644 --- a/src/apprt/gtk-ng/ui/1.3/debug-warning.blp +++ b/src/apprt/gtk-ng/ui/1.3/debug-warning.blp @@ -4,6 +4,6 @@ using Adw 1; template $GhosttyDebugWarning: Adw.Bin { Adw.Banner { title: _("⚠️ You're running a debug build of Ghostty! Performance will be degraded."); - revealed: bind template.debug; + revealed: true; } } diff --git a/src/apprt/gtk-ng/ui/1.5/window.blp b/src/apprt/gtk-ng/ui/1.5/window.blp index c8a36dd07..77d1a5215 100644 --- a/src/apprt/gtk-ng/ui/1.5/window.blp +++ b/src/apprt/gtk-ng/ui/1.5/window.blp @@ -13,7 +13,9 @@ template $GhosttyWindow: Adw.ApplicationWindow { orientation: vertical; spacing: 0; - $GhosttyDebugWarning {} + $GhosttyDebugWarning { + visible: bind template.debug; + } $GhosttySurface surface { close-request => $surface_close_request();