diff --git a/src/apprt/gtk/notebook.zig b/src/apprt/gtk/notebook.zig index 4b826f8a0..71345c311 100644 --- a/src/apprt/gtk/notebook.zig +++ b/src/apprt/gtk/notebook.zig @@ -198,6 +198,13 @@ pub const Notebook = union(enum) { } } + fn newTabInsertPosition(self: Notebook, tab: *Tab) c_int { + return switch (tab.window.app.config.@"window-new-tab-position") { + .current => self.currentPage() + 1, + .end => self.nPages(), + }; + } + /// Adds a new tab with the given title to the notebook. If the notebook /// is an adwaita tab view, this will return an AdwTabPage. If the notebook /// is a GTK notebook, this will return null. @@ -207,7 +214,7 @@ pub const Notebook = union(enum) { .adw_tab_view => |tab_view| { if (comptime !adwaita.versionAtLeast(0, 0, 0)) unreachable; - const page = c.adw_tab_view_append(tab_view, box_widget); + const page = c.adw_tab_view_insert(tab_view, box_widget, self.newTabInsertPosition(tab)); c.adw_tab_page_set_title(page, title.ptr); // Switch to the new tab @@ -248,12 +255,11 @@ pub const Notebook = union(enum) { c.gtk_button_set_has_frame(label_close, 0); c.gtk_box_append(label_box, label_close_widget); - const parent_page_idx = self.nPages(); const page_idx = c.gtk_notebook_insert_page( notebook, box_widget, label_box_widget, - parent_page_idx, + self.newTabInsertPosition(tab), ); // Clicks diff --git a/src/config/Config.zig b/src/config/Config.zig index 141ae3b20..b8fb43a87 100644 --- a/src/config/Config.zig +++ b/src/config/Config.zig @@ -949,8 +949,6 @@ keybind: Keybinds = .{}, /// or at the end if there are no focused tabs. /// /// * `end` - Insert the new tab at the end of the tab list. -/// -/// This configuration currently only works with GTK. @"window-new-tab-position": WindowNewTabPosition = .current, /// This controls when resize overlays are shown. Resize overlays are a