st: Only notify on property changes

Since commit 5a23c96bd9 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>
This commit is contained in:
Florian Müllner 2022-06-03 20:32:03 +02:00 committed by Marge Bot
parent 8713f9d878
commit a06b469fbb
4 changed files with 44 additions and 8 deletions

View File

@ -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]);
}

View File

@ -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);

View File

@ -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);

View File

@ -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]);