Skip to content

Fix text label sizing with --width and --geometry#318

Open
mg-dev25 wants to merge 1 commit intov1cont:masterfrom
Mgdev-25:fix/text-sizing
Open

Fix text label sizing with --width and --geometry#318
mg-dev25 wants to merge 1 commit intov1cont:masterfrom
Mgdev-25:fix/text-sizing

Conversation

@mg-dev25
Copy link
Contributor

@mg-dev25 mg-dev25 commented Dec 2, 2025

Fix text label sizing with --width and --geometry

Fixes window sizing issues when using --width, --geometry, or --wrap options with long text content.

Fixes #107, #140, #32, #297, #300

Problem

When a dialog has long text and --width is specified, GTK requests the natural (unwrapped) width first, then tries to wrap the text. This causes windows to expand far beyond the requested width.

Solution

Added a size-allocate callback that constrains the label width to the allocated space. Also set max_width_chars with ELLIPSIZE_NONE to force text wrapping instead of window expansion.

Changes in src/main.c:

  • New text_size_allocate_cb() callback
  • Set PANGO_WRAP_WORD_CHAR mode for better word breaking
  • Calculate and set max_width_chars based on window width
  • Connect size-allocate signal when width is constrained

Testing

# Before: Window expands to fit unwrapped text
# After: Window stays at specified width, text wraps

yad --text="This is a very long text that should wrap properly when the window width is constrained by the --width option" --width=400

yad --geometry=400x200 --text="Long text that should wrap within the geometry constraints"

Fixes window sizing issues when using --width, --geometry, or --wrap options
with long text content. Without this fix, GTK requests the natural (unwrapped)
width first, causing windows to become excessively large.

Changes:
- Add text_size_allocate_cb() callback to constrain label width
- Set PANGO_WRAP_WORD_CHAR mode for better word breaking
- Use max_width_chars with ELLIPSIZE_NONE to force wrapping
- Connect size-allocate signal when width is constrained

Fixes v1cont#107, v1cont#140, v1cont#32, v1cont#297, v1cont#300
@mg-dev25 mg-dev25 closed this Dec 7, 2025
@mg-dev25 mg-dev25 deleted the fix/text-sizing branch December 7, 2025 10:52
@mg-dev25 mg-dev25 restored the fix/text-sizing branch December 7, 2025 23:16
@mg-dev25 mg-dev25 reopened this Dec 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

YAD 7.3: Dialog height too large

1 participant