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.
This commit is contained in:
Benjamin Otte 2020-02-05 02:46:13 +01:00
parent 8722837e67
commit 546a748cd8
24 changed files with 106 additions and 145 deletions

View File

@ -3793,7 +3793,7 @@ gdk_surface_get_unscaled_size (GdkSurface *surface,
* GTK will update this property automatically if * GTK will update this property automatically if
* the @surface background is opaque, as we know where the opaque regions * the @surface background is opaque, as we know where the opaque regions
* are. If your surface background is not opaque, please update this * 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 void
gdk_surface_set_opaque_region (GdkSurface *surface, gdk_surface_set_opaque_region (GdkSurface *surface,

View File

@ -55,15 +55,10 @@ gtk_builtin_icon_snapshot (GtkWidget *widget,
} }
static void static void
gtk_builtin_icon_style_updated (GtkWidget *widget) gtk_builtin_icon_css_changed (GtkWidget *widget,
GtkCssStyleChange *change)
{ {
GtkStyleContext *context; GTK_WIDGET_CLASS (gtk_builtin_icon_parent_class)->css_changed (widget, change);
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);
if (change == NULL || if (change == NULL ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE)) 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->snapshot = gtk_builtin_icon_snapshot;
wclass->measure = gtk_builtin_icon_measure; wclass->measure = gtk_builtin_icon_measure;
wclass->style_updated = gtk_builtin_icon_style_updated; wclass->css_changed = gtk_builtin_icon_css_changed;
} }
static void static void

View File

@ -350,7 +350,7 @@ gtk_container_idle_sizer (GdkFrameClock *clock,
/* We validate the style contexts in a single loop before even trying /* We validate the style contexts in a single loop before even trying
* to handle resizes instead of doing validations inline. * to handle resizes instead of doing validations inline.
* This is mostly necessary for compatibility reasons with old code, * 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. * styles and so could cause infinite loops in this function.
* *
* It's important to note that even an invalid style context returns * It's important to note that even an invalid style context returns

View File

@ -22,8 +22,6 @@
G_BEGIN_DECLS G_BEGIN_DECLS
typedef struct _GtkCssStyleChange GtkCssStyleChange;
struct _GtkCssStyleChange { struct _GtkCssStyleChange {
GtkCssStyle *old_style; GtkCssStyle *old_style;
GtkCssStyle *new_style; GtkCssStyle *new_style;

View File

@ -101,7 +101,7 @@ gtk_css_widget_node_validate (GtkCssNode *node)
if (context) if (context)
gtk_style_context_validate (context, &change); gtk_style_context_validate (context, &change);
else 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); g_set_object (&widget_node->last_updated_style, style);
} }
gtk_css_style_change_finish (&change); gtk_css_style_change_finish (&change);

View File

@ -278,9 +278,10 @@ static void gtk_file_chooser_button_root (GtkWidget *widget);
static void gtk_file_chooser_button_map (GtkWidget *widget); static void gtk_file_chooser_button_map (GtkWidget *widget);
static gboolean gtk_file_chooser_button_mnemonic_activate (GtkWidget *widget, static gboolean gtk_file_chooser_button_mnemonic_activate (GtkWidget *widget,
gboolean group_cycling); gboolean group_cycling);
static void gtk_file_chooser_button_style_updated (GtkWidget *widget); static void gtk_file_chooser_button_css_changed (GtkWidget *widget,
static void gtk_file_chooser_button_state_flags_changed (GtkWidget *widget, GtkCssStyleChange *change);
GtkStateFlags previous_state); static void gtk_file_chooser_button_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state);
/* Utility Functions */ /* Utility Functions */
static void set_info_for_file_at_iter (GtkFileChooserButton *fs, 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->show = gtk_file_chooser_button_show;
widget_class->hide = gtk_file_chooser_button_hide; widget_class->hide = gtk_file_chooser_button_hide;
widget_class->map = gtk_file_chooser_button_map; 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->root = gtk_file_chooser_button_root;
widget_class->mnemonic_activate = gtk_file_chooser_button_mnemonic_activate; widget_class->mnemonic_activate = gtk_file_chooser_button_mnemonic_activate;
widget_class->state_flags_changed = gtk_file_chooser_button_state_flags_changed; widget_class->state_flags_changed = gtk_file_chooser_button_state_flags_changed;
@ -1456,12 +1457,10 @@ change_icon_theme (GtkFileChooserButton *button)
} }
static void 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); GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->css_changed (widget, change);
GtkCssStyleChange *change = gtk_style_context_get_change (context);
GTK_WIDGET_CLASS (gtk_file_chooser_button_parent_class)->style_updated (widget);
/* We need to update the icon surface, but only in case /* We need to update the icon surface, but only in case
* the icon theme really changed. */ * the icon theme really changed. */

