GNOME Bugzilla – Bug 639754
GtkCssProvider - Must widget class names begin with uppercase letter?
Last modified: 2011-01-20 14:48:44 UTC
File gtkcssprovider.c contains a detailed description of the style sheets that can be parsed. One missing detail is that it's nowhere mentioned that the first character of an identifier is in some situations used to determine what kind of entity is identified. Specifically it's assumed in the source code that the name of a widget class begins with an uppercase letter. gtkcssprovider.c, function parse_selector line 1764: else if (g_ascii_isupper (scanner->value.v_identifier[0])) Then it's a widget class. line 1805: else if (g_ascii_islower (scanner->value.v_identifier[0])) Then it's a region. gtkcssprovider.c, function parse_rule line 3316: else if (prop[0] == '-' && g_ascii_isupper (prop[1])) Then it's a widget class + property name registered with gtk_widget_class_install_style_property(), else if it's not a registered property, then it's ignored without a warning message or anything similar. All class names that are registered by C++ classes in gtkmm get the name prefix gtkmm__ which is incompatible with the parsing in gtkcssprovider.c. It's not possible to use style sheets to set values of properties of custom widgets, defined by such a class. If the restriction on class names and other names will remain, it should be documented. The name prefix can be changed in gtkmm 3, but from the description in gtk+ it should be possible to conclude that changing is necessary.
line 1764: else if (g_ascii_isupper (scanner->value.v_identifier[0])) Then it's a widget class. line 1805: else if (g_ascii_islower (scanner->value.v_identifier[0])) Then it's a region. In this case, I think we could first check if the identifier is an registered type name, and if not fall back to treating it like a region. line 3316: else if (prop[0] == '-' && g_ascii_isupper (prop[1])) In this case, I think we can just drop the isupper check without any harm
another proposal that came up on irc: - if it contains any uppercase, it is a widget class - else it is a region I think that should work for gtkmm ?
I've gone ahead and implemented this in commit 0b7496558d, feel free to close if this fixes it
The implementation in comment 3 fixes the problem for gtkmm. Thanks. Closing this bug. The implementation is approximately as described in comment 2: - if it contains any uppercase, it is a widget class name - else if it begins with lowercase and contains only lowercase and hyphens, it is a region name