Mono fonts for all GtkTextView with CSS file with GTK+ 3.20

lock

I work on a project in C using GTK+. This project is for GTK+3.6 minimum.

I would like to set all GTKTextView in monospace font. Before the last update of GTK to GTK3.20, my CSS sheet was working well with :

GtkTextView {
  font: Mono
}

Now, it is not working anymore. However, glade has a property : <property name="monospace">True</property> but this property exists since GTK 3.16 and debian stable is on GTK3.14. Of course I want it portable.

My question is: how I can do it ? How I can set all my gtkTextView to the monospace font ?

ptomato

GTK 3.20 changed the way that CSS selectors work.

Pre-GTK 3.20, this was correct:

GtkTextView {
    font-family: monospace;
}

Starting with GTK 3.20, this is correct:

textview {
    font-family: monospace;
}

If you're not sure about a particular platform, you can check with the GTK Inspector what selector is needed: run your app with GTK_DEBUG=interactive and press Ctrl+Shift+D.

It's worth noting that the pre-GTK 3.20 CSS selectors were experimental and not intended to be stable API.

If you have to support both forms, then your best bet is probably to make two stylesheets and load one or the other depending on the value of GTK_MAJOR_VERSION and GTK_MINOR_VERSION.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related