diff --git a/src/apprt/gtk/Paned.zig b/src/apprt/gtk/Paned.zig index 7d377031e..af548b349 100644 --- a/src/apprt/gtk/Paned.zig +++ b/src/apprt/gtk/Paned.zig @@ -4,6 +4,7 @@ const std = @import("std"); const Allocator = std.mem.Allocator; const assert = std.debug.assert; const font = @import("../../font/main.zig"); +const input = @import("../../input.zig"); const CoreSurface = @import("../../Surface.zig"); const Window = @import("Window.zig"); @@ -32,14 +33,14 @@ child2: Tab.Child, // maximize the parent pane, or close the tab. parent: Parent, -pub fn create(alloc: Allocator, window: *Window, label_text: *c.GtkWidget) !*Paned { +pub fn create(alloc: Allocator, window: *Window, direction: input.SplitDirection, label_text: *c.GtkWidget) !*Paned { var paned = try alloc.create(Paned); errdefer alloc.destroy(paned); - try paned.init(window, label_text); + try paned.init(window, direction, label_text); return paned; } -pub fn init(self: *Paned, window: *Window, label_text: *c.GtkWidget) !void { +pub fn init(self: *Paned, window: *Window, direction: input.SplitDirection, label_text: *c.GtkWidget) !void { self.* = .{ .window = window, .label_text = label_text, @@ -49,7 +50,12 @@ pub fn init(self: *Paned, window: *Window, label_text: *c.GtkWidget) !void { .parent = undefined, }; - const paned = c.gtk_paned_new(c.GTK_ORIENTATION_HORIZONTAL); + const orientation: c_uint = switch (direction) { + .right => c.GTK_ORIENTATION_HORIZONTAL, + .down => c.GTK_ORIENTATION_VERTICAL, + }; + + const paned = c.gtk_paned_new(orientation); const gtk_paned: *c.GtkPaned = @ptrCast(paned); errdefer c.gtk_widget_destroy(paned); self.paned = gtk_paned; diff --git a/src/apprt/gtk/Surface.zig b/src/apprt/gtk/Surface.zig index 805378923..98f49f6c7 100644 --- a/src/apprt/gtk/Surface.zig +++ b/src/apprt/gtk/Surface.zig @@ -366,7 +366,7 @@ pub fn newSplit(self: *Surface, direction: input.SplitDirection) !void { tab.removeChild(); - const paned = try Paned.create(self.app.core_app.alloc, self.window, label_text); + const paned = try Paned.create(self.app.core_app.alloc, self.window, direction, label_text); const new_surface = try paned.newSurface(tab, &self.core_surface); // This sets .parent on each surface paned.addChild1Surface(self);