Widen the approval dialog and narrow the rest

The approval dialog set AdwDialog:content-width, which an AdwAlertDialog
ignores — it uses internal breakpoints, and a breakpoint-using AdwDialog has
no minimum size, so the dialog rendered 300px wide however large the request.
Pin it with a width-request instead (plain::alert_width), which the dialog
honours exactly.

With that working, drop the shared dialog width from 560 to 480 and shrink
the main window to 560x740 so both dialogs sit comfortably inside it.
This commit is contained in:
raucao committed 2026-11-26 12:12:32 +04:00
1 parent e0eec2df63
commit e2785afa37
4 files changed
+32 -13

No files matched your search

+12 -4
View File
@@ -144,8 +144,9 @@ data/ desktop, metainfo, gschema, icons, resources (ui/*.blp, sty
for") live in a collapsed **Details** expander. The "name and URL are supplied
by the application" warning is shown on the **pair** screen only — on an
already-approved app's request it is banner blindness. Both this dialog and
"Connect an app" use `plain::DIALOG_WIDTH` (560) so neither resizes as the user
moves between them.
"Connect an app" use `plain::DIALOG_WIDTH` (480) so neither resizes as the user
moves between them — the approval dialog pins it with `plain::alert_width`,
because `AdwAlertDialog` ignores `content-width` (see trap 17).
- **The dialog owns the deadline, and it is absolute.** `ASK_TIMEOUT` (60 s) is
turned into an `Instant` **when the ask starts** and travels to the UI in the
`Prompt`; the dialog answers `Deny` and closes itself when that instant arrives
@@ -616,10 +617,17 @@ UI lives in `data/resources/ui/*.blp` (Blueprint) and is compiled to `.ui` by
**ignores `content-width`/`content-height`** and uses the content's natural
size, so a dialog that needs a fixed width must pin it on the child instead
(`toolbar.set_size_request(width, -1)`). Measured for "Connect an app":
without follows, 560×176 collapsed and expanded; with follows and no width
pin, 229×176/229×492; with follows plus the pin, 560×176/560×492. Pinning the
without follows, 480×176 collapsed and expanded; with follows and no width
pin, 229×176/229×492; with follows plus the pin, 480×176/480×492. Pinning the
width on the scroller or the content box instead of the toolbar view leaves
the height stuck.
17. **`AdwAlertDialog` ignores `content-width`.** It uses internal breakpoints,
and a breakpoint-using `AdwDialog` has **no minimum size** — its
`content-width` property does not drive the floating size (measured: a `560`
request still renders 300 px wide; the same value set after `present()` is
ignored too). A plain `AdwDialog` *does* honour it, which is why "Connect an
app" worked. Set `width-request` instead (`plain::alert_width`), which the
dialog honours exactly. Do not "simplify" it back to `content_width`.
## Blueprint / Meson traps
+2 -2
View File
@@ -3,8 +3,8 @@ using Adw 1;
Adw.ApplicationWindow window {
title: "Regent";
default-width: 600;
default-height: 800;
default-width: 560;
default-height: 740;
content: Adw.ToolbarView toolbar_view {
[top]
+5 -4
View File
@@ -250,15 +250,16 @@ pub async fn present_question(
let dialog = adw::AlertDialog::builder()
.heading(heading(request))
.body(story(request))
// The same width as the "Connect an app" dialog. A floating `AdwDialog`
// is part of the window and is clipped by it, so it must be able to
// shrink to fit rather than poke out of the sides.
.content_width(plain::DIALOG_WIDTH)
.extra_child(&details(question))
.build();
// Heading and body are plain text too: the heading carries no client data
// today, but the extra child is where all of it belongs.
plain::dialog(&dialog);
// The same width as the "Connect an app" dialog. A floating `AdwDialog` is
// part of the window and is clipped by it, so it must be able to shrink to
// fit rather than poke out of the sides — and `content_width` does nothing
// on an `AdwAlertDialog` (see `plain::alert_width`).
plain::alert_width(&dialog, plain::DIALOG_WIDTH);
dialog.add_response("deny", "Deny");
dialog.set_close_response("deny");
+13 -3
View File
@@ -18,9 +18,8 @@ use libadwaita as adw;
///
/// A floating `AdwDialog` is part of the window and is clipped by it, so a
/// single width keeps the two dialogs from resizing as the user moves between
/// them. 560 is what the "Connect an app" dialog already uses and it fits the
/// main window.
pub const DIALOG_WIDTH: i32 = 560;
/// them. 480 fits comfortably inside the main window (560 px wide).
pub const DIALOG_WIDTH: i32 = 480;
/// A plain "Something went wrong" dialog, parented to the widget's window.
///
@@ -114,3 +113,14 @@ pub fn dialog(dialog: &adw::AlertDialog) {
dialog.set_heading_use_markup(false);
dialog.set_body_use_markup(false);
}
/// Pin an `AlertDialog`'s width with a `width-request`.
///
/// `AdwAlertDialog` uses internal breakpoints, and a breakpoint-using
/// `AdwDialog` deliberately has **no minimum size** — its `content-width`
/// property does not drive its size (measured: a 560 request still renders
/// 300 px wide). The documented way is to set `width-request` manually, which
/// the dialog does honour. Do **not** "simplify" this back to `content_width`.
pub fn alert_width(dialog: &adw::AlertDialog, width: i32) {
dialog.set_size_request(width, -1);
}