MCPcopy Create free account
hub / github.com/BuddySirJava/SSH-Studio / _show_unsaved_changes_dialog

Method _show_unsaved_changes_dialog

src/ui/main_window.py:440–475  ·  view source on GitHub ↗

Show alert dialog asking user what to do with unsaved changes.

(self)

Source from the content-addressed store, hash-verified

438 return False
439
440 def _show_unsaved_changes_dialog(self):
441 """Show alert dialog asking user what to do with unsaved changes."""
442 builder = Gtk.Builder.new_from_resource(
443 "/io/github/BuddySirJava/SSH-Studio/ui/unsaved_changes_dialog.ui"
444 )
445 dialog = builder.get_object("unsaved_changes_dialog")
446 dialog.set_close_response("cancel")
447 dialog.add_response("discard", _("Discard Changes"))
448 dialog.add_response("cancel", _("Cancel"))
449 dialog.add_response("save", _("Save & Quit"))
450 dialog.set_response_appearance("discard", Adw.ResponseAppearance.DESTRUCTIVE)
451 dialog.set_response_appearance("save", Adw.ResponseAppearance.SUGGESTED)
452 dialog.set_default_response("save")
453
454 def on_response(dialog, response):
455 if response == "save":
456 try:
457 if (
458 hasattr(self.host_editor, "unsaved_banner")
459 and self.host_editor.unsaved_banner
460 ):
461 self.host_editor._on_save_clicked(None)
462 dialog.close()
463 GLib.timeout_add(200, self._delayed_close)
464 except Exception as e:
465 self.show_toast(_(f"Failed to save: {e}"))
466 elif response == "discard":
467 dialog.close()
468 self.destroy()
469 else:
470 dialog.close()
471 return True
472
473 dialog.connect("response", on_response)
474 dialog.present(self)
475 return True
476
477 def _delayed_close(self):
478 """Close the window after a short delay to allow save to complete."""

Callers 1

_on_close_requestMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected