forked from AuroraMiddleware/gtk
Allow printing css matchers
This can help in debugging css matching.
This commit is contained in:
parent
007713c0ba
commit
7588655a42
@ -23,6 +23,21 @@
|
||||
#include "gtkcssnodeprivate.h"
|
||||
#include "gtkwidgetpath.h"
|
||||
|
||||
void
|
||||
gtk_css_matcher_print (const GtkCssMatcher *matcher,
|
||||
GString *string)
|
||||
{
|
||||
matcher->klass->print (matcher, string);
|
||||
}
|
||||
|
||||
char *
|
||||
gtk_css_matcher_to_string (const GtkCssMatcher *matcher)
|
||||
{
|
||||
GString *string = g_string_new ("");
|
||||
gtk_css_matcher_print (matcher, string);
|
||||
return g_string_free (string, FALSE);
|
||||
}
|
||||
|
||||
/* GTK_CSS_MATCHER_WIDGET_PATH */
|
||||
|
||||
static gboolean
|
||||
@ -158,6 +173,15 @@ gtk_css_matcher_widget_path_has_position (const GtkCssMatcher *matcher,
|
||||
return x / a >= 0;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_matcher_widget_path_print (const GtkCssMatcher *matcher,
|
||||
GString *string)
|
||||
{
|
||||
char *s = gtk_widget_path_to_string (matcher->path.path);
|
||||
g_string_append (string, s);
|
||||
g_free (s);
|
||||
}
|
||||
|
||||
static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
|
||||
GTK_CSS_MATCHER_TYPE_WIDGET_PATH,
|
||||
gtk_css_matcher_widget_path_get_parent,
|
||||
@ -166,7 +190,8 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_WIDGET_PATH = {
|
||||
gtk_css_matcher_widget_path_has_name,
|
||||
gtk_css_matcher_widget_path_has_class,
|
||||
gtk_css_matcher_widget_path_has_id,
|
||||
gtk_css_matcher_widget_path_has_position
|
||||
gtk_css_matcher_widget_path_has_position,
|
||||
gtk_css_matcher_widget_path_print
|
||||
};
|
||||
|
||||
gboolean
|
||||
@ -334,6 +359,13 @@ gtk_css_matcher_node_has_position (const GtkCssMatcher *matcher,
|
||||
a, b);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_matcher_node_print (const GtkCssMatcher *matcher,
|
||||
GString *string)
|
||||
{
|
||||
gtk_css_node_print (matcher->node.node, 0, string, 0);
|
||||
}
|
||||
|
||||
static const GtkCssMatcherClass GTK_CSS_MATCHER_NODE = {
|
||||
GTK_CSS_MATCHER_TYPE_NODE,
|
||||
gtk_css_matcher_node_get_parent,
|
||||
@ -342,7 +374,8 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_NODE = {
|
||||
gtk_css_matcher_node_has_name,
|
||||
gtk_css_matcher_node_has_class,
|
||||
gtk_css_matcher_node_has_id,
|
||||
gtk_css_matcher_node_has_position
|
||||
gtk_css_matcher_node_has_position,
|
||||
gtk_css_matcher_node_print
|
||||
};
|
||||
|
||||
void
|
||||
@ -429,6 +462,13 @@ gtk_css_matcher_any_has_position (const GtkCssMatcher *matcher,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_matcher_any_print (const GtkCssMatcher *matcher,
|
||||
GString *string)
|
||||
{
|
||||
g_string_append (string, "ANY");
|
||||
}
|
||||
|
||||
static const GtkCssMatcherClass GTK_CSS_MATCHER_ANY = {
|
||||
GTK_CSS_MATCHER_TYPE_ANY,
|
||||
gtk_css_matcher_any_get_parent,
|
||||
@ -437,7 +477,8 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_ANY = {
|
||||
gtk_css_matcher_any_has_name,
|
||||
gtk_css_matcher_any_has_class,
|
||||
gtk_css_matcher_any_has_id,
|
||||
gtk_css_matcher_any_has_position
|
||||
gtk_css_matcher_any_has_position,
|
||||
gtk_css_matcher_any_print
|
||||
};
|
||||
|
||||
void
|
||||
@ -517,6 +558,15 @@ gtk_css_matcher_superset_has_position (const GtkCssMatcher *matcher,
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_css_matcher_superset_print (const GtkCssMatcher *matcher,
|
||||
GString *string)
|
||||
{
|
||||
g_string_append (string, "SUPERSET(");
|
||||
gtk_css_matcher_print (matcher->superset.subset, string);
|
||||
g_string_append (string, ")");
|
||||
}
|
||||
|
||||
static const GtkCssMatcherClass GTK_CSS_MATCHER_SUPERSET = {
|
||||
GTK_CSS_MATCHER_TYPE_SUPERSET,
|
||||
gtk_css_matcher_superset_get_parent,
|
||||
@ -525,7 +575,8 @@ static const GtkCssMatcherClass GTK_CSS_MATCHER_SUPERSET = {
|
||||
gtk_css_matcher_superset_has_name,
|
||||
gtk_css_matcher_superset_has_class,
|
||||
gtk_css_matcher_superset_has_id,
|
||||
gtk_css_matcher_superset_has_position
|
||||
gtk_css_matcher_superset_has_position,
|
||||
gtk_css_matcher_superset_print
|
||||
};
|
||||
|
||||
void
|
||||
|
@ -54,6 +54,8 @@ struct _GtkCssMatcherClass {
|
||||
gboolean forward,
|
||||
int a,
|
||||
int b);
|
||||
void (* print) (const GtkCssMatcher *matcher,
|
||||
GString *string);
|
||||
};
|
||||
|
||||
struct _GtkCssMatcherWidgetPath {
|
||||
@ -95,6 +97,10 @@ void _gtk_css_matcher_any_init (GtkCssMatcher *match
|
||||
void _gtk_css_matcher_superset_init (GtkCssMatcher *matcher,
|
||||
const GtkCssMatcher *subset);
|
||||
|
||||
void gtk_css_matcher_print (const GtkCssMatcher *matcher,
|
||||
GString *string);
|
||||
char * gtk_css_matcher_to_string (const GtkCssMatcher *matcher);
|
||||
|
||||
|
||||
static inline gboolean
|
||||
_gtk_css_matcher_get_parent (GtkCssMatcher *matcher,
|
||||
@ -152,7 +158,6 @@ _gtk_css_matcher_matches_any (const GtkCssMatcher *matcher)
|
||||
return matcher->klass->type == GTK_CSS_MATCHER_TYPE_ANY;
|
||||
}
|
||||
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_CSS_MATCHER_PRIVATE_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user