I'm trying to style widget from inside of it's constructor in Vala but I don't get the result I want. Here is the original code sample:
public class MyWidget : Gtk.FlowBox {
public MyWidget () {
var css_provider = new Gtk.CssProvider ();
try {
css_provider.load_from_data (
"""
label {
color: blue;
}
"""
);
get_style_context ().add_provider (css_provider, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION);
} catch (Error e) {
message ("error");
}
}
public void add_entry (string s) {
var entry = new Gtk.Label (s);
add (entry);
}
}
I've tried all different variants of styling "flowbox", "flowboxchild", "label" etc. and only one that works is "*" for every element inside GtkFlowbox or assigning it to a class, thought I still can't style it's children. Priorities don't seem to change anything, adding global "flowbox" styles for screen context don't work too.
I've tried to do it using gtk inspector but no result here too.
So how do I style all children of widget? Or do I need to specify class for them?