[gtk+] inspector: Track updates of node styles
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] inspector: Track updates of node styles
- Date: Sun, 1 Nov 2015 17:04:42 +0000 (UTC)
commit 5c53e873b1f6a2af481be850ab6c9e9915b60b3a
Author: Benjamin Otte <otte redhat com>
Date: Sun Nov 1 16:45:11 2015 +0100
inspector: Track updates of node styles
When the CSS style of a node changes, we want to display the new values
in the inspector.
This for example allows to see how styles update on hover or during
animations.
gtk/inspector/css-node-tree.c | 65 ++++++++++++++++++++++++++++------------
1 files changed, 45 insertions(+), 20 deletions(-)
---
diff --git a/gtk/inspector/css-node-tree.c b/gtk/inspector/css-node-tree.c
index 6d7cfa9..cf6c391 100644
--- a/gtk/inspector/css-node-tree.c
+++ b/gtk/inspector/css-node-tree.c
@@ -135,6 +135,10 @@ gtk_inspector_css_node_tree_unset_node (GtkInspectorCssNodeTree *cnt)
if (priv->node)
{
+ g_signal_handlers_disconnect_matched (priv->node,
+ G_SIGNAL_MATCH_DATA,
+ 0, 0, NULL, NULL,
+ cnt);
g_object_unref (priv->node);
priv->node = NULL;
}
@@ -353,25 +357,14 @@ gtk_inspector_css_node_tree_set_object (GtkInspectorCssNodeTree *cnt,
}
static void
-gtk_inspector_css_node_tree_set_node (GtkInspectorCssNodeTree *cnt,
- GtkCssNode *node)
+gtk_inspector_css_node_tree_update_style (GtkCssNode *node,
+ GtkCssStyle *old_style,
+ GtkCssStyle *new_style,
+ GtkInspectorCssNodeTree *cnt)
{
GtkInspectorCssNodeTreePrivate *priv = cnt->priv;
- GtkCssStyle *style;
gint i;
- if (priv->node == node)
- return;
-
- if (node)
- g_object_ref (node);
-
- gtk_inspector_css_node_tree_unset_node (cnt);
-
- priv->node = node;
-
- style = gtk_css_node_get_style (node);
-
for (i = 0; i < _gtk_css_style_property_get_n_properties (); i++)
{
GtkCssStyleProperty *prop;
@@ -386,13 +379,21 @@ gtk_inspector_css_node_tree_set_node (GtkInspectorCssNodeTree *cnt,
iter = (GtkTreeIter *)g_hash_table_lookup (priv->prop_iters, name);
- value = _gtk_css_value_to_string (gtk_css_style_get_value (style, i));
+ if (new_style)
+ {
+ value = _gtk_css_value_to_string (gtk_css_style_get_value (new_style, i));
- section = gtk_css_style_get_section (style, i);
- if (section)
- location = _gtk_css_section_to_string (section);
+ section = gtk_css_style_get_section (new_style, i);
+ if (section)
+ location = _gtk_css_section_to_string (section);
+ else
+ location = NULL;
+ }
else
- location = NULL;
+ {
+ value = NULL;
+ location = NULL;
+ }
gtk_list_store_set (priv->prop_model,
iter,
@@ -406,6 +407,30 @@ gtk_inspector_css_node_tree_set_node (GtkInspectorCssNodeTree *cnt,
}
static void
+gtk_inspector_css_node_tree_set_node (GtkInspectorCssNodeTree *cnt,
+ GtkCssNode *node)
+{
+ GtkInspectorCssNodeTreePrivate *priv = cnt->priv;
+
+ if (priv->node == node)
+ return;
+
+ if (node)
+ g_object_ref (node);
+
+ gtk_inspector_css_node_tree_update_style (node,
+ node ? gtk_css_node_get_style (node) : NULL,
+ priv->node ? gtk_css_node_get_style (priv->node) : NULL,
+ cnt);
+
+ gtk_inspector_css_node_tree_unset_node (cnt);
+
+ priv->node = node;
+
+ g_signal_connect (node, "style-changed", G_CALLBACK (gtk_inspector_css_node_tree_update_style), cnt);
+}
+
+static void
populate_properties (GtkInspectorCssNodeTree *cnt)
{
GtkInspectorCssNodeTreePrivate *priv = cnt->priv;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]