From db9730b73401cbb3c0fa6c396efb47e95704b973 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Wed, 5 Feb 2020 02:54:32 +0100 Subject: [PATCH] stylecontext: Remove the "changed" signal Instead, always go directly to the GtkWidget::css_changed() call. --- gtk/gtkcsswidgetnode.c | 8 +-- gtk/gtkstylecontext.c | 94 ------------------------------------ gtk/gtkstylecontextprivate.h | 5 -- 3 files changed, 1 insertion(+), 106 deletions(-) diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c index 7ade48a753..7a3a37ffc1 100644 --- a/gtk/gtkcsswidgetnode.c +++ b/gtk/gtkcsswidgetnode.c @@ -95,13 +95,7 @@ gtk_css_widget_node_validate (GtkCssNode *node) gtk_css_style_change_init (&change, widget_node->last_updated_style, style); if (gtk_css_style_change_has_change (&change)) { - GtkStyleContext *context; - - context = _gtk_widget_peek_style_context (widget_node->widget); - if (context) - gtk_style_context_validate (context, &change); - else - gtk_widget_css_changed (widget_node->widget, &change); + gtk_widget_css_changed (widget_node->widget, &change); g_set_object (&widget_node->last_updated_style, style); } gtk_css_style_change_finish (&change); diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c index 8566c8b644..a5db7066aa 100644 --- a/gtk/gtkstylecontext.c +++ b/gtk/gtkstylecontext.c @@ -119,8 +119,6 @@ struct _GtkStyleContextPrivate GtkStyleContext *parent; GtkCssNode *cssnode; GSList *saved_nodes; - - GtkCssStyleChange *invalidating_context; }; typedef struct _GtkStyleContextPrivate GtkStyleContextPrivate; @@ -131,15 +129,8 @@ enum { LAST_PROP }; -enum { - CHANGED, - LAST_SIGNAL -}; - static GParamSpec *properties[LAST_PROP] = { NULL, }; -static guint signals[LAST_SIGNAL] = { 0 }; - static void gtk_style_context_finalize (GObject *object); static void gtk_style_context_impl_set_property (GObject *object, @@ -155,19 +146,6 @@ static GtkCssNode * gtk_style_context_get_root (GtkStyleContext *context); G_DEFINE_TYPE_WITH_PRIVATE (GtkStyleContext, gtk_style_context, G_TYPE_OBJECT) -static void -gtk_style_context_real_changed (GtkStyleContext *context) -{ - GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context); - - if (GTK_IS_CSS_WIDGET_NODE (priv->cssnode)) - { - GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (priv->cssnode)); - if (widget != NULL) - gtk_widget_css_changed (widget, gtk_style_context_get_change (context)); - } -} - static void gtk_style_context_class_init (GtkStyleContextClass *klass) { @@ -177,28 +155,6 @@ 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; - - /** - * GtkStyleContext::changed: - * - * The ::changed signal is emitted when there is a change in the - * #GtkStyleContext. - * - * For a #GtkStyleContext returned by gtk_widget_get_style_context(), the - * #GtkWidget:css-changed vfunc might be more convenient to use. - * - * This signal is useful when using the theming layer standalone. - */ - signals[CHANGED] = - g_signal_new (I_("changed"), - G_TYPE_FROM_CLASS (object_class), - G_SIGNAL_RUN_FIRST, - G_STRUCT_OFFSET (GtkStyleContextClass, changed), - NULL, NULL, - NULL, - G_TYPE_NONE, 0); - properties[PROP_DISPLAY] = g_param_spec_object ("display", P_("Display"), @@ -1143,30 +1099,6 @@ gtk_style_context_lookup_color (GtkStyleContext *context, return gtk_style_context_resolve_color (context, value, color); } -static GtkCssStyleChange magic_number; - -void -gtk_style_context_validate (GtkStyleContext *context, - GtkCssStyleChange *change) -{ - GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context); - - g_return_if_fail (GTK_IS_STYLE_CONTEXT (context)); - - /* Avoid reentrancy */ - if (priv->invalidating_context) - return; - - if (change) - priv->invalidating_context = change; - else - priv->invalidating_context = &magic_number; - - g_signal_emit (context, signals[CHANGED], 0); - - priv->invalidating_context = NULL; -} - /** * gtk_style_context_get_color: * @context: a #GtkStyleContext @@ -1597,32 +1529,6 @@ gtk_snapshot_render_insertion_cursor (GtkSnapshot *snapshot, } } -/** - * gtk_style_context_get_change: - * @context: the context to query - * - * Queries the context for the changes for the currently executing - * GtkStyleContext::invalidate signal. If no signal is currently - * emitted or the signal has not been triggered by a CssNode - * invalidation, this function returns %NULL. - * - * FIXME 4.0: Make this part of the signal. - * - * Returns: %NULL or the currently invalidating changes - **/ -GtkCssStyleChange * -gtk_style_context_get_change (GtkStyleContext *context) -{ - GtkStyleContextPrivate *priv = gtk_style_context_get_instance_private (context); - - g_return_val_if_fail (GTK_IS_STYLE_CONTEXT (context), NULL); - - if (priv->invalidating_context == &magic_number) - return NULL; - - return priv->invalidating_context; -} - PangoAttrList * _gtk_style_context_get_pango_attributes (GtkStyleContext *context) { diff --git a/gtk/gtkstylecontextprivate.h b/gtk/gtkstylecontextprivate.h index e3cc0fff39..4074d06a96 100644 --- a/gtk/gtkstylecontextprivate.h +++ b/gtk/gtkstylecontextprivate.h @@ -44,14 +44,9 @@ void gtk_style_context_save_named (GtkStyleContext *c void gtk_style_context_save_to_node (GtkStyleContext *context, GtkCssNode *node); -GtkCssStyleChange * - gtk_style_context_get_change (GtkStyleContext *context); - GtkCssStyle * gtk_style_context_lookup_style (GtkStyleContext *context); GtkCssValue * _gtk_style_context_peek_property (GtkStyleContext *context, guint property_id); -void gtk_style_context_validate (GtkStyleContext *context, - GtkCssStyleChange *change); gboolean _gtk_style_context_check_region_name (const gchar *str); void _gtk_style_context_get_cursor_color (GtkStyleContext *context,