apprt/gtk-ng: GhosttyConfigErrors

This commit is contained in:
Mitchell Hashimoto
2025-07-16 13:44:59 -07:00
parent e76a151b42
commit 897649a3af
3 changed files with 97 additions and 0 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 = 5, .name = "config-errors-dialog" },
.{ .major = 1, .minor = 5, .name = "window" },
};

View File

@ -0,0 +1,70 @@
const std = @import("std");
const adw = @import("adw");
const gobject = @import("gobject");
const gtk = @import("gtk");
const gresource = @import("../build/gresource.zig");
const adw_version = @import("../adw_version.zig");
const GhosttyConfig = @import("config.zig").GhosttyConfig;
const log = std.log.scoped(.gtk_ghostty_window);
pub const GhosttyConfigErrors = extern struct {
const Self = @This();
parent_instance: Parent,
pub const Parent = if (adw_version.supportsDialogs())
adw.AlertDialog
else
adw.MessageDialog;
pub const getGObjectType = gobject.ext.defineClass(Self, .{
.instanceInit = &init,
.classInit = &Class.init,
.parent_class = &Class.parent,
.private = .{ .Type = Private, .offset = &Private.offset },
});
const Private = struct {
_todo: u8 = 0,
var offset: c_int = 0;
};
pub fn new(config: *GhosttyConfig) *Self {
return gobject.ext.newInstance(Self, .{
.config = config,
});
}
fn init(self: *Self, _: *Class) callconv(.C) void {
gtk.Widget.initTemplate(self.as(gtk.Widget));
}
pub fn as(win: *Self, comptime T: type) *T {
return gobject.ext.as(T, win);
}
pub const Class = extern struct {
parent_class: Parent.Class,
var parent: *Parent.Class = undefined;
pub const Instance = Self;
fn init(class: *Class) callconv(.C) void {
gtk.Widget.Class.setTemplateFromResource(
class.as(gtk.Widget.Class),
switch (Parent) {
adw.AlertDialog => comptime gresource.blueprint(.{
.major = 1,
.minor = 5,
.name = "config-errors-dialog",
}),
else => unreachable,
},
);
}
pub fn as(class: *Class, comptime T: type) *T {
return gobject.ext.as(T, class);
}
};
};

View File

@ -0,0 +1,26 @@
using Gtk 4.0;
using Adw 1;
Adw.AlertDialog config_errors_dialog {
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;
}
};
}