+/* Function used to decide whether to show the placeholder or not */
+static void
+hildon_entry_refresh_contents (GtkWidget *entry)
+{
+ HildonEntryPrivate *priv = HILDON_ENTRY (entry)->priv;
+ gboolean showing_placeholder, entry_has_focus;
+
+ showing_placeholder = g_str_equal (gtk_widget_get_name (entry), placeholder_widget_name);
+ entry_has_focus = GTK_WIDGET_HAS_FOCUS (entry);
+
+ if (showing_placeholder) {
+ if (entry_has_focus) {
+ /* Remove the placeholder when the widget obtains focus */
+ gtk_widget_set_name (entry, NULL);
+ gtk_entry_set_text (GTK_ENTRY (entry), "");
+ } else {
+ /* Update the placeholder (it may have been changed) */
+ gtk_entry_set_text (GTK_ENTRY (entry), priv->placeholder);
+ }
+ } else {
+ /* Show the placeholder when the widget is empty and has no focus */
+ const gchar *text = gtk_entry_get_text (GTK_ENTRY (entry));
+ if (text[0] == '\0' && !entry_has_focus) {
+ if (priv->placeholder[0] != '\0') {
+ gtk_widget_set_name (entry, placeholder_widget_name);
+ gtk_entry_set_text (GTK_ENTRY (entry), priv->placeholder);
+ }
+ }
+ }
+}
+
+/**
+ * hildon_entry_set_text:
+ * @entry: a #HildonEntry
+ * @text: the new text
+ *
+ * Sets the text in @entry to @text, replacing its current contents.
+ *
+ * Note that you must never use gtk_entry_set_text() to set the text
+ * of a #HildonEntry.
+ *
+ * Since: 2.2
+ */