From bc6cbdc41a1ce4b21708d35efd91e390b19da39f Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Mon, 28 Jul 2025 07:35:40 -0700 Subject: [PATCH] apprt/gtk-ng: toolbar style config --- src/apprt/gtk-ng/class/window.zig | 35 +++++++++++++++++++++++++++++- src/apprt/gtk-ng/ui/1.5/window.blp | 4 ++-- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/apprt/gtk-ng/class/window.zig b/src/apprt/gtk-ng/class/window.zig index ae624afb4..2f9ccb80f 100644 --- a/src/apprt/gtk-ng/class/window.zig +++ b/src/apprt/gtk-ng/class/window.zig @@ -170,7 +170,7 @@ pub const Window = extern struct { Self, bool, .{ - .nick = "Tab Bar Visiblity", + .nick = "Tab Bar Visibility", .blurb = "If true, tab bar should be visible.", .default = true, .accessor = gobject.ext.typedAccessor(Self, bool, .{ @@ -179,6 +179,27 @@ pub const Window = extern struct { }, ); }; + + pub const @"toolbar-style" = struct { + pub const name = "toolbar-style"; + const impl = gobject.ext.defineProperty( + name, + Self, + adw.ToolbarStyle, + .{ + .nick = "Toolbar Style", + .blurb = "The style for the toolbar top/bottom bars.", + .default = .raised, + .accessor = gobject.ext.typedAccessor( + Self, + adw.ToolbarStyle, + .{ + .getter = Self.getToolbarStyle, + }, + ), + }, + ); + }; }; const Private = struct { @@ -284,6 +305,7 @@ pub const Window = extern struct { "tabs-autohide", "tabs-visible", "tabs-wide", + "toolbar-style", }) |key| { self.as(gobject.Object).notifyByPspec( @field(properties, key).impl.param_spec, @@ -404,6 +426,16 @@ pub const Window = extern struct { return config.@"gtk-wide-tabs"; } + fn getToolbarStyle(self: *Self) adw.ToolbarStyle { + const priv = self.private(); + const config = if (priv.config) |v| v.get() else return .raised; + return switch (config.@"gtk-toolbar-style") { + .flat => .flat, + .raised => .raised, + .@"raised-border" => .raised_border, + }; + } + fn propConfig( _: *adw.ApplicationWindow, _: *gobject.ParamSpec, @@ -721,6 +753,7 @@ pub const Window = extern struct { properties.@"tabs-autohide".impl, properties.@"tabs-visible".impl, properties.@"tabs-wide".impl, + properties.@"toolbar-style".impl, }); // Bindings diff --git a/src/apprt/gtk-ng/ui/1.5/window.blp b/src/apprt/gtk-ng/ui/1.5/window.blp index b46fd6415..8197a8e02 100644 --- a/src/apprt/gtk-ng/ui/1.5/window.blp +++ b/src/apprt/gtk-ng/ui/1.5/window.blp @@ -24,8 +24,8 @@ template $GhosttyWindow: Adw.ApplicationWindow { view: tab_view; Adw.ToolbarView toolbar { - top-bar-style: raised; - bottom-bar-style: raised; + top-bar-style: bind template.toolbar-style; + bottom-bar-style: bind template.toolbar-style; [top] Adw.HeaderBar {