forked from AuroraMiddleware/gtk
stylecontext: Add setter for widget
... and actually set the widget on the style context. Note that this function does not take a reference on the widget, which is a very good reason to keep it private.
This commit is contained in:
parent
102d10016f
commit
1aa4a196dc
@ -361,6 +361,7 @@ struct _GtkStyleContextPrivate
|
||||
GtkStyleCascade *cascade;
|
||||
|
||||
GtkStyleContext *parent;
|
||||
GtkWidget *widget;
|
||||
GtkWidgetPath *widget_path;
|
||||
GHashTable *style_data;
|
||||
GSList *info_stack;
|
||||
@ -1021,6 +1022,16 @@ gtk_style_context_new (void)
|
||||
return g_object_new (GTK_TYPE_STYLE_CONTEXT, NULL);
|
||||
}
|
||||
|
||||
void
|
||||
_gtk_style_context_set_widget (GtkStyleContext *context,
|
||||
GtkWidget *widget)
|
||||
{
|
||||
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
|
||||
g_return_if_fail (widget == NULL || GTK_IS_WIDGET (widget));
|
||||
|
||||
context->priv->widget = widget;
|
||||
}
|
||||
|
||||
/**
|
||||
* gtk_style_context_add_provider:
|
||||
* @context: a #GtkStyleContext
|
||||
@ -1492,6 +1503,7 @@ gtk_style_context_set_path (GtkStyleContext *context,
|
||||
g_return_if_fail (path != NULL);
|
||||
|
||||
priv = context->priv;
|
||||
g_return_if_fail (priv->widget == NULL);
|
||||
|
||||
if (priv->widget_path)
|
||||
{
|
||||
@ -2214,7 +2226,7 @@ _gtk_style_context_peek_style_property (GtkStyleContext *context,
|
||||
g_param_spec_ref (pcache->pspec);
|
||||
g_value_init (&pcache->value, G_PARAM_SPEC_VALUE_TYPE (pspec));
|
||||
|
||||
if (priv->widget_path)
|
||||
if (priv->widget || priv->widget_path)
|
||||
{
|
||||
if (gtk_style_provider_get_style_property (GTK_STYLE_PROVIDER (priv->cascade),
|
||||
priv->widget_path, state,
|
||||
|
@ -24,7 +24,9 @@
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
GtkCssValue * _gtk_style_context_peek_property (GtkStyleContext *context,
|
||||
void _gtk_style_context_set_widget (GtkStyleContext *context,
|
||||
GtkWidget *widget);
|
||||
GtkCssValue * _gtk_style_context_peek_property (GtkStyleContext *context,
|
||||
const char *property_name);
|
||||
double _gtk_style_context_get_number (GtkStyleContext *context,
|
||||
const char *property_name,
|
||||
|
@ -10402,7 +10402,10 @@ gtk_widget_finalize (GObject *object)
|
||||
gtk_widget_path_free (priv->path);
|
||||
|
||||
if (priv->context)
|
||||
g_object_unref (priv->context);
|
||||
{
|
||||
_gtk_style_context_set_widget (priv->context, NULL);
|
||||
g_object_unref (priv->context);
|
||||
}
|
||||
|
||||
_gtk_widget_free_cached_sizes (widget);
|
||||
|
||||
@ -14128,6 +14131,7 @@ gtk_widget_get_style_context (GtkWidget *widget)
|
||||
gtk_style_context_set_parent (priv->context,
|
||||
gtk_widget_get_style_context (priv->parent));
|
||||
|
||||
_gtk_style_context_set_widget (priv->context, widget);
|
||||
g_signal_connect (widget->priv->context, "changed",
|
||||
G_CALLBACK (style_context_changed), widget);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user