summaryrefslogtreecommitdiff
path: root/gtk/gtkcssnodedeclaration.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2016-01-03 14:02:00 -0500
committerMatthias Clasen <mclasen@redhat.com>2016-01-03 14:41:43 -0500
commit0c52eca34cd1edeb51b930f756652e359ed6ee10 (patch)
tree36b7b7bf7527610188979b184d202e860c96f08a /gtk/gtkcssnodedeclaration.c
parent28e185dd1b8b5fcf90993e9d698110328c1d497d (diff)
downloadgtk+-0c52eca34cd1edeb51b930f756652e359ed6ee10.tar.gz
Move node printing to GtkCssNodeDeclaration
The node declaration has all the information we are printing here (except for visibility). At the same time, redo the format to print the information in selector format, and indicate (in)visibility by enclosing the selector in square brackets.
Diffstat (limited to 'gtk/gtkcssnodedeclaration.c')
-rw-r--r--gtk/gtkcssnodedeclaration.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/gtk/gtkcssnodedeclaration.c b/gtk/gtkcssnodedeclaration.c
index bc139ffe7a..78441c8cb0 100644
--- a/gtk/gtkcssnodedeclaration.c
+++ b/gtk/gtkcssnodedeclaration.c
@@ -648,3 +648,53 @@ G_GNUC_END_IGNORE_DEPRECATIONS
gtk_widget_path_iter_set_state (path, pos, decl->state);
}
+/* Append the declaration to the string, in selector format */
+void
+gtk_css_node_declaration_print (const GtkCssNodeDeclaration *decl,
+ GString *string)
+{
+ static const char *state_names[] = {
+ "active",
+ "hover",
+ "selected",
+ "disabled",
+ "indeterminate",
+ "focus",
+ "backdrop",
+ "dir(ltr)",
+ "dir(rtl)",
+ "link",
+ "visited",
+ "checked",
+ "drop(active)"
+ };
+ const GQuark *classes;
+ guint i;
+
+ if (decl->name)
+ g_string_append (string, decl->name);
+ else
+ g_string_append (string, g_type_name (decl->type));
+
+ if (decl->id)
+ {
+ g_string_append_c (string, '#');
+ g_string_append (string, decl->id);
+ }
+
+ classes = get_classes (decl);
+ for (i = 0; i < decl->n_classes; i++)
+ {
+ g_string_append_c (string, '.');
+ g_string_append (string, g_quark_to_string (classes[i]));
+ }
+
+ for (i = 0; i < G_N_ELEMENTS (state_names); i++)
+ {
+ if (decl->state & (1 << i))
+ {
+ g_string_append_c (string, ':');
+ g_string_append (string, state_names[i]);
+ }
+ }
+}