From fcab393c3b250e139afa5e2c9b3614b474c74f66 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 16 Apr 2022 23:29:04 -0400 Subject: [PATCH 1/2] filechooser: Prevent random completion popups It is very irritating when the entry completion popup appears not in response to user input in the entry. In particular, when that happens right as the dialog is shown. To prevent that, temporarily disable completion when setting the entry text programmatically. --- gtk/gtkfilechooserwidget.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index a2310f35d8..f08e5ad6ea 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -4748,9 +4748,15 @@ update_chooser_entry (GtkFileChooserWidget *impl) if (change_entry && !impl->auto_selecting_first_row) { + GtkEntryCompletion *completion = gtk_entry_get_completion (GTK_ENTRY (impl->location_entry)); + + if (completion) + gtk_entry_completion_set_popup_completion (completion, FALSE); g_signal_handlers_block_by_func (impl->location_entry, G_CALLBACK (location_entry_changed_cb), impl); gtk_editable_set_text (GTK_EDITABLE (impl->location_entry), impl->browse_files_last_selected_name); g_signal_handlers_unblock_by_func (impl->location_entry, G_CALLBACK (location_entry_changed_cb), impl); + if (completion) + gtk_entry_completion_set_popup_completion (completion, TRUE); if (impl->action == GTK_FILE_CHOOSER_ACTION_SAVE) _gtk_file_chooser_entry_select_filename (GTK_FILE_CHOOSER_ENTRY (impl->location_entry)); From eb2699aa9f177cea67bb22bcebd6bb170853b571 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Sat, 16 Apr 2022 22:00:22 -0400 Subject: [PATCH 2/2] filechooser: Small fix for save mode When changing folders, we were making the select button insensitive when there's no files around. That doesn't make sense in save mode when we don't want to select a file but create one. Fixes: #4851 --- gtk/gtkfilechooserwidget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index f08e5ad6ea..b365204d88 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -2193,7 +2193,7 @@ update_default (GtkFileChooserWidget *impl) return; files = gtk_file_chooser_get_files (GTK_FILE_CHOOSER (impl)); - sensitive = (g_list_model_get_n_items (files) > 0); + sensitive = (g_list_model_get_n_items (files) > 0 || impl->action == GTK_FILE_CHOOSER_ACTION_SAVE); gtk_widget_set_sensitive (button, sensitive); g_object_unref (files);