text: Update placeholder visibility more often

We need to update the visibility of the placeholder
label when we create it, otherwise we can end up
with placeholder text on top of entry content.

Fixes: #4066
This commit is contained in:
Matthias Clasen 2021-07-03 22:15:38 -04:00
parent e516ce428a
commit c79f289d67

View File

@ -3580,7 +3580,8 @@ update_placeholder_visibility (GtkText *self)
if (priv->placeholder)
gtk_widget_set_child_visible (priv->placeholder,
priv->preedit_length == 0 &&
gtk_entry_buffer_get_length (priv->buffer) == 0);
(priv->buffer == NULL ||
gtk_entry_buffer_get_length (priv->buffer) == 0));
}
/* GtkEntryBuffer signal handlers
@ -6652,6 +6653,8 @@ gtk_text_set_placeholder_text (GtkText *self,
gtk_label_set_text (GTK_LABEL (priv->placeholder), text);
}
update_placeholder_visibility (self);
g_object_notify_by_pspec (G_OBJECT (self), text_props[PROP_PLACEHOLDER_TEXT]);
}