apprt/gtk-ng: hook up adw < 1.5 support

This commit is contained in:
Mitchell Hashimoto
2025-07-17 09:49:17 -07:00
parent 039e248ec9
commit cac32fc60d
3 changed files with 39 additions and 3 deletions

View File

@ -30,6 +30,7 @@ pub const icon_sizes: []const comptime_int = &.{ 16, 32, 128, 256, 512, 1024 };
///
/// These will be asserted to exist at runtime.
pub const blueprints: []const Blueprint = &.{
.{ .major = 1, .minor = 2, .name = "config-errors-dialog" },
.{ .major = 1, .minor = 5, .name = "config-errors-dialog" },
.{ .major = 1, .minor = 5, .name = "window" },
};

View File

@ -74,14 +74,16 @@ pub const ConfigErrorsDialog = extern struct {
pub fn present(self: *Self, parent: ?*gtk.Widget) void {
switch (Parent) {
adw.AlertDialog => self.as(adw.Dialog).present(parent),
else => unreachable,
adw.MessageDialog => self.as(gtk.Window).present(),
else => comptime unreachable,
}
}
pub fn close(self: *Self) void {
switch (Parent) {
adw.AlertDialog => self.as(adw.Dialog).forceClose(),
else => unreachable,
adw.MessageDialog => self.as(gtk.Window).close(),
else => comptime unreachable,
}
}
@ -160,7 +162,13 @@ pub const ConfigErrorsDialog = extern struct {
.name = "config-errors-dialog",
}),
else => unreachable,
adw.MessageDialog => comptime gresource.blueprint(.{
.major = 1,
.minor = 2,
.name = "config-errors-dialog",
}),
else => comptime unreachable,
},
);

View File

@ -0,0 +1,27 @@
using Gtk 4.0;
using Adw 1;
template $GhosttyConfigErrorsDialog: Adw.MessageDialog {
heading: _("Configuration Errors");
body: _("One or more configuration errors were found. Please review the errors below, and either reload your configuration or ignore these errors.");
responses [
ignore: _("Ignore"),
reload: _("Reload Configuration") suggested,
]
extra-child: ScrolledWindow {
min-content-width: 500;
min-content-height: 100;
TextView {
editable: false;
cursor-visible: false;
top-margin: 8;
bottom-margin: 8;
left-margin: 8;
right-margin: 8;
buffer: bind (template.config as <$GhosttyConfig>).diagnostics-buffer;
}
};
}