[gtk/placeholder-visibility] text: Update placeholder visibility more often




commit c79f289d67e101a5539fcf05123a2c3589bb3345
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jul 3 22:15:38 2021 -0400

    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

 gtk/gtktext.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
---
diff --git a/gtk/gtktext.c b/gtk/gtktext.c
index 2416e980f9..f3c23c3365 100644
--- a/gtk/gtktext.c
+++ b/gtk/gtktext.c
@@ -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]);
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]