mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 00:36:07 +03:00
gtk: introduce helper method on Paned
This commit is contained in:

committed by
Mitchell Hashimoto

parent
dc0f6e3a5b
commit
aaa6ff8884
@ -110,35 +110,18 @@ pub fn newSurface(self: *Paned, tab: *Tab, parent_: ?*CoreSurface) !*Surface {
|
|||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn focusSurfaceInPosition(self: *Paned, position: Position) void {
|
|
||||||
const child = switch (position) {
|
|
||||||
.start => self.child1,
|
|
||||||
.end => self.child2,
|
|
||||||
};
|
|
||||||
|
|
||||||
const surface = switch (child) {
|
|
||||||
.surface => |surface| surface,
|
|
||||||
else => return,
|
|
||||||
};
|
|
||||||
|
|
||||||
const widget = @as(*c.GtkWidget, @ptrCast(surface.gl_area));
|
|
||||||
_ = c.gtk_widget_grab_focus(widget);
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn setParent(self: *Paned, parent: Parent) void {
|
pub fn setParent(self: *Paned, parent: Parent) void {
|
||||||
self.parent = parent;
|
self.parent = parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn splitSurfaceInPosition(self: *Paned, position: Position, direction: input.SplitDirection) !void {
|
pub fn focusSurfaceInPosition(self: *Paned, position: Position) void {
|
||||||
const child = switch (position) {
|
const surface: *Surface = self.surfaceInPosition(position) orelse return;
|
||||||
.start => self.child1,
|
const widget = @as(*c.GtkWidget, @ptrCast(surface.gl_area));
|
||||||
.end => self.child2,
|
_ = c.gtk_widget_grab_focus(widget);
|
||||||
};
|
}
|
||||||
|
|
||||||
const surface: *Surface = switch (child) {
|
pub fn splitSurfaceInPosition(self: *Paned, position: Position, direction: input.SplitDirection) !void {
|
||||||
.surface => |surface| surface,
|
const surface: *Surface = self.surfaceInPosition(position) orelse return;
|
||||||
else => return,
|
|
||||||
};
|
|
||||||
|
|
||||||
// Keep explicit reference to surface gl_area before we remove it.
|
// Keep explicit reference to surface gl_area before we remove it.
|
||||||
const object: *c.GObject = @ptrCast(surface.gl_area);
|
const object: *c.GObject = @ptrCast(surface.gl_area);
|
||||||
@ -237,3 +220,15 @@ pub fn deinit(self: *Paned, alloc: Allocator) void {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn surfaceInPosition(self: *Paned, position: Position) ?*Surface {
|
||||||
|
const child = switch (position) {
|
||||||
|
.start => self.child1,
|
||||||
|
.end => self.child2,
|
||||||
|
};
|
||||||
|
|
||||||
|
return switch (child) {
|
||||||
|
.surface => |surface| surface,
|
||||||
|
else => null,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user