From cac32fc60dcea3c83aaab6ea11768e8ab3603ca1 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 17 Jul 2025 09:49:17 -0700 Subject: [PATCH] apprt/gtk-ng: hook up adw < 1.5 support --- src/apprt/gtk-ng/build/gresource.zig | 1 + .../gtk-ng/class/config_errors_dialog.zig | 14 +++++++--- .../gtk-ng/ui/1.2/config-errors-dialog.blp | 27 +++++++++++++++++++ 3 files changed, 39 insertions(+), 3 deletions(-) create mode 100644 src/apprt/gtk-ng/ui/1.2/config-errors-dialog.blp diff --git a/src/apprt/gtk-ng/build/gresource.zig b/src/apprt/gtk-ng/build/gresource.zig index 433c504da..f38e73b01 100644 --- a/src/apprt/gtk-ng/build/gresource.zig +++ b/src/apprt/gtk-ng/build/gresource.zig @@ -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" }, }; diff --git a/src/apprt/gtk-ng/class/config_errors_dialog.zig b/src/apprt/gtk-ng/class/config_errors_dialog.zig index 46ec5671d..ad04e182a 100644 --- a/src/apprt/gtk-ng/class/config_errors_dialog.zig +++ b/src/apprt/gtk-ng/class/config_errors_dialog.zig @@ -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, }, ); diff --git a/src/apprt/gtk-ng/ui/1.2/config-errors-dialog.blp b/src/apprt/gtk-ng/ui/1.2/config-errors-dialog.blp new file mode 100644 index 000000000..7c16c3363 --- /dev/null +++ b/src/apprt/gtk-ng/ui/1.2/config-errors-dialog.blp @@ -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; + } + }; +}