mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 11:46:11 +03:00
apprt/gtk-ng: GhosttyConfigErrors
This commit is contained in:
@ -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" },
|
||||
};
|
||||
|
||||
|
70
src/apprt/gtk-ng/class/config_errors.zig
Normal file
70
src/apprt/gtk-ng/class/config_errors.zig
Normal 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);
|
||||
}
|
||||
};
|
||||
};
|
26
src/apprt/gtk-ng/ui/1.5/config-errors-dialog.blp
Normal file
26
src/apprt/gtk-ng/ui/1.5/config-errors-dialog.blp
Normal 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;
|
||||
}
|
||||
};
|
||||
}
|
Reference in New Issue
Block a user