From 4812fddc5c29c9a5ad8d9ec062c39e677fd2ac8b Mon Sep 17 00:00:00 2001 From: Alx Sa Date: Wed, 29 Oct 2025 14:40:19 +0000 Subject: [PATCH] widgets, actions: Allow multi-select in Document History This patch enables multiple selections in the GimpDocumentView widget and dockable. It also updates the "documents-open" and "documents-remove" actions to check if the GimpContainerView has more than one selection, and if so, tries to load/remove all of those images. The action wording is slightly edited to indicate multiple images can now be opened/removed. --- app/actions/documents-actions.c | 8 +++--- app/actions/documents-commands.c | 45 +++++++++++++++++++++++++------- app/widgets/gimpdocumentview.c | 2 ++ 3 files changed, 41 insertions(+), 14 deletions(-) diff --git a/app/actions/documents-actions.c b/app/actions/documents-actions.c index 119a4aff13..5202fa35de 100644 --- a/app/actions/documents-actions.c +++ b/app/actions/documents-actions.c @@ -39,8 +39,8 @@ static const GimpActionEntry documents_actions[] = { { "documents-open", GIMP_ICON_DOCUMENT_OPEN, - NC_("documents-action", "_Open Image"), NULL, { NULL }, - NC_("documents-action", "Open the selected entry"), + NC_("documents-action", "_Open Images"), NULL, { NULL }, + NC_("documents-action", "Open the selected entries"), documents_open_cmd_callback, GIMP_HELP_DOCUMENT_OPEN }, @@ -69,8 +69,8 @@ static const GimpActionEntry documents_actions[] = GIMP_HELP_DOCUMENT_SHOW_IN_FILE_MANAGER }, { "documents-remove", GIMP_ICON_LIST_REMOVE, - NC_("documents-action", "Remove _Entry"), NULL, { NULL }, - NC_("documents-action", "Remove the selected entry"), + NC_("documents-action", "Remove _Entries"), NULL, { NULL }, + NC_("documents-action", "Remove the selected entries"), documents_remove_cmd_callback, GIMP_HELP_DOCUMENT_REMOVE }, diff --git a/app/actions/documents-commands.c b/app/actions/documents-commands.c index 8a5d21fb74..0a006e2846 100644 --- a/app/actions/documents-commands.c +++ b/app/actions/documents-commands.c @@ -84,20 +84,35 @@ documents_open_cmd_callback (GimpAction *action, GimpContext *context; GimpContainer *container; GimpImagefile *imagefile; + GList *images = NULL; + GList *list; context = gimp_container_view_get_context (editor->view); container = gimp_container_view_get_container (editor->view); imagefile = gimp_context_get_imagefile (context); - if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile))) + if (gimp_container_view_get_selected (editor->view, &images) > 1) { - documents_open_image (GTK_WIDGET (editor), context, imagefile); + for (list = images; list; list = list->next) + documents_open_image (GTK_WIDGET (editor), context, + GIMP_IMAGEFILE (list->data)); + + g_list_free (list); } else { - file_file_open_dialog (context->gimp, NULL, GTK_WIDGET (editor)); + if (imagefile && gimp_container_have (container, GIMP_OBJECT (imagefile))) + { + documents_open_image (GTK_WIDGET (editor), context, imagefile); + } + else + { + file_file_open_dialog (context->gimp, NULL, GTK_WIDGET (editor)); + } } + if (images) + g_list_free (images); } void @@ -206,16 +221,26 @@ documents_remove_cmd_callback (GimpAction *action, GVariant *value, gpointer data) { - GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data); - GimpContext *context = gimp_container_view_get_context (editor->view); - GimpImagefile *imagefile = gimp_context_get_imagefile (context); + GimpContainerEditor *editor = GIMP_CONTAINER_EDITOR (data); const gchar *uri; + GList *images = NULL; + GList *list; - uri = gimp_object_get_name (imagefile); + if (gimp_container_view_get_selected (editor->view, &images) > 1) + { + for (list = images; list; list = list->next) + { + uri = gimp_object_get_name (GIMP_IMAGEFILE (list->data)); - gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), uri, NULL); - - gimp_container_view_remove_active (editor->view); + gtk_recent_manager_remove_item (gtk_recent_manager_get_default (), + uri, NULL); + gimp_container_view_set_1_selected (editor->view, + GIMP_VIEWABLE (list->data)); + gimp_container_view_remove_active (editor->view); + } + g_list_free (list); + g_list_free (images); + } } void diff --git a/app/widgets/gimpdocumentview.c b/app/widgets/gimpdocumentview.c index 1308efcf5d..b19f992eeb 100644 --- a/app/widgets/gimpdocumentview.c +++ b/app/widgets/gimpdocumentview.c @@ -106,6 +106,8 @@ gimp_document_view_new (GimpViewType view_type, editor = GIMP_CONTAINER_EDITOR (document_view); + gimp_container_editor_set_selection_mode (editor, GTK_SELECTION_MULTIPLE); + document_view->open_button = gimp_editor_add_action_button (GIMP_EDITOR (editor->view), "documents", "documents-open",