Fix #1151: Can't re-add items to collection after accidentally removing them
authorColin Clark <colin.clark@cclark.uk>
Tue, 15 Aug 2023 08:29:23 +0000 (09:29 +0100)
committerColin Clark <colin.clark@cclark.uk>
Tue, 15 Aug 2023 08:29:23 +0000 (09:29 +0100)
https://github.com/BestImageViewer/geeqie/issues/1151

Option in Preferences/Behavior to permit duplicates also solves this
problem.

doc/docbook/GuideOptionsBehavior.xml
src/collect.cc
src/options.cc
src/options.h
src/preferences.cc
src/rcfile.cc

index 9fb2a7b..82d8f08 100644 (file)
           <para>Move the "With Rename" button to the default position.</para>
         </listitem>
       </varlistentry>
+      <varlistentry>
+        <term>
+          <guilabel>Permit duplicates in Collections</guilabel>
+        </term>
+       <listitem>
+          <para>If this option is set, an image can be inserted into a Collection any number of times.</para>
+        </listitem>
+      </varlistentry>
       <varlistentry>
         <term>
           <guilabel>Open Collections on top</guilabel>
index 57fe4c0..8d68bcd 100644 (file)
@@ -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(""));
index 43ce45b..c29a344 100644 (file)
@@ -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;
 
index 062280e..c626598 100644 (file)
@@ -76,6 +76,7 @@ struct ConfOptions
        gboolean appimage_notifications;
 
        gboolean with_rename;
+       gboolean collections_duplicates;
        gboolean collections_on_top;
        gboolean hide_window_in_fullscreen;
 
index 30220f9..77e29b7 100644 (file)
@@ -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");
index 72a3530..9b834a7 100644 (file)
@@ -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;