The darktable team are in the process of converting from GTK 3 to version 4.
Looking at the code for some of the tooltips reveals numerous newline characters in longer tips.
I have tried using the CSS properties max-width and width, but these are flagged as “not a valid property name”, as is “word-wrap”.
Without these, and without hard-coded newline characters, the tip is displayed as a single, huge line.
Is there any way of specifying the width of a tooltip text box, given the unavailability of these properties? To avoid refactoring the underlying code, this should be done in CSS.
No. GTK’s CSS does not control the layout or sizing of text, as that’s the remit of the UI element that displays the text.
The only want to control the contents of a tooltip, like the maximum length in characters and the word wrapping, is to create your own widget, and then calling gtk_tooltip_set_custom() inside the GtkWidget::query-tooltip signal.
The default tooltip contents are set to:
expand horizontally
have a maximum width of 50 characters
wrap on a word boundary if the line width reaches the maximum width
If you’re experiencing a different behaviour, feel free to open an issue in the GTK issue tracker with a self-contained example exhibiting the behaviour.
I should note that I am acting as an intermediary here, not as the developer.
The code looks like:
gtk_widget_set_tooltip_text(controls->toe_warning_icon,
_("the curve has lost its 'S' shape, toe power cannot be applied.\n"
"target black cannot be reached with the selected contrast and pivot position.\n"
"increase contrast, move the pivot lower (reduce the pivot target output or\n"
"curve y gamma), or increase the distance between the pivot and the left edge\n"
"(increase the pivot shift, move the black point farther from the pivot by raising\n"
"the relative black exposure or move the white point closer to the pivot\n"
"by decreasing relative white exposure)."));