st/icon: Use own methods for updating GIcon when setting icon names

Instead of reimplementing the functions to set the GIcon inside the
`set_*_icon_name` functions, just use the already defined methods for
that.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/888
This commit is contained in:
Jonas Dreßler 2019-11-21 19:05:04 +07:00 committed by Florian Müllner
parent e784afe9ac
commit 69a5e89096

View File

@ -549,7 +549,6 @@ void
st_icon_set_icon_name (StIcon *icon,
const gchar *icon_name)
{
StIconPrivate *priv = icon->priv;
GIcon *gicon = NULL;
g_return_if_fail (ST_IS_ICON (icon));
@ -557,26 +556,12 @@ st_icon_set_icon_name (StIcon *icon,
if (icon_name)
gicon = g_themed_icon_new_with_default_fallbacks (icon_name);
if (g_icon_equal (priv->gicon, gicon)) /* do nothing */
{
if (gicon)
g_object_unref (gicon);
return;
}
if (priv->gicon)
g_object_unref (priv->gicon);
g_object_freeze_notify (G_OBJECT (icon));
priv->gicon = gicon;
g_object_notify_by_pspec (G_OBJECT (icon), props[PROP_GICON]);
st_icon_set_gicon (icon, gicon);
g_object_notify_by_pspec (G_OBJECT (icon), props[PROP_ICON_NAME]);
g_object_thaw_notify (G_OBJECT (icon));
st_icon_update (icon);
}
/**
@ -741,7 +726,6 @@ void
st_icon_set_fallback_icon_name (StIcon *icon,
const gchar *fallback_icon_name)
{
StIconPrivate *priv = icon->priv;
GIcon *gicon = NULL;
g_return_if_fail (ST_IS_ICON (icon));
@ -749,19 +733,10 @@ st_icon_set_fallback_icon_name (StIcon *icon,
if (fallback_icon_name != NULL)
gicon = g_themed_icon_new_with_default_fallbacks (fallback_icon_name);
if (g_icon_equal (priv->fallback_gicon, gicon)) /* do nothing */
{
if (gicon)
g_object_unref (gicon);
return;
}
if (priv->fallback_gicon)
g_object_unref (priv->fallback_gicon);
priv->fallback_gicon = gicon;
g_object_freeze_notify (G_OBJECT (icon));
st_icon_set_fallback_gicon (icon, gicon);
g_object_notify_by_pspec (G_OBJECT (icon), props[PROP_FALLBACK_ICON_NAME]);
st_icon_update (icon);
g_object_thaw_notify (G_OBJECT (icon));
}