use adw::{
prelude::{AdwDialogExt, AlertDialogExt, AlertDialogExtManual},
AlertDialog, ResponseAppearance,
};
use gtk::prelude::IsA;
const HEADING: &str = "Oops";
const BODY: &str = "Identity not supported for this request";
const RESPONSE_QUIT: (&str, &str) = ("close", "Close");
pub struct Widget {
gobject: AlertDialog,
}
impl Widget {
pub fn new() -> Self {
let gobject = AlertDialog::builder()
.heading(HEADING)
.body(BODY)
.close_response(RESPONSE_QUIT.0)
.default_response(RESPONSE_QUIT.0)
.build();
gobject.add_responses(&[RESPONSE_QUIT]);
gobject.set_response_appearance(RESPONSE_QUIT.0, ResponseAppearance::Destructive);
gobject.connect_response(None, move |dialog, response| {
if response == RESPONSE_QUIT.0 {
dialog.close();
}
});
Self { gobject }
}
pub fn present(&self, parent: Option<&impl IsA<gtk::Widget>>) {
self.gobject.present(parent)
}
}