stylecontext: Add gtk_style_context_add_named()

This is an intermediate step for cssnode introduction. It gives a name
for the node created by saving the style context.
This commit is contained in:
Benjamin Otte 2015-09-05 06:58:17 +02:00
parent 385fda80b4
commit 72615a1b16
2 changed files with 27 additions and 16 deletions

View File

@ -1179,6 +1179,29 @@ gtk_style_context_get_parent (GtkStyleContext *context)
return context->priv->parent;
}
void
gtk_style_context_save_named (GtkStyleContext *context,
const char *name)
{
GtkStyleContextPrivate *priv;
GtkCssNode *cssnode;
priv = context->priv;
/* Make sure we have the style existing. It is the
* parent of the new saved node after all. */
if (!gtk_style_context_is_saved (context))
gtk_style_context_lookup_style (context);
cssnode = gtk_css_transient_node_new (priv->cssnode);
gtk_css_node_set_parent (cssnode, gtk_style_context_get_root (context));
if (name)
gtk_css_node_set_name (cssnode, g_intern_string (name));
priv->saved_nodes = g_slist_prepend (priv->saved_nodes, priv->cssnode);
priv->cssnode = cssnode;
}
/**
* gtk_style_context_save:
* @context: a #GtkStyleContext
@ -1196,24 +1219,9 @@ gtk_style_context_get_parent (GtkStyleContext *context)
void
gtk_style_context_save (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
GtkCssNode *cssnode;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
priv = context->priv;
/* Make sure we have the style existing. It is the
* parent of the new saved node after all.
*/
if (!gtk_style_context_is_saved (context))
gtk_style_context_lookup_style (context);
cssnode = gtk_css_transient_node_new (priv->cssnode);
gtk_css_node_set_parent (cssnode, gtk_style_context_get_root (context));
priv->saved_nodes = g_slist_prepend (priv->saved_nodes, priv->cssnode);
priv->cssnode = cssnode;
gtk_style_context_save_named (context, NULL);
}
/**

View File

@ -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_named (GtkStyleContext *context,
const char *name);
const GtkBitmask *
_gtk_style_context_get_changes (GtkStyleContext *context);