Skip to content

Commit 8a5f15d

Browse files
committed
feat: do the graceful exit when the tab count is 0 the GTK way
1 parent eb9bf92 commit 8a5f15d

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/widgets/window.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,17 @@ impl Window {
317317
this.page_switched(tab_view);
318318
}),
319319
);
320+
imp.tab_view.connect_close_page(
321+
clone!(@weak self as this => @default-panic, move |tab_view, page| {
322+
tab_view.close_page_finish(page, !page.is_pinned());
323+
324+
if tab_view.n_pages() == 0 {
325+
this.close();
326+
};
327+
328+
true
329+
}),
330+
);
320331
imp.tab_overview.connect_create_tab(
321332
clone!(@weak self as this => @default-panic, move |_| {
322333
this.new_tab();
@@ -571,9 +582,6 @@ impl Window {
571582
let imp = self.imp();
572583
imp.tab_view
573584
.close_page(&imp.tab_view.page(&self.current_tab()));
574-
if imp.tab_view.n_pages() == 0 {
575-
std::process::exit(0); // TODO: maybe there's a better way for gtk apps...
576-
}
577585
}
578586

579587
fn focus_url_bar(&self) {

0 commit comments

Comments
 (0)