gtk-ng: move debug property to window

This commit is contained in:
Jeffrey C. Ollie
2025-07-25 12:46:41 -05:00
parent 33135f19dc
commit f390941fd6
5 changed files with 32 additions and 31 deletions

View File

@ -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;

View File

@ -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", .{});

View File

@ -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;
}

View File

@ -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;
}
}

View File

@ -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();