Migration - GTK 2 > GTK 3 > GTK 4

Right… Done.

Thanks for pointing out the distinction between these. Because of their similarities (all those dashes) I assumed they were one and the same. I have yet to dig into CSS and I misunderstood that quote from the migration doc to mean that CSS would be disappearing in GTK 4. But now I see it’s just the style properties.

@ebassi:

I’m trying to find out what paradigm replaces widget style properties, but the reference guide doesn’t seem to mention it. Nor does the migration doc.

Could you please point me in the right direction?

I don’t understand what you mean by “paradigm”.

Style properties are, in GTK3, special CSS properties that affect part of the styling of widgets. In GTK4 those special properties don’t exist, and you should use standard CSS properties and selectors.

If you are writing a theme, or are writing custom CSS for your application, then you should consult the API reference of the widgets to know which CSS selectors apply to each part of the widget; then you can use standard CSS properties, like min-width or color, to define the style you’re looking for.

My bad. I guess ‘paradigm’ is too generic a word for this discussion. I just meant: how do we now set the properties, but you answered that.

Okay, thanks, Emmanuele.

Something I’m not clear on, though… for instance, with such style properties as “font-desc” and “foreground-rgba” in GtkCellRendererText, do the CSS versions of these properties have the same names? If not, do you know where I’d find a reference? (Or perhaps a cross-reference showing the style property and its CSS equivalent.)

With GTK3, I’ve been using (for example) set_property(“font-desc”), but I assume there’s a different function for setting CSS properties and I’m not finding it. I’m know I’m looking in the wrong places, but I don’t know where I should be looking.

Please forgive my confusion. There’s no mention of CSS on the GTK4 GtkCellRendererText page from the API and after skimming through all the CSS pages listed in the API ToC, I don’t see any mention of how CSS is applied (if that’s the right word) to a widget. Drilling down to the page on the widget class, the only functions I find with ‘css’ in their names are:

  • gtk_widget_get_css_name(), and
  • gtk_widget_set_css_name()

but I doubt these are what I’m looking for.

I’m sure there must be examples, tutorials, or something on all this, but I’m assuming I’m using the wrong search criteria or I’m just too unfamiliar with the whole GTK CSS thing to get the results I’m hoping for.

Any suggestions on where I can find this type of thing?

Those are not style properties. Style properties in GTK have a very specific meaning—they are properties installed by the widget class that can only be set from within the theme, and they are not GObject properties. GtkCellRendererText:font-desc is a plain object property that is set and retrieved using the GObject properties API. Some property may affect the style, but it’s not necessarily a style property. The PangoFontDescription applied to a text cell renderer is not part of the theme, though the default font used by cell renderers will come from the theme applied to the GtkTreeView widget that uses those cell renderers.

If you’re changing the font description of the cell renderer using a column of a tree model, or using a cell data function, then you still can do that. You’re not changing a style property, and it has nothing to do with theming or CSS.

There’s the added issue that cell renderers are not widgets, so they do not have a style; they reflect the style applied to the GtkTreeView that uses them.

LOL. Okay, I’m definitely gonna have to find some documentation on all this. Thanks, Emmanuele.

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