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)
|
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
|
static void
|
||||||
gtk_style_context_class_init (GtkStyleContextClass *klass)
|
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->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;
|
||||||
|
|
||||||
|
klass->changed = gtk_style_context_real_changed;
|
||||||
|
|
||||||
signals[CHANGED] =
|
signals[CHANGED] =
|
||||||
g_signal_new (I_("changed"),
|
g_signal_new (I_("changed"),
|
||||||
G_TYPE_FROM_CLASS (object_class),
|
G_TYPE_FROM_CLASS (object_class),
|
||||||
|
@ -14072,12 +14072,9 @@ gtk_widget_get_path (GtkWidget *widget)
|
|||||||
return widget->priv->path;
|
return widget->priv->path;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
void
|
||||||
style_context_changed (GtkStyleContext *context,
|
_gtk_widget_style_context_invalidated (GtkWidget *widget)
|
||||||
gpointer user_data)
|
|
||||||
{
|
{
|
||||||
GtkWidget *widget = user_data;
|
|
||||||
|
|
||||||
if (gtk_widget_get_realized (widget))
|
if (gtk_widget_get_realized (widget))
|
||||||
g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
|
g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
|
||||||
else
|
else
|
||||||
@ -14132,8 +14129,6 @@ gtk_widget_get_style_context (GtkWidget *widget)
|
|||||||
gtk_widget_get_style_context (priv->parent));
|
gtk_widget_get_style_context (priv->parent));
|
||||||
|
|
||||||
_gtk_style_context_set_widget (priv->context, widget);
|
_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;
|
return widget->priv->context;
|
||||||
|
@ -173,6 +173,8 @@ void _gtk_widget_set_captured_event_handler (GtkWidget
|
|||||||
gboolean _gtk_widget_captured_event (GtkWidget *widget,
|
gboolean _gtk_widget_captured_event (GtkWidget *widget,
|
||||||
GdkEvent *event);
|
GdkEvent *event);
|
||||||
|
|
||||||
|
void _gtk_widget_style_context_invalidated (GtkWidget *widget);
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
||||||
#endif /* __GTK_WIDGET_PRIVATE_H__ */
|
#endif /* __GTK_WIDGET_PRIVATE_H__ */
|
||||||
|
Loading…
Reference in New Issue
Block a user