gadget: Add helpers for modifying state

They will be used in future commits.

I also was too lazy to convert existing widgets.
This commit is contained in:
Benjamin Otte 2015-12-19 08:46:28 +01:00
parent e27551ddb2
commit 8c1a73326c
2 changed files with 56 additions and 0 deletions

View File

@ -394,6 +394,56 @@ gtk_css_gadget_remove_class (GtkCssGadget *gadget,
gtk_css_node_remove_class (priv->node, quark);
}
/**
* gtk_css_gadget_set_state:
* @gadget: a #GtkCssGadget
* @state: The new state
*
* Sets the state of the gadget's CSS node.
*/
void
gtk_css_gadget_set_state (GtkCssGadget *gadget,
GtkStateFlags state)
{
GtkCssGadgetPrivate *priv = gtk_css_gadget_get_instance_private (gadget);
gtk_css_node_set_state (priv->node, state);
}
/**
* gtk_css_gadget_add_state:
* @gadget: a #GtkCssGadget
* @state: The state to add
*
* Adds the given states to the states of gadget's CSS node. Other states
* will be kept as they are.
*/
void
gtk_css_gadget_add_state (GtkCssGadget *gadget,
GtkStateFlags state)
{
GtkCssGadgetPrivate *priv = gtk_css_gadget_get_instance_private (gadget);
gtk_css_node_set_state (priv->node, gtk_css_node_get_state (priv->node) | state);
}
/**
* gtk_css_gadget_remove_state:
* @gadget: a #GtkCssGadget
* @state: The state to remove
*
* Adds the given states to the states of gadget's CSS node. Other states
* will be kept as they are.
*/
void
gtk_css_gadget_remove_state (GtkCssGadget *gadget,
GtkStateFlags state)
{
GtkCssGadgetPrivate *priv = gtk_css_gadget_get_instance_private (gadget);
gtk_css_node_set_state (priv->node, gtk_css_node_get_state (priv->node) & ~state);
}
static gint
get_number (GtkCssStyle *style,
guint property)

View File

@ -86,6 +86,12 @@ void gtk_css_gadget_add_class (GtkCssGadget
const char *name);
void gtk_css_gadget_remove_class (GtkCssGadget *gadget,
const char *name);
void gtk_css_gadget_set_state (GtkCssGadget *gadget,
GtkStateFlags state);
void gtk_css_gadget_add_state (GtkCssGadget *gadget,
GtkStateFlags state);
void gtk_css_gadget_remove_state (GtkCssGadget *gadget,
GtkStateFlags state);
void gtk_css_gadget_get_preferred_size (GtkCssGadget *gadget,
GtkOrientation orientation,