apprt/gtk-ng: background-opacity doesn't need to be a window property

We only need properties for things that are bound via the blueprint
files. Otherwise, its kind of just a pain. This fixes a bug where it
wasn't being properly set initially anyways because we didn't trigger
syncAppearance.
This commit is contained in:
Mitchell Hashimoto
2025-08-04 12:41:38 -07:00
parent 55c68d809d
commit 8c85bae931
2 changed files with 6 additions and 37 deletions

View File

@@ -117,23 +117,6 @@ pub const Window = extern struct {
);
};
pub const @"background-opaque" = struct {
pub const name = "background-opaque";
const impl = gobject.ext.defineProperty(
name,
Self,
bool,
.{
.nick = "Background Opaque",
.blurb = "True if the background should be opaque.",
.default = true,
.accessor = gobject.ext.typedAccessor(Self, bool, .{
.getter = Self.getBackgroundOpaque,
}),
},
);
};
pub const @"quick-terminal" = struct {
pub const name = "quick-terminal";
const impl = gobject.ext.defineProperty(
@@ -553,7 +536,6 @@ pub const Window = extern struct {
// Trigger all our dynamic properties that depend on the config.
inline for (&.{
"background-opaque",
"headerbar-visible",
"tabs-autohide",
"tabs-visible",
@@ -568,6 +550,12 @@ pub const Window = extern struct {
// Remainder uses the config
const config = if (priv.config) |v| v.get() else return;
// Only add a solid background if we're opaque.
self.toggleCssClass(
"background",
config.@"background-opacity" >= 1,
);
// Apply class to color headerbar if window-theme is set to `ghostty` and
// GTK version is before 4.16. The conditional is because above 4.16
// we use GTK CSS color variables.
@@ -751,12 +739,6 @@ pub const Window = extern struct {
return config.@"gtk-titlebar";
}
fn getBackgroundOpaque(self: *Self) bool {
const priv = self.private();
const config = (priv.config orelse return true).get();
return config.@"background-opacity" >= 1.0;
}
fn getTabsAutohide(self: *Self) bool {
const priv = self.private();
const config = if (priv.config) |v| v.get() else return true;
@@ -889,16 +871,6 @@ pub const Window = extern struct {
}
}
/// Add or remove "background" CSS class depending on if the background
/// should be opaque.
fn propBackgroundOpaque(
_: *adw.ApplicationWindow,
_: *gobject.ParamSpec,
self: *Self,
) callconv(.c) void {
self.toggleCssClass("background", self.getBackgroundOpaque());
}
fn propScaleFactor(
_: *adw.ApplicationWindow,
_: *gobject.ParamSpec,
@@ -1604,7 +1576,6 @@ pub const Window = extern struct {
// Properties
gobject.ext.registerProperties(class, &.{
properties.@"active-surface".impl,
properties.@"background-opaque".impl,
properties.config.impl,
properties.debug.impl,
properties.@"headerbar-visible".impl,
@@ -1634,7 +1605,6 @@ pub const Window = extern struct {
class.bindTemplateCallback("tab_create_window", &tabViewCreateWindow);
class.bindTemplateCallback("notify_n_pages", &tabViewNPages);
class.bindTemplateCallback("notify_selected_page", &tabViewSelectedPage);
class.bindTemplateCallback("notify_background_opaque", &propBackgroundOpaque);
class.bindTemplateCallback("notify_config", &propConfig);
class.bindTemplateCallback("notify_fullscreened", &propFullscreened);
class.bindTemplateCallback("notify_maximized", &propMaximized);

View File

@@ -8,7 +8,6 @@ template $GhosttyWindow: Adw.ApplicationWindow {
close-request => $close_request();
realize => $realize();
notify::background-opaque => $notify_background_opaque();
notify::config => $notify_config();
notify::fullscreened => $notify_fullscreened();
notify::maximized => $notify_maximized();