mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-22 11:46:11 +03:00
apprt/gtk: add comments, rename some funcs
This commit is contained in:
@ -47,7 +47,7 @@ pub fn init(
|
|||||||
sibling: *Surface,
|
sibling: *Surface,
|
||||||
direction: input.SplitDirection,
|
direction: input.SplitDirection,
|
||||||
) !void {
|
) !void {
|
||||||
// Create the new child surface
|
// Create the new child surface for the other direction.
|
||||||
const alloc = sibling.app.core_app.alloc;
|
const alloc = sibling.app.core_app.alloc;
|
||||||
var surface = try Surface.create(alloc, sibling.app, .{
|
var surface = try Surface.create(alloc, sibling.app, .{
|
||||||
.parent = &sibling.core_surface,
|
.parent = &sibling.core_surface,
|
||||||
@ -97,7 +97,8 @@ pub fn destroy(self: *Split, alloc: Allocator) void {
|
|||||||
self.top_left.deinit(alloc);
|
self.top_left.deinit(alloc);
|
||||||
self.bottom_right.deinit(alloc);
|
self.bottom_right.deinit(alloc);
|
||||||
|
|
||||||
// Clean up our GTK reference.
|
// Clean up our GTK reference. This will trigger all the destroy callbacks
|
||||||
|
// that are necessary for the surfaces to clean up.
|
||||||
c.g_object_unref(self.paned);
|
c.g_object_unref(self.paned);
|
||||||
|
|
||||||
alloc.destroy(self);
|
alloc.destroy(self);
|
||||||
@ -114,7 +115,11 @@ pub fn removeBottomRight(self: *Split) void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Is this Zig-y?
|
// TODO: Is this Zig-y?
|
||||||
inline fn removeChild(self: *Split, remove: Surface.Container.Elem, keep: Surface.Container.Elem) void {
|
fn removeChild(
|
||||||
|
self: *Split,
|
||||||
|
remove: Surface.Container.Elem,
|
||||||
|
keep: Surface.Container.Elem,
|
||||||
|
) void {
|
||||||
const window = self.container.window() orelse return;
|
const window = self.container.window() orelse return;
|
||||||
const alloc = window.app.core_app.alloc;
|
const alloc = window.app.core_app.alloc;
|
||||||
|
|
||||||
@ -128,7 +133,7 @@ inline fn removeChild(self: *Split, remove: Surface.Container.Elem, keep: Surfac
|
|||||||
// Grab focus of the left-over side
|
// Grab focus of the left-over side
|
||||||
keep.grabFocus();
|
keep.grabFocus();
|
||||||
|
|
||||||
// TODO: is this correct?
|
// When a child is removed we are no longer a split, so destroy ourself
|
||||||
remove.deinit(alloc);
|
remove.deinit(alloc);
|
||||||
alloc.destroy(self);
|
alloc.destroy(self);
|
||||||
}
|
}
|
||||||
|
@ -147,12 +147,12 @@ pub const Container = union(enum) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Remove ourselves from the container. This is used by
|
/// Remove ourselves from the container. This is used by
|
||||||
/// children to effectively notify they're containing that
|
/// children to effectively notify they're container that
|
||||||
/// all children at this level are exiting.
|
/// all children at this level are exiting.
|
||||||
pub fn remove(self: Container) void {
|
pub fn remove(self: Container) void {
|
||||||
switch (self) {
|
switch (self) {
|
||||||
.none => {},
|
.none => {},
|
||||||
.tab_ => |t| t.closeElem(),
|
.tab_ => |t| t.remove(),
|
||||||
.split_tl => self.split().?.removeTopLeft(),
|
.split_tl => self.split().?.removeTopLeft(),
|
||||||
.split_br => self.split().?.removeBottomRight(),
|
.split_br => self.split().?.removeBottomRight(),
|
||||||
}
|
}
|
||||||
|
@ -166,10 +166,8 @@ pub fn replaceElem(self: *Tab, elem: Surface.Container.Elem) void {
|
|||||||
self.elem = elem;
|
self.elem = elem;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: move this
|
/// Remove this tab from the window.
|
||||||
/// The surface element is closing. If we're the direct parent
|
pub fn remove(self: *Tab) void {
|
||||||
/// then that means our tab is also closing.
|
|
||||||
pub fn closeElem(self: *Tab) void {
|
|
||||||
self.window.closeTab(self);
|
self.window.closeTab(self);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user