From 642988715a71221d3d0b3321b99c36d6cf77ec43 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Tue, 15 Aug 2023 09:29:23 +0100 Subject: [PATCH] Fix #1151: Can't re-add items to collection after accidentally removing them https://github.com/BestImageViewer/geeqie/issues/1151 Option in Preferences/Behavior to permit duplicates also solves this problem. --- doc/docbook/GuideOptionsBehavior.xml | 8 ++++++++ src/collect.cc | 5 ++++- src/options.cc | 1 + src/options.h | 1 + src/preferences.cc | 5 +++++ src/rcfile.cc | 2 ++ 6 files changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/docbook/GuideOptionsBehavior.xml b/doc/docbook/GuideOptionsBehavior.xml index 9fb2a7b9..82d8f089 100644 --- a/doc/docbook/GuideOptionsBehavior.xml +++ b/doc/docbook/GuideOptionsBehavior.xml @@ -164,6 +164,14 @@ Move the "With Rename" button to the default position. + + + Permit duplicates in Collections + + + If this option is set, an image can be inserted into a Collection any number of times. + + Open Collections on top diff --git a/src/collect.cc b/src/collect.cc index 57fe4c0e..8d68bcd4 100644 --- a/src/collect.cc +++ b/src/collect.cc @@ -730,7 +730,10 @@ static CollectInfo *collection_info_new_if_not_exists(CollectionData *cd, struct { CollectInfo *ci; - if (g_hash_table_lookup(cd->existence, fd->path)) return nullptr; + if (!options->collections_duplicates) + { + if (g_hash_table_lookup(cd->existence, fd->path)) return nullptr; + } ci = collection_info_new(fd, st, nullptr); if (ci) g_hash_table_insert(cd->existence, fd->path, g_strdup("")); diff --git a/src/options.cc b/src/options.cc index 43ce45b7..c29a3440 100644 --- a/src/options.cc +++ b/src/options.cc @@ -85,6 +85,7 @@ ConfOptions *init_options(ConfOptions *options) options->appimage_notifications = TRUE; options->marks_save = TRUE; options->with_rename = FALSE; + options->collections_duplicates = FALSE; options->collections_on_top = FALSE; options->hide_window_in_fullscreen = TRUE; diff --git a/src/options.h b/src/options.h index 062280ee..c626598d 100644 --- a/src/options.h +++ b/src/options.h @@ -76,6 +76,7 @@ struct ConfOptions gboolean appimage_notifications; gboolean with_rename; + gboolean collections_duplicates; gboolean collections_on_top; gboolean hide_window_in_fullscreen; diff --git a/src/preferences.cc b/src/preferences.cc index 30220f98..77e29b79 100644 --- a/src/preferences.cc +++ b/src/preferences.cc @@ -444,6 +444,7 @@ static void config_window_apply() options->marks_save = c_options->marks_save; options->with_rename = c_options->with_rename; + options->collections_duplicates = c_options->collections_duplicates; options->collections_on_top = c_options->collections_on_top; options->hide_window_in_fullscreen = c_options->hide_window_in_fullscreen; config_entry_to_option(help_search_engine_entry, &options->help_search_engine, nullptr); @@ -3484,6 +3485,10 @@ static void config_tab_behavior(GtkWidget *notebook) options->with_rename, &c_options->with_rename); gtk_widget_set_tooltip_text(with_rename,"Change the default button for Copy/Move dialogs"); + collections_on_top = pref_checkbox_new_int(group, _("Permit duplicates in Collections"), + options->collections_duplicates, &c_options->collections_duplicates); + gtk_widget_set_tooltip_text(collections_on_top,"Allow the same image to be in a Collection more than once"); + collections_on_top = pref_checkbox_new_int(group, _("Open collections on top"), options->collections_on_top, &c_options->collections_on_top); gtk_widget_set_tooltip_text(collections_on_top,"Open collections window on top"); diff --git a/src/rcfile.cc b/src/rcfile.cc index 72a35309..9b834a7e 100644 --- a/src/rcfile.cc +++ b/src/rcfile.cc @@ -360,6 +360,7 @@ static void write_global_attributes(GString *outstr, gint indent) WRITE_NL(); WRITE_CHAR(*options, external_preview.extract); WRITE_NL(); WRITE_BOOL(*options, with_rename); + WRITE_NL(); WRITE_BOOL(*options, collections_duplicates); WRITE_NL(); WRITE_BOOL(*options, collections_on_top); WRITE_NL(); WRITE_BOOL(*options, hide_window_in_fullscreen); @@ -856,6 +857,7 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar ** if (READ_CHAR(*options, external_preview.select)) continue; if (READ_CHAR(*options, external_preview.extract)) continue; + if (READ_BOOL(*options, collections_duplicates)) continue; if (READ_BOOL(*options, collections_on_top)) continue; if (READ_BOOL(*options, hide_window_in_fullscreen)) continue; -- 2.20.1