# SPDX-FileCopyrightText: 2024 Luca Weiss
# SPDX-License-Identifier: GPL-3.0-only

from gi.repository import Adw
from gi.repository import Gtk


def show_toast(overlay: Adw.ToastOverlay, title: str) -> None:
    t = Adw.Toast()
    t.set_title(title)
    overlay.add_toast(t)


def show_toast_info(overlay: Adw.ToastOverlay, parent: Gtk.Widget, title: str, info: str, markup: bool) -> None:
    def toast_button_clicked(_param):
        dialog = Adw.AlertDialog()
        dialog.set_heading(_("Details"))
        dialog.set_body_use_markup(markup)
        dialog.set_body(info)
        dialog.add_response("close", _("Close"))
        dialog.choose(parent, None, None, None)

    t = Adw.Toast()
    t.set_title(title)
    t.set_button_label(_("Details"))
    t.connect("button-clicked", toast_button_clicked)
    overlay.add_toast(t)
