gtk: move Child/Parent/Position into same file

This commit is contained in:
Thorsten Ball
2023-10-24 06:54:41 +02:00
committed by Mitchell Hashimoto
parent be836bc777
commit 19f7b37bb3
4 changed files with 20 additions and 18 deletions

View File

@ -10,8 +10,9 @@ const CoreSurface = @import("../../Surface.zig");
const Window = @import("Window.zig");
const Surface = @import("Surface.zig");
const Tab = @import("Tab.zig");
const Position = @import("parent.zig").Position;
const Parent = @import("parent.zig").Parent;
const Position = @import("relation.zig").Position;
const Parent = @import("relation.zig").Parent;
const Child = @import("relation.zig").Child;
const c = @import("c.zig");
/// We'll need to keep a reference to the Window this belongs to for various reasons
@ -26,8 +27,8 @@ paned: *c.GtkPaned,
// We have two children, each of which can be either a Surface, another pane,
// or empty. We're going to keep track of which each child is here.
child1: Tab.Child,
child2: Tab.Child,
child1: Child,
child2: Child,
// We also hold a reference to our parent widget, so that when we close we can either
// maximize the parent pane, or close the tab.
@ -126,28 +127,28 @@ pub fn removeChildInPosition(self: *Paned, position: Position) void {
pub fn addChild1Surface(self: *Paned, surface: *Surface) void {
assert(self.child1 == .none);
self.child1 = Tab.Child{ .surface = surface };
self.child1 = Child{ .surface = surface };
surface.setParent(Parent{ .paned = .{ self, .start } });
c.gtk_paned_set_start_child(@ptrCast(self.paned), @ptrCast(surface.gl_area));
}
pub fn addChild2Surface(self: *Paned, surface: *Surface) void {
assert(self.child2 == .none);
self.child2 = Tab.Child{ .surface = surface };
self.child2 = Child{ .surface = surface };
surface.setParent(Parent{ .paned = .{ self, .end } });
c.gtk_paned_set_end_child(@ptrCast(self.paned), @ptrCast(surface.gl_area));
}
pub fn addChild1Paned(self: *Paned, paned: *Paned) void {
assert(self.child1 == .none);
self.child1 = Tab.Child{ .paned = paned };
self.child1 = Child{ .paned = paned };
paned.setParent(Parent{ .paned = .{ self, .start } });
c.gtk_paned_set_start_child(@ptrCast(self.paned), @ptrCast(@alignCast(paned.paned)));
}
pub fn addChild2Paned(self: *Paned, paned: *Paned) void {
assert(self.child2 == .none);
self.child2 = Tab.Child{ .paned = paned };
self.child2 = Child{ .paned = paned };
paned.setParent(Parent{ .paned = .{ self, .end } });
c.gtk_paned_set_end_child(@ptrCast(self.paned), @ptrCast(@alignCast(paned.paned)));
}

View File

@ -16,8 +16,7 @@ const Paned = @import("Paned.zig");
const Tab = @import("Tab.zig");
const Window = @import("Window.zig");
const ClipboardConfirmationWindow = @import("ClipboardConfirmationWindow.zig");
const Position = @import("parent.zig").Position;
const Parent = @import("parent.zig").Parent;
const Parent = @import("relation.zig").Parent;
const inspector = @import("inspector.zig");
const gtk_key = @import("key.zig");
const c = @import("c.zig");

View File

@ -6,7 +6,8 @@ const assert = std.debug.assert;
const font = @import("../../font/main.zig");
const CoreSurface = @import("../../Surface.zig");
const Paned = @import("Paned.zig");
const Parent = @import("parent.zig").Parent;
const Parent = @import("relation.zig").Parent;
const Child = @import("relation.zig").Child;
const Surface = @import("Surface.zig");
const Window = @import("Window.zig");
const c = @import("c.zig");
@ -15,12 +16,6 @@ const log = std.log.scoped(.gtk);
pub const GHOSTTY_TAB = "ghostty_tab";
pub const Child = union(enum) {
surface: *Surface,
paned: *Paned,
none,
};
window: *Window,
label_text: *c.GtkLabel,
close_button: *c.GtkButton,

View File

@ -1,3 +1,4 @@
const Surface = @import("Surface.zig");
const Paned = @import("Paned.zig");
const Tab = @import("Tab.zig");
@ -7,10 +8,16 @@ pub const Position = enum {
};
pub const Parent = union(enum) {
none: void,
none,
tab: *Tab,
paned: struct {
*Paned,
Position,
},
};
pub const Child = union(enum) {
none,
surface: *Surface,
paned: *Paned,
};