mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-06 19:00:12 +00:00
inspector: Show CSS node state
This is useful when debugging state propagation issues between CSS nodes.
This commit is contained in:
parent
c265b58181
commit
b6fda5dc0a
@ -40,6 +40,7 @@
|
|||||||
#include "gtksettings.h"
|
#include "gtksettings.h"
|
||||||
#include "gtktreeview.h"
|
#include "gtktreeview.h"
|
||||||
#include "gtktreeselection.h"
|
#include "gtktreeselection.h"
|
||||||
|
#include "gtktypebuiltins.h"
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
COLUMN_NODE_NAME,
|
COLUMN_NODE_NAME,
|
||||||
@ -47,6 +48,7 @@ enum {
|
|||||||
COLUMN_NODE_VISIBLE,
|
COLUMN_NODE_VISIBLE,
|
||||||
COLUMN_NODE_CLASSES,
|
COLUMN_NODE_CLASSES,
|
||||||
COLUMN_NODE_ID,
|
COLUMN_NODE_ID,
|
||||||
|
COLUMN_NODE_STATE,
|
||||||
/* add more */
|
/* add more */
|
||||||
N_NODE_COLUMNS
|
N_NODE_COLUMNS
|
||||||
};
|
};
|
||||||
@ -194,6 +196,35 @@ strv_sort (char **strv)
|
|||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gchar *
|
||||||
|
format_state_flags (GtkStateFlags state)
|
||||||
|
{
|
||||||
|
GFlagsClass *fclass;
|
||||||
|
GString *str;
|
||||||
|
gint i;
|
||||||
|
|
||||||
|
str = g_string_new ("");
|
||||||
|
|
||||||
|
if (state)
|
||||||
|
{
|
||||||
|
fclass = g_type_class_ref (GTK_TYPE_STATE_FLAGS);
|
||||||
|
for (i = 0; i < fclass->n_values; i++)
|
||||||
|
{
|
||||||
|
if (state & fclass->values[i].value)
|
||||||
|
{
|
||||||
|
if (str->len)
|
||||||
|
g_string_append (str, " | ");
|
||||||
|
g_string_append (str, fclass->values[i].value_nick);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
g_type_class_unref (fclass);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
g_string_append (str, "normal");
|
||||||
|
|
||||||
|
return g_string_free (str, FALSE);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gtk_inspector_css_node_tree_get_node_value (GtkTreeModelCssNode *model,
|
gtk_inspector_css_node_tree_get_node_value (GtkTreeModelCssNode *model,
|
||||||
GtkCssNode *node,
|
GtkCssNode *node,
|
||||||
@ -229,6 +260,10 @@ gtk_inspector_css_node_tree_get_node_value (GtkTreeModelCssNode *model,
|
|||||||
g_value_set_string (value, gtk_css_node_get_id (node));
|
g_value_set_string (value, gtk_css_node_get_id (node));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case COLUMN_NODE_STATE:
|
||||||
|
g_value_take_string (value, format_state_flags (gtk_css_node_get_state (node)));
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
g_assert_not_reached ();
|
g_assert_not_reached ();
|
||||||
break;
|
break;
|
||||||
@ -251,6 +286,7 @@ gtk_inspector_css_node_tree_init (GtkInspectorCssNodeTree *cnt)
|
|||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
G_TYPE_BOOLEAN,
|
G_TYPE_BOOLEAN,
|
||||||
G_TYPE_STRING,
|
G_TYPE_STRING,
|
||||||
|
G_TYPE_STRING,
|
||||||
G_TYPE_STRING);
|
G_TYPE_STRING);
|
||||||
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->node_tree), priv->node_model);
|
gtk_tree_view_set_model (GTK_TREE_VIEW (priv->node_tree), priv->node_model);
|
||||||
g_object_unref (priv->node_model);
|
g_object_unref (priv->node_model);
|
||||||
|
@ -93,6 +93,19 @@
|
|||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
|
<child>
|
||||||
|
<object class="GtkTreeViewColumn" id="node_state_column">
|
||||||
|
<property name="resizable">1</property>
|
||||||
|
<property name="title" translatable="yes">State</property>
|
||||||
|
<child>
|
||||||
|
<object class="GtkCellRendererText"/>
|
||||||
|
<attributes>
|
||||||
|
<attribute name="text">5</attribute>
|
||||||
|
<attribute name="sensitive">2</attribute>
|
||||||
|
</attributes>
|
||||||
|
</child>
|
||||||
|
</object>
|
||||||
|
</child>
|
||||||
</object>
|
</object>
|
||||||
</child>
|
</child>
|
||||||
</object>
|
</object>
|
||||||
|
Loading…
Reference in New Issue
Block a user