From 59a53251cfee08a598ee4222cd1f800171c58978 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 31 Oct 2023 09:49:39 -0700 Subject: [PATCH] apprt/gtk: create new tab after current tab This behaves the same as macOS, and personally I prefer this behavior because when I create a new tab, it is often contextual to what I'm currently working on and keeping the tab nearby feels right. --- src/apprt/gtk/Window.zig | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/apprt/gtk/Window.zig b/src/apprt/gtk/Window.zig index fda4466b0..6b6661e31 100644 --- a/src/apprt/gtk/Window.zig +++ b/src/apprt/gtk/Window.zig @@ -219,7 +219,15 @@ pub fn newTab(self: *Window, parent_: ?*CoreSurface) !void { .parent = parent_ != null, }); errdefer surface.deinit(); - const page_idx = c.gtk_notebook_append_page(self.notebook, gl_area, 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( + self.notebook, + gl_area, + label_box_widget, + c.gtk_notebook_get_current_page(self.notebook) + 1, + ); if (page_idx < 0) { log.warn("failed to add surface to notebook", .{}); return error.GtkAppendPageFailed;