Show a toast with an Undo action; executes on_undo when clicked.
(self, message: str, on_undo)
| 125 | pass |
| 126 | |
| 127 | def _show_undo_toast(self, message: str, on_undo): |
| 128 | """Show a toast with an Undo action; executes on_undo when clicked.""" |
| 129 | try: |
| 130 | toast = Adw.Toast.new(message) |
| 131 | if hasattr(toast, "set_button_label"): |
| 132 | try: |
| 133 | toast.set_button_label(_("Undo")) |
| 134 | except Exception: |
| 135 | pass |
| 136 | if hasattr(toast, "connect"): |
| 137 | try: |
| 138 | toast.connect("button-clicked", lambda t: on_undo()) |
| 139 | except Exception: |
| 140 | pass |
| 141 | if hasattr(self, "toast_overlay") and self.toast_overlay is not None: |
| 142 | self.toast_overlay.add_toast(toast) |
| 143 | else: |
| 144 | self.show_toast(message) |
| 145 | except Exception: |
| 146 | self.show_toast(message) |
| 147 | |
| 148 | def _setup_split_view(self): |
| 149 | """Set up the split view between host list and editor.""" |
no test coverage detected