[gtk+] gadget: Add helpers for modifying state
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+] gadget: Add helpers for modifying state
- Date: Mon, 11 Jan 2016 16:30:08 +0000 (UTC)
commit 8c1a73326c2871206a007b55da587000760cc15b
Author: Benjamin Otte <otte redhat com>
Date: Sat Dec 19 08:46:28 2015 +0100
gadget: Add helpers for modifying state
They will be used in future commits.
I also was too lazy to convert existing widgets.
gtk/gtkcssgadget.c | 50 +++++++++++++++++++++++++++++++++++++++++++++
gtk/gtkcssgadgetprivate.h | 6 +++++
2 files changed, 56 insertions(+), 0 deletions(-)
---
diff --git a/gtk/gtkcssgadget.c b/gtk/gtkcssgadget.c
index c068c95..dfda403 100644
--- a/gtk/gtkcssgadget.c
+++ b/gtk/gtkcssgadget.c
@@ -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)
diff --git a/gtk/gtkcssgadgetprivate.h b/gtk/gtkcssgadgetprivate.h
index b23f5e7..40efe8d 100644
--- a/gtk/gtkcssgadgetprivate.h
+++ b/gtk/gtkcssgadgetprivate.h
@@ -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,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]