apprt/gtk-ng: toolbar style config

This commit is contained in:
Mitchell Hashimoto
2025-07-28 07:35:40 -07:00
parent d7e42e6614
commit bc6cbdc41a
2 changed files with 36 additions and 3 deletions

View File

@ -170,7 +170,7 @@ pub const Window = extern struct {
Self, Self,
bool, bool,
.{ .{
.nick = "Tab Bar Visiblity", .nick = "Tab Bar Visibility",
.blurb = "If true, tab bar should be visible.", .blurb = "If true, tab bar should be visible.",
.default = true, .default = true,
.accessor = gobject.ext.typedAccessor(Self, bool, .{ .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 { const Private = struct {
@ -284,6 +305,7 @@ pub const Window = extern struct {
"tabs-autohide", "tabs-autohide",
"tabs-visible", "tabs-visible",
"tabs-wide", "tabs-wide",
"toolbar-style",
}) |key| { }) |key| {
self.as(gobject.Object).notifyByPspec( self.as(gobject.Object).notifyByPspec(
@field(properties, key).impl.param_spec, @field(properties, key).impl.param_spec,
@ -404,6 +426,16 @@ pub const Window = extern struct {
return config.@"gtk-wide-tabs"; 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( fn propConfig(
_: *adw.ApplicationWindow, _: *adw.ApplicationWindow,
_: *gobject.ParamSpec, _: *gobject.ParamSpec,
@ -721,6 +753,7 @@ pub const Window = extern struct {
properties.@"tabs-autohide".impl, properties.@"tabs-autohide".impl,
properties.@"tabs-visible".impl, properties.@"tabs-visible".impl,
properties.@"tabs-wide".impl, properties.@"tabs-wide".impl,
properties.@"toolbar-style".impl,
}); });
// Bindings // Bindings

View File

@ -24,8 +24,8 @@ template $GhosttyWindow: Adw.ApplicationWindow {
view: tab_view; view: tab_view;
Adw.ToolbarView toolbar { Adw.ToolbarView toolbar {
top-bar-style: raised; top-bar-style: bind template.toolbar-style;
bottom-bar-style: raised; bottom-bar-style: bind template.toolbar-style;
[top] [top]
Adw.HeaderBar { Adw.HeaderBar {