forked from AuroraMiddleware/gtk
stylecontext: Notify widget directly of changes
This way, we don't need to g_signal_connect(), which saves a bunch of memory and performance.
This commit is contained in:
parent
1aa4a196dc
commit
e5ab48ac59
@ -410,6 +410,15 @@ static GtkSymbolicColor *
|
||||
|
||||
G_DEFINE_TYPE (GtkStyleContext, gtk_style_context, G_TYPE_OBJECT)
|
||||
|
||||
static void
|
||||
gtk_style_context_real_changed (GtkStyleContext *context)
|
||||
{
|
||||
GtkStyleContextPrivate *priv = context->priv;
|
||||
|
||||
if (priv->widget)
|
||||
_gtk_widget_style_context_invalidated (priv->widget);
|
||||
}
|
||||
|
||||
static void
|
||||
gtk_style_context_class_init (GtkStyleContextClass *klass)
|
||||
{
|
||||
@ -419,6 +428,8 @@ 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;
|
||||
|
||||
klass->changed = gtk_style_context_real_changed;
|
||||
|
||||
signals[CHANGED] =
|
||||
g_signal_new (I_("changed"),
|
||||
G_TYPE_FROM_CLASS (object_class),
|
||||
|
@ -14072,12 +14072,9 @@ gtk_widget_get_path (GtkWidget *widget)
|
||||
return widget->priv->path;
|
||||
}
|
||||
|
||||
static void
|
||||
style_context_changed (GtkStyleContext *context,
|
||||
gpointer user_data)
|
||||
void
|
||||
_gtk_widget_style_context_invalidated (GtkWidget *widget)
|
||||
{
|
||||
GtkWidget *widget = user_data;
|
||||
|
||||
if (gtk_widget_get_realized (widget))
|
||||
g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
|
||||
else
|
||||
@ -14132,8 +14129,6 @@ gtk_widget_get_style_context (GtkWidget *widget)
|
||||
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);
|
||||
}
|
||||
|
||||
return widget->priv->context;
|
||||
|
@ -173,6 +173,8 @@ void _gtk_widget_set_captured_event_handler (GtkWidget
|
||||
gboolean _gtk_widget_captured_event (GtkWidget *widget,
|
||||
GdkEvent *event);
|
||||
|
||||
void _gtk_widget_style_context_invalidated (GtkWidget *widget);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GTK_WIDGET_PRIVATE_H__ */
|
||||
|
Loading…
Reference in New Issue
Block a user