GtkStyleContext: Add gtk_style_context_invalidate().

This function will regenerate all styling information.
This commit is contained in:
Carlos Garnacho 2010-09-11 12:18:26 +02:00
parent 756bbf526f
commit 9f84e101bf
2 changed files with 51 additions and 1 deletions

View File

@ -97,7 +97,9 @@ struct GtkStyleContextPrivate
GSList *animation_regions;
GSList *animations;
gboolean animations_invalidated;
guint animations_invalidated : 1;
guint invalidating_context : 1;
GtkThemingEngine *theming_engine;
@ -110,6 +112,13 @@ enum {
PROP_DIRECTION
};
enum {
CHANGED,
LAST_SIGNAL
};
guint signals[LAST_SIGNAL] = { 0 };
static void gtk_style_context_finalize (GObject *object);
static void gtk_style_context_impl_set_property (GObject *object,
@ -133,6 +142,15 @@ gtk_style_context_class_init (GtkStyleContextClass *klass)
object_class->set_property = gtk_style_context_impl_set_property;
object_class->get_property = gtk_style_context_impl_get_property;
signals[CHANGED] =
g_signal_new (I_("changed"),
G_TYPE_FROM_CLASS (object_class),
G_SIGNAL_RUN_FIRST,
G_STRUCT_OFFSET (GtkStyleContextClass, changed),
NULL, NULL,
g_cclosure_marshal_VOID__VOID,
G_TYPE_NONE, 0);
g_object_class_install_property (object_class,
PROP_SCREEN,
g_param_spec_object ("screen",
@ -1798,6 +1816,33 @@ store_animation_region (GtkStyleContext *context,
}
}
void
gtk_style_context_invalidate (GtkStyleContext *context)
{
GtkStyleContextPrivate *priv;
g_return_if_fail (GTK_IS_STYLE_CONTEXT (context));
priv = context->priv;
/* Avoid reentrancy */
if (priv->invalidating_context)
return;
if (!priv->widget_path)
return;
priv->invalidating_context = TRUE;
rebuild_properties (context);
clear_property_cache (context);
rebuild_icon_factories (context);
g_signal_emit (context, signals[CHANGED], 0);
priv->invalidating_context = FALSE;
}
/* Paint methods */
void
gtk_render_check (GtkStyleContext *context,

View File

@ -45,6 +45,8 @@ struct GtkStyleContext
struct GtkStyleContextClass
{
GObjectClass parent_class;
void (* changed) (GtkStyleContext *context);
};
GType gtk_style_context_get_type (void) G_GNUC_CONST;
@ -160,6 +162,9 @@ void gtk_style_context_state_transition_update (GtkStyleContext *context,
void gtk_style_context_state_transition_stop (GtkStyleContext *context,
gpointer identifier);
void gtk_style_context_invalidate (GtkStyleContext *context);
/* Paint methods */
void gtk_render_check (GtkStyleContext *context,
cairo_t *cr,