Gtk+ styling questions

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Gtk+ styling questions

Glus Xof
Hi guys,

Trying to better understand the Gtk+ styling mechanism, I wrote the code: http://codepad.org/AgkL7oZ1

And I'd like to ask you:

Why if the label (Gtk::Label la_test) is named (ie. "TestStyle", as shown in lines 227, 317-327) does not reflect the style selections inside ???
Why I'm doing wrong??

Glus

_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list
Reply | Threaded
Open this post in threaded view
|

Re: Gtk+ styling questions

Daniel Boles

On 28 November 2017 at 17:58, Glus Xof <[hidden email]> wrote:
Hi guys,

Trying to better understand the Gtk+ styling mechanism, I wrote the code: http://codepad.org/AgkL7oZ1

And I'd like to ask you:

Why if the label (Gtk::Label la_test) is named (ie. "TestStyle", as shown in lines 227, 317-327) does not reflect the style selections inside ???
Why I'm doing wrong?


First, a cosmetic thing: StyleContext::add_provider_for_screen() is a static method, so getting the Window's StyleContext just to invoke that static method on it is unnecessary.


Next, we see that your CSS in the TextView *does* work if manually copied/pasted into the GTK+ Inspector...

and that replacing #TestStyle with label is the same in both (A) not working programmatically (B) working when pasted into the Inspector.

which is weird. I guess the Inspector is more forgiving, or this CSS invokes UB and just happens to work there.


but anyway... it points more at some problem with your code. and your problem is that you caught the exception from add_provider_for_screen(), but didn't bother checking its message...

> <data>:1:30Junk at end of value for font-family

This program produces the property font-family: Sans 12; which is not valid as it includes a size too.

Changing that to font: doesn't work either. You need to isolate the individual parts of the font description and pass that to GTK+'s CSS properly. I'll leave that as an exercise... The point here is that you don't just write a try/catch and then ignore what you catch.

> Gtk-WARNING **: 01:55:03.899: Theme parsing error: <data>:1:27: Using Pango syntax for the font: style property is deprecated; please use CSS syntax
> <data>:1:13not a number



_______________________________________________
gtkmm-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtkmm-list