[gtk+/wip/cssnode3: 56/102] cssnode: Change vfunc
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3: 56/102] cssnode: Change vfunc
- Date: Wed, 11 Mar 2015 00:21:07 +0000 (UTC)
commit 245a5f5a7d63522d6b1736dbfddfd93ec00e9259
Author: Benjamin Otte <otte redhat com>
Date: Sat Feb 14 06:45:21 2015 +0100
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.
gtk/gtkcssnode.c | 18 +++++++++++++++---
gtk/gtkcssnodeprivate.h | 3 ++-
gtk/gtkcsswidgetnode.c | 20 ++++++++++----------
3 files changed, 27 insertions(+), 14 deletions(-)
---
diff --git a/gtk/gtkcssnode.c b/gtk/gtkcssnode.c
index d9ea83c..0e85d9d 100644
--- a/gtk/gtkcssnode.c
+++ b/gtk/gtkcssnode.c
@@ -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;
diff --git a/gtk/gtkcssnodeprivate.h b/gtk/gtkcssnodeprivate.h
index 3394999..9101507 100644
--- a/gtk/gtkcssnodeprivate.h
+++ b/gtk/gtkcssnodeprivate.h
@@ -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);
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index ca48284..12e346b 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -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 *);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]