gtksearchentry: Add getter/setter for placeholder text
authorAlexandros Theodotou <alex@zrythm.org>
Sat, 1 Jan 2022 20:08:53 +0000 (20:08 +0000)
committerAlexandros Theodotou <alex@zrythm.org>
Sun, 12 Feb 2023 21:46:31 +0000 (06:46 +0900)
gtk/gtksearchentry.c
gtk/gtksearchentry.h

index d11c65943199ce691aab7b22d284cafd22a4db9a..8173e5ee65a8af7b2528d4ab9b18d106d71dc165 100644 (file)
@@ -832,6 +832,42 @@ gtk_search_entry_get_key_controller (GtkSearchEntry *entry)
   return gtk_text_get_key_controller (GTK_TEXT (entry->entry));
 }
 
+/**
+ * gtk_search_entry_get_placeholder_text:
+ * @entry: a `GtkSearchEntry`
+ *
+ * Gets the placeholder text associated with @entry.
+ *
+ * Returns: (nullable): The placeholder text.
+ *
+ * Since: 4.8
+ */
+const char *
+gtk_search_entry_get_placeholder_text (GtkSearchEntry *entry)
+{
+  g_return_val_if_fail (GTK_IS_SEARCH_ENTRY (entry), NULL);
+
+  return gtk_text_get_placeholder_text (GTK_TEXT (entry->entry));
+}
+
+/**
+ * gtk_search_entry_set_placeholder_text:
+ * @entry: a `GtkSearchEntry`
+ * @text: (nullable): the text to set as a placeholder
+ *
+ * Sets the placeholder text associated with @entry.
+ *
+ * Since: 4.8
+ */
+void
+gtk_search_entry_set_placeholder_text (GtkSearchEntry *entry,
+                                       const char     *text)
+{
+  g_return_if_fail (GTK_IS_SEARCH_ENTRY (entry));
+
+  gtk_text_set_placeholder_text (GTK_TEXT (entry->entry), text);
+}
+
 GtkText *
 gtk_search_entry_get_text_widget (GtkSearchEntry *entry)
 {
index 8a7ecaf038177a7af2b025044f92cdcd1b8db0d1..805436fa429e212691fc7861954d8393220e799c 100644 (file)
@@ -60,6 +60,12 @@ void gtk_search_entry_set_search_delay (GtkSearchEntry *entry,
 GDK_AVAILABLE_IN_4_8
 guint gtk_search_entry_get_search_delay (GtkSearchEntry *entry);
 
+GDK_AVAILABLE_IN_4_6
+void            gtk_search_entry_set_placeholder_text (GtkSearchEntry *entry,
+                                                       const char     *text);
+GDK_AVAILABLE_IN_4_6
+const char *    gtk_search_entry_get_placeholder_text (GtkSearchEntry *entry);
+
 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSearchEntry, g_object_unref)
 
 G_END_DECLS