diff --git a/src/apprt/gtk-ng/class/application.zig b/src/apprt/gtk-ng/class/application.zig index 1345fb273..ce6e4d9f6 100644 --- a/src/apprt/gtk-ng/class/application.zig +++ b/src/apprt/gtk-ng/class/application.zig @@ -1355,7 +1355,7 @@ const Action = struct { self: *Application, parent: ?*CoreSurface, ) !void { - const win = Window.new(self, parent); + const win = Window.new(self); // Setup a binding so that whenever our config changes so does the // window. There's never a time when the window config should be out @@ -1368,6 +1368,9 @@ const Action = struct { .{}, ); + // Create a new tab + win.newTab(parent); + // Show the window gtk.Window.present(win.as(gtk.Window)); } diff --git a/src/apprt/gtk-ng/class/window.zig b/src/apprt/gtk-ng/class/window.zig index 145a8c7bf..5a61c725b 100644 --- a/src/apprt/gtk-ng/class/window.zig +++ b/src/apprt/gtk-ng/class/window.zig @@ -224,12 +224,10 @@ pub const Window = extern struct { pub var offset: c_int = 0; }; - pub fn new(app: *Application, parent_: ?*CoreSurface) *Self { - const self = gobject.ext.newInstance(Self, .{ + pub fn new(app: *Application) *Self { + return gobject.ext.newInstance(Self, .{ .application = app, }); - self.newTab(parent_); - return self; } fn init(self: *Self, _: *Class) callconv(.C) void { @@ -1012,6 +1010,25 @@ pub const Window = extern struct { ); } + fn tabViewCreateWindow( + _: *adw.TabView, + _: *Self, + ) callconv(.c) *adw.TabView { + // Create a new window without creating a new tab. + const win = gobject.ext.newInstance( + Self, + .{ + .application = Application.default(), + }, + ); + + // We have to show it otherwise it'll just be hidden. + gtk.Window.present(win.as(gtk.Window)); + + // Get our tab view + return win.private().tab_view; + } + fn tabCloseRequest( tab: *Tab, self: *Self, @@ -1262,6 +1279,7 @@ pub const Window = extern struct { class.bindTemplateCallback("close_page", &tabViewClosePage); class.bindTemplateCallback("page_attached", &tabViewPageAttached); class.bindTemplateCallback("page_detached", &tabViewPageDetached); + class.bindTemplateCallback("tab_create_window", &tabViewCreateWindow); class.bindTemplateCallback("notify_n_pages", &tabViewNPages); class.bindTemplateCallback("notify_selected_page", &tabViewSelectedPage); class.bindTemplateCallback("notify_config", &propConfig); diff --git a/src/apprt/gtk-ng/ui/1.5/window.blp b/src/apprt/gtk-ng/ui/1.5/window.blp index ce1741ebb..07057142b 100644 --- a/src/apprt/gtk-ng/ui/1.5/window.blp +++ b/src/apprt/gtk-ng/ui/1.5/window.blp @@ -86,6 +86,7 @@ template $GhosttyWindow: Adw.ApplicationWindow { close-page => $close_page(); page-attached => $page_attached(); page-detached => $page_detached(); + create-window => $tab_create_window(); shortcuts: none; } }