Improve styling.

This commit is contained in:
Greyson Parrelli
2026-08-12 21:15:07 -04:00
parent 4e0e400372
commit e16b147e16
13 changed files with 1104 additions and 119 deletions
+4 -28
View File
@@ -7,11 +7,10 @@
const std = @import("std");
const adw = @import("adw");
const gdk = @import("gdk");
const gio = @import("gio");
const gtk = @import("gtk");
const Window = @import("Window.zig");
const appearance = @import("appearance.zig");
/// libghostty-vt logs unimplemented sequences at debug level, which is very
/// chatty against a real shell. Keep the app's own warnings and errors.
@@ -19,8 +18,6 @@ pub const std_options: std.Options = .{
.log_level = .info,
};
const css = @embedFile("style.css");
var gpa: std.heap.DebugAllocator(.{}) = .init;
pub fn main() u8 {
@@ -40,8 +37,9 @@ pub fn main() u8 {
}
fn onActivate(app: *adw.Application, _: ?*anyopaque) callconv(.c) void {
forceDark();
loadCss();
// Before the window, so that the first frame is drawn in the scheme the
// user chose rather than repainted into it a moment later.
appearance.init();
const window = Window.create(gpa.allocator(), app) catch |err| {
std.log.err("failed to create window: {s}", .{@errorName(err)});
@@ -49,25 +47,3 @@ fn onActivate(app: *adw.Application, _: ?*anyopaque) callconv(.c) void {
};
window.present();
}
/// The window's own chrome is dark by hand in `style.css`, but stock widgets —
/// popovers, dialogs, text entries — follow the desktop's colour scheme and
/// would come up light against it. Layouts brought the first real dialogs into
/// the app, which is where that mismatch became visible.
fn forceDark() void {
const manager = adw.StyleManager.getDefault();
manager.setColorScheme(.force_dark);
}
fn loadCss() void {
const display = gdk.Display.getDefault() orelse return;
const provider = gtk.CssProvider.new();
defer provider.unref();
provider.loadFromString(css);
gtk.StyleContext.addProviderForDisplay(
display,
provider.as(gtk.StyleProvider),
gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
);
}