Reputation: 33
When I create a CSS provider with gtk_css_provider_new, and load it with gtk_css_provider_load_from_data, giving it "textview { color: red; font: 30px serif; }" as the data, and apply it to a gtk_text_view by using gtk_style_context_add_provider, the result is that it changes the font size to 30, but leaves the text color as black. What do I have to do the change the text color?
That it changes the font size shows that the CSS is actually working. That it doesn't change the color shows that it's only partly working. Is there something special that has to be done to change text color? Something different than what changes the font size?
If I use gdk_rgba_to_string to show the rgba, it shows it as "rgb(255,0,0)" which shows that the style context actually has the color red. So the only issue is why the red isn't used as the actual text color when the 30px serif is used as the actual font.
Upvotes: 1
Views: 1248
Reputation: 694
To change the color of the text you have to select the text part of the TextView in CSS... it would be something like this
textview text {
color : #4fc3f7;
}
This would change the text color to blue.You could always use the Gtk inspector to identify the css nodes associated with the window(Ctrl + Shift + I or D ) if you want to modify more..
Another way to do this is to use (gtk_text_buffer_create_tag https://developer.gnome.org/gtk3/stable/GtkTextView.html) and add the text using (gtk_text_buffer_insert_with_tags_by_name)
Upvotes: 2