[gtk/wip/otte/css: 122/128] widget: Replace style-updated signal with css_changed vfunc



commit 546a748cd8859daeb6e1ab78579396dc62977945
Author: Benjamin Otte <otte redhat com>
Date:   Wed Feb 5 02:46:13 2020 +0100

    widget: Replace style-updated signal with css_changed vfunc
    
    1. Rename the thing
    2. Turn it from a signal to a vfunc
    3. Pass the GtkCssStyleChange to it
    
    We don't export any public API about the GtkCssStyleChange yet, it's
    just a boring opaque struct.

 gdk/gdksurface.c               |  2 +-
 gtk/gtkbuiltinicon.c           | 13 ++++---------
 gtk/gtkcontainer.c             |  2 +-
 gtk/gtkcssstylechangeprivate.h |  2 --
 gtk/gtkcsswidgetnode.c         |  2 +-
 gtk/gtkfilechooserbutton.c     | 17 ++++++++---------
 gtk/gtkfilechooserwidget.c     | 14 ++++++++------
 gtk/gtkfontchooserwidget.c     |  1 -
 gtk/gtkicontheme.c             |  4 ++--
 gtk/gtkimage.c                 | 12 ++++++------
 gtk/gtklabel.c                 | 19 ++++++++-----------
 gtk/gtkpaned.c                 | 22 +++++++++-------------
 gtk/gtkspinner.c               | 13 ++++---------
 gtk/gtkstylecontext.c          |  4 ++--
 gtk/gtktext.c                  | 15 ++++++---------
 gtk/gtktextview.c              | 21 +++++++++------------
 gtk/gtktoolbar.c               | 10 ++++++----
 gtk/gtktreeview.c              | 15 ++++++---------
 gtk/gtktypes.h                 |  1 +
 gtk/gtkwidget.c                | 34 ++++++++--------------------------
 gtk/gtkwidget.h                |  9 ++++++---
 gtk/gtkwidgetprivate.h         |  3 ++-
 gtk/gtkwindow.c                | 15 ++++++++-------
 gtk/ui/gtkfontchooserwidget.ui |  1 -
 24 files changed, 106 insertions(+), 145 deletions(-)
