Switch crash dialog from AlertDialog to Dialog for proper sizing

AlertDialog has an internal width cap that ignores content_width. Use
adw::Dialog instead with a ToolbarView layout for full control over the
900x550 dimensions.
This commit is contained in:
lashman
2026-02-27 20:31:03 +02:00
parent bb71f5d4d5
commit df3efa3b51

View File

@@ -209,18 +209,6 @@ pub fn show_crash_dialog(
.map(|c| c.to_string())
.unwrap_or_else(|| "unknown".to_string());
let body = format!("{}\n\nExit code: {}", explanation, exit_str);
let dialog = adw::AlertDialog::builder()
.heading(&format!("{} failed to start", app_name))
.body(&body)
.close_response("close")
.default_response("close")
.prefer_wide_layout(true)
.build();
dialog.set_content_width(700);
dialog.set_content_height(500);
// Build the full text that gets copied
let full_error = format!(
"App: {}\nExit code: {}\n\n{}\n\nError output:\n{}",
@@ -230,19 +218,42 @@ pub fn show_crash_dialog(
stderr.trim(),
);
// Extra content: scrollable text view with full stderr + copy button
if !stderr.trim().is_empty() {
let vbox = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.spacing(8)
// Use adw::Dialog (not AlertDialog) for full size control
let dialog = adw::Dialog::builder()
.title(&format!("{} failed to start", app_name))
.content_width(900)
.content_height(550)
.build();
let toolbar = adw::ToolbarView::new();
let header = adw::HeaderBar::new();
toolbar.add_top_bar(&header);
let content = gtk::Box::builder()
.orientation(gtk::Orientation::Vertical)
.spacing(12)
.margin_top(16)
.margin_bottom(16)
.margin_start(24)
.margin_end(24)
.build();
// Explanation
let explanation_label = gtk::Label::builder()
.label(&format!("{}\n\nExit code: {}", explanation, exit_str))
.wrap(true)
.xalign(0.0)
.build();
content.append(&explanation_label);
// Error output
if !stderr.trim().is_empty() {
let heading = gtk::Label::builder()
.label("Error output:")
.xalign(0.0)
.build();
heading.add_css_class("heading");
vbox.append(&heading);
content.append(&heading);
let text_view = gtk::TextView::builder()
.editable(false)
@@ -259,11 +270,9 @@ pub fn show_crash_dialog(
let scrolled = gtk::ScrolledWindow::builder()
.child(&text_view)
.min_content_height(250)
.max_content_height(500)
.vexpand(true)
.build();
vbox.append(&scrolled);
content.append(&scrolled);
let copy_btn = gtk::Button::builder()
.label("Copy to clipboard")
@@ -277,12 +286,11 @@ pub fn show_crash_dialog(
btn.set_label("Copied!");
btn.set_sensitive(false);
});
vbox.append(&copy_btn);
dialog.set_extra_child(Some(&vbox));
content.append(&copy_btn);
}
dialog.add_response("close", "Close");
toolbar.set_content(Some(&content));
dialog.set_child(Some(&toolbar));
dialog.present(Some(parent));
}