View File

@ -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_unmap (GtkWidget *widget);
static void gtk_file_chooser_widget_root (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_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, static gboolean gtk_file_chooser_widget_set_current_folder (GtkFileChooser *chooser,
GFile *folder, GFile *folder,
@ -3647,7 +3648,8 @@ check_icon_theme (GtkFileChooserWidget *impl)
} }
static void static void
gtk_file_chooser_widget_style_updated (GtkWidget *widget) gtk_file_chooser_widget_css_changed (GtkWidget *widget,
GtkCssStyleChange *change)
{ {
GtkFileChooserWidget *impl; GtkFileChooserWidget *impl;
@ -3655,9 +3657,9 @@ gtk_file_chooser_widget_style_updated (GtkWidget *widget)
impl = GTK_FILE_CHOOSER_WIDGET (widget); impl = GTK_FILE_CHOOSER_WIDGET (widget);
profile_msg (" parent class style_udpated start", NULL); profile_msg (" parent class css_changed start", NULL);
GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->style_updated (widget); GTK_WIDGET_CLASS (gtk_file_chooser_widget_parent_class)->css_changed (widget, change);
profile_msg (" parent class style_updated end", NULL); profile_msg (" parent class css_changed end", NULL);
change_icon_theme (impl); 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->unmap = gtk_file_chooser_widget_unmap;
widget_class->root = gtk_file_chooser_widget_root; widget_class->root = gtk_file_chooser_widget_root;
widget_class->unroot = gtk_file_chooser_widget_unroot; 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 * Signals

View File

@ -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, stop_search_cb);
gtk_widget_class_bind_template_callback (widget_class, cursor_changed_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, 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, rows_changed_cb);
gtk_widget_class_bind_template_callback (widget_class, size_change_cb); gtk_widget_class_bind_template_callback (widget_class, size_change_cb);
gtk_widget_class_bind_template_callback (widget_class, output_cb); gtk_widget_class_bind_template_callback (widget_class, output_cb);

View File

@ -2172,8 +2172,8 @@ choose_icon (GtkIconTheme *self,
* they will be tried in order. * they will be tried in order.
* *
* Note that you probably want to listen for icon theme changes and * Note that you probably want to listen for icon theme changes and
* update the icon. This is usually done by connecting to the * update the icon. This is usually done by overriding the
* GtkWidget::style-updated signal. * #GtkWidget:css-changed function.
* *
* Returns: (nullable) (transfer full): a #GtkIconPaintable object * Returns: (nullable) (transfer full): a #GtkIconPaintable object
* containing the icon, or %NULL if the icon wasnt found. * containing the icon, or %NULL if the icon wasnt found.

View File

@ -111,7 +111,8 @@ static void gtk_image_measure (GtkWidget *widget,
int *minimum_baseline, int *minimum_baseline,
int *natural_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_finalize (GObject *object);
static void gtk_image_set_property (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->snapshot = gtk_image_snapshot;
widget_class->measure = gtk_image_measure; widget_class->measure = gtk_image_measure;
widget_class->unrealize = gtk_image_unrealize; 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] = image_props[PROP_PAINTABLE] =
g_param_spec_object ("paintable", g_param_spec_object ("paintable",
@ -1283,16 +1284,15 @@ gtk_image_measure (GtkWidget *widget,
} }
static void static void
gtk_image_style_updated (GtkWidget *widget) gtk_image_css_changed (GtkWidget *widget,
GtkCssStyleChange *change)
{ {
GtkImage *image = GTK_IMAGE (widget); GtkImage *image = GTK_IMAGE (widget);
GtkImagePrivate *priv = gtk_image_get_instance_private (image); 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_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; priv->baseline_align = 0.0;
} }

View File

@ -434,9 +434,10 @@ static void gtk_label_size_allocate (GtkWidget *widget,
int baseline); int baseline);
static void gtk_label_state_flags_changed (GtkWidget *widget, static void gtk_label_state_flags_changed (GtkWidget *widget,
GtkStateFlags prev_state); GtkStateFlags prev_state);
static void gtk_label_style_updated (GtkWidget *widget); static void gtk_label_css_changed (GtkWidget *widget,
static void gtk_label_snapshot (GtkWidget *widget, GtkCssStyleChange *change);
GtkSnapshot *snapshot); static void gtk_label_snapshot (GtkWidget *widget,
GtkSnapshot *snapshot);
static gboolean gtk_label_focus (GtkWidget *widget, static gboolean gtk_label_focus (GtkWidget *widget,
GtkDirectionType direction); GtkDirectionType direction);
@ -641,7 +642,7 @@ gtk_label_class_init (GtkLabelClass *class)
widget_class->destroy = gtk_label_destroy; widget_class->destroy = gtk_label_destroy;
widget_class->size_allocate = gtk_label_size_allocate; widget_class->size_allocate = gtk_label_size_allocate;
widget_class->state_flags_changed = gtk_label_state_flags_changed; 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->query_tooltip = gtk_label_query_tooltip;
widget_class->snapshot = gtk_label_snapshot; widget_class->snapshot = gtk_label_snapshot;
widget_class->unrealize = gtk_label_unrealize; widget_class->unrealize = gtk_label_unrealize;
@ -3790,17 +3791,13 @@ gtk_label_state_flags_changed (GtkWidget *widget,
} }
static void static void
gtk_label_style_updated (GtkWidget *widget) gtk_label_css_changed (GtkWidget *widget,
GtkCssStyleChange *change)
{ {
GtkLabel *label = GTK_LABEL (widget); GtkLabel *label = GTK_LABEL (widget);
GtkLabelPrivate *priv = gtk_label_get_instance_private (label); GtkLabelPrivate *priv = gtk_label_get_instance_private (label);
GtkStyleContext *context;
GtkCssStyleChange *change;
GTK_WIDGET_CLASS (gtk_label_parent_class)->style_updated (widget); GTK_WIDGET_CLASS (gtk_label_parent_class)->css_changed (widget, change);
context = gtk_widget_get_style_context (widget);
change = gtk_style_context_get_change (context);
if (change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_ATTRS) || if (change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT_ATTRS) ||
(priv->select_info && priv->select_info->links)) (priv->select_info && priv->select_info->links))

View File

@ -227,10 +227,11 @@ static void gtk_paned_size_allocate (GtkWidget *widget,
int width, int width,
int height, int height,
int baseline); int baseline);
static void gtk_paned_unrealize (GtkWidget *widget); static void gtk_paned_unrealize (GtkWidget *widget);
static gboolean gtk_paned_focus (GtkWidget *widget, static gboolean gtk_paned_focus (GtkWidget *widget,
GtkDirectionType direction); GtkDirectionType direction);
static void gtk_paned_style_updated (GtkWidget *widget); static void gtk_paned_css_changed (GtkWidget *widget,
GtkCssStyleChange *change);
static void gtk_paned_add (GtkContainer *container, static void gtk_paned_add (GtkContainer *container,
GtkWidget *widget); GtkWidget *widget);
static void gtk_paned_remove (GtkContainer *container, 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->size_allocate = gtk_paned_size_allocate;
widget_class->unrealize = gtk_paned_unrealize; widget_class->unrealize = gtk_paned_unrealize;
widget_class->focus = gtk_paned_focus; 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->add = gtk_paned_add;
container_class->remove = gtk_paned_remove; container_class->remove = gtk_paned_remove;
@ -1465,15 +1466,10 @@ gtk_paned_focus (GtkWidget *widget,
} }
static void static void
gtk_paned_style_updated (GtkWidget *widget) gtk_paned_css_changed (GtkWidget *widget,
GtkCssStyleChange *change)
{ {
GtkStyleContext *context; GTK_WIDGET_CLASS (gtk_paned_parent_class)->css_changed (widget, change);
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);
if (change == NULL || if (change == NULL ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE)) gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE))

