gtk: append new tabs at the end if config is set

This adds a new config option: `window-append-new-tabs` (please: if you
have a better name, let me know). If this is set to true, then new GTK
tabs aren't added after the current tab, but after at the end.
This commit is contained in:
Thorsten Ball
2024-01-12 17:35:15 +01:00
parent bea377b184
commit 2aa1874f94
2 changed files with 15 additions and 3 deletions

View File

@ -107,13 +107,21 @@ 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);
// Add the notebook page (create tab). We create the tab after our
// current selected tab if we have one.
// Add the notebook page (create tab).
const parent_page_idx = parent_page_idx: {
// If this option is enabled we append the new tab to the end of the notebook.
if (window.app.config.@"window-append-new-tabs") {
break :parent_page_idx c.gtk_notebook_get_n_pages(window.notebook);
}
// Otherwise we add it after the current tab.
break :parent_page_idx c.gtk_notebook_get_current_page(window.notebook) + 1;
};
const page_idx = c.gtk_notebook_insert_page(
window.notebook,
box_widget,
label_box_widget,
c.gtk_notebook_get_current_page(window.notebook) + 1,
parent_page_idx,
);
if (page_idx < 0) {
log.warn("failed to add page to notebook", .{});

View File

@ -656,6 +656,10 @@ keybind: Keybinds = .{},
/// Currently only supported on macOS.
@"window-step-resize": bool = false,
/// Append new tabs to the end of the tab list instead of right after the
/// current tab.
@"window-append-new-tabs": bool = false,
/// When enabled, the full GTK titlebar is displayed instead of your window
/// manager's simple titlebar. The behavior of this option will vary with your
/// window manager.