widget: Always set the type on css nodes

See the previous commit for why this is necessary.

Also make gtk_widget_class_set_css_name work by looking at
the correct class for the name.

Note for future reference: GTK_WIDGET_GET_CLASS() does not
work in the instance init function.
This commit is contained in:
Matthias Clasen
2015-10-22 21:00:12 -04:00
parent d1a85fc9e4
commit 203742b188

View File

@ -4366,10 +4366,9 @@ gtk_widget_init (GTypeInstance *instance, gpointer g_class)
priv->cssnode = gtk_css_widget_node_new (widget);
gtk_css_node_set_state (priv->cssnode, GTK_STATE_FLAG_DIR_LTR);
/* need to set correct type here, and only class has the correct type here */
if (GTK_WIDGET_GET_CLASS (widget)->priv->css_name)
gtk_css_node_set_name (priv->cssnode, GTK_WIDGET_GET_CLASS (widget)->priv->css_name);
else
gtk_css_node_set_widget_type (priv->cssnode, G_TYPE_FROM_CLASS (g_class));
if (GTK_WIDGET_CLASS (g_class)->priv->css_name)
gtk_css_node_set_name (priv->cssnode, GTK_WIDGET_CLASS (g_class)->priv->css_name);
G_GNUC_BEGIN_IGNORE_DEPRECATIONS;
priv->style = gtk_widget_get_default_style ();