From ab93579bf6f8d0199c3b8d46d8e6ab695b783f63 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Tue, 31 Oct 2023 20:38:17 +0100 Subject: [PATCH] gtk: port new-tab behavior over after rebase and refactor This is the new behavior from #776. --- src/apprt/gtk/Tab.zig | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/apprt/gtk/Tab.zig b/src/apprt/gtk/Tab.zig index 315db2ffd..5ded58f4c 100644 --- a/src/apprt/gtk/Tab.zig +++ b/src/apprt/gtk/Tab.zig @@ -100,7 +100,14 @@ pub fn init(self: *Tab, window: *Window, parent_: ?*CoreSurface) !void { const gl_area_widget = @as(*c.GtkWidget, @ptrCast(surface.gl_area)); c.gtk_box_append(self.box, gl_area_widget); - const page_idx = c.gtk_notebook_append_page(window.notebook, box_widget, label_box_widget); + // Add the notebook page (create tab). We create the tab after our + // current selected tab if we have one. + const page_idx = c.gtk_notebook_insert_page( + window.notebook, + box_widget, + label_box_widget, + c.gtk_notebook_get_current_page(window.notebook) + 1, + ); if (page_idx < 0) { log.warn("failed to add page to notebook", .{}); return error.GtkAppendPageFailed;