mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
gtk: refactor replacing child of Paned
This commit is contained in:

committed by
Mitchell Hashimoto

parent
0add9de0eb
commit
de7cbb602f
@ -130,6 +130,21 @@ pub fn setParent(self: *Paned, parent: Parent) void {
|
|||||||
self.parent = parent;
|
self.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn replaceChildInPosition(self: *Paned, child: Child, position: Position) void {
|
||||||
|
// Keep position of divider
|
||||||
|
const parent_paned_position_before = c.gtk_paned_get_position(self.paned);
|
||||||
|
|
||||||
|
self.removeChildInPosition(position);
|
||||||
|
|
||||||
|
switch (position) {
|
||||||
|
.start => self.addChild1(child),
|
||||||
|
.end => self.addChild2(child),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Restore position
|
||||||
|
c.gtk_paned_set_position(self.paned, parent_paned_position_before);
|
||||||
|
}
|
||||||
|
|
||||||
pub fn removeChildren(self: *Paned) void {
|
pub fn removeChildren(self: *Paned) void {
|
||||||
self.removeChildInPosition(.start);
|
self.removeChildInPosition(.start);
|
||||||
self.removeChildInPosition(.end);
|
self.removeChildInPosition(.end);
|
||||||
|
@ -300,18 +300,7 @@ pub fn closeSurface(self: *Window, surface: *Surface) void {
|
|||||||
const parent_paned = parent_paned_tuple[0];
|
const parent_paned = parent_paned_tuple[0];
|
||||||
const parent_paned_position = parent_paned_tuple[1];
|
const parent_paned_position = parent_paned_tuple[1];
|
||||||
|
|
||||||
// Keep position of divider
|
parent_paned.replaceChildInPosition(sibling_child, parent_paned_position);
|
||||||
const parent_paned_position_before = c.gtk_paned_get_position(parent_paned.paned);
|
|
||||||
|
|
||||||
parent_paned.removeChildInPosition(parent_paned_position);
|
|
||||||
|
|
||||||
switch (parent_paned_position) {
|
|
||||||
.start => parent_paned.addChild1(sibling_child),
|
|
||||||
.end => parent_paned.addChild2(sibling_child),
|
|
||||||
}
|
|
||||||
|
|
||||||
// Restore position
|
|
||||||
c.gtk_paned_set_position(parent_paned.paned, parent_paned_position_before);
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user