diff --git a/gtk/gtksearchentry.c b/gtk/gtksearchentry.c index eb35fc1bd4..6f7bf5321e 100644 --- a/gtk/gtksearchentry.c +++ b/gtk/gtksearchentry.c @@ -39,6 +39,7 @@ #include "gtkprivate.h" #include "gtkmarshalers.h" #include "gtkeventcontrollerkey.h" +#include "gtktypebuiltins.h" #include "gtkwidgetprivate.h" #include "gtkcssnodeprivate.h" #include "gtkcsspositionvalueprivate.h" @@ -105,6 +106,8 @@ enum { enum { PROP_0, PROP_PLACEHOLDER_TEXT, + PROP_INPUT_PURPOSE, + PROP_INPUT_HINTS, PROP_ACTIVATES_DEFAULT, PROP_SEARCH_DELAY, NUM_PROPERTIES, @@ -216,6 +219,14 @@ gtk_search_entry_set_property (GObject *object, -1); break; + case PROP_INPUT_PURPOSE: + gtk_search_entry_set_input_purpose (entry, g_value_get_enum (value)); + break; + + case PROP_INPUT_HINTS: + gtk_search_entry_set_input_hints (entry, g_value_get_flags (value)); + break; + case PROP_ACTIVATES_DEFAULT: if (gtk_text_get_activates_default (GTK_TEXT (entry->entry)) != g_value_get_boolean (value)) { @@ -250,6 +261,14 @@ gtk_search_entry_get_property (GObject *object, g_value_set_string (value, gtk_text_get_placeholder_text (GTK_TEXT (entry->entry))); break; + case PROP_INPUT_PURPOSE: + g_value_set_enum (value, gtk_text_get_input_purpose (GTK_TEXT (entry->entry))); + break; + + case PROP_INPUT_HINTS: + g_value_set_flags (value, gtk_text_get_input_hints (GTK_TEXT (entry->entry))); + break; + case PROP_ACTIVATES_DEFAULT: g_value_set_boolean (value, gtk_text_get_activates_default (GTK_TEXT (entry->entry))); break; @@ -449,6 +468,30 @@ gtk_search_entry_class_init (GtkSearchEntryClass *klass) NULL, GTK_PARAM_READWRITE); + /** + * GtkSearchEntry:input-purpose: + * + * The purpose for the `GtkSearchEntry` input used to alter the + * behaviour of input methods. + */ + props[PROP_INPUT_PURPOSE] = + g_param_spec_enum ("input-purpose", NULL, NULL, + GTK_TYPE_INPUT_PURPOSE, + GTK_INPUT_PURPOSE_FREE_FORM, + GTK_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); + + /** + * GtkSearchEntry:input-hints: + * + * The hints about input for the `GtkSearchEntry` used to alter the + * behaviour of input methods. + */ + props[PROP_INPUT_HINTS] = + g_param_spec_flags ("input-hints", NULL, NULL, + GTK_TYPE_INPUT_HINTS, + GTK_INPUT_HINT_NONE, + GTK_PARAM_READWRITE | G_PARAM_STATIC_STRINGS | G_PARAM_EXPLICIT_NOTIFY); + /** * GtkSearchEntry:activates-default: * @@ -1013,6 +1056,88 @@ gtk_search_entry_set_placeholder_text (GtkSearchEntry *entry, gtk_text_set_placeholder_text (GTK_TEXT (entry->entry), text); } +/** + * gtk_search_entry_get_input_purpose: + * @entry: a `GtkSearchEntry` + * + * Gets the input purpose of @entry. + * + * Returns: The input hints + * + * Since: 4.14 + */ +GtkInputPurpose +gtk_search_entry_get_input_purpose (GtkSearchEntry *entry) +{ + g_return_val_if_fail (GTK_IS_SEARCH_ENTRY (entry), GTK_INPUT_PURPOSE_FREE_FORM); + + return gtk_text_get_input_purpose (GTK_TEXT (entry->entry)); +} + +/** + * gtk_search_entry_set_input_purpose: + * @entry: a `GtkSearchEntry` + * @purpose: the new input purpose + * + * Sets the input purpose of @entry. + * + * Since: 4.14 + */ +void +gtk_search_entry_set_input_purpose (GtkSearchEntry *entry, + GtkInputPurpose purpose) +{ + g_return_if_fail (GTK_IS_SEARCH_ENTRY (entry)); + + if (purpose != gtk_search_entry_get_input_purpose (entry)) + { + gtk_text_set_input_purpose (GTK_TEXT (entry->entry), purpose); + + g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_INPUT_PURPOSE]); + } +} + +/** + * gtk_search_entry_get_input_hints: + * @entry: a `GtkSearchEntry` + * + * Gets the input purpose for @entry. + * + * Returns: The input hints + * + * Since: 4.14 + */ +GtkInputHints +gtk_search_entry_get_input_hints (GtkSearchEntry *entry) +{ + g_return_val_if_fail (GTK_IS_SEARCH_ENTRY (entry), GTK_INPUT_HINT_NONE); + + return gtk_text_get_input_hints (GTK_TEXT (entry->entry)); +} + +/** + * gtk_search_entry_set_input_hints: + * @entry: a `GtkSearchEntry` + * @hints: the new input hints + * + * Sets the input hints for @entry. + * + * Since: 4.14 + */ +void +gtk_search_entry_set_input_hints (GtkSearchEntry *entry, + GtkInputHints hints) +{ + g_return_if_fail (GTK_IS_SEARCH_ENTRY (entry)); + + if (hints != gtk_search_entry_get_input_hints (entry)) + { + gtk_text_set_input_hints (GTK_TEXT (entry->entry), hints); + + g_object_notify_by_pspec (G_OBJECT (entry), props[PROP_INPUT_HINTS]); + } +} + GtkText * gtk_search_entry_get_text_widget (GtkSearchEntry *entry) { diff --git a/gtk/gtksearchentry.h b/gtk/gtksearchentry.h index 0a80c3b79c..d5409c5c5b 100644 --- a/gtk/gtksearchentry.h +++ b/gtk/gtksearchentry.h @@ -65,6 +65,18 @@ void gtk_search_entry_set_placeholder_text (GtkSearchEntry *entry, GDK_AVAILABLE_IN_4_10 const char * gtk_search_entry_get_placeholder_text (GtkSearchEntry *entry); +GDK_AVAILABLE_IN_4_14 +void gtk_search_entry_set_input_purpose (GtkSearchEntry *entry, + GtkInputPurpose purpose); +GDK_AVAILABLE_IN_4_14 +GtkInputPurpose gtk_search_entry_get_input_purpose (GtkSearchEntry *entry); + +GDK_AVAILABLE_IN_4_14 +void gtk_search_entry_set_input_hints (GtkSearchEntry *entry, + GtkInputHints hints); +GDK_AVAILABLE_IN_4_14 +GtkInputHints gtk_search_entry_get_input_hints (GtkSearchEntry *entry); + G_DEFINE_AUTOPTR_CLEANUP_FUNC(GtkSearchEntry, g_object_unref) G_END_DECLS