[gtk+/wip/cssnode3: 1/18] stylecontext: Add gtk_style_context_save_to_node()
- From: Benjamin Otte <otte src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/wip/cssnode3: 1/18] stylecontext: Add gtk_style_context_save_to_node()
- Date: Tue, 24 Mar 2015 03:31:52 +0000 (UTC)
commit c0c79eee038eb4ed8f9b26d4ec5d89f23e8ba26f
Author: Benjamin Otte <otte redhat com>
Date: Mon Feb 16 16:37:33 2015 +0100
stylecontext: Add gtk_style_context_save_to_node()
To be used instead of gtk_style_context_save() with persistent nodes.
gtk/gtkstylecontext.c | 36 ++++++++++++++++++++++++++++++++++--
gtk/gtkstylecontextprivate.h | 3 +++
2 files changed, 37 insertions(+), 2 deletions(-)
---
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index 3786e35..65b6c4b 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -1193,6 +1193,37 @@ gtk_style_context_get_parent (GtkStyleContext *context)
return context->priv->parent;
}
+/*
+ * gtk_style_context_save_to_node:
+ * @context: a #GtkStyleContext
+ * @node: the node to save to
+ *
+ * Saves the @context state, so temporary modifications done through
+ * gtk_style_context_add_class(), gtk_style_context_remove_class(),
+ * gtk_style_context_set_state(), etc. and rendering using
+ * gtk_render_background() or similar functions are done using the
+ * given @node.
+ *
+ * To undo, call gtk_style_context_restore().
+ *
+ * The matching call to gtk_style_context_restore() must be done
+ * before GTK returns to the main loop.
+ **/
+void
+gtk_style_context_save_to_node (GtkStyleContext *context,
+ GtkCssNode *node)
+{
+ GtkStyleContextPrivate *priv;
+
+ g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
+ g_return_if_fail (GTK_IS_CSS_NODE (node));
+
+ priv = context->priv;
+
+ priv->saved_nodes = g_slist_prepend (priv->saved_nodes, priv->cssnode);
+ priv->cssnode = g_object_ref (node);
+}
+
/**
* gtk_style_context_save:
* @context: a #GtkStyleContext
@@ -1226,8 +1257,9 @@ gtk_style_context_save (GtkStyleContext *context)
gtk_css_node_set_parent (cssnode, gtk_style_context_get_root (context));
gtk_css_node_set_widget_type (cssnode, gtk_css_node_get_widget_type (priv->cssnode));
- priv->saved_nodes = g_slist_prepend (priv->saved_nodes, priv->cssnode);
- priv->cssnode = cssnode;
+ gtk_style_context_save_to_node (context, cssnode);
+
+ g_object_unref (cssnode);
}
/**
diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h
index 331eb60..e01f427 100644
--- a/gtk/gtkstylecontextprivate.h
+++ b/gtk/gtkstylecontextprivate.h
@@ -36,6 +36,9 @@ const char * gtk_style_context_get_id (GtkStyleContext *c
GtkStyleProviderPrivate *
gtk_style_context_get_style_provider (GtkStyleContext *context);
+void gtk_style_context_save_to_node (GtkStyleContext *context,
+ GtkCssNode *node);
+
const GtkBitmask *
_gtk_style_context_get_changes (GtkStyleContext *context);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]