diff options
author | robxnano <91250-robxnano@users.noreply.gitlab.gnome.org> | 2023-02-28 22:50:56 +0000 |
---|---|---|
committer | robxnano <91250-robxnano@users.noreply.gitlab.gnome.org> | 2023-03-01 13:56:52 +0000 |
commit | 5a5a36151a867ce8761fef392a2526cc0fd96a16 (patch) | |
tree | 3579b3cf8a4416303944622e73e8c75b811226b4 /gtk | |
parent | 471ebabd77c014f47fbe162becfd98a8fb37c954 (diff) | |
download | gtk+-5a5a36151a867ce8761fef392a2526cc0fd96a16.tar.gz |
filechooser: Don't automatically select a file
When the folder changes, do not select the first item in the list,
so if the user enters a folder and then clicks the accept button,
the current folder is returned instead of the selected one.
To maintain consistency with the previous implementation, when a
folder in the path bar is clicked the previously-entered folder is
selected, and when the file chooser is in open file mode the first
item is always selected.
See #5438
Diffstat (limited to 'gtk')
-rw-r--r-- | gtk/gtkfilechooserwidget.c | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/gtk/gtkfilechooserwidget.c b/gtk/gtkfilechooserwidget.c index 70276967e5..5653ae7a3d 100644 --- a/gtk/gtkfilechooserwidget.c +++ b/gtk/gtkfilechooserwidget.c @@ -2571,7 +2571,11 @@ set_select_multiple (GtkFileChooserWidget *impl, if (select_multiple) impl->selection_model = GTK_SELECTION_MODEL (gtk_multi_selection_new (model)); else - impl->selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (model)); + { + impl->selection_model = GTK_SELECTION_MODEL (gtk_single_selection_new (model)); + gtk_single_selection_set_can_unselect (GTK_SINGLE_SELECTION (impl->selection_model), TRUE); + gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (impl->selection_model), FALSE); + } g_signal_connect (impl->selection_model, "selection-changed", G_CALLBACK (list_selection_changed), impl); @@ -7289,6 +7293,9 @@ gtk_file_chooser_widget_init (GtkFileChooserWidget *impl) G_CALLBACK (list_items_changed), impl); gtk_single_selection_set_model (GTK_SINGLE_SELECTION (impl->selection_model), G_LIST_MODEL (impl->sort_model)); + gtk_single_selection_set_can_unselect (GTK_SINGLE_SELECTION (impl->selection_model), TRUE); + gtk_single_selection_set_autoselect (GTK_SINGLE_SELECTION (impl->selection_model), FALSE); + gtk_sort_list_model_set_model (impl->sort_model, G_LIST_MODEL (impl->filter_model)); gtk_column_view_set_model (GTK_COLUMN_VIEW (impl->browse_files_column_view), impl->selection_model); |