From 9ad92d2c3d6c3a80b7abc2dbe9c6d7d478f38d06 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 9 Aug 2025 12:21:24 -0700 Subject: [PATCH] apprt/gtk-ng: proper split operations --- src/apprt/gtk-ng/class/split_tree.zig | 52 ++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/src/apprt/gtk-ng/class/split_tree.zig b/src/apprt/gtk-ng/class/split_tree.zig index cd03297b4..bc6bc6c3c 100644 --- a/src/apprt/gtk-ng/class/split_tree.zig +++ b/src/apprt/gtk-ng/class/split_tree.zig @@ -148,10 +148,10 @@ pub const SplitTree = extern struct { const actions = .{ // All of these will eventually take a target surface parameter. // For now all our targets originate from the focused surface. - .{ "new-left", actionNew, null }, - .{ "new-right", actionNew, null }, - .{ "new-up", actionNew, null }, - .{ "new-down", actionNew, null }, + .{ "new-left", actionNewLeft, null }, + .{ "new-right", actionNewRight, null }, + .{ "new-up", actionNewUp, null }, + .{ "new-down", actionNewDown, null }, }; // We need to collect our actions into a group since we're just @@ -405,7 +405,21 @@ pub const SplitTree = extern struct { //--------------------------------------------------------------- // Signal handlers - pub fn actionNew( + pub fn actionNewLeft( + _: *gio.SimpleAction, + parameter_: ?*glib.Variant, + self: *Self, + ) callconv(.c) void { + _ = parameter_; + self.newSplit( + .left, + self.getActiveSurface(), + ) catch |err| { + log.warn("new split failed error={}", .{err}); + }; + } + + pub fn actionNewRight( _: *gio.SimpleAction, parameter_: ?*glib.Variant, self: *Self, @@ -419,6 +433,34 @@ pub const SplitTree = extern struct { }; } + pub fn actionNewUp( + _: *gio.SimpleAction, + parameter_: ?*glib.Variant, + self: *Self, + ) callconv(.c) void { + _ = parameter_; + self.newSplit( + .up, + self.getActiveSurface(), + ) catch |err| { + log.warn("new split failed error={}", .{err}); + }; + } + + pub fn actionNewDown( + _: *gio.SimpleAction, + parameter_: ?*glib.Variant, + self: *Self, + ) callconv(.c) void { + _ = parameter_; + self.newSplit( + .down, + self.getActiveSurface(), + ) catch |err| { + log.warn("new split failed error={}", .{err}); + }; + } + fn propSurfaceFocused( surface: *Surface, _: *gobject.ParamSpec,