[gnome-shell] st: Only notify on property changes
- From: Marge Bot <marge-bot src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-shell] st: Only notify on property changes
- Date: Wed, 8 Jun 2022 14:19:31 +0000 (UTC)
commit a06b469fbb5bbdd19ae95d49f3a1b96f2dbd336d
Author: Florian Müllner <fmuellner gnome org>
Date: Fri Jun 3 20:32:03 2022 +0200
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: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/2325>
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 c04a70eb69..148197c24c 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 625bbf2523..64f85fd516 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 f7586b9471..6009afec50 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 f50be949af..92d6456a19 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]);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]