CSS and documentation

Hi, ALL,

In this page it is said that this property is deprecated and the CSS should be used.

However it is not explained what is the CSS property name.

Is It “ShadowType”, “shadowtype”, “shadow-type” or something else?
Or maybe it is a “bevel-type” or something?

And finally - I’m curious on how to set it up from the code inside the C source. Is there a function that will apply the CSS string to the appropriate widget? And is there a function to get the CSS from the widget and then parse it?

Thank you.

You can use various CSS properties that affect the border of a widget. CSS properties are much more powerful than the existing shadow type enumeration.

From within your code you will typically assign a style class to the widget’s GtkStyleContext:

GtkStyleContext *context = gtk_widget_get_style_context (widget);
gtk_style_context_add_class (context, "your-widget-class");

You should define your CSS style classes in an ancillary CSS file, string, or resource, and then use GtkCSSProvider to load the CSS style classes.

You can read more about how to define CSS that GTK can parse in the API reference.

Hi, Emmanuelle,
The CSS properties might be much more powerful. But I’d like to set this from the code itself and not use the CSS.
Something that can be done from the C/C++ code.

Any suggestions?

Also, I’m curious - why GNOME3 and GNOME2 have different styles for the status bar.
According to the screenshot in the docs GTK2 has a line that distinguishing the status bar from the window, while GTK3 does not. Also, GTK2 has a resize grip property while GTK3 does not.

Is there a reason for such significant changes in the UI design? And please understand - I’m not questioning it, just want to know why? Because visually status bar cannot be distinguished from the frame/window in GTK3 application.

Thank you.

Also, a little OT - how do I reply with quoting your message? Do I have to have some kind of reputation on this forum?

I don’t understand what you’re trying to achieve. CSS properties control how GTK widgets draw themselves, and you can set the style properties by loading CSS fragments from within your application code. That’s how GTK works—and has worked for a long time, even before we used CSS and used resource files instead.

We decided a long time ago to stop using API to control the appearances of widgets that wish to be themed, and instead we use style classes that can be set from ancillary files and themes.

For most part, it depends on the theme in use. The resize grip was a stop-gap solution before we had the ability to set a resize region around the window’s border, so it was removed in GTK3.

To be fair, status bars are generally disappearing from the common GTK applications; they consume space and more often than not are completely empty. Showing a line of text there is not really a good use of space—either the text is important, in which case it should be more visible (for instance using an InfoBar); or it’s not important at all, in which case it should not be visible. Concepts like progressive disclosure, in-app notifications, and overlays are much more useful to communicate state to the user.

Because appearances change over the years. GTK2 was released in 2001; GTK3 was released in 2011. We don’t use the same style forever; we do style refreshes over the same major version, even, because we’re not a dead project. New concepts are ported over from other platforms, or designed ex novo and tested. We’re not developing a project for how people used computers in 2001.

I usually select something from the post I’m replying to, and a “Quote” button appears that will automatically add a quoted section.

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