css: Avoid redundant change notification
When adding or removing css class doesn't change anything, we should not notify the css-classes property. This is more efficient and avoids some suboptimal behavior in the inspector. Fixes: #7111
This commit is contained in:
@@ -1203,7 +1203,7 @@ gtk_css_node_get_classes (GtkCssNode *cssnode)
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
gtk_css_node_add_class (GtkCssNode *cssnode,
|
||||
GQuark style_class)
|
||||
{
|
||||
@@ -1211,10 +1211,13 @@ gtk_css_node_add_class (GtkCssNode *cssnode,
|
||||
{
|
||||
gtk_css_node_invalidate (cssnode, GTK_CSS_CHANGE_CLASS);
|
||||
g_object_notify_by_pspec (G_OBJECT (cssnode), cssnode_properties[PROP_CLASSES]);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
gboolean
|
||||
gtk_css_node_remove_class (GtkCssNode *cssnode,
|
||||
GQuark style_class)
|
||||
{
|
||||
@@ -1222,7 +1225,10 @@ gtk_css_node_remove_class (GtkCssNode *cssnode,
|
||||
{
|
||||
gtk_css_node_invalidate (cssnode, GTK_CSS_CHANGE_CLASS);
|
||||
g_object_notify_by_pspec (G_OBJECT (cssnode), cssnode_properties[PROP_CLASSES]);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
gboolean
|
||||
|
@@ -128,9 +128,9 @@ GtkStateFlags gtk_css_node_get_state (GtkCssNode *
|
||||
void gtk_css_node_set_classes (GtkCssNode *cssnode,
|
||||
const char **classes);
|
||||
char ** gtk_css_node_get_classes (GtkCssNode *cssnode);
|
||||
void gtk_css_node_add_class (GtkCssNode *cssnode,
|
||||
gboolean gtk_css_node_add_class (GtkCssNode *cssnode,
|
||||
GQuark style_class);
|
||||
void gtk_css_node_remove_class (GtkCssNode *cssnode,
|
||||
gboolean gtk_css_node_remove_class (GtkCssNode *cssnode,
|
||||
GQuark style_class);
|
||||
gboolean gtk_css_node_has_class (GtkCssNode *cssnode,
|
||||
GQuark style_class) G_GNUC_PURE;
|
||||
|
@@ -13053,8 +13053,8 @@ gtk_widget_add_css_class (GtkWidget *widget,
|
||||
g_return_if_fail (css_class[0] != '\0');
|
||||
g_return_if_fail (css_class[0] != '.');
|
||||
|
||||
gtk_css_node_add_class (priv->cssnode, g_quark_from_string (css_class));
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CSS_CLASSES]);
|
||||
if (gtk_css_node_add_class (priv->cssnode, g_quark_from_string (css_class)))
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CSS_CLASSES]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -13083,8 +13083,8 @@ gtk_widget_remove_css_class (GtkWidget *widget,
|
||||
if (!class_quark)
|
||||
return;
|
||||
|
||||
gtk_css_node_remove_class (priv->cssnode, class_quark);
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CSS_CLASSES]);
|
||||
if (gtk_css_node_remove_class (priv->cssnode, class_quark))
|
||||
g_object_notify_by_pspec (G_OBJECT (widget), widget_props[PROP_CSS_CLASSES]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user