View File

@ -121,15 +121,10 @@ gtk_spinner_snapshot (GtkWidget *widget,
} }
static void static void
gtk_spinner_style_updated (GtkWidget *widget) gtk_spinner_css_changed (GtkWidget *widget,
GtkCssStyleChange *change)
{ {
GtkStyleContext *context; GTK_WIDGET_CLASS (gtk_spinner_parent_class)->css_changed (widget, change);
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);
if (change == NULL || if (change == NULL ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_ICON_SIZE)) 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 = GTK_WIDGET_CLASS(klass);
widget_class->snapshot = gtk_spinner_snapshot; widget_class->snapshot = gtk_spinner_snapshot;
widget_class->measure = gtk_spinner_measure; widget_class->measure = gtk_spinner_measure;
widget_class->style_updated = gtk_spinner_style_updated; widget_class->css_changed = gtk_spinner_css_changed;
/* GtkSpinner:active: /* GtkSpinner:active:
* *

View File

@ -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)); GtkWidget *widget = gtk_css_widget_node_get_widget (GTK_CSS_WIDGET_NODE (priv->cssnode));
if (widget != NULL) 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. * #GtkStyleContext.
* *
* For a #GtkStyleContext returned by gtk_widget_get_style_context(), the * 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. * This signal is useful when using the theming layer standalone.
*/ */

View File

@ -327,7 +327,8 @@ static void gtk_text_snapshot (GtkWidget *widget,
static void gtk_text_focus_in (GtkWidget *widget); static void gtk_text_focus_in (GtkWidget *widget);
static void gtk_text_focus_out (GtkWidget *widget); static void gtk_text_focus_out (GtkWidget *widget);
static gboolean gtk_text_grab_focus (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, static void gtk_text_direction_changed (GtkWidget *widget,
GtkTextDirection previous_dir); GtkTextDirection previous_dir);
static void gtk_text_state_flags_changed (GtkWidget *widget, 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->size_allocate = gtk_text_size_allocate;
widget_class->snapshot = gtk_text_snapshot; widget_class->snapshot = gtk_text_snapshot;
widget_class->grab_focus = gtk_text_grab_focus; 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->direction_changed = gtk_text_direction_changed;
widget_class->state_flags_changed = gtk_text_state_flags_changed; widget_class->state_flags_changed = gtk_text_state_flags_changed;
widget_class->root = gtk_text_root; widget_class->root = gtk_text_root;
@ -3362,16 +3363,12 @@ gtk_text_update_cached_style_values (GtkText *self)
} }
static void static void
gtk_text_style_updated (GtkWidget *widget) gtk_text_css_changed (GtkWidget *widget,
GtkCssStyleChange *change)
{ {
GtkText *self = GTK_TEXT (widget); GtkText *self = GTK_TEXT (widget);
GtkStyleContext *context;
GtkCssStyleChange *change = NULL;
context = gtk_widget_get_style_context (widget); GTK_WIDGET_CLASS (gtk_text_parent_class)->css_changed (widget, change);
change = gtk_style_context_get_change (context);
GTK_WIDGET_CLASS (gtk_text_parent_class)->style_updated (widget);
gtk_text_update_cached_style_values (self); gtk_text_update_cached_style_values (self);

View File

@ -373,10 +373,11 @@ static void gtk_text_view_size_allocate (GtkWidget *widget,
int width, int width,
int height, int height,
int baseline); int baseline);
static void gtk_text_view_realize (GtkWidget *widget); static void gtk_text_view_realize (GtkWidget *widget);
static void gtk_text_view_unrealize (GtkWidget *widget); static void gtk_text_view_unrealize (GtkWidget *widget);
static void gtk_text_view_map (GtkWidget *widget); static void gtk_text_view_map (GtkWidget *widget);
static void gtk_text_view_style_updated (GtkWidget *widget); static void gtk_text_view_css_changed (GtkWidget *widget,
GtkCssStyleChange *change);
static void gtk_text_view_direction_changed (GtkWidget *widget, static void gtk_text_view_direction_changed (GtkWidget *widget,
GtkTextDirection previous_direction); GtkTextDirection previous_direction);
static void gtk_text_view_state_flags_changed (GtkWidget *widget, 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->realize = gtk_text_view_realize;
widget_class->unrealize = gtk_text_view_unrealize; widget_class->unrealize = gtk_text_view_unrealize;
widget_class->map = gtk_text_view_map; 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->direction_changed = gtk_text_view_direction_changed;
widget_class->state_flags_changed = gtk_text_view_state_flags_changed; widget_class->state_flags_changed = gtk_text_view_state_flags_changed;
widget_class->measure = gtk_text_view_measure; widget_class->measure = gtk_text_view_measure;
@ -4640,21 +4641,17 @@ gtk_text_view_map (GtkWidget *widget)
} }
static void static void
gtk_text_view_style_updated (GtkWidget *widget) gtk_text_view_css_changed (GtkWidget *widget,
GtkCssStyleChange *change)
{ {
GtkTextView *text_view; GtkTextView *text_view;
GtkTextViewPrivate *priv; GtkTextViewPrivate *priv;
PangoContext *ltr_context, *rtl_context; PangoContext *ltr_context, *rtl_context;
GtkStyleContext *style_context;
GtkCssStyleChange *change;
text_view = GTK_TEXT_VIEW (widget); text_view = GTK_TEXT_VIEW (widget);
priv = text_view->priv; priv = text_view->priv;
GTK_WIDGET_CLASS (gtk_text_view_parent_class)->style_updated (widget); GTK_WIDGET_CLASS (gtk_text_view_parent_class)->css_changed (widget, change);
style_context = gtk_widget_get_style_context (widget);
change = gtk_style_context_get_change (style_context);
if ((change == NULL || if ((change == NULL ||
gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT | gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_TEXT |

View File

@ -205,7 +205,8 @@ static void gtk_toolbar_size_allocate (GtkWidget *widget,
int width, int width,
int height, int height,
int baseline); 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, static gboolean gtk_toolbar_focus (GtkWidget *widget,
GtkDirectionType dir); GtkDirectionType dir);
static void gtk_toolbar_move_focus (GtkWidget *widget, 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->snapshot = gtk_toolbar_snapshot;
widget_class->measure = gtk_toolbar_measure; widget_class->measure = gtk_toolbar_measure;
widget_class->size_allocate = gtk_toolbar_size_allocate; 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; widget_class->focus = gtk_toolbar_focus;
gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_TOOL_BAR); gtk_widget_class_set_accessible_role (widget_class, ATK_ROLE_TOOL_BAR);
@ -1440,12 +1441,13 @@ gtk_toolbar_size_allocate (GtkWidget *widget,
} }
static void static void
gtk_toolbar_style_updated (GtkWidget *widget) gtk_toolbar_css_changed (GtkWidget *widget,
GtkCssStyleChange *change)
{ {
GtkToolbar *toolbar = GTK_TOOLBAR (widget); GtkToolbar *toolbar = GTK_TOOLBAR (widget);
GtkToolbarPrivate *priv = toolbar->priv; 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; priv->max_homogeneous_pixels = -1;
} }

View File

@ -675,7 +675,8 @@ static void gtk_tree_view_key_controller_focus_out (GtkEventControllerKey
static gint gtk_tree_view_focus (GtkWidget *widget, static gint gtk_tree_view_focus (GtkWidget *widget,
GtkDirectionType direction); GtkDirectionType direction);
static gboolean gtk_tree_view_grab_focus (GtkWidget *widget); 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 */ /* container signals */
static void gtk_tree_view_remove (GtkContainer *container, 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->snapshot = gtk_tree_view_snapshot;
widget_class->focus = gtk_tree_view_focus; widget_class->focus = gtk_tree_view_focus;
widget_class->grab_focus = gtk_tree_view_grab_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 */ /* GtkContainer signals */
container_class->remove = gtk_tree_view_remove; container_class->remove = gtk_tree_view_remove;
@ -7958,15 +7959,14 @@ gtk_tree_view_grab_focus (GtkWidget *widget)
} }
static void 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); GtkTreeView *tree_view = GTK_TREE_VIEW (widget);
GList *list; GList *list;
GtkTreeViewColumn *column; 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)) 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); 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)) if (change == NULL || gtk_css_style_change_affects (change, GTK_CSS_AFFECTS_SIZE))
{ {
for (list = tree_view->columns; list; list = list->next) for (list = tree_view->columns; list; list = list->next)

View File

@ -37,6 +37,7 @@ typedef struct _GtkAdjustment GtkAdjustment;
typedef struct _GtkBuilder GtkBuilder; typedef struct _GtkBuilder GtkBuilder;
typedef struct _GtkBuilderScope GtkBuilderScope; typedef struct _GtkBuilderScope GtkBuilderScope;
typedef struct _GtkClipboard GtkClipboard; typedef struct _GtkClipboard GtkClipboard;
typedef struct _GtkCssStyleChange GtkCssStyleChange;
typedef struct _GtkEventController GtkEventController; typedef struct _GtkEventController GtkEventController;
typedef struct _GtkGesture GtkGesture; typedef struct _GtkGesture GtkGesture;
typedef struct _GtkLayoutManager GtkLayoutManager; typedef struct _GtkLayoutManager GtkLayoutManager;

View File

@ -614,7 +614,8 @@ static gboolean gtk_widget_real_query_tooltip (GtkWidget *widget,
gint y, gint y,
gboolean keyboard_tip, gboolean keyboard_tip,
GtkTooltip *tooltip); 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, static gboolean gtk_widget_real_focus (GtkWidget *widget,
GtkDirectionType direction); GtkDirectionType direction);
@ -908,7 +909,7 @@ gtk_widget_class_init (GtkWidgetClass *klass)
klass->keynav_failed = gtk_widget_real_keynav_failed; klass->keynav_failed = gtk_widget_real_keynav_failed;
klass->can_activate_accel = gtk_widget_real_can_activate_accel; klass->can_activate_accel = gtk_widget_real_can_activate_accel;
klass->query_tooltip = gtk_widget_real_query_tooltip; 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 */ /* Accessibility support */
klass->priv->accessible_type = GTK_TYPE_ACCESSIBLE; klass->priv->accessible_type = GTK_TYPE_ACCESSIBLE;
@ -1512,23 +1513,6 @@ gtk_widget_class_init (GtkWidgetClass *klass)
G_TYPE_NONE, 1, G_TYPE_NONE, 1,
GTK_TYPE_STATE_FLAGS); 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: * GtkWidget::direction-changed:
* @widget: the object on which the signal is emitted * @widget: the object on which the signal is emitted
@ -5115,16 +5099,13 @@ gtk_widget_real_state_flags_changed (GtkWidget *widget,
} }
static void 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); GtkWidgetPrivate *priv = gtk_widget_get_instance_private (widget);
GtkCssStyleChange *change = NULL;
gtk_widget_update_alpha (widget); gtk_widget_update_alpha (widget);
if (priv->context)
change = gtk_style_context_get_change (priv->context);
if (change) if (change)
{ {
const gboolean has_text = gtk_widget_peek_pango_context (widget) != NULL; 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 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 * GtkCssNode *

View File

@ -199,8 +199,10 @@ struct _GtkWidget
* widget; or emitted when widget got focus in keyboard mode. * widget; or emitted when widget got focus in keyboard mode.
* @compute_expand: Computes whether a container should give this * @compute_expand: Computes whether a container should give this
* widget extra space when possible. * widget extra space when possible.
* @style_updated: Signal emitted when the GtkStyleContext of a widget * @css_changed: Signal emitted when the CSS used by widget was changed. Widgets
* is changed. * 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(). * @snapshot: Vfunc for gtk_widget_snapshot().
* @contains: Vfunc for gtk_widget_contains(). * @contains: Vfunc for gtk_widget_contains().
*/ */
@ -279,7 +281,8 @@ struct _GtkWidgetClass
gboolean *hexpand_p, gboolean *hexpand_p,
gboolean *vexpand_p); gboolean *vexpand_p);
void (* style_updated) (GtkWidget *widget); void (* css_changed) (GtkWidget *widget,
GtkCssStyleChange *change);
void (* snapshot) (GtkWidget *widget, void (* snapshot) (GtkWidget *widget,
GtkSnapshot *snapshot); GtkSnapshot *snapshot);

