From ba2992d4d08c32035219f12458a0260d05d207c7 Mon Sep 17 00:00:00 2001 From: Thorsten Ball Date: Wed, 1 Nov 2023 09:21:15 +0100 Subject: [PATCH] gtk: remove fields on Paned we don't need --- src/apprt/gtk/Paned.zig | 22 ++++------------------ src/apprt/gtk/Tab.zig | 2 +- 2 files changed, 5 insertions(+), 19 deletions(-) diff --git a/src/apprt/gtk/Paned.zig b/src/apprt/gtk/Paned.zig index a77e599c8..029161a43 100644 --- a/src/apprt/gtk/Paned.zig +++ b/src/apprt/gtk/Paned.zig @@ -17,13 +17,6 @@ const c = @import("c.zig"); const log = std.log.scoped(.gtk); -/// We'll need to keep a reference to the Window this belongs to for various reasons -window: *Window, - -// We keep track of the tab label's text so that if a child widget of this pane -// gets focus (and is a Surface) we can reset the tab label appropriately -label_text: *c.GtkWidget, - /// Our actual GtkPaned widget paned: *c.GtkPaned, @@ -36,17 +29,15 @@ child2: Child, // maximize the parent pane, or close the tab. parent: Parent, -pub fn create(alloc: Allocator, window: *Window, sibling: *Surface, direction: input.SplitDirection) !*Paned { +pub fn create(alloc: Allocator, sibling: *Surface, direction: input.SplitDirection) !*Paned { var paned = try alloc.create(Paned); errdefer alloc.destroy(paned); - try paned.init(window, sibling, direction); + try paned.init(sibling, direction); return paned; } -pub fn init(self: *Paned, window: *Window, sibling: *Surface, direction: input.SplitDirection) !void { +pub fn init(self: *Paned, sibling: *Surface, direction: input.SplitDirection) !void { self.* = .{ - .window = window, - .label_text = undefined, .paned = undefined, .child1 = .none, .child2 = .none, @@ -54,11 +45,6 @@ pub fn init(self: *Paned, window: *Window, sibling: *Surface, direction: input.S }; errdefer self.* = undefined; - self.label_text = sibling.getTitleLabel() orelse { - log.warn("sibling surface has no title label", .{}); - return; - }; - const orientation: c_uint = switch (direction) { .right => c.GTK_ORIENTATION_HORIZONTAL, .down => c.GTK_ORIENTATION_VERTICAL, @@ -113,7 +99,7 @@ pub fn splitSurfaceInPosition(self: *Paned, position: Position, direction: input // Create new Paned // NOTE: We cannot use `replaceChildInPosition` here because we need to // first remove the surface before we create a new pane. - const paned = try Paned.create(self.window.app.core_app.alloc, self.window, surface, direction); + const paned = try Paned.create(surface.window.app.core_app.alloc, surface, direction); switch (position) { .start => self.addChild1(.{ .paned = paned }), .end => self.addChild2(.{ .paned = paned }), diff --git a/src/apprt/gtk/Tab.zig b/src/apprt/gtk/Tab.zig index d4504f96c..2945f42a0 100644 --- a/src/apprt/gtk/Tab.zig +++ b/src/apprt/gtk/Tab.zig @@ -180,7 +180,7 @@ pub fn splitSurface(self: *Tab, direction: input.SplitDirection) !void { self.removeChild(); // Create a Paned with two Surfaces. - const paned = try Paned.create(self.window.app.core_app.alloc, self.window, surface, direction); + const paned = try Paned.create(self.window.app.core_app.alloc, surface, direction); // Add Paned to the Tab. self.setChild(.{ .paned = paned });