From c2223cd928c54e31a2ac3c10caac041bca9ec2e6 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Mon, 30 Dec 2024 14:44:56 -0600 Subject: [PATCH] gtk: don't use gtk_window_set_titlebar if adwaita is enabled but it's older than 1.4.0 --- src/apprt/gtk/Window.zig | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index ea863051c..f3d53e4eb 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -216,6 +216,14 @@ pub fn init(self: *Window, app: *App) !void { } } + // If Adwaita is enabled and is older than 1.4.0 we don't have the tab overview and so we + // need to stick the headerbar into the content box. + if (!adwaita.versionAtLeast(1, 4, 0) and adwaita.enabled(&self.app.config)) { + if (self.header) |h| { + c.gtk_box_append(@ptrCast(box), h.asWidget()); + } + } + // In debug we show a warning and apply the 'devel' class to the window. // This is a really common issue where people build from source in debug and performance is really bad. if (comptime std.debug.runtime_safety) { @@ -363,8 +371,17 @@ pub fn init(self: *Window, app: *App) !void { } // The box is our main child - c.gtk_window_set_child(gtk_window, box); - if (self.header) |h| c.gtk_window_set_titlebar(gtk_window, h.asWidget()); + if (!adwaita.versionAtLeast(1, 4, 0) and adwaita.enabled(&self.app.config)) { + c.adw_application_window_set_content( + @ptrCast(gtk_window), + box, + ); + } else { + c.gtk_window_set_child(gtk_window, box); + if (self.header) |h| { + c.gtk_window_set_titlebar(gtk_window, h.asWidget()); + } + } } // Show the window