How to shrink GtkDropDown beyond its content width?

Hi! I’m having an issue with GtkDropDown taking too much horizontal space and pushing main window’s minimum width, so that it doesn’t fit on the phone screen. It uses GtkStringList model, populated at runtime. Is there a simple way to allow it to shrink below the width required to display the full selected item? Ideally, if the label on the drop-down itself would automatically cut and end with ellipsis, and the popover would display the full labels.

I’m using Gtk4 via Relm4 and Rust, if that matters.

You need to set up your list item factory and create your own label widget so it can ellipsize at the threshold of your choice.

Thank you. Is there any simpler solution if the label doesn’t have to be ellipsized?

I ended up putting label inside a scrolled window (like this). Took a while for me to understand how to set a custom list item factory, but in the end it turned out to be quite a small change. And I think it’s actually even better then ellipsizing. The code is pretty simple, and the full label is easily readable on a narrow window.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.