mirror of
https://gitlab.gnome.org/GNOME/gtk.git
synced 2025-01-17 15:40:12 +00:00
GtkCssProvider: Allow '*' selectors.
These would match a single widget of any type.
This commit is contained in:
parent
468f216b1c
commit
4c8353bcbf
@ -38,7 +38,8 @@ typedef enum ParserScope ParserScope;
|
|||||||
enum SelectorElementType {
|
enum SelectorElementType {
|
||||||
SELECTOR_TYPE_NAME,
|
SELECTOR_TYPE_NAME,
|
||||||
SELECTOR_NAME,
|
SELECTOR_NAME,
|
||||||
SELECTOR_GTYPE
|
SELECTOR_GTYPE,
|
||||||
|
SELECTOR_GLOB
|
||||||
};
|
};
|
||||||
|
|
||||||
struct SelectorElement
|
struct SelectorElement
|
||||||
@ -165,6 +166,17 @@ selector_path_prepend_type (SelectorPath *path,
|
|||||||
path->elements = g_slist_prepend (path->elements, elem);
|
path->elements = g_slist_prepend (path->elements, elem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
selector_path_prepend_glob (SelectorPath *path)
|
||||||
|
{
|
||||||
|
SelectorElement *elem;
|
||||||
|
|
||||||
|
elem = g_slice_new (SelectorElement);
|
||||||
|
elem->elem_type = SELECTOR_GLOB;
|
||||||
|
|
||||||
|
path->elements = g_slist_prepend (path->elements, elem);
|
||||||
|
}
|
||||||
|
|
||||||
static SelectorStyleInfo *
|
static SelectorStyleInfo *
|
||||||
selector_style_info_new (SelectorPath *path)
|
selector_style_info_new (SelectorPath *path)
|
||||||
{
|
{
|
||||||
@ -295,6 +307,11 @@ compare_path_foreach (GType type,
|
|||||||
data->score |= score;
|
data->score |= score;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (elem->elem_type == SELECTOR_GLOB)
|
||||||
|
{
|
||||||
|
/* Treat as lowest matching type */
|
||||||
|
data->score++;
|
||||||
|
}
|
||||||
|
|
||||||
data->iter = data->iter->next;
|
data->iter = data->iter->next;
|
||||||
|
|
||||||
@ -460,11 +477,19 @@ css_provider_apply_scope (GtkCssProvider *css_provider,
|
|||||||
{
|
{
|
||||||
priv->scanner->config->cset_identifier_first = G_CSET_a_2_z "#-_0123456789" G_CSET_A_2_Z;
|
priv->scanner->config->cset_identifier_first = G_CSET_a_2_z "#-_0123456789" G_CSET_A_2_Z;
|
||||||
priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "#-_ 0123456789" G_CSET_A_2_Z;
|
priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "#-_ 0123456789" G_CSET_A_2_Z;
|
||||||
|
priv->scanner->config->scan_identifier_1char = FALSE;
|
||||||
|
}
|
||||||
|
else if (scope == SCOPE_SELECTOR)
|
||||||
|
{
|
||||||
|
priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z "*";
|
||||||
|
priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z;
|
||||||
|
priv->scanner->config->scan_identifier_1char = TRUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z;
|
priv->scanner->config->cset_identifier_first = G_CSET_a_2_z G_CSET_A_2_Z;
|
||||||
priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z;
|
priv->scanner->config->cset_identifier_nth = G_CSET_a_2_z "-" G_CSET_A_2_Z;
|
||||||
|
priv->scanner->config->scan_identifier_1char = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
priv->scanner->config->scan_float = FALSE;
|
priv->scanner->config->scan_float = FALSE;
|
||||||
@ -569,36 +594,21 @@ parse_selector (GtkCssProvider *css_provider,
|
|||||||
|
|
||||||
path = selector_path_new ();
|
path = selector_path_new ();
|
||||||
|
|
||||||
|
while (scanner->token == G_TOKEN_IDENTIFIER)
|
||||||
|
{
|
||||||
if (g_ascii_isupper (scanner->value.v_identifier[0]))
|
if (g_ascii_isupper (scanner->value.v_identifier[0]))
|
||||||
{
|
|
||||||
while (scanner->token == G_TOKEN_IDENTIFIER &&
|
|
||||||
g_ascii_isupper (scanner->value.v_identifier[0]))
|
|
||||||
{
|
|
||||||
selector_path_prepend_type (path, scanner->value.v_identifier);
|
selector_path_prepend_type (path, scanner->value.v_identifier);
|
||||||
g_scanner_get_next_token (scanner);
|
else if (scanner->value.v_identifier[0] == '*')
|
||||||
}
|
selector_path_prepend_glob (path);
|
||||||
|
|
||||||
if (scanner->token == '.')
|
|
||||||
{
|
|
||||||
/* style class scanning */
|
|
||||||
g_scanner_get_next_token (scanner);
|
|
||||||
|
|
||||||
if (scanner->token != G_TOKEN_IDENTIFIER)
|
|
||||||
{
|
|
||||||
selector_path_unref (path);
|
|
||||||
return G_TOKEN_IDENTIFIER;
|
|
||||||
}
|
|
||||||
|
|
||||||
g_print ("Style class: %s\n", scanner->value.v_identifier);
|
|
||||||
g_scanner_get_next_token (scanner);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
selector_path_unref (path);
|
selector_path_unref (path);
|
||||||
return G_TOKEN_IDENTIFIER;
|
return G_TOKEN_IDENTIFIER;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
g_scanner_get_next_token (scanner);
|
||||||
|
}
|
||||||
|
|
||||||
if (scanner->token == ':')
|
if (scanner->token == ':')
|
||||||
{
|
{
|
||||||
/* Pseudo-class scanning */
|
/* Pseudo-class scanning */
|
||||||
|
Loading…
Reference in New Issue
Block a user