mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
gtk: simplify code when creating new split
This commit is contained in:

committed by
Mitchell Hashimoto

parent
601eed24c4
commit
98a5016598
@ -347,35 +347,28 @@ pub fn toggleFullscreen(self: *Surface, mac_non_native: configpkg.NonNativeFulls
|
||||
}
|
||||
|
||||
pub fn newSplit(self: *Surface, direction: input.SplitDirection) !void {
|
||||
log.info("surface.newSplit. direction={}", .{direction});
|
||||
log.debug("new split, direction: {}", .{direction});
|
||||
|
||||
switch (self.parent) {
|
||||
.none => {
|
||||
log.info("no parent\n", .{});
|
||||
},
|
||||
.none => return,
|
||||
.paned => {
|
||||
log.info("parent is paned \n", .{});
|
||||
// TODO: Implement this
|
||||
log.info("parent is paned", .{});
|
||||
},
|
||||
.tab => |tab| {
|
||||
const tab_idx = for (self.window.tabs.items, 0..) |t, i| {
|
||||
if (t == tab) break i;
|
||||
} else null;
|
||||
|
||||
const label_text: ?*c.GtkWidget = switch (self.title) {
|
||||
.none => null,
|
||||
const label_text: *c.GtkWidget = switch (self.title) {
|
||||
.none => return,
|
||||
.label => |label| l: {
|
||||
const widget = @as(*c.GtkWidget, @ptrCast(@alignCast(label)));
|
||||
break :l widget;
|
||||
},
|
||||
};
|
||||
|
||||
if (label_text) |text| {
|
||||
tab.removeChild();
|
||||
|
||||
const paned = try Paned.create(self.app.core_app.alloc, self.window, text);
|
||||
|
||||
const paned = try Paned.create(self.app.core_app.alloc, self.window, label_text);
|
||||
const new_surface = try paned.newSurface(tab, &self.core_surface);
|
||||
// // This sets .parent on each surface
|
||||
// This sets .parent on each surface
|
||||
paned.addChild1Surface(self);
|
||||
paned.addChild2Surface(new_surface);
|
||||
|
||||
@ -384,9 +377,6 @@ pub fn newSplit(self: *Surface, direction: input.SplitDirection) !void {
|
||||
// FOCUS ON NEW SURFACE
|
||||
const widget = @as(*c.GtkWidget, @ptrCast(new_surface.gl_area));
|
||||
_ = c.gtk_widget_grab_focus(widget);
|
||||
} else {
|
||||
log.info("no label text: {?}\n", .{tab_idx});
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user