From 2805657213b2511ab1f3331af3fc87137c924ed2 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Mon, 23 Sep 2024 10:31:01 -0500 Subject: [PATCH 1/2] gtk/adw: conditional tab keybindings adw_tab_view_remove_shortcuts (and related APIs) was added in libadwaita 1.2.0. --- src/apprt/gtk/notebook.zig | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/apprt/gtk/notebook.zig b/src/apprt/gtk/notebook.zig index dad42e730..13db7a69e 100644 --- a/src/apprt/gtk/notebook.zig +++ b/src/apprt/gtk/notebook.zig @@ -66,9 +66,11 @@ pub const Notebook = union(enum) { const tab_view: *c.AdwTabView = c.adw_tab_view_new().?; - // Adwaita enables all of the shortcuts by default. - // We want to manage keybindings ourselves. - c.adw_tab_view_remove_shortcuts(tab_view, c.ADW_TAB_VIEW_SHORTCUT_ALL_SHORTCUTS); + if (comptime adwaita.versionAtLeast(1, 2, 0)) { + // Adwaita enables all of the shortcuts by default. + // We want to manage keybindings ourselves. + c.adw_tab_view_remove_shortcuts(tab_view, c.ADW_TAB_VIEW_SHORTCUT_ALL_SHORTCUTS); + } _ = c.g_signal_connect_data(tab_view, "page-attached", c.G_CALLBACK(&adwPageAttached), window, null, c.G_CONNECT_DEFAULT); _ = c.g_signal_connect_data(tab_view, "create-window", c.G_CALLBACK(&adwTabViewCreateWindow), window, null, c.G_CONNECT_DEFAULT); From 8186e95902caf51c8e4276788d9ff7de77080fb0 Mon Sep 17 00:00:00 2001 From: "Jeffrey C. Ollie" Date: Mon, 23 Sep 2024 11:41:39 -0500 Subject: [PATCH 2/2] gtk/adw: perform version check at both comptime and runtime --- src/apprt/gtk/notebook.zig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/apprt/gtk/notebook.zig b/src/apprt/gtk/notebook.zig index 13db7a69e..a42c58ce0 100644 --- a/src/apprt/gtk/notebook.zig +++ b/src/apprt/gtk/notebook.zig @@ -66,7 +66,7 @@ pub const Notebook = union(enum) { const tab_view: *c.AdwTabView = c.adw_tab_view_new().?; - if (comptime adwaita.versionAtLeast(1, 2, 0)) { + if (comptime adwaita.versionAtLeast(1, 2, 0) and adwaita.versionAtLeast(1, 2, 0)) { // Adwaita enables all of the shortcuts by default. // We want to manage keybindings ourselves. c.adw_tab_view_remove_shortcuts(tab_view, c.ADW_TAB_VIEW_SHORTCUT_ALL_SHORTCUTS);