From a06b469fbb5bbdd19ae95d49f3a1b96f2dbd336d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20M=C3=BCllner?= Date: Fri, 3 Jun 2022 20:32:03 +0200 Subject: [PATCH] st: Only notify on property changes Since commit 5a23c96bd918 we use EXPLICIT_NOTIFY for properties, however there are still cases where we still notify unconditionally from the setter, because we don't check the existing value first. Part-of: --- src/st/st-button.c | 30 ++++++++++++++++++++++-------- src/st/st-entry.c | 9 +++++++++ src/st/st-icon.c | 6 ++++++ src/st/st-widget.c | 7 +++++++ 4 files changed, 44 insertions(+), 8 deletions(-) diff --git a/src/st/st-button.c b/src/st/st-button.c index c04a70eb6..148197c24 100644 --- a/src/st/st-button.c +++ b/src/st/st-button.c @@ -662,6 +662,9 @@ st_button_set_label (StButton *button, priv = st_button_get_instance_private (button); + if (g_strcmp0 (priv->text, text) == 0) + return; + g_free (priv->text); if (text) @@ -739,6 +742,9 @@ st_button_set_icon_name (StButton *button, if (ST_IS_ICON (icon)) { + if (g_strcmp0 (st_icon_get_icon_name (ST_ICON (icon)), icon_name) == 0) + return; + st_icon_set_icon_name (ST_ICON (icon), icon_name); } else @@ -788,6 +794,10 @@ st_button_set_button_mask (StButton *button, g_return_if_fail (ST_IS_BUTTON (button)); priv = st_button_get_instance_private (button); + + if (priv->button_mask == mask) + return; + priv->button_mask = mask; g_object_notify_by_pspec (G_OBJECT (button), props[PROP_BUTTON_MASK]); @@ -826,6 +836,10 @@ st_button_set_toggle_mode (StButton *button, g_return_if_fail (ST_IS_BUTTON (button)); priv = st_button_get_instance_private (button); + + if (priv->is_toggle == toggle) + return; + priv->is_toggle = toggle; g_object_notify_by_pspec (G_OBJECT (button), props[PROP_TOGGLE_MODE]); @@ -864,15 +878,15 @@ st_button_set_checked (StButton *button, g_return_if_fail (ST_IS_BUTTON (button)); priv = st_button_get_instance_private (button); - if (priv->is_checked != checked) - { - priv->is_checked = checked; + if (priv->is_checked == checked) + return; - if (checked) - st_widget_add_style_pseudo_class (ST_WIDGET (button), "checked"); - else - st_widget_remove_style_pseudo_class (ST_WIDGET (button), "checked"); - } + priv->is_checked = checked; + + if (checked) + st_widget_add_style_pseudo_class (ST_WIDGET (button), "checked"); + else + st_widget_remove_style_pseudo_class (ST_WIDGET (button), "checked"); g_object_notify_by_pspec (G_OBJECT (button), props[PROP_CHECKED]); } diff --git a/src/st/st-entry.c b/src/st/st-entry.c index 625bbf252..64f85fd51 100644 --- a/src/st/st-entry.c +++ b/src/st/st-entry.c @@ -1400,6 +1400,9 @@ st_entry_set_primary_icon (StEntry *entry, priv = st_entry_get_instance_private (entry); + if (priv->primary_icon == icon) + return; + _st_entry_set_icon (entry, &priv->primary_icon, icon); g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_PRIMARY_ICON]); } @@ -1440,6 +1443,9 @@ st_entry_set_secondary_icon (StEntry *entry, priv = st_entry_get_instance_private (entry); + if (priv->secondary_icon == icon) + return; + _st_entry_set_icon (entry, &priv->secondary_icon, icon); g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_SECONDARY_ICON]); } @@ -1480,6 +1486,9 @@ st_entry_set_hint_actor (StEntry *entry, priv = ST_ENTRY_PRIV (entry); + if (priv->hint_actor == hint_actor) + return; + if (priv->hint_actor != NULL) { clutter_actor_remove_child (CLUTTER_ACTOR (entry), priv->hint_actor); diff --git a/src/st/st-icon.c b/src/st/st-icon.c index f7586b947..6009afec5 100644 --- a/src/st/st-icon.c +++ b/src/st/st-icon.c @@ -638,6 +638,9 @@ st_icon_set_icon_name (StIcon *icon, g_return_if_fail (ST_IS_ICON (icon)); + if (g_strcmp0 (icon_name, st_icon_get_icon_name (icon)) == 0) + return; + if (icon_name && *icon_name) gicon = g_themed_icon_new_with_default_fallbacks (icon_name); @@ -815,6 +818,9 @@ st_icon_set_fallback_icon_name (StIcon *icon, g_return_if_fail (ST_IS_ICON (icon)); + if (g_strcmp0 (fallback_icon_name, st_icon_get_fallback_icon_name (icon)) == 0) + return; + if (fallback_icon_name && *fallback_icon_name) gicon = g_themed_icon_new_with_default_fallbacks (fallback_icon_name); diff --git a/src/st/st-widget.c b/src/st/st-widget.c index f50be949a..92d6456a1 100644 --- a/src/st/st-widget.c +++ b/src/st/st-widget.c @@ -2434,6 +2434,9 @@ st_widget_set_accessible_name (StWidget *widget, priv = st_widget_get_instance_private (widget); + if (g_strcmp0 (name, priv->accessible_name) == 0) + return; + if (priv->accessible_name != NULL) g_free (priv->accessible_name); @@ -2490,6 +2493,10 @@ st_widget_set_accessible_role (StWidget *widget, g_return_if_fail (ST_IS_WIDGET (widget)); priv = st_widget_get_instance_private (widget); + + if (priv->accessible_role == role) + return; + priv->accessible_role = role; g_object_notify_by_pspec (G_OBJECT (widget), props[PROP_ACCESSIBLE_ROLE]);