forked from AuroraMiddleware/gtk
css: Redo the pseudoclass selectors
There is no need to duplicate the classes, we can make do with a single class for all the states.
This commit is contained in:
parent
55cfeccfd2
commit
95f00c6071
@ -726,31 +726,30 @@ comp_pseudoclass_state (const GtkCssSelector *a,
|
||||
return a->state.state - b->state.state;
|
||||
}
|
||||
|
||||
#define GTK_CSS_CHANGE_PSEUDOCLASS_HOVER GTK_CSS_CHANGE_HOVER
|
||||
DEFINE_SIMPLE_SELECTOR(pseudoclass_hover, PSEUDOCLASS_HOVER, print_pseudoclass_state,
|
||||
match_pseudoclass_state, hash_pseudoclass_state, comp_pseudoclass_state,
|
||||
FALSE, TRUE, FALSE, TRUE)
|
||||
#undef GTK_CSS_CHANGE_PSEUDOCLASS_HOVER
|
||||
static GtkCssChange
|
||||
change_pseudoclass_state (const GtkCssSelector *selector)
|
||||
{
|
||||
GtkStateFlags states = selector->state.state;
|
||||
GtkCssChange change = 0;
|
||||
|
||||
#define GTK_CSS_CHANGE_PSEUDOCLASS_DISABLED GTK_CSS_CHANGE_DISABLED
|
||||
DEFINE_SIMPLE_SELECTOR(pseudoclass_disabled, PSEUDOCLASS_DISABLED, print_pseudoclass_state,
|
||||
match_pseudoclass_state, hash_pseudoclass_state, comp_pseudoclass_state,
|
||||
FALSE, TRUE, FALSE, TRUE)
|
||||
#undef GTK_CSS_CHANGE_PSEUDOCLASS_DISABLED
|
||||
if (states & GTK_STATE_FLAG_PRELIGHT)
|
||||
change |= GTK_CSS_CHANGE_HOVER;
|
||||
if (states & GTK_STATE_FLAG_INSENSITIVE)
|
||||
change |= GTK_CSS_CHANGE_DISABLED;
|
||||
if (states & GTK_STATE_FLAG_BACKDROP)
|
||||
change |= GTK_CSS_CHANGE_BACKDROP;
|
||||
if (states & GTK_STATE_FLAG_SELECTED)
|
||||
change |= GTK_CSS_CHANGE_SELECTED;
|
||||
if (states & ~(GTK_STATE_FLAG_PRELIGHT |
|
||||
GTK_STATE_FLAG_INSENSITIVE |
|
||||
GTK_STATE_FLAG_BACKDROP |
|
||||
GTK_STATE_FLAG_SELECTED))
|
||||
change |= GTK_CSS_CHANGE_STATE;
|
||||
|
||||
#define GTK_CSS_CHANGE_PSEUDOCLASS_BACKDROP GTK_CSS_CHANGE_BACKDROP
|
||||
DEFINE_SIMPLE_SELECTOR(pseudoclass_backdrop, PSEUDOCLASS_BACKDROP, print_pseudoclass_state,
|
||||
match_pseudoclass_state, hash_pseudoclass_state, comp_pseudoclass_state,
|
||||
FALSE, TRUE, FALSE, TRUE)
|
||||
#undef GTK_CSS_CHANGE_PSEUDOCLASS_BACKDROP
|
||||
return change;
|
||||
}
|
||||
|
||||
#define GTK_CSS_CHANGE_PSEUDOCLASS_SELECTED GTK_CSS_CHANGE_SELECTED
|
||||
DEFINE_SIMPLE_SELECTOR(pseudoclass_selected, PSEUDOCLASS_SELECTED, print_pseudoclass_state,
|
||||
match_pseudoclass_state, hash_pseudoclass_state, comp_pseudoclass_state,
|
||||
FALSE, TRUE, FALSE, TRUE)
|
||||
#undef GTK_CSS_CHANGE_PSEUDOCLASS_SELECTED
|
||||
|
||||
#define GTK_CSS_CHANGE_PSEUDOCLASS_STATE GTK_CSS_CHANGE_STATE
|
||||
#define GTK_CSS_CHANGE_PSEUDOCLASS_STATE change_pseudoclass_state (selector)
|
||||
DEFINE_SIMPLE_SELECTOR(pseudoclass_state, PSEUDOCLASS_STATE, print_pseudoclass_state,
|
||||
match_pseudoclass_state, hash_pseudoclass_state, comp_pseudoclass_state,
|
||||
FALSE, TRUE, FALSE, TRUE)
|
||||
@ -1310,26 +1309,9 @@ gtk_css_selector_parse_selector_pseudo_class (GtkCssParser *parser,
|
||||
{
|
||||
if (pseudo_classes[i].state_flag)
|
||||
{
|
||||
if (pseudo_classes[i].state_flag == GTK_STATE_FLAG_PRELIGHT)
|
||||
selector = gtk_css_selector_new (negate ? >K_CSS_SELECTOR_NOT_PSEUDOCLASS_HOVER
|
||||
: >K_CSS_SELECTOR_PSEUDOCLASS_HOVER,
|
||||
selector);
|
||||
else if (pseudo_classes[i].state_flag == GTK_STATE_FLAG_INSENSITIVE)
|
||||
selector = gtk_css_selector_new (negate ? >K_CSS_SELECTOR_NOT_PSEUDOCLASS_DISABLED
|
||||
: >K_CSS_SELECTOR_PSEUDOCLASS_DISABLED,
|
||||
selector);
|
||||
else if (pseudo_classes[i].state_flag == GTK_STATE_FLAG_BACKDROP)
|
||||
selector = gtk_css_selector_new (negate ? >K_CSS_SELECTOR_NOT_PSEUDOCLASS_BACKDROP
|
||||
: >K_CSS_SELECTOR_PSEUDOCLASS_BACKDROP,
|
||||
selector);
|
||||
else if (pseudo_classes[i].state_flag == GTK_STATE_FLAG_SELECTED)
|
||||
selector = gtk_css_selector_new (negate ? >K_CSS_SELECTOR_NOT_PSEUDOCLASS_SELECTED
|
||||
: >K_CSS_SELECTOR_PSEUDOCLASS_SELECTED,
|
||||
selector);
|
||||
else
|
||||
selector = gtk_css_selector_new (negate ? >K_CSS_SELECTOR_NOT_PSEUDOCLASS_STATE
|
||||
selector = gtk_css_selector_new (negate ? >K_CSS_SELECTOR_NOT_PSEUDOCLASS_STATE
|
||||
: >K_CSS_SELECTOR_PSEUDOCLASS_STATE,
|
||||
selector);
|
||||
selector);
|
||||
selector->state.state = pseudo_classes[i].state_flag;
|
||||
}
|
||||
else
|
||||
|
Loading…
Reference in New Issue
Block a user