From 8ac5f1983ed2f63a51662be60bb85f66ed2033e1 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Wed, 12 Oct 2022 00:05:44 -0400 Subject: [PATCH] filechooserentry: Add a set_text api This function prevents the completion popup from coming up when setting the entry text. --- gtk/gtkfilechooserentry.c | 17 +++++++++++++++++ gtk/gtkfilechooserentry.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/gtk/gtkfilechooserentry.c b/gtk/gtkfilechooserentry.c index 62d751fa86..1d5c66c435 100644 --- a/gtk/gtkfilechooserentry.c +++ b/gtk/gtkfilechooserentry.c @@ -1017,3 +1017,20 @@ _gtk_file_chooser_entry_set_file_filter (GtkFileChooserEntry *chooser_entry, { chooser_entry->current_filter = filter; } + +void +gtk_file_chooser_entry_set_text (GtkFileChooserEntry *entry, + const char *text) +{ + GtkEntryCompletion *completion; + gboolean popup; + + completion = gtk_entry_get_completion (GTK_ENTRY (entry)); + popup = gtk_entry_completion_get_popup_completion (completion); + + gtk_entry_completion_set_popup_completion (completion, FALSE); + + gtk_editable_set_text (GTK_EDITABLE (entry), text); + + gtk_entry_completion_set_popup_completion (completion, popup); +} diff --git a/gtk/gtkfilechooserentry.h b/gtk/gtkfilechooserentry.h index 6ee277f8f7..f7fd7428ec 100644 --- a/gtk/gtkfilechooserentry.h +++ b/gtk/gtkfilechooserentry.h @@ -44,6 +44,8 @@ gboolean _gtk_file_chooser_entry_get_is_folder (GtkFileChooserEnt void _gtk_file_chooser_entry_select_filename (GtkFileChooserEntry *chooser_entry); void _gtk_file_chooser_entry_set_file_filter (GtkFileChooserEntry *chooser_entry, GtkFileFilter *filter); +void gtk_file_chooser_entry_set_text (GtkFileChooserEntry *entry, + const char *text); G_END_DECLS