gtk: remove fields on Paned we don't need

This commit is contained in:
Thorsten Ball
2023-11-01 09:21:15 +01:00
committed by Mitchell Hashimoto
parent 09bbaa82b4
commit ba2992d4d0
2 changed files with 5 additions and 19 deletions

View File

@ -17,13 +17,6 @@ const c = @import("c.zig");
const log = std.log.scoped(.gtk); 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 /// Our actual GtkPaned widget
paned: *c.GtkPaned, paned: *c.GtkPaned,
@ -36,17 +29,15 @@ child2: Child,
// maximize the parent pane, or close the tab. // maximize the parent pane, or close the tab.
parent: Parent, 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); var paned = try alloc.create(Paned);
errdefer alloc.destroy(paned); errdefer alloc.destroy(paned);
try paned.init(window, sibling, direction); try paned.init(sibling, direction);
return paned; 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.* = .{ self.* = .{
.window = window,
.label_text = undefined,
.paned = undefined, .paned = undefined,
.child1 = .none, .child1 = .none,
.child2 = .none, .child2 = .none,
@ -54,11 +45,6 @@ pub fn init(self: *Paned, window: *Window, sibling: *Surface, direction: input.S
}; };
errdefer self.* = undefined; errdefer self.* = undefined;
self.label_text = sibling.getTitleLabel() orelse {
log.warn("sibling surface has no title label", .{});
return;
};
const orientation: c_uint = switch (direction) { const orientation: c_uint = switch (direction) {
.right => c.GTK_ORIENTATION_HORIZONTAL, .right => c.GTK_ORIENTATION_HORIZONTAL,
.down => c.GTK_ORIENTATION_VERTICAL, .down => c.GTK_ORIENTATION_VERTICAL,
@ -113,7 +99,7 @@ pub fn splitSurfaceInPosition(self: *Paned, position: Position, direction: input
// Create new Paned // Create new Paned
// NOTE: We cannot use `replaceChildInPosition` here because we need to // NOTE: We cannot use `replaceChildInPosition` here because we need to
// first remove the surface before we create a new pane. // 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) { switch (position) {
.start => self.addChild1(.{ .paned = paned }), .start => self.addChild1(.{ .paned = paned }),
.end => self.addChild2(.{ .paned = paned }), .end => self.addChild2(.{ .paned = paned }),

View File

@ -180,7 +180,7 @@ pub fn splitSurface(self: *Tab, direction: input.SplitDirection) !void {
self.removeChild(); self.removeChild();
// Create a Paned with two Surfaces. // 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. // Add Paned to the Tab.
self.setChild(.{ .paned = paned }); self.setChild(.{ .paned = paned });