View File

@ -278,7 +278,8 @@ GtkStyleContext * _gtk_widget_peek_style_context (GtkWidget *widget);
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); void gtk_widget_css_changed (GtkWidget *widget,
GtkCssStyleChange *change);
void _gtk_widget_update_parent_muxer (GtkWidget *widget); void _gtk_widget_update_parent_muxer (GtkWidget *widget);
GtkActionMuxer * _gtk_widget_get_action_muxer (GtkWidget *widget, GtkActionMuxer * _gtk_widget_get_action_muxer (GtkWidget *widget,

View File

@ -500,9 +500,10 @@ static void gtk_window_activate_default_activate (GtkWidget *widget,
const char *action_name, const char *action_name,
GVariant *parameter); GVariant *parameter);
static void gtk_window_do_popup (GtkWindow *window, static void gtk_window_do_popup (GtkWindow *window,
GdkEventButton *event); GdkEventButton *event);
static void gtk_window_style_updated (GtkWidget *widget); static void gtk_window_css_changed (GtkWidget *widget,
GtkCssStyleChange *change);
static void gtk_window_state_flags_changed (GtkWidget *widget, static void gtk_window_state_flags_changed (GtkWidget *widget,
GtkStateFlags previous_state); GtkStateFlags previous_state);
static void _gtk_window_set_is_active (GtkWindow *window, 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->move_focus = gtk_window_move_focus;
widget_class->measure = gtk_window_measure; widget_class->measure = gtk_window_measure;
widget_class->state_flags_changed = gtk_window_state_flags_changed; 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; widget_class->snapshot = gtk_window_snapshot;
container_class->add = gtk_window_add; container_class->add = gtk_window_add;
@ -6491,12 +6492,12 @@ gtk_window_state_flags_changed (GtkWidget *widget,
} }
static void 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); 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) && if (!_gtk_widget_get_alloc_needed (widget) &&
(change == NULL || gtk_css_style_change_changes_property (change, GTK_CSS_PROPERTY_BACKGROUND_COLOR))) (change == NULL || gtk_css_style_change_changes_property (change, GTK_CSS_PROPERTY_BACKGROUND_COLOR)))

View File

@ -75,7 +75,6 @@
<property name="fixed-height-mode">1</property> <property name="fixed-height-mode">1</property>
<signal name="cursor-changed" handler="cursor_changed_cb" swapped="no"/> <signal name="cursor-changed" handler="cursor_changed_cb" swapped="no"/>
<signal name="row-activated" handler="row_activated_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"> <child internal-child="selection">
<object class="GtkTreeSelection" id="treeview-selection1"> <object class="GtkTreeSelection" id="treeview-selection1">
<property name="mode">browse</property> <property name="mode">browse</property>