st_label_set_text: no-op if the text is unchanged
If a caller sets an StLabel's text to what it already is (as, eg, the clock menu does), do nothing. Unless the label is editable, in which case, setting the text has a visible side effect (dropping the selection), so we don't optimize that out. https://bugzilla.gnome.org/show_bug.cgi?id=645648
This commit is contained in:
parent
5b93525ce8
commit
a56bc9d933
@ -376,22 +376,28 @@ st_label_set_text (StLabel *label,
|
|||||||
const gchar *text)
|
const gchar *text)
|
||||||
{
|
{
|
||||||
StLabelPrivate *priv;
|
StLabelPrivate *priv;
|
||||||
|
ClutterText *ctext;
|
||||||
|
|
||||||
g_return_if_fail (ST_IS_LABEL (label));
|
g_return_if_fail (ST_IS_LABEL (label));
|
||||||
g_return_if_fail (text != NULL);
|
g_return_if_fail (text != NULL);
|
||||||
|
|
||||||
priv = label->priv;
|
priv = label->priv;
|
||||||
|
ctext = CLUTTER_TEXT (priv->label);
|
||||||
|
|
||||||
|
if (clutter_text_get_editable (ctext) ||
|
||||||
|
g_strcmp0 (clutter_text_get_text (ctext), text) != 0)
|
||||||
|
{
|
||||||
if (priv->text_shadow_material != COGL_INVALID_HANDLE)
|
if (priv->text_shadow_material != COGL_INVALID_HANDLE)
|
||||||
{
|
{
|
||||||
cogl_handle_unref (priv->text_shadow_material);
|
cogl_handle_unref (priv->text_shadow_material);
|
||||||
priv->text_shadow_material = COGL_INVALID_HANDLE;
|
priv->text_shadow_material = COGL_INVALID_HANDLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
clutter_text_set_text (CLUTTER_TEXT (priv->label), text);
|
clutter_text_set_text (ctext, text);
|
||||||
|
|
||||||
g_object_notify (G_OBJECT (label), "text");
|
g_object_notify (G_OBJECT (label), "text");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* st_label_get_clutter_text:
|
* st_label_get_clutter_text:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user