Commit 13fd3687 authored by Benjamin Otte's avatar Benjamin Otte

cssnode: Change vfunc

This is mainly an attempt to merge the update_style() and validte()
vfuncs. Code is not there yet, but that's the idea.

Also, gtk_css_node_set_style() should not be public. And this gets
closer to that goal, too.
parent 75b633ae
......@@ -241,13 +241,14 @@ gtk_css_node_real_dequeue_validate (GtkCssNode *node)
{
}
static gboolean
static GtkCssStyle *
gtk_css_node_real_validate (GtkCssNode *cssnode,
GtkCssStyle *current_style,
gint64 timestamp,
GtkCssChange change,
gboolean parent_changed)
{
return FALSE;
return NULL;
}
gboolean
......@@ -707,6 +708,7 @@ gtk_css_node_validate (GtkCssNode *cssnode,
{
GtkCssChange change;
GtkCssNode *child;
GtkCssStyle *new_style;
gboolean changed;
/* If you run your application with
......@@ -734,7 +736,17 @@ gtk_css_node_validate (GtkCssNode *cssnode,
change = cssnode->pending_changes;
cssnode->pending_changes = 0;
changed = GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode, timestamp, change, parent_changed);
new_style = GTK_CSS_NODE_GET_CLASS (cssnode)->validate (cssnode, cssnode->style, timestamp, change, parent_changed);
if (new_style)
{
gtk_css_node_set_style (cssnode, new_style);
g_object_unref (new_style);
changed = TRUE;
}
else
{
changed = FALSE;
}
for (child = gtk_css_node_get_first_child (cssnode);
child;
......
......@@ -69,7 +69,8 @@ struct _GtkCssNodeClass
void (* invalidate) (GtkCssNode *node);
void (* queue_validate) (GtkCssNode *node);
void (* dequeue_validate) (GtkCssNode *node);
gboolean (* validate) (GtkCssNode *cssnode,
GtkCssStyle * (* validate) (GtkCssNode *cssnode,
GtkCssStyle *current_style,
gint64 timestamp,
GtkCssChange change,
gboolean parent_changed);
......
......@@ -101,8 +101,9 @@ validate_static_style (GtkCssNode *node,
}
}
static gboolean
static GtkCssStyle *
gtk_css_widget_node_validate (GtkCssNode *node,
GtkCssStyle *style,
gint64 timestamp,
GtkCssChange change,
gboolean parent_changed)
......@@ -110,15 +111,12 @@ gtk_css_widget_node_validate (GtkCssNode *node,
GtkCssWidgetNode *widget_node = GTK_CSS_WIDGET_NODE (node);
GtkStyleContext *context;
GtkBitmask *changes;
GtkCssStyle *style, *static_style;
GtkCssStyle *new_style, *new_static_style;
gboolean result;
GtkCssStyle *static_style, *new_style, *new_static_style;
if (widget_node->widget == NULL)
return FALSE;
context = gtk_widget_get_style_context (widget_node->widget);
style = gtk_css_node_get_style (node);
if (style == NULL)
style = gtk_css_static_style_get_default ();
......@@ -161,15 +159,17 @@ gtk_css_widget_node_validate (GtkCssNode *node,
!gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (new_style)))
gtk_css_node_set_invalid (node, TRUE);
gtk_css_node_set_style (node, new_style);
g_object_unref (new_style);
gtk_style_context_validate (context, changes);
result = !_gtk_bitmask_is_empty (changes);
if (_gtk_bitmask_is_empty (changes) && !GTK_IS_CSS_ANIMATED_STYLE (new_style))
{
g_object_unref (new_style);
new_style = NULL;
}
_gtk_bitmask_free (changes);
return result;
return new_style;
}
typedef GtkWidgetPath * (* GetPathForChildFunc) (GtkContainer *, GtkWidget *);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment