css: Add gtk_css_change_to_string()
Nobody is able to look up those hex values.
This commit is contained in:
@ -1654,11 +1654,20 @@ verify_tree_get_change_results (GtkCssProvider *provider,
|
||||
GString *s;
|
||||
|
||||
s = g_string_new ("");
|
||||
g_string_append_printf (s, "expected change 0x%x, but it was 0x%x", verify_change, change);
|
||||
g_string_append (s, "expected change ");
|
||||
gtk_css_change_print (verify_change, s);
|
||||
g_string_append (s, ", but it was ");
|
||||
gtk_css_change_print (change, s);
|
||||
if ((change & ~verify_change) != 0)
|
||||
g_string_append_printf (s, ", unexpectedly set: 0x%x", change & ~verify_change);
|
||||
{
|
||||
g_string_append (s, ", unexpectedly set: ");
|
||||
gtk_css_change_print (change & ~verify_change, s);
|
||||
}
|
||||
if ((~change & verify_change) != 0)
|
||||
g_string_append_printf (s, ", unexpectedly no set: 0x%x", ~change & verify_change);
|
||||
{
|
||||
g_string_append_printf (s, ", unexpectedly not set: ");
|
||||
gtk_css_change_print (~change & verify_change, s);
|
||||
}
|
||||
g_warning (s->str);
|
||||
g_string_free (s, TRUE);
|
||||
}
|
||||
|
||||
@ -94,3 +94,76 @@ _gtk_css_change_for_child (GtkCssChange match)
|
||||
return gtk_css_change_translate (match, table, G_N_ELEMENTS (table));
|
||||
}
|
||||
|
||||
void
|
||||
gtk_css_change_print (GtkCssChange change,
|
||||
GString *string)
|
||||
{
|
||||
const struct {
|
||||
GtkCssChange flags;
|
||||
const char *name;
|
||||
} names[] = {
|
||||
{ GTK_CSS_CHANGE_CLASS, "class" },
|
||||
{ GTK_CSS_CHANGE_NAME, "name" },
|
||||
{ GTK_CSS_CHANGE_ID, "id" },
|
||||
{ GTK_CSS_CHANGE_FIRST_CHILD, "first-child" },
|
||||
{ GTK_CSS_CHANGE_LAST_CHILD, "last-child" },
|
||||
{ GTK_CSS_CHANGE_NTH_CHILD, "nth-child" },
|
||||
{ GTK_CSS_CHANGE_NTH_LAST_CHILD, "nth-last-child" },
|
||||
{ GTK_CSS_CHANGE_STATE, "state" },
|
||||
{ GTK_CSS_CHANGE_SIBLING_CLASS, "sibling-class" },
|
||||
{ GTK_CSS_CHANGE_SIBLING_NAME, "sibling-name" },
|
||||
{ GTK_CSS_CHANGE_SIBLING_ID, "sibling-id" },
|
||||
{ GTK_CSS_CHANGE_SIBLING_FIRST_CHILD, "sibling-first-child" },
|
||||
{ GTK_CSS_CHANGE_SIBLING_LAST_CHILD, "sibling-last-child" },
|
||||
{ GTK_CSS_CHANGE_SIBLING_NTH_CHILD, "sibling-nth-child" },
|
||||
{ GTK_CSS_CHANGE_SIBLING_NTH_LAST_CHILD, "sibling-nth-last-child" },
|
||||
{ GTK_CSS_CHANGE_SIBLING_STATE, "sibling-state" },
|
||||
{ GTK_CSS_CHANGE_PARENT_CLASS, "parent-class" },
|
||||
{ GTK_CSS_CHANGE_PARENT_NAME, "parent-name" },
|
||||
{ GTK_CSS_CHANGE_PARENT_ID, "parent-id" },
|
||||
{ GTK_CSS_CHANGE_PARENT_FIRST_CHILD, "parent-first-child" },
|
||||
{ GTK_CSS_CHANGE_PARENT_LAST_CHILD, "parent-last-child" },
|
||||
{ GTK_CSS_CHANGE_PARENT_NTH_CHILD, "parent-nth-child" },
|
||||
{ GTK_CSS_CHANGE_PARENT_NTH_LAST_CHILD, "parent-nth-last-child" },
|
||||
{ GTK_CSS_CHANGE_PARENT_STATE, "parent-state" },
|
||||
{ GTK_CSS_CHANGE_PARENT_SIBLING_CLASS, "parent-sibling-" },
|
||||
{ GTK_CSS_CHANGE_PARENT_SIBLING_NAME, "parent-sibling-name" },
|
||||
{ GTK_CSS_CHANGE_PARENT_SIBLING_ID, "parent-sibling-id" },
|
||||
{ GTK_CSS_CHANGE_PARENT_SIBLING_FIRST_CHILD, "parent-sibling-first-child" },
|
||||
{ GTK_CSS_CHANGE_PARENT_SIBLING_LAST_CHILD, "parent-sibling-last-child" },
|
||||
{ GTK_CSS_CHANGE_PARENT_SIBLING_NTH_CHILD, "parent-sibling-nth-child" },
|
||||
{ GTK_CSS_CHANGE_PARENT_SIBLING_NTH_LAST_CHILD, "parent-sibling-nth-last-child" },
|
||||
{ GTK_CSS_CHANGE_PARENT_SIBLING_STATE, "parent-sibling-state" },
|
||||
{ GTK_CSS_CHANGE_SOURCE, "source" },
|
||||
{ GTK_CSS_CHANGE_PARENT_STYLE, "parent-style" },
|
||||
{ GTK_CSS_CHANGE_TIMESTAMP, "timestamp" },
|
||||
{ GTK_CSS_CHANGE_ANIMATIONS, "animations" },
|
||||
};
|
||||
guint i;
|
||||
gboolean first;
|
||||
|
||||
first = TRUE;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (names); i++)
|
||||
{
|
||||
if (change & names[i].flags)
|
||||
{
|
||||
if (first)
|
||||
first = FALSE;
|
||||
else
|
||||
g_string_append (string, "|");
|
||||
g_string_append (string, names[i].name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
char *
|
||||
gtk_css_change_to_string (GtkCssChange change)
|
||||
{
|
||||
GString *string = g_string_new (NULL);
|
||||
|
||||
gtk_css_change_print (change, string);
|
||||
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
|
||||
@ -330,6 +330,10 @@ typedef enum /*< skip >*/ {
|
||||
GtkCssChange _gtk_css_change_for_sibling (GtkCssChange match);
|
||||
GtkCssChange _gtk_css_change_for_child (GtkCssChange match);
|
||||
|
||||
char * gtk_css_change_to_string (GtkCssChange change);
|
||||
void gtk_css_change_print (GtkCssChange change,
|
||||
GString *string);
|
||||
|
||||
/* for lack of better place to put it */
|
||||
/* mirror what cairo does */
|
||||
#define gtk_rgba_is_clear(rgba) ((rgba)->alpha < ((double)0x00ff / (double)0xffff))
|
||||
|
||||
Reference in New Issue
Block a user