Updating css styles



Dear all,

I'm trying  to create a simple widget to display temperatures. I want something which is essentially a 
progress bar with a colour gradient going from green some of the way to red depending on what the temperature 
is. Since I like the way the standard Gtk progress bar does most things, I wanted to base my widget on that. 
Thus, the best way seemed to be to use css providers and the "-gtk-gradient" property (I give each widget a 
unique number and use this to set a different name for each widget, which allows me to set a different 
gradient for each widget).

I've found when I want to update the gradient, if I just call the gtk_css_provider_load_from_data function on 
my css provider then nothing happens. Instead, I seem to have to remove my css provider from the style 
context, call load_from_data and then re-add it. I had a look in the docs but couldn't see any info about the 
correct way of doing this. Is this right, or is there a way I can notify my widget of the updated style?

Also, while this method works nicely in most ways, it seems a like quite a lot of overhead having to create a 
different css class for each widget. Can anyone suggest a simpler way of achieving the same effect?

Thanks,

Tom



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]