forked from AuroraMiddleware/gtk
css: Move utility function
The function was not selector-specific, so putting it with all the other utility functions makes more sense. Also use the utility function in the node declaration printing.
This commit is contained in:
parent
d0aa79b5a1
commit
c2d69643a8
@ -447,21 +447,6 @@ 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;
|
||||
char **classnames;
|
||||
@ -492,12 +477,14 @@ gtk_css_node_declaration_print (const GtkCssNodeDeclaration *decl,
|
||||
}
|
||||
g_free (classnames);
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (state_names); i++)
|
||||
for (i = 0; i < sizeof (GtkStateFlags) * 8; i++)
|
||||
{
|
||||
if (decl->state & (1 << i))
|
||||
{
|
||||
const char *name = gtk_css_pseudoclass_name (1 << i);
|
||||
g_assert (name);
|
||||
g_string_append_c (string, ':');
|
||||
g_string_append (string, state_names[i]);
|
||||
g_string_append (string, name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -675,36 +675,6 @@ comp_id (const GtkCssSelector *a,
|
||||
|
||||
DEFINE_SIMPLE_SELECTOR(id, ID, print_id, match_id, hash_id, comp_id, TRUE, FALSE, FALSE, FALSE)
|
||||
|
||||
const gchar *
|
||||
gtk_css_pseudoclass_name (GtkStateFlags state)
|
||||
{
|
||||
static const char * state_names[] = {
|
||||
"active",
|
||||
"hover",
|
||||
"selected",
|
||||
"disabled",
|
||||
"indeterminate",
|
||||
"focus",
|
||||
"backdrop",
|
||||
"dir(ltr)",
|
||||
"dir(rtl)",
|
||||
"link",
|
||||
"visited",
|
||||
"checked",
|
||||
"drop(active)",
|
||||
"focus(visible)"
|
||||
};
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (state_names); i++)
|
||||
{
|
||||
if (state == (1 << i))
|
||||
return state_names[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* PSEUDOCLASS FOR STATE */
|
||||
static void
|
||||
print_pseudoclass_state (const GtkCssSelector *selector,
|
||||
|
@ -59,8 +59,6 @@ void _gtk_css_selector_tree_builder_add (GtkCssSelectorT
|
||||
GtkCssSelectorTree * _gtk_css_selector_tree_builder_build (GtkCssSelectorTreeBuilder *builder);
|
||||
void _gtk_css_selector_tree_builder_free (GtkCssSelectorTreeBuilder *builder);
|
||||
|
||||
const char *gtk_css_pseudoclass_name (GtkStateFlags flags);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_SELECTOR_PRIVATE_H__ */
|
||||
|
@ -257,3 +257,33 @@ gtk_css_change_to_string (GtkCssChange change)
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
const gchar *
|
||||
gtk_css_pseudoclass_name (GtkStateFlags state)
|
||||
{
|
||||
static const char * state_names[] = {
|
||||
"active",
|
||||
"hover",
|
||||
"selected",
|
||||
"disabled",
|
||||
"indeterminate",
|
||||
"focus",
|
||||
"backdrop",
|
||||
"dir(ltr)",
|
||||
"dir(rtl)",
|
||||
"link",
|
||||
"visited",
|
||||
"checked",
|
||||
"drop(active)",
|
||||
"focus(visible)"
|
||||
};
|
||||
guint i;
|
||||
|
||||
for (i = 0; i < G_N_ELEMENTS (state_names); i++)
|
||||
{
|
||||
if (state == (1 << i))
|
||||
return state_names[i];
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,8 @@
|
||||
#include <glib-object.h>
|
||||
#include <gsk/gsk.h>
|
||||
|
||||
#include <gtk/gtkenums.h>
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
typedef union _GtkCssMatcher GtkCssMatcher;
|
||||
@ -456,6 +458,9 @@ char * gtk_css_change_to_string (GtkCssChange
|
||||
void gtk_css_change_print (GtkCssChange change,
|
||||
GString *string);
|
||||
|
||||
const char * gtk_css_pseudoclass_name (GtkStateFlags flags);
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_TYPES_PRIVATE_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user