Skip to content

Commit

Permalink
gtk: noop if last active tab is closed
Browse files Browse the repository at this point in the history
  • Loading branch information
SkamDart committed Jul 3, 2024
1 parent 27f5a6d commit 0d5067a
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/apprt/gtk/Window.zig
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,13 @@ pub fn closeTab(self: *Window, tab: *Tab) void {
// Find page and tab which we're closing
const page_idx = getNotebookPageIndex(page);

// If the page we are closing is the last active tab,
// then make the last active tab keybind a noop until
// a new tab is selected.
if (page_idx == self.last_active_tab_index) {
self.last_active_tab_index = -1;
}

// Remove the page. This will destroy the GTK widgets in the page which
// will trigger Tab cleanup.
c.gtk_notebook_remove_page(self.notebook, page_idx);
Expand Down Expand Up @@ -297,7 +304,6 @@ pub fn gotoLastActiveTab(self: *Window) void {
const page_idx = c.gtk_notebook_get_current_page(self.notebook);
c.gtk_notebook_set_current_page(self.notebook, self.last_active_tab_index);
self.focusCurrentTab();
log.debug("going to last active tab", .{});
self.last_active_tab_index = page_idx;
}
}
Expand Down

0 comments on commit 0d5067a

Please sign in to comment.