Commit 9f84e101 authored by Carlos Garnacho's avatar Carlos Garnacho

GtkStyleContext: Add gtk_style_context_invalidate().

This function will regenerate all styling information.
parent 756bbf52
...@@ -97,7 +97,9 @@ struct GtkStyleContextPrivate ...@@ -97,7 +97,9 @@ struct GtkStyleContextPrivate
GSList *animation_regions; GSList *animation_regions;
GSList *animations; GSList *animations;
gboolean animations_invalidated;
guint animations_invalidated : 1;
guint invalidating_context : 1;
GtkThemingEngine *theming_engine; GtkThemingEngine *theming_engine;
...@@ -110,6 +112,13 @@ enum { ...@@ -110,6 +112,13 @@ enum {
PROP_DIRECTION PROP_DIRECTION
}; };
enum {
CHANGED,
LAST_SIGNAL
};
guint signals[LAST_SIGNAL] = { 0 };
static void gtk_style_context_finalize (GObject *object); static void gtk_style_context_finalize (GObject *object);
static void gtk_style_context_impl_set_property (GObject *object, static void gtk_style_context_impl_set_property (GObject *object,
...@@ -133,6 +142,15 @@ gtk_style_context_class_init (GtkStyleContextClass *klass) ...@@ -133,6 +142,15 @@ gtk_style_context_class_init (GtkStyleContextClass *klass)
object_class->set_property = gtk_style_context_impl_set_property; object_class->set_property = gtk_style_context_impl_set_property;
object_class->get_property = gtk_style_context_impl_get_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, g_object_class_install_property (object_class,
PROP_SCREEN, PROP_SCREEN,
g_param_spec_object ("screen", g_param_spec_object ("screen",
...@@ -1798,6 +1816,33 @@ store_animation_region (GtkStyleContext *context, ...@@ -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 */ /* Paint methods */
void void
gtk_render_check (GtkStyleContext *context, gtk_render_check (GtkStyleContext *context,
......
...@@ -45,6 +45,8 @@ struct GtkStyleContext ...@@ -45,6 +45,8 @@ struct GtkStyleContext
struct GtkStyleContextClass struct GtkStyleContextClass
{ {
GObjectClass parent_class; GObjectClass parent_class;
void (* changed) (GtkStyleContext *context);
}; };
GType gtk_style_context_get_type (void) G_GNUC_CONST; GType gtk_style_context_get_type (void) G_GNUC_CONST;
...@@ -160,6 +162,9 @@ void gtk_style_context_state_transition_update (GtkStyleContext *context, ...@@ -160,6 +162,9 @@ void gtk_style_context_state_transition_update (GtkStyleContext *context,
void gtk_style_context_state_transition_stop (GtkStyleContext *context, void gtk_style_context_state_transition_stop (GtkStyleContext *context,
gpointer identifier); gpointer identifier);
void gtk_style_context_invalidate (GtkStyleContext *context);
/* Paint methods */ /* Paint methods */
void gtk_render_check (GtkStyleContext *context, void gtk_render_check (GtkStyleContext *context,
cairo_t *cr, cairo_t *cr,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment