Window: always ask confirmation to close, even with only one terminal

This commit is contained in:
Vulcalien 2023-10-10 15:47:39 +02:00
parent 6d225c7aee
commit 8911723518

View File

@ -280,22 +280,14 @@ class Window(Container, Gtk.Window):
def on_delete_event(self, window, event, data=None): def on_delete_event(self, window, event, data=None):
"""Handle a window close request""" """Handle a window close request"""
maker = Factory() maker = Factory()
if maker.isinstance(self.get_child(), 'Terminal'):
if self.is_zoomed(): if (maker.isinstance(self.get_child(), 'Terminal') or
return(self.confirm_close(window, _('window'))) maker.isinstance(self.get_child(), 'Container')):
else: confirm_close = self.construct_confirm_close(window, _('window'))
dbg('Only one child, closing is fine') return (confirm_close != Gtk.ResponseType.ACCEPT)
return(False)
elif maker.isinstance(self.get_child(), 'Container'):
return(self.confirm_close(window, _('window')))
else: else:
dbg('unknown child: %s' % self.get_child()) dbg('unknown child: %s' % self.get_child())
return False # close anyway
def confirm_close(self, window, type):
"""Display a confirmation dialog when the user is closing multiple
terminals in one window"""
return(not (self.construct_confirm_close(window, type) == Gtk.ResponseType.ACCEPT))
def on_destroy_event(self, widget, data=None): def on_destroy_event(self, widget, data=None):
"""Handle window destruction""" """Handle window destruction"""