core/gtk: unify libadwaita/adwaita options in the code

Fixes #2574
This commit is contained in:
Jeffrey C. Ollie
2024-11-08 22:16:44 -06:00
parent 75fe0b2dfb
commit b353ddf46d
6 changed files with 16 additions and 16 deletions

View File

@ -92,10 +92,10 @@ pub fn build(b: *std.Build) !void {
"The app runtime to use. Not all values supported on all platforms.",
) orelse renderer.Impl.default(target.result, wasm_target);
config.libadwaita = b.option(
config.adwaita = b.option(
bool,
"gtk-libadwaita",
"Enables the use of libadwaita when using the gtk rendering backend.",
"gtk-adwaita",
"Enables the use of Adwaita when using the GTK rendering backend.",
) orelse true;
const conformance = b.option(
@ -1321,7 +1321,7 @@ fn addDeps(
.gtk => {
step.linkSystemLibrary2("gtk4", dynamic_link_opts);
if (config.libadwaita) step.linkSystemLibrary2("adwaita-1", dynamic_link_opts);
if (config.adwaita) step.linkSystemLibrary2("adwaita-1", dynamic_link_opts);
{
const gresource = @import("src/apprt/gtk/gresource.zig");

View File

@ -12,7 +12,7 @@ const Config = @import("../../config.zig").Config;
/// This must be `inline` so that the comptime check noops conditional
/// paths that are not enabled.
pub inline fn enabled(config: *const Config) bool {
return build_options.libadwaita and
return build_options.adwaita and
config.@"gtk-adwaita";
}
@ -30,7 +30,7 @@ pub fn versionAtLeast(
comptime minor: u16,
comptime micro: u16,
) bool {
if (comptime !build_options.libadwaita) return false;
if (comptime !build_options.adwaita) return false;
// If our header has lower versions than the given version,
// we can return false immediately. This prevents us from

View File

@ -1,7 +1,7 @@
/// Imported C API directly from header files
pub const c = @cImport({
@cInclude("gtk/gtk.h");
if (@import("build_options").libadwaita) {
if (@import("build_options").adwaita) {
@cInclude("libadwaita-1/adwaita.h");
}

View File

@ -21,7 +21,7 @@ const WasmTarget = @import("os/wasm/target.zig").Target;
pub const BuildConfig = struct {
version: std.SemanticVersion = .{ .major = 0, .minor = 0, .patch = 0 },
flatpak: bool = false,
libadwaita: bool = false,
adwaita: bool = false,
app_runtime: apprt.Runtime = .none,
renderer: rendererpkg.Impl = .opengl,
font_backend: font.Backend = .freetype,
@ -40,7 +40,7 @@ pub const BuildConfig = struct {
// We need to break these down individual because addOption doesn't
// support all types.
step.addOption(bool, "flatpak", self.flatpak);
step.addOption(bool, "libadwaita", self.libadwaita);
step.addOption(bool, "adwaita", self.adwaita);
step.addOption(apprt.Runtime, "app_runtime", self.app_runtime);
step.addOption(font.Backend, "font_backend", self.font_backend);
step.addOption(rendererpkg.Impl, "renderer", self.renderer);
@ -67,7 +67,7 @@ pub const BuildConfig = struct {
return .{
.version = options.app_version,
.flatpak = options.flatpak,
.libadwaita = options.libadwaita,
.adwaita = options.adwaita,
.app_runtime = std.meta.stringToEnum(apprt.Runtime, @tagName(options.app_runtime)).?,
.font_backend = std.meta.stringToEnum(font.Backend, @tagName(options.font_backend)).?,
.renderer = std.meta.stringToEnum(rendererpkg.Impl, @tagName(options.renderer)).?,

View File

@ -42,7 +42,7 @@ pub fn run(alloc: Allocator) !u8 {
gtk.gtk_get_minor_version(),
gtk.gtk_get_micro_version(),
});
if (comptime build_options.libadwaita) {
if (comptime build_options.adwaita) {
try stdout.print(" - libadwaita : enabled\n", .{});
try stdout.print(" build : {s}\n", .{
gtk.ADW_VERSION_S,

View File

@ -940,7 +940,7 @@ keybind: Keybinds = .{},
/// * `dark` - Use the dark theme regardless of system theme.
/// * `ghostty` - Use the background and foreground colors specified in the
/// Ghostty configuration. This is only supported on Linux builds with
/// libadwaita and `gtk-adwaita` enabled.
/// Adwaita and `gtk-adwaita` enabled.
///
/// On macOS, if `macos-titlebar-style` is "tabs", the window theme will be
/// automatically set based on the luminosity of the terminal background color.
@ -1618,12 +1618,12 @@ keybind: Keybinds = .{},
/// Determines the side of the screen that the GTK tab bar will stick to.
/// Top, bottom, left, and right are supported. The default is top.
///
/// If this option has value `left` or `right` when using `libadwaita`, it falls
/// If this option has value `left` or `right` when using Adwaita, it falls
/// back to `top`.
@"gtk-tabs-location": GtkTabsLocation = .top,
/// Determines the appearance of the top and bottom bars when using the
/// adwaita tab bar. This requires `gtk-adwaita` to be enabled (it is
/// Adwaita tab bar. This requires `gtk-adwaita` to be enabled (it is
/// by default).
///
/// Valid values are:
@ -1642,7 +1642,7 @@ keybind: Keybinds = .{},
/// which is the old style.
@"gtk-wide-tabs": bool = true,
/// If `true` (default), Ghostty will enable libadwaita theme support. This
/// If `true` (default), Ghostty will enable Adwaita theme support. This
/// will make `window-theme` work properly and will also allow Ghostty to
/// properly respond to system theme changes, light/dark mode changing, etc.
/// This requires a GTK4 desktop with a GTK4 theme.
@ -1653,7 +1653,7 @@ keybind: Keybinds = .{},
/// expected.
///
/// This configuration only has an effect if Ghostty was built with
/// libadwaita support.
/// Adwaita support.
@"gtk-adwaita": bool = true,
/// If `true` (default), applications running in the terminal can show desktop