After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 639754 - GtkCssProvider - Must widget class names begin with uppercase letter?
GtkCssProvider - Must widget class names begin with uppercase letter?
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Class: GtkStyleContext
2.99.x
Other Linux
: Normal normal
: ---
Assigned To: Carlos Garnacho
gtk-bugs
Depends on:
Blocks: 639073
 
 
Reported: 2011-01-17 15:23 UTC by Kjell Ahlstedt
Modified: 2011-01-20 14:48 UTC
See Also:
GNOME target: ---
GNOME version: ---



Description Kjell Ahlstedt 2011-01-17 15:23:16 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.
Comment 1 Matthias Clasen 2011-01-18 18:43:13 UTC
   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
Comment 2 Matthias Clasen 2011-01-18 19:02:47 UTC
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 ?
Comment 3 Carlos Garnacho 2011-01-19 03:50:30 UTC
I've gone ahead and implemented this in commit 0b7496558d, feel free to close if this fixes it
Comment 4 Kjell Ahlstedt 2011-01-20 14:48:44 UTC
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