mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-14 15:56:13 +03:00
apprt/gtk: support last_tab
This commit is contained in:
@ -795,31 +795,7 @@ pub fn hasTabs(self: *const Surface) bool {
|
||||
return window.hasTabs();
|
||||
}
|
||||
|
||||
pub fn gotoPreviousTab(self: *Surface) void {
|
||||
const window = self.container.window() orelse {
|
||||
log.info(
|
||||
"gotoPreviousTab invalid for container={s}",
|
||||
.{@tagName(self.container)},
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
window.gotoPreviousTab(self);
|
||||
}
|
||||
|
||||
pub fn gotoNextTab(self: *Surface) void {
|
||||
const window = self.container.window() orelse {
|
||||
log.info(
|
||||
"gotoNextTab invalid for container={s}",
|
||||
.{@tagName(self.container)},
|
||||
);
|
||||
return;
|
||||
};
|
||||
|
||||
window.gotoNextTab(self);
|
||||
}
|
||||
|
||||
pub fn gotoTab(self: *Surface, n: usize) void {
|
||||
pub fn gotoTab(self: *Surface, tab: apprt.GotoTab) void {
|
||||
const window = self.container.window() orelse {
|
||||
log.info(
|
||||
"gotoTab invalid for container={s}",
|
||||
@ -828,7 +804,12 @@ pub fn gotoTab(self: *Surface, n: usize) void {
|
||||
return;
|
||||
};
|
||||
|
||||
window.gotoTab(n);
|
||||
switch (tab) {
|
||||
.previous => window.gotoPreviousTab(self),
|
||||
.next => window.gotoNextTab(self),
|
||||
.last => window.gotoLastTab(),
|
||||
else => window.gotoTab(@intFromEnum(tab)),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn setShouldClose(self: *Surface) void {
|
||||
|
@ -288,6 +288,13 @@ pub fn gotoNextTab(self: *Window, surface: *Surface) void {
|
||||
self.focusCurrentTab();
|
||||
}
|
||||
|
||||
/// Go to the next tab for a surface.
|
||||
pub fn gotoLastTab(self: *Window) void {
|
||||
const max = c.gtk_notebook_get_n_pages(self.notebook) -| 1;
|
||||
c.gtk_notebook_set_current_page(self.notebook, max);
|
||||
self.focusCurrentTab();
|
||||
}
|
||||
|
||||
/// Go to the specific tab index.
|
||||
pub fn gotoTab(self: *Window, n: usize) void {
|
||||
if (n == 0) return;
|
||||
|
Reference in New Issue
Block a user