It might be lack of sleep, but I can’t figure this out.

I have a Label, and I want its text to be red when it represents an error, and I want it be green when it represent “good to go”.

I found search result for C and maybe a solution for Python, but nothing for Rust.

I tried manually setting the css-classes property and running queue_draw(); it didn’t work.

I can have a gtk::Box or a Frame that I place where the Label should go, then declare two Labels, and use set_child() to switch between them, but that seems like an ugly solution.

Do you have a solution?

  • DoodsOP
    link
    fedilink
    arrow-up
    3
    ·
    4 hours ago

    This is embarrassing, but when was it not?

    I have to add a “.” before the name of a css class, I must learn my tools.

    • zlatko@programming.dev
      link
      fedilink
      arrow-up
      1
      ·
      13 minutes ago

      I mean, it is not embarrassing for you. In the browser, the CSS’s “native platform”, you add classes, via the JavaScript API, without the dot. It’s not a stupid assumption.

      To have to add the dot in the CSS class name seems a bit of an oversight in the gtkrs API.

    • d_k_bo@feddit.org
      link
      fedilink
      arrow-up
      1
      ·
      39 minutes ago

      Well, that’s CSS :D

      Note that if you create a custom Widget class, you can set a CSS name, wich isn’t a CSS class and doesn’t use a leading dot.