---
diff --git a/gdk/gdksurface.c b/gdk/gdksurface.c
index 7af60c09c3..10046c4ca1 100644
--- a/gdk/gdksurface.c
+++ b/gdk/gdksurface.c
@@ -3793,7 +3793,7 @@ gdk_surface_get_unscaled_size (GdkSurface *surface,
  * GTK will update this property automatically if
  * the @surface background is opaque, as we know where the opaque regions
  * are. If your surface background is not opaque, please update this
- * property in your #GtkWidget::style-updated handler.
+ * property in your #GtkWidget:css-changed handler.
  */
 void
 gdk_surface_set_opaque_region (GdkSurface      *surface,
diff --git a/gtk/gtkbuiltinicon.c b/gtk/gtkbuiltinicon.c
index f6a819159c..b91864db44 100644
--- a/gtk/gtkbuiltinicon.c
+++ b/gtk/gtkbuiltinicon.c
@@ -55,15 +55,10 @@ gtk_builtin_icon_snapshot (GtkWidget   *widget,
 }
 
 static void
-gtk_builtin_icon_style_updated (GtkWidget *widget)
+gtk_builtin_icon_css_changed (GtkWidget         *widget,
+                              GtkCssStyleChange *change)
 {
-  GtkStyleContext *context;
-  GtkCssStyleChange *change = NULL;
-
-  context = gtk_widget_get_style_context (widget);
-  change = gtk_style_context_get_change (context);
-
-  GTK_WIDGET_CLASS (gtk_builtin_icon_parent_class)->style_updated (widget);
+  GTK_WIDGET_CLASS (gtk_builtin_icon_parent_class)->css_changed (widget, change);
 
   if (change == NULL ||
       gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE))
@@ -99,7 +94,7 @@ gtk_builtin_icon_class_init (GtkBuiltinIconClass *klass)
 
   wclass->snapshot = gtk_builtin_icon_snapshot;
   wclass->measure = gtk_builtin_icon_measure;
-  wclass->style_updated = gtk_builtin_icon_style_updated;
+  wclass->css_changed = gtk_builtin_icon_css_changed;
 }
 
 static void
diff --git a/gtk/gtkcontainer.c b/gtk/gtkcontainer.c
index 9da5fb4c6e..7d74e4f069 100644
--- a/gtk/gtkcontainer.c
+++ b/gtk/gtkcontainer.c
@@ -350,7 +350,7 @@ gtk_container_idle_sizer (GdkFrameClock *clock,
   /* We validate the style contexts in a single loop before even trying
    * to handle resizes instead of doing validations inline.
    * This is mostly necessary for compatibility reasons with old code,
-   * because both style_updated and size_allocate functions often change
+   * because both css_changed and size_allocate functions often change
    * styles and so could cause infinite loops in this function.
    *
    * It's important to note that even an invalid style context returns
diff --git a/gtk/gtkcssstylechangeprivate.h b/gtk/gtkcssstylechangeprivate.h
index d71a9c87ef..557cba37fe 100644
--- a/gtk/gtkcssstylechangeprivate.h
+++ b/gtk/gtkcssstylechangeprivate.h
@@ -22,8 +22,6 @@
 
 G_BEGIN_DECLS
 
-typedef struct _GtkCssStyleChange GtkCssStyleChange;
-
 struct _GtkCssStyleChange {
   GtkCssStyle   *old_style;
   GtkCssStyle   *new_style;
diff --git a/gtk/gtkcsswidgetnode.c b/gtk/gtkcsswidgetnode.c
index 90a0127661..7ade48a753 100644
--- a/gtk/gtkcsswidgetnode.c
+++ b/gtk/gtkcsswidgetnode.c
@@ -101,7 +101,7 @@ gtk_css_widget_node_validate (GtkCssNode *node)
       if (context)
         gtk_style_context_validate (context, &change);
       else
-        _gtk_widget_style_context_invalidated (widget_node->widget);
+        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/gtkfilechooserbutton.c b/gtk/gtkfilechooserbutton.c
index 00bacca83f..95b366753f 100644
--- a/gtk/gtkfilechooserbutton.c
+++ b/gtk/gtkfilechooserbutton.c
@@ -278,9 +278,10 @@ static void     gtk_file_chooser_button_root               (GtkWidget *widget);
 static void     gtk_file_chooser_button_map                (GtkWidget        *widget);
 static gboolean gtk_file_chooser_button_mnemonic_activate  (GtkWidget        *widget,
                                                            gboolean          group_cycling);
-static void     gtk_file_chooser_button_style_updated      (GtkWidget        *widget);
-static void     gtk_file_chooser_button_state_flags_changed (GtkWidget       *widget,
-                                                             GtkStateFlags    previous_state);
+static void     gtk_file_chooser_button_css_changed             (GtkWidget              *widget,
+                                                                 GtkCssStyleChange      *change);
+static void     gtk_file_chooser_button_state_flags_changed     (GtkWidget       *widget,
+                                                                 GtkStateFlags    previous_state);
 
 /* Utility Functions */
 static void          set_info_for_file_at_iter         (GtkFileChooserButton *fs,
@@ -371,7 +372,7 @@ gtk_file_chooser_button_class_init (GtkFileChooserButtonClass * class)
   widget_class->show = gtk_file_chooser_button_show;
   widget_class->hide = gtk_file_chooser_button_hide;
   widget_class->map = gtk_file_chooser_button_map;
-  widget_class->style_updated = gtk_file_chooser_button_style_updated;
+  widget_class->css_changed = gtk_file_chooser_button_css_changed;
   widget_class->root = gtk_file_chooser_button_root;
   widget_class->mnemonic_activate = gtk_file_chooser_button_mnemonic_activate;
   widget_class->state_flags_changed = gtk_file_chooser_button_state_flags_changed;
@@ -1456,12 +1457,10 @@ change_icon_theme (GtkFileChooserButton *button)
 }
 
 static void
-gtk_file_chooser_button_style_updated (GtkWidget *widget)
+gtk_file_chooser_button_css_changed (GtkWidget         *widget,
+                                     GtkCssStyleChange *change)
 {
-  GtkStyleContext *context = gtk_widget_get_style_context (widget);
-  GtkCssStyleChange *change = gtk_style_context_get_change (context);
-
-  GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->style_updated (widget);
+  GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->css_changed (widget, change);
 
   /* We need to update the icon surface, but only in case
    * the icon theme really changed. */
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c
index 12988b498c..a1e1e29128 100644
--- a/gtk/gtkfilechooserwidget.c
+++ b/gtk/gtkfilechooserwidget.c
@@ -480,7 +480,8 @@ static void     gtk_file_chooser_widget_map            (GtkWidget             *w
 static void     gtk_file_chooser_widget_unmap          (GtkWidget             *widget);
 static void     gtk_file_chooser_widget_root           (GtkWidget             *widget);
 static void     gtk_file_chooser_widget_unroot         (GtkWidget             *widget);
-static void     gtk_file_chooser_widget_style_updated   (GtkWidget             *widget);
+static void     gtk_file_chooser_widget_css_changed    (GtkWidget             *widget,
+                                                        GtkCssStyleChange     *change);
 
 static gboolean       gtk_file_chooser_widget_set_current_folder           (GtkFileChooser    *chooser,
                                                                             GFile             *folder,
@@ -3647,7 +3648,8 @@ check_icon_theme (GtkFileChooserWidget *impl)
 }
 
 static void
-gtk_file_chooser_widget_style_updated (GtkWidget *widget)
+gtk_file_chooser_widget_css_changed (GtkWidget         *widget,
+                                     GtkCssStyleChange *change)
 {
   GtkFileChooserWidget *impl;
 
@@ -3655,9 +3657,9 @@ gtk_file_chooser_widget_style_updated (GtkWidget *widget)
 
   impl = GTK_FILE_CHOOSER_WIDGET (widget);
 
-  profile_msg ("    parent class style_udpated start", NULL);
-  GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->style_updated (widget);
-  profile_msg ("    parent class style_updated end", NULL);
+  profile_msg ("    parent class css_changed start", NULL);
+  GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->css_changed (widget, change);
+  profile_msg ("    parent class css_changed end", NULL);
 
   change_icon_theme (impl);
 
@@ -7945,7 +7947,7 @@ gtk_file_chooser_widget_class_init (GtkFileChooserWidgetClass *class)
   widget_class->unmap = gtk_file_chooser_widget_unmap;
   widget_class->root = gtk_file_chooser_widget_root;
   widget_class->unroot = gtk_file_chooser_widget_unroot;
-  widget_class->style_updated = gtk_file_chooser_widget_style_updated;
+  widget_class->css_changed = gtk_file_chooser_widget_css_changed;
 
   /*
    * Signals
diff --git a/gtk/gtkfontchooserwidget.c b/gtk/gtkfontchooserwidget.c
index c25a4889b3..be77f9bf5d 100644
--- a/gtk/gtkfontchooserwidget.c
+++ b/gtk/gtkfontchooserwidget.c
@@ -790,7 +790,6 @@ gtk_font_chooser_widget_class_init (GtkFontChooserWidgetClass *klass)
   gtk_widget_class_bind_template_callback (widget_class, stop_search_cb);
   gtk_widget_class_bind_template_callback (widget_class, cursor_changed_cb);
   gtk_widget_class_bind_template_callback (widget_class, row_activated_cb);
-  gtk_widget_class_bind_template_callback (widget_class, gtk_font_chooser_widget_set_cell_size);
   gtk_widget_class_bind_template_callback (widget_class, rows_changed_cb);
   gtk_widget_class_bind_template_callback (widget_class, size_change_cb);
   gtk_widget_class_bind_template_callback (widget_class, output_cb);
diff --git a/gtk/gtkicontheme.c b/gtk/gtkicontheme.c
index 9820aacb6a..96b8954f4d 100644
--- a/gtk/gtkicontheme.c
+++ b/gtk/gtkicontheme.c
@@ -2172,8 +2172,8 @@ choose_icon (GtkIconTheme      *self,
  * they will be tried in order.
  *
  * Note that you probably want to listen for icon theme changes and
- * update the icon. This is usually done by connecting to the
- * GtkWidget::style-updated signal.
+ * update the icon. This is usually done by overriding the
+ * #GtkWidget:css-changed function.
  *
  * Returns: (nullable) (transfer full): a #GtkIconPaintable object
  *     containing the icon, or %NULL if the icon wasn’t found.
diff --git a/gtk/gtkimage.c b/gtk/gtkimage.c
index 8a415750e9..b5eb28f1ff 100644
--- a/gtk/gtkimage.c
+++ b/gtk/gtkimage.c
@@ -111,7 +111,8 @@ static void gtk_image_measure (GtkWidget      *widget,
                                int           *minimum_baseline,
                                int           *natural_baseline);
 
-static void gtk_image_style_updated        (GtkWidget    *widget);
+static void gtk_image_css_changed          (GtkWidget    *widget,
+                                            GtkCssStyleChange *change);
 static void gtk_image_finalize             (GObject      *object);
 
 static void gtk_image_set_property         (GObject      *object,
@@ -158,7 +159,7 @@ gtk_image_class_init (GtkImageClass *class)
   widget_class->snapshot = gtk_image_snapshot;
   widget_class->measure = gtk_image_measure;
   widget_class->unrealize = gtk_image_unrealize;
-  widget_class->style_updated = gtk_image_style_updated;
+  widget_class->css_changed = gtk_image_css_changed;
 
   image_props[PROP_PAINTABLE] =
       g_param_spec_object ("paintable",
@@ -1283,16 +1284,15 @@ gtk_image_measure (GtkWidget      *widget,
 }
 
 static void
-gtk_image_style_updated (GtkWidget *widget)
+gtk_image_css_changed (GtkWidget         *widget,
+                       GtkCssStyleChange *change)
 {
   GtkImage *image = GTK_IMAGE (widget);
   GtkImagePrivate *priv = gtk_image_get_instance_private (image);
-  GtkStyleContext *context = gtk_widget_get_style_context (widget);
-  GtkCssStyleChange *change = gtk_style_context_get_change (context);
 
   gtk_icon_helper_invalidate_for_change (priv->icon_helper, change);
 
-  GTK_WIDGET_CLASS (gtk_image_parent_class)->style_updated (widget);
+  GTK_WIDGET_CLASS (gtk_image_parent_class)->css_changed (widget, change);
 
   priv->baseline_align = 0.0;
 }
diff --git a/gtk/gtklabel.c b/gtk/gtklabel.c
index 6e76d8ae3f..abcf2a2871 100644
--- a/gtk/gtklabel.c
+++ b/gtk/gtklabel.c
@@ -434,9 +434,10 @@ static void gtk_label_size_allocate     (GtkWidget        *widget,
                                          int               baseline);
 static void gtk_label_state_flags_changed   (GtkWidget        *widget,
                                              GtkStateFlags     prev_state);
-static void gtk_label_style_updated     (GtkWidget        *widget);
-static void gtk_label_snapshot          (GtkWidget        *widget,
-                                         GtkSnapshot      *snapshot);
+static void gtk_label_css_changed       (GtkWidget         *widget,
+                                         GtkCssStyleChange *change);
+static void gtk_label_snapshot          (GtkWidget         *widget,
+                                         GtkSnapshot       *snapshot);
 static gboolean gtk_label_focus         (GtkWidget         *widget,
                                          GtkDirectionType   direction);
 
@@ -641,7 +642,7 @@ gtk_label_class_init (GtkLabelClass *class)
   widget_class->destroy = gtk_label_destroy;
   widget_class->size_allocate = gtk_label_size_allocate;
   widget_class->state_flags_changed = gtk_label_state_flags_changed;
-  widget_class->style_updated = gtk_label_style_updated;
+  widget_class->css_changed = gtk_label_css_changed;
   widget_class->query_tooltip = gtk_label_query_tooltip;
   widget_class->snapshot = gtk_label_snapshot;
   widget_class->unrealize = gtk_label_unrealize;
@@ -3790,17 +3791,13 @@ gtk_label_state_flags_changed (GtkWidget     *widget,
 }
 
 static void 
-gtk_label_style_updated (GtkWidget *widget)
+gtk_label_css_changed (GtkWidget         *widget,
+                       GtkCssStyleChange *change)
 {
   GtkLabel *label = GTK_LABEL (widget);
   GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
-  GtkStyleContext *context;
-  GtkCssStyleChange *change;
-
-  GTK_WIDGET_CLASS (gtk_label_parent_class)->style_updated (widget);
 
-  context = gtk_widget_get_style_context (widget);
-  change = gtk_style_context_get_change (context);
+  GTK_WIDGET_CLASS (gtk_label_parent_class)->css_changed (widget, change);
 
   if (change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_ATTRS) ||
       (priv->select_info && priv->select_info->links))
diff --git a/gtk/gtkpaned.c b/gtk/gtkpaned.c
index f1689302ca..429c6d5e04 100644
--- a/gtk/gtkpaned.c
+++ b/gtk/gtkpaned.c
@@ -227,10 +227,11 @@ static void     gtk_paned_size_allocate         (GtkWidget           *widget,
                                                  int                  width,
                                                  int                  height,
                                                  int                  baseline);
-static void     gtk_paned_unrealize             (GtkWidget        *widget);
-static gboolean gtk_paned_focus                 (GtkWidget        *widget,
-                                                GtkDirectionType  direction);
-static void     gtk_paned_style_updated         (GtkWidget        *widget);
+static void     gtk_paned_unrealize             (GtkWidget           *widget);
+static gboolean gtk_paned_focus                 (GtkWidget           *widget,
+                                                GtkDirectionType     direction);
+static void     gtk_paned_css_changed           (GtkWidget           *widget,
+                                                 GtkCssStyleChange   *change);
 static void     gtk_paned_add                   (GtkContainer     *container,
                                                 GtkWidget        *widget);
 static void     gtk_paned_remove                (GtkContainer     *container,
@@ -355,7 +356,7 @@ gtk_paned_class_init (GtkPanedClass *class)
   widget_class->size_allocate = gtk_paned_size_allocate;
   widget_class->unrealize = gtk_paned_unrealize;
   widget_class->focus = gtk_paned_focus;
-  widget_class->style_updated = gtk_paned_style_updated;
+  widget_class->css_changed = gtk_paned_css_changed;
 
   container_class->add = gtk_paned_add;
   container_class->remove = gtk_paned_remove;
@@ -1465,15 +1466,10 @@ gtk_paned_focus (GtkWidget        *widget,
 }
 
 static void
-gtk_paned_style_updated (GtkWidget *widget)
+gtk_paned_css_changed (GtkWidget         *widget,
+                       GtkCssStyleChange *change)
 {
-  GtkStyleContext *context;
-  GtkCssStyleChange *change = NULL;
-
-  context = gtk_widget_get_style_context (widget);
-  change = gtk_style_context_get_change (context);
-
-  GTK_WIDGET_CLASS (gtk_paned_parent_class)->style_updated (widget);
+  GTK_WIDGET_CLASS (gtk_paned_parent_class)->css_changed (widget, change);
 
   if (change == NULL ||
       gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE))
diff --git a/gtk/gtkspinner.c b/gtk/gtkspinner.c
index c117347652..65e5b5c6d0 100644
--- a/gtk/gtkspinner.c
+++ b/gtk/gtkspinner.c
@@ -121,15 +121,10 @@ gtk_spinner_snapshot (GtkWidget   *widget,
 }
 
 static void
-gtk_spinner_style_updated (GtkWidget *widget)
+gtk_spinner_css_changed (GtkWidget         *widget,
+                         GtkCssStyleChange *change)
 { 
-  GtkStyleContext *context; 
-  GtkCssStyleChange *change = NULL;
-  
-  context = gtk_widget_get_style_context (widget);
-  change = gtk_style_context_get_change (context);
-  
-  GTK_WIDGET_CLASS (gtk_spinner_parent_class)->style_updated (widget);
+  GTK_WIDGET_CLASS (gtk_spinner_parent_class)->css_changed (widget, change);
   
   if (change == NULL ||
       gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE))
@@ -215,7 +210,7 @@ gtk_spinner_class_init (GtkSpinnerClass *klass)
   widget_class = GTK_WIDGET_CLASS(klass);
   widget_class->snapshot = gtk_spinner_snapshot;
   widget_class->measure = gtk_spinner_measure;
-  widget_class->style_updated = gtk_spinner_style_updated;
+  widget_class->css_changed = gtk_spinner_css_changed;
 
   /* GtkSpinner:active:
    *
diff --git a/gtk/gtkstylecontext.c b/gtk/gtkstylecontext.c
index cd0d628942..8566c8b644 100644
--- a/gtk/gtkstylecontext.c
+++ b/gtk/gtkstylecontext.c
@@ -164,7 +164,7 @@ gtk_style_context_real_changed (GtkStyleContext *context)
     {
       GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (priv->cssnode));
       if (widget != NULL)
-        _gtk_widget_style_context_invalidated (widget);
+        gtk_widget_css_changed (widget, gtk_style_context_get_change (context));
     }
 }
 
@@ -186,7 +186,7 @@ gtk_style_context_class_init (GtkStyleContextClass *klass)
    * #GtkStyleContext.
    *
    * For a #GtkStyleContext returned by gtk_widget_get_style_context(), the
-   * #GtkWidget::style-updated signal/vfunc might be more convenient to use.
+   * #GtkWidget:css-changed vfunc might be more convenient to use.
    *
    * This signal is useful when using the theming layer standalone.
    */
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 78a3d0c4b9..a3df9f7cee 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -327,7 +327,8 @@ static void   gtk_text_snapshot             (GtkWidget        *widget,
 static void   gtk_text_focus_in             (GtkWidget        *widget);
 static void   gtk_text_focus_out            (GtkWidget        *widget);
 static gboolean gtk_text_grab_focus         (GtkWidget        *widget);
-static void   gtk_text_style_updated        (GtkWidget        *widget);
+static void   gtk_text_css_changed          (GtkWidget        *widget,
+                                             GtkCssStyleChange *change);
 static void   gtk_text_direction_changed    (GtkWidget        *widget,
                                              GtkTextDirection  previous_dir);
 static void   gtk_text_state_flags_changed  (GtkWidget        *widget,
@@ -725,7 +726,7 @@ gtk_text_class_init (GtkTextClass *class)
   widget_class->size_allocate = gtk_text_size_allocate;
   widget_class->snapshot = gtk_text_snapshot;
   widget_class->grab_focus = gtk_text_grab_focus;
-  widget_class->style_updated = gtk_text_style_updated;
+  widget_class->css_changed = gtk_text_css_changed;
   widget_class->direction_changed = gtk_text_direction_changed;
   widget_class->state_flags_changed = gtk_text_state_flags_changed;
   widget_class->root = gtk_text_root;
@@ -3362,16 +3363,12 @@ gtk_text_update_cached_style_values (GtkText *self)
 }
 
 static void 
-gtk_text_style_updated (GtkWidget *widget)
+gtk_text_css_changed (GtkWidget         *widget,
+                      GtkCssStyleChange *change)
 {
   GtkText *self = GTK_TEXT (widget);
-  GtkStyleContext *context;
-  GtkCssStyleChange *change = NULL;
-
-  context = gtk_widget_get_style_context (widget);
-  change = gtk_style_context_get_change (context);
 
-  GTK_WIDGET_CLASS (gtk_text_parent_class)->style_updated (widget);
+  GTK_WIDGET_CLASS (gtk_text_parent_class)->css_changed (widget, change);
 
   gtk_text_update_cached_style_values (self);
 
diff --git a/gtk/gtktextview.c b/gtk/gtktextview.c
index 4e6ce8d468..6ac41604ee 100644
--- a/gtk/gtktextview.c
+++ b/gtk/gtktextview.c
@@ -373,10 +373,11 @@ static void gtk_text_view_size_allocate        (GtkWidget           *widget,
                                                 int                  width,
                                                 int                  height,
                                                 int                  baseline);
-static void gtk_text_view_realize              (GtkWidget        *widget);
-static void gtk_text_view_unrealize            (GtkWidget        *widget);
-static void gtk_text_view_map                  (GtkWidget        *widget);
-static void gtk_text_view_style_updated        (GtkWidget        *widget);
+static void gtk_text_view_realize              (GtkWidget           *widget);
+static void gtk_text_view_unrealize            (GtkWidget           *widget);
+static void gtk_text_view_map                  (GtkWidget           *widget);
+static void gtk_text_view_css_changed          (GtkWidget           *widget,
+                                                GtkCssStyleChange   *change);
 static void gtk_text_view_direction_changed    (GtkWidget        *widget,
                                                 GtkTextDirection  previous_direction);
 static void gtk_text_view_state_flags_changed  (GtkWidget        *widget,
@@ -702,7 +703,7 @@ gtk_text_view_class_init (GtkTextViewClass *klass)
   widget_class->realize = gtk_text_view_realize;
   widget_class->unrealize = gtk_text_view_unrealize;
   widget_class->map = gtk_text_view_map;
-  widget_class->style_updated = gtk_text_view_style_updated;
+  widget_class->css_changed = gtk_text_view_css_changed;
   widget_class->direction_changed = gtk_text_view_direction_changed;
   widget_class->state_flags_changed = gtk_text_view_state_flags_changed;
   widget_class->measure = gtk_text_view_measure;
@@ -4640,21 +4641,17 @@ gtk_text_view_map (GtkWidget *widget)
 }
 
 static void
-gtk_text_view_style_updated (GtkWidget *widget)
+gtk_text_view_css_changed (GtkWidget         *widget,
+                           GtkCssStyleChange *change)
 {
   GtkTextView *text_view;
   GtkTextViewPrivate *priv;
   PangoContext *ltr_context, *rtl_context;
-  GtkStyleContext *style_context;
-  GtkCssStyleChange *change;
 
   text_view = GTK_TEXT_VIEW (widget);
   priv = text_view->priv;
 
-  GTK_WIDGET_CLASS (gtk_text_view_parent_class)->style_updated (widget);
-
-  style_context = gtk_widget_get_style_context (widget);
-  change = gtk_style_context_get_change (style_context);
+  GTK_WIDGET_CLASS (gtk_text_view_parent_class)->css_changed (widget, change);
 
   if ((change == NULL ||
        gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT |
diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c
index f97ede89c2..0192d35384 100644
--- a/gtk/gtktoolbar.c
+++ b/gtk/gtktoolbar.c
@@ -205,7 +205,8 @@ static void       gtk_toolbar_size_allocate        (GtkWidget           *widget,
                                                     int                  width,
                                                     int                  height,
                                                     int                  baseline);
-static void       gtk_toolbar_style_updated        (GtkWidget           *widget);
+static void       gtk_toolbar_css_changed          (GtkWidget           *widget,
+                                                    GtkCssStyleChange   *change);
 static gboolean   gtk_toolbar_focus                (GtkWidget           *widget,
                                                    GtkDirectionType     dir);
 static void       gtk_toolbar_move_focus           (GtkWidget           *widget,
@@ -371,7 +372,7 @@ gtk_toolbar_class_init (GtkToolbarClass *klass)
   widget_class->snapshot = gtk_toolbar_snapshot;
   widget_class->measure = gtk_toolbar_measure;
   widget_class->size_allocate = gtk_toolbar_size_allocate;
-  widget_class->style_updated = gtk_toolbar_style_updated;
+  widget_class->css_changed = gtk_toolbar_css_changed;
   widget_class->focus = gtk_toolbar_focus;
 
   gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_TOOL_BAR);
@@ -1440,12 +1441,13 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
 }
 
 static void
-gtk_toolbar_style_updated (GtkWidget *widget)
+gtk_toolbar_css_changed (GtkWidget         *widget,
+                         GtkCssStyleChange *change)
 {
   GtkToolbar *toolbar = GTK_TOOLBAR (widget);
   GtkToolbarPrivate *priv = toolbar->priv;
 
-  GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->style_updated (widget);
+  GTK_WIDGET_CLASS (gtk_toolbar_parent_class)->css_changed (widget, change);
 
   priv->max_homogeneous_pixels = -1;
 }
diff --git a/gtk/gtktreeview.c b/gtk/gtktreeview.c
index 4b2f995207..bac22de83c 100644
--- a/gtk/gtktreeview.c
+++ b/gtk/gtktreeview.c
@@ -675,7 +675,8 @@ static void     gtk_tree_view_key_controller_focus_out    (GtkEventControllerKey
 static gint     gtk_tree_view_focus                (GtkWidget        *widget,
                                                    GtkDirectionType  direction);
 static gboolean gtk_tree_view_grab_focus           (GtkWidget        *widget);
-static void     gtk_tree_view_style_updated        (GtkWidget        *widget);
+static void     gtk_tree_view_css_changed          (GtkWidget        *widget,
+                                                    GtkCssStyleChange *change);
 
 /* container signals */
 static void     gtk_tree_view_remove               (GtkContainer     *container,
@@ -1028,7 +1029,7 @@ gtk_tree_view_class_init (GtkTreeViewClass *class)
   widget_class->snapshot = gtk_tree_view_snapshot;
   widget_class->focus = gtk_tree_view_focus;
   widget_class->grab_focus = gtk_tree_view_grab_focus;
-  widget_class->style_updated = gtk_tree_view_style_updated;
+  widget_class->css_changed = gtk_tree_view_css_changed;
 
   /* GtkContainer signals */
   container_class->remove = gtk_tree_view_remove;
@@ -7958,15 +7959,14 @@ gtk_tree_view_grab_focus (GtkWidget *widget)
 }
 
 static void
-gtk_tree_view_style_updated (GtkWidget *widget)
+gtk_tree_view_css_changed (GtkWidget         *widget,
+                           GtkCssStyleChange *change)
 {
   GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
   GList *list;
   GtkTreeViewColumn *column;
-  GtkStyleContext *style_context;
-  GtkCssStyleChange *change;
 
-  GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->style_updated (widget);
+  GTK_WIDGET_CLASS (gtk_tree_view_parent_class)->css_changed (widget, change);
 
   if (gtk_widget_get_realized (widget))
     {
@@ -7974,9 +7974,6 @@ gtk_tree_view_style_updated (GtkWidget *widget)
       gtk_tree_view_set_enable_tree_lines (tree_view, tree_view->tree_lines_enabled);
     }
 
-  style_context = gtk_widget_get_style_context (widget);
-  change = gtk_style_context_get_change (style_context);
-
   if (change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE))
     {
       for (list = tree_view->columns; list; list = list->next)
diff --git a/gtk/gtktypes.h b/gtk/gtktypes.h
index 5b7f6686aa..777a120746 100644
--- a/gtk/gtktypes.h
+++ b/gtk/gtktypes.h
@@ -37,6 +37,7 @@ typedef struct _GtkAdjustment          GtkAdjustment;
 typedef struct _GtkBuilder             GtkBuilder;
 typedef struct _GtkBuilderScope        GtkBuilderScope;
 typedef struct _GtkClipboard          GtkClipboard;
+typedef struct _GtkCssStyleChange      GtkCssStyleChange;
 typedef struct _GtkEventController     GtkEventController;
 typedef struct _GtkGesture             GtkGesture;
 typedef struct _GtkLayoutManager       GtkLayoutManager;
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index d93b4b13a5..503208e17f 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -614,7 +614,8 @@ static gboolean gtk_widget_real_query_tooltip    (GtkWidget         *widget,
                                                  gint               y,
                                                  gboolean           keyboard_tip,
                                                  GtkTooltip        *tooltip);
-static void     gtk_widget_real_style_updated    (GtkWidget         *widget);
+static void     gtk_widget_real_css_changed      (GtkWidget         *widget,
+                                                  GtkCssStyleChange *change);
 
 static gboolean                gtk_widget_real_focus                   (GtkWidget        *widget,
                                                                 GtkDirectionType  direction);
@@ -908,7 +909,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
   klass->keynav_failed = gtk_widget_real_keynav_failed;
   klass->can_activate_accel = gtk_widget_real_can_activate_accel;
   klass->query_tooltip = gtk_widget_real_query_tooltip;
-  klass->style_updated = gtk_widget_real_style_updated;
+  klass->css_changed = gtk_widget_real_css_changed;
 
   /* Accessibility support */
   klass->priv->accessible_type = GTK_TYPE_ACCESSIBLE;
@@ -1512,23 +1513,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
                   G_TYPE_NONE, 1,
                   GTK_TYPE_STATE_FLAGS);
 
-  /**
-   * GtkWidget::style-updated:
-   * @widget: the object on which the signal is emitted
-   *
-   * The ::style-updated signal is a convenience signal that is emitted when the
-   * #GtkStyleContext::changed signal is emitted on the @widget's associated
-   * #GtkStyleContext as returned by gtk_widget_get_style_context().
-   */
-  widget_signals[STYLE_UPDATED] =
-    g_signal_new (I_("style-updated"),
-                  G_TYPE_FROM_CLASS (gobject_class),
-                  G_SIGNAL_RUN_FIRST,
-                  G_STRUCT_OFFSET (GtkWidgetClass, style_updated),
-                  NULL, NULL,
-                  NULL,
-                  G_TYPE_NONE, 0);
-
   /**
    * GtkWidget::direction-changed:
    * @widget: the object on which the signal is emitted
@@ -5115,16 +5099,13 @@ gtk_widget_real_state_flags_changed (GtkWidget     *widget,
 }
 
 static void
-gtk_widget_real_style_updated (GtkWidget *widget)
+gtk_widget_real_css_changed (GtkWidget         *widget,
+                             GtkCssStyleChange *change)
 {
   GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
-  GtkCssStyleChange *change = NULL;
 
   gtk_widget_update_alpha (widget);
 
-  if (priv->context)
-    change = gtk_style_context_get_change (priv->context);
-
   if (change)
     {
       const gboolean has_text = gtk_widget_peek_pango_context (widget) != NULL;
@@ -11223,9 +11204,10 @@ gtk_widget_class_get_css_name (GtkWidgetClass *widget_class)
 }
 
 void
-_gtk_widget_style_context_invalidated (GtkWidget *widget)
+gtk_widget_css_changed (GtkWidget         *widget,
+                        GtkCssStyleChange *change)
 {
-  g_signal_emit (widget, widget_signals[STYLE_UPDATED], 0);
+  GTK_WIDGET_GET_CLASS (widget)->css_changed (widget, change);
 }
 
 GtkCssNode *
diff --git a/gtk/gtkwidget.h b/gtk/gtkwidget.h
index bcde90db00..957fb58853 100644
--- a/gtk/gtkwidget.h
+++ b/gtk/gtkwidget.h
@@ -199,8 +199,10 @@ struct _GtkWidget
  *   widget; or emitted when widget got focus in keyboard mode.
  * @compute_expand: Computes whether a container should give this
  *   widget extra space when possible.
- * @style_updated: Signal emitted when the GtkStyleContext of a widget
- *   is changed.
+ * @css_changed: Signal emitted when the CSS used by widget was changed. Widgets
+ *   should then discard their caches that depend on CSS and queue resizes or
+ *   redraws accordingly. The default implementation will take care of this for
+ *   all the default CSS properties, so implementations must chain up.
  * @snapshot: Vfunc for gtk_widget_snapshot().
  * @contains: Vfunc for gtk_widget_contains().
  */
@@ -279,7 +281,8 @@ struct _GtkWidgetClass
                                        gboolean   *hexpand_p,
                                        gboolean   *vexpand_p);
 
-  void         (* style_updated)          (GtkWidget *widget);
+  void         (* css_changed)                 (GtkWidget            *widget,
+                                                GtkCssStyleChange    *change);
 
   void         (* snapshot)                    (GtkWidget            *widget,
                                                 GtkSnapshot          *snapshot);
diff --git a/gtk/gtkwidgetprivate.h b/gtk/gtkwidgetprivate.h
index 72fb1df993..0b808af40c 100644
--- a/gtk/gtkwidgetprivate.h
+++ b/gtk/gtkwidgetprivate.h
@@ -278,7 +278,8 @@ GtkStyleContext * _gtk_widget_peek_style_context           (GtkWidget *widget);
 gboolean          _gtk_widget_captured_event               (GtkWidget *widget,
                                                             GdkEvent  *event);
 
-void              _gtk_widget_style_context_invalidated    (GtkWidget    *widget);
+void              gtk_widget_css_changed                   (GtkWidget           *widget,
+                                                            GtkCssStyleChange   *change);
 
 void              _gtk_widget_update_parent_muxer          (GtkWidget    *widget);
 GtkActionMuxer *  _gtk_widget_get_action_muxer             (GtkWidget    *widget,
diff --git a/gtk/gtkwindow.c b/gtk/gtkwindow.c
index 9c998ec2dc..bb251e3205 100644
--- a/gtk/gtkwindow.c
+++ b/gtk/gtkwindow.c
@@ -500,9 +500,10 @@ static void gtk_window_activate_default_activate (GtkWidget *widget,
                                                   const char *action_name,
                                                   GVariant *parameter);
 
-static void        gtk_window_do_popup         (GtkWindow      *window,
-                                                GdkEventButton *event);
-static void gtk_window_style_updated (GtkWidget     *widget);
+static void        gtk_window_do_popup                  (GtkWindow      *window,
+                                                         GdkEventButton *event);
+static void        gtk_window_css_changed               (GtkWidget      *widget,
+                                                         GtkCssStyleChange *change);
 static void gtk_window_state_flags_changed (GtkWidget     *widget,
                                             GtkStateFlags  previous_state);
 static void _gtk_window_set_is_active (GtkWindow *window,
@@ -800,7 +801,7 @@ gtk_window_class_init (GtkWindowClass *klass)
   widget_class->move_focus = gtk_window_move_focus;
   widget_class->measure = gtk_window_measure;
   widget_class->state_flags_changed = gtk_window_state_flags_changed;
-  widget_class->style_updated = gtk_window_style_updated;
+  widget_class->css_changed = gtk_window_css_changed;
   widget_class->snapshot = gtk_window_snapshot;
 
   container_class->add = gtk_window_add;
@@ -6491,12 +6492,12 @@ gtk_window_state_flags_changed (GtkWidget     *widget,
 }
 
 static void
-gtk_window_style_updated (GtkWidget *widget)
+gtk_window_css_changed (GtkWidget         *widget,
+                        GtkCssStyleChange *change)
 {
-  GtkCssStyleChange *change = gtk_style_context_get_change (gtk_widget_get_style_context (widget));
   GtkWindow *window = GTK_WINDOW (widget);
 
-  GTK_WIDGET_CLASS (gtk_window_parent_class)->style_updated (widget);
+  GTK_WIDGET_CLASS (gtk_window_parent_class)->css_changed (widget, change);
 
   if (!_gtk_widget_get_alloc_needed (widget) &&
       (change == NULL || gtk_css_style_change_changes_property (change, GTK_CSS_PROPERTY_BACKGROUND_COLOR)))
diff --git a/gtk/ui/gtkfontchooserwidget.ui b/gtk/ui/gtkfontchooserwidget.ui
index 1a4ea543ae..b745aaf487 100644
--- a/gtk/ui/gtkfontchooserwidget.ui
+++ b/gtk/ui/gtkfontchooserwidget.ui
@@ -75,7 +75,6 @@
                                     <property name="fixed-height-mode">1</property>
                                     <signal name="cursor-changed" handler="cursor_changed_cb" swapped="no"/>
                                     <signal name="row-activated" handler="row_activated_cb" swapped="no"/>
-                                    <signal name="style-updated" 
handler="gtk_font_chooser_widget_set_cell_size" object="GtkFontChooserWidget" after="yes" swapped="yes"/>
                                     <child internal-child="selection">
                                       <object class="GtkTreeSelection" id="treeview-selection1">
                                         <property name="mode">browse</property>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]