Modify part of Collections user interface
authorColin Clark <colin.clark@cclark.uk>
Thu, 10 Aug 2023 10:54:51 +0000 (11:54 +0100)
committerColin Clark <colin.clark@cclark.uk>
Thu, 10 Aug 2023 10:54:51 +0000 (11:54 +0100)
Collections .gqv files are expected to be in the default directory.
The user no longer sees file paths or file extensions, only the
collection name.
If the user navigates to a .gqv file located elsewhere and opens it, the
contents will be displayed and operated on as a collection. It will
appear in the "recently used collections" menu (there may be a name
conflict) but not on the "open collection" menu, which shows only the
collections in the default directory.

doc/docbook/GuideReferenceCollectionsShortcuts.xml
src/collect-dlg.cc
src/collect-dlg.h
src/collect-io.cc
src/collect-table.cc
src/collect.cc
src/layout-util.cc
src/typedefs.h

index e830cac..3435636 100644 (file)
@@ -45,4 +45,6 @@ keyboard shortcuts
 <row> <entry> <code>    <keycap>  D </keycap> </code> </entry> <entry>  Sort by date </entry> </row>
 <row> <entry> <code>    <keycap>  B </keycap> </code> </entry> <entry>  Sort by size </entry> </row>
 <row> <entry> <code>    <keycap>  P </keycap> </code> </entry> <entry>  Sort by path </entry> </row>
-<row> <entry> <code>   Shift + <keycap>  P </keycap> </code> </entry> <entry>  Print </entry> </row> </tbody></tgroup></table>
+<row> <entry> <code>   Shift + <keycap>  P </keycap> </code> </entry> <entry>  Print </entry> </row>
+<row> <entry> <code>   Alt + <keycap>  A </keycap> </code> </entry> <entry>  Append (Append collection dialog) </entry> </row>
+<row> <entry> <code>   Alt + <keycap>  D </keycap> </code> </entry> <entry>  Discard (Close modified collection dialog) </entry> </row> </tbody></tgroup></table>
index 33a0971..e148c51 100644 (file)
@@ -36,181 +36,118 @@ enum {
        DIALOG_APPEND
 };
 
+static void collection_save_confirmed(GenericDialog *gdlg, gboolean overwrite, CollectionData *cd);
 
-static gboolean collection_save_confirmed(FileDialog *fd, gboolean overwrite, CollectionData *cd);
-
-
-static void collection_confirm_ok_cb(GenericDialog *, gpointer data)
+static void collection_confirm_ok_cb(GenericDialog *gdlg, gpointer data)
 {
-       auto fd = static_cast<FileDialog *>(data);
-       auto cd = static_cast<CollectionData *>(GENERIC_DIALOG(fd)->data);
+       auto cd = static_cast<CollectionData *>(data);
 
-       if (!collection_save_confirmed(fd, TRUE, cd))
-               {
-               collection_unref(cd);
-               file_dialog_close(fd);
-               }
+       collection_save_confirmed(gdlg, TRUE, cd);
 }
 
-static void collection_confirm_cancel_cb(GenericDialog *, gpointer)
+static void collection_confirm_cancel_cb(GenericDialog *gdlg, gpointer)
 {
-       /* this is a no-op, so the cancel button is added */
+       generic_dialog_close(gdlg);
 }
 
-static gboolean collection_save_confirmed(FileDialog *fd, gboolean overwrite, CollectionData *cd)
+static void collection_save_confirmed(GenericDialog *gdlg, gboolean overwrite, CollectionData *cd)
 {
        gchar *buf;
+       GenericDialog *gdlg_overwrite;
 
-       if (isdir(fd->dest_path))
-               {
-               buf = g_strdup_printf(_("Specified path:\n%s\nis a folder, collections are files"), fd->dest_path);
-               file_util_warning_dialog(_("Invalid filename"), buf, GQ_ICON_DIALOG_INFO, GENERIC_DIALOG(fd)->dialog);
-               g_free(buf);
-               return FALSE;
-               }
+       generic_dialog_close(gdlg);
 
-       if (!overwrite && isfile(fd->dest_path))
+       if (!overwrite && isfile(cd->collection_path))
                {
-               GenericDialog *gd;
-
-               gd = file_util_gen_dlg(_("Overwrite File"), "dlg_confirm",
-                                       GENERIC_DIALOG(fd)->dialog, TRUE,
-                                       collection_confirm_cancel_cb, fd);
+               gdlg_overwrite = file_util_gen_dlg(_("Overwrite collection"), "dlg_confirm", nullptr, FALSE, collection_confirm_cancel_cb, cd);
+               generic_dialog_add_message(gdlg_overwrite, GQ_ICON_DIALOG_QUESTION, _("Overwrite existing collection?"), cd->name, TRUE);
+               generic_dialog_add_button(gdlg_overwrite, GQ_ICON_OK, _("Overwrite"), collection_confirm_ok_cb, TRUE);
 
-               generic_dialog_add_message(gd, GQ_ICON_DIALOG_QUESTION,
-                                          _("Overwrite existing file?"), fd->dest_path, TRUE);
+               gtk_widget_show(gdlg_overwrite->dialog);
 
-               generic_dialog_add_button(gd, GQ_ICON_OK, _("_Overwrite"), collection_confirm_ok_cb, TRUE);
-
-               gtk_widget_show(gd->dialog);
-
-               return TRUE;
+               return;
                }
 
-       if (!collection_save(cd, fd->dest_path))
+       if (!collection_save(cd, cd->collection_path))
                {
-               buf = g_strdup_printf(_("Failed to save the collection:\n%s"), fd->dest_path);
-               file_util_warning_dialog(_("Save Failed"), buf, GQ_ICON_DIALOG_ERROR, GENERIC_DIALOG(fd)->dialog);
+               buf = g_strdup_printf(_("Failed to save the collection:\n%s"), cd->collection_path);
+               file_util_warning_dialog(_("Save Failed"), buf, GQ_ICON_DIALOG_ERROR, GENERIC_DIALOG(gdlg)->dialog);
                g_free(buf);
                }
 
        collection_unref(cd);
-       file_dialog_sync_history(fd, TRUE);
-
-       if (fd->type == DIALOG_SAVE_CLOSE) collection_window_close_by_collection(cd);
-       file_dialog_close(fd);
-
-       return TRUE;
+       collection_window_close_by_collection(cd);
 }
 
-static void collection_save_cb(FileDialog *fd, gpointer data)
+static void collection_save_cb(GenericDialog *gd, gpointer data)
 {
        auto cd = static_cast<CollectionData *>(data);
-       const gchar *path;
 
-       path = fd->dest_path;
-
-       /** @FIXME utf8 */
-       if (!file_extension_match(path, GQ_COLLECTION_EXT))
-               {
-               gchar *buf;
-               buf = g_strconcat(path, GQ_COLLECTION_EXT, NULL);
-               gtk_entry_set_text(GTK_ENTRY(fd->entry), buf);
-               g_free(buf);
-               }
+       cd->collection_path = g_strconcat(get_collections_dir(), G_DIR_SEPARATOR_S, gtk_entry_get_text(GTK_ENTRY(cd->dialog_name_entry)), GQ_COLLECTION_EXT, nullptr);
 
-       collection_save_confirmed(fd, FALSE, cd);
+       collection_save_confirmed(gd, FALSE, cd);
 }
 
-static void real_collection_button_pressed(FileDialog *fd, gpointer data, gint append)
+static void real_collection_button_pressed(GenericDialog *, gpointer data)
 {
        auto cd = static_cast<CollectionData *>(data);
-       gboolean err = FALSE;
-       std::unique_ptr<gchar, decltype(&g_free)> text{nullptr, g_free};
+       GList *collection_list = nullptr;
 
-       if (!isname(fd->dest_path))
-               {
-               err = TRUE;
-               text.reset(g_strdup_printf(_("No such file '%s'."), fd->dest_path));
-               }
-       if (!err && isdir(fd->dest_path))
-               {
-               err = TRUE;
-               text.reset(g_strdup_printf(_("'%s' is a directory, not a collection file."), fd->dest_path));
-               }
-       if (!err && !access_file(fd->dest_path, R_OK))
-               {
-               err = TRUE;
-               text.reset(g_strdup_printf(_("You do not have read permissions on the file '%s'."), fd->dest_path));
-               }
+       collect_manager_list(nullptr, nullptr, &collection_list);
 
-       if (err)
-               {
-               if (text)
-                       {
-                       file_util_warning_dialog(_("Can not open collection file"), text.get(), GQ_ICON_DIALOG_ERROR, nullptr);
-                       }
-               return;
-               }
-
-       if (append)
-               {
-               collection_load(cd, fd->dest_path, COLLECTION_LOAD_APPEND);
-               collection_unref(cd);
-               }
-       else
-               {
-               collection_window_new(fd->dest_path);
-               }
+       auto append_collection_path = static_cast<gchar *>(g_list_nth_data(collection_list, cd->collection_append_index));
+       collection_load(cd, append_collection_path, COLLECTION_LOAD_APPEND);
 
-       file_dialog_sync_history(fd, TRUE);
-       file_dialog_close(fd);
+       collection_unref(cd);
+       string_list_free(collection_list);
 }
 
-static void collection_load_cb(FileDialog *fd, gpointer data)
+static void collection_append_cb(GenericDialog *gd, gpointer data)
 {
-       real_collection_button_pressed(fd, data, FALSE);
+       real_collection_button_pressed(gd, data);
 }
 
-static void collection_append_cb(FileDialog *fd, gpointer data)
+static void collection_save_or_load_dialog_close_cb(GenericDialog *gdlg, gpointer data)
 {
-       real_collection_button_pressed(fd, data, TRUE);
+       auto cd = static_cast<CollectionData *>(data);
+
+       if (cd) collection_unref(cd);
+       generic_dialog_close(gdlg);
 }
 
-static void collection_save_or_load_dialog_close_cb(FileDialog *fd, gpointer data)
+static void collection_append_menu_cb(GtkWidget *collection_append_combo, gpointer data)
 {
-       auto cd = static_cast<CollectionData *>(data);
+       auto option = static_cast<gint *>(data);
 
-       if (cd) collection_unref(cd);
-       file_dialog_close(fd);
+       *option = gtk_combo_box_get_active(GTK_COMBO_BOX(collection_append_combo));
 }
 
-static void collection_save_or_load_dialog(const gchar *path,
-                                          gint type, CollectionData *cd)
+static void collection_save_or_append_dialog(gint type, CollectionData *cd)
 {
-       FileDialog *fd;
+       GenericDialog *gdlg;
        GtkWidget *parent = nullptr;
        CollectWindow *cw;
        const gchar *title;
        const gchar *btntext;
        gpointer btnfunc;
        const gchar *icon_name;
+       GList *collection_list = nullptr;
+       GList *work;
+       GString *out_string = g_string_new(nullptr);
+       GtkWidget *collection_append_combo;
+       GtkWidget *existing_collections;
+       GtkWidget *save_as_label;
+       GtkWidget *scrolled;
+       GtkWidget *viewport;
 
        if (type == DIALOG_SAVE || type == DIALOG_SAVE_CLOSE)
                {
                if (!cd) return;
                title = _("Save collection");
-               btntext = nullptr;
+               btntext = _("Save");
                btnfunc = reinterpret_cast<gpointer>(collection_save_cb);
                icon_name = GQ_ICON_SAVE;
                }
-       else if (type == DIALOG_LOAD)
-               {
-               title = _("Open collection");
-               btntext = nullptr;
-               btnfunc = reinterpret_cast<gpointer>(collection_load_cb);
-               icon_name = GQ_ICON_OPEN;
-               }
        else
                {
                if (!cd) return;
@@ -225,43 +162,100 @@ static void collection_save_or_load_dialog(const gchar *path,
        cw = collection_window_find(cd);
        if (cw) parent = cw->window;
 
-       fd = file_util_file_dlg(title, "dlg_collection", parent,
-                            collection_save_or_load_dialog_close_cb, cd);
+       if (g_strcmp0(icon_name, GQ_ICON_SAVE) == 0)
+               {
+               gdlg = file_util_gen_dlg(title, "dlg_collection_save", NULL, FALSE, collection_save_or_load_dialog_close_cb, cd);
 
-       generic_dialog_add_message(GENERIC_DIALOG(fd), nullptr, title, nullptr, FALSE);
-       file_dialog_add_button(fd, icon_name, btntext, reinterpret_cast<void (*)(FileDialog *, gpointer)>(btnfunc), TRUE);
+               generic_dialog_add_message(GENERIC_DIALOG(gdlg), nullptr, title, _("Existing collections:"), FALSE);
+               generic_dialog_add_button(gdlg, icon_name, btntext, reinterpret_cast<void (*)(GenericDialog *, gpointer)>(btnfunc), TRUE);
 
-       file_dialog_add_path_widgets(fd, get_collections_dir(), path,
-                                    "collection_load_save", GQ_COLLECTION_EXT, _("Collection Files"));
+               collect_manager_list(&collection_list, nullptr, nullptr);
 
-       fd->type = type;
+               work = collection_list;
+               while (work)
+                       {
+                       auto collection_name = static_cast<const gchar *>(work->data);
+                       out_string = g_string_append(out_string, g_strdup(collection_name));
+                       out_string = g_string_append(out_string, "\n");
 
-       gtk_widget_show(GENERIC_DIALOG(fd)->dialog);
-}
+                       work = work->next;
+                       }
 
-void collection_dialog_save_as(gchar *path, CollectionData *cd)
-{
-       if (!path) path = cd->path;
-       if (!path) path = cd->name;
+               string_list_free(collection_list);
+
+               existing_collections = gtk_label_new(out_string->str);
+
+               scrolled = gtk_scrolled_window_new(nullptr, nullptr);
+               gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(scrolled), GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC);
+               gtk_widget_show(scrolled);
+
+               viewport = gtk_viewport_new(nullptr, nullptr);
+               gtk_viewport_set_shadow_type(GTK_VIEWPORT(viewport), GTK_SHADOW_NONE);
+               gtk_container_add(GTK_CONTAINER(viewport), existing_collections);
+               gtk_widget_show(viewport);
+               gtk_widget_show(existing_collections);
+               gtk_container_add(GTK_CONTAINER(scrolled), viewport);
+
+               gtk_box_pack_start(GTK_BOX(gdlg->vbox), scrolled, TRUE,TRUE, 0);
 
-       collection_save_or_load_dialog(path, DIALOG_SAVE, cd);
+               save_as_label = gtk_label_new("Save collection as:");
+               gtk_box_pack_start(GTK_BOX(gdlg->vbox), save_as_label, FALSE,FALSE, 0);
+               gtk_label_set_xalign(GTK_LABEL(save_as_label), 0.0);
+               gtk_widget_show(save_as_label);
+
+               cd->dialog_name_entry = gtk_entry_new();
+               gtk_widget_show(cd->dialog_name_entry);
+
+               gtk_box_pack_start(GTK_BOX(gdlg->vbox), cd->dialog_name_entry, FALSE, FALSE, 0);
+
+               gtk_entry_set_text(GTK_ENTRY(cd->dialog_name_entry), cd->name);
+               gtk_widget_grab_focus(cd->dialog_name_entry);
+               gtk_widget_show(GENERIC_DIALOG(gdlg)->dialog);
+               }
+       else if (g_strcmp0(icon_name, GQ_ICON_ADD) == 0)
+               {
+               gdlg = file_util_gen_dlg(title, "dlg_collection_append", parent, true, nullptr, cd);
+
+               generic_dialog_add_message(GENERIC_DIALOG(gdlg), nullptr, title, _("Select from existing collections:"), FALSE);
+               generic_dialog_add_button(gdlg, GQ_ICON_CANCEL, _("Cancel"), nullptr, TRUE);
+               generic_dialog_add_button(gdlg, icon_name, btntext, reinterpret_cast<void (*)(GenericDialog *, gpointer)>(btnfunc), TRUE);
+
+               collect_manager_list(&collection_list, nullptr, nullptr);
+
+               collection_append_combo = gtk_combo_box_text_new();
+
+               work = collection_list;
+               while (work)
+                       {
+                       auto collection_name = static_cast<const gchar *>(work->data);
+                       gtk_combo_box_text_append_text(GTK_COMBO_BOX_TEXT(collection_append_combo), collection_name);
+                       work = work->next;
+                       }
+               string_list_free(collection_list);
+
+               gtk_combo_box_set_active(GTK_COMBO_BOX(collection_append_combo), 0);
+
+               g_signal_connect(G_OBJECT(collection_append_combo), "changed", G_CALLBACK(collection_append_menu_cb), &cd->collection_append_index);
+
+               gtk_widget_show(collection_append_combo);
+
+               gtk_box_pack_start(GTK_BOX(gdlg->vbox), collection_append_combo, TRUE,TRUE, 0);
+               gtk_widget_show(GENERIC_DIALOG(gdlg)->dialog);
+               }
 }
 
-void collection_dialog_save_close(gchar *path, CollectionData *cd)
+void collection_dialog_save_as(CollectionData *cd)
 {
-       if (!path) path = cd->path;
-       if (!path) path = cd->name;
-
-       collection_save_or_load_dialog(path, DIALOG_SAVE_CLOSE, cd);
+       collection_save_or_append_dialog(DIALOG_SAVE, cd);
 }
 
-void collection_dialog_load(gchar *path)
+void collection_dialog_save_close(CollectionData *cd)
 {
-       collection_save_or_load_dialog(path, DIALOG_LOAD, nullptr);
+       collection_save_or_append_dialog(DIALOG_SAVE_CLOSE, cd);
 }
 
-void collection_dialog_append(gchar *path, CollectionData *cd)
+void collection_dialog_append(CollectionData *cd)
 {
-       collection_save_or_load_dialog(path, DIALOG_APPEND, cd);
+       collection_save_or_append_dialog(DIALOG_APPEND, cd);
 }
 /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
index 6d5488b..8d7b6bc 100644 (file)
 #define COLLECT_DLG_H
 
 
-void collection_dialog_save_as(gchar *path, CollectionData *cd);
-void collection_dialog_save_close(gchar *path, CollectionData *cd);
+void collection_dialog_save_as(CollectionData *cd);
+void collection_dialog_save_close(CollectionData *cd);
 
-void collection_dialog_load(gchar *path);
-void collection_dialog_append(gchar *path, CollectionData *cd);
+//~ void collection_dialog_load(gchar *path);
+void collection_dialog_append(CollectionData *cd);
 
 
 #endif
index 6f909a7..a460938 100644 (file)
@@ -1062,7 +1062,7 @@ void collect_manager_list(GList **names_exc, GList **names_inc, GList **paths)
                                }
                        if (paths != nullptr)
                                {
-                               *paths = g_list_insert_sorted(*paths,fd->path,
+                               *paths = g_list_insert_sorted(*paths, g_strdup(fd->path),
                                                                                        collection_manager_sort_cb);
                                *paths = g_list_first(*paths);
                                }
index efb1ed3..1a79b1f 100644 (file)
@@ -95,6 +95,8 @@ hard_coded_window_keys collection_window_keys[] = {
        {static_cast<GdkModifierType>(0), 'B', N_("Sort by size")},
        {static_cast<GdkModifierType>(0), 'P', N_("Sort by path")},
        {GDK_SHIFT_MASK, 'P', N_("Print")},
+       {GDK_MOD1_MASK, 'A', N_("Append (Append collection dialog)")},
+       {GDK_MOD1_MASK, 'D', N_("Discard (Close modified collection dialog)")},
        {static_cast<GdkModifierType>(0), 0, nullptr}
 };
 
@@ -677,7 +679,7 @@ static void collection_table_popup_save_as_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
-       collection_dialog_save_as(nullptr, ct->cd);
+       collection_dialog_save_as(ct->cd);
 }
 
 static void collection_table_popup_save_cb(GtkWidget *widget, gpointer data)
@@ -887,7 +889,7 @@ static void collection_table_popup_add_collection_cb(GtkWidget *, gpointer data)
 {
        auto ct = static_cast<CollectTable *>(data);
 
-       collection_dialog_append(nullptr, ct->cd);
+       collection_dialog_append(ct->cd);
 }
 
 static void collection_table_popup_goto_original_cb(GtkWidget *, gpointer data)
index f5fea7d..57fe4c0 100644 (file)
@@ -502,6 +502,7 @@ void collection_free(CollectionData *cd)
 
        g_hash_table_destroy(cd->existence);
 
+       g_free(cd->collection_path);
        g_free(cd->path);
        g_free(cd->name);
 
@@ -977,7 +978,7 @@ static gboolean collection_window_keypress(GtkWidget *, GdkEventKey *event, gpoi
                                file_util_delete(nullptr, collection_table_selection_get_list(cw->table), cw->window);
                                break;
                        case 'S': case 's':
-                               collection_dialog_save_as(nullptr, cw->cd);
+                               collection_dialog_save_as(cw->cd);
                                break;
                        case 'W': case 'w':
                                collection_window_close(cw);
@@ -1003,7 +1004,7 @@ static gboolean collection_window_keypress(GtkWidget *, GdkEventKey *event, gpoi
                        case 'S': case 's':
                                if (!cw->cd->path)
                                        {
-                                       collection_dialog_save_as(nullptr, cw->cd);
+                                       collection_dialog_save_as(cw->cd);
                                        }
                                else if (!collection_save(cw->cd, cw->cd->path))
                                        {
@@ -1011,7 +1012,7 @@ static gboolean collection_window_keypress(GtkWidget *, GdkEventKey *event, gpoi
                                        }
                                break;
                        case 'A': case 'a':
-                               collection_dialog_append(nullptr, cw->cd);
+                               collection_dialog_append(cw->cd);
                                break;
                        case 'N': case 'n':
                                collection_set_sort_method(cw->cd, SORT_NAME);
@@ -1184,7 +1185,7 @@ static void collection_close_save_cb(GenericDialog *gd, gpointer data)
 
        if (!cw->cd->path)
                {
-               collection_dialog_save_close(nullptr, cw->cd);
+               collection_dialog_save_close(cw->cd);
                return;
                }
        else if (!collection_save(cw->cd, cw->cd->path))
index 53986ff..dc0e699 100644 (file)
@@ -29,6 +29,7 @@
 #include "cache-maint.h"
 #include "collect.h"
 #include "collect-dlg.h"
+#include "collect-io.h"
 #include "color-man.h"
 #include "dupe.h"
 #include "editors.h"
@@ -257,12 +258,29 @@ static void layout_menu_new_cb(GtkAction *, gpointer data)
        collection_window_new(nullptr);
 }
 
-static void layout_menu_open_cb(GtkAction *, gpointer data)
+static void layout_menu_open_cb(GtkAction *widget, gpointer data)
 {
        auto lw = static_cast<LayoutWindow *>(data);
+       gchar *path;
+       gint n;
+       GList *collection_list = nullptr;
 
        layout_exit_fullscreen(lw);
-       collection_dialog_load(nullptr);
+
+       n = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(widget), "recent_index"));
+       collect_manager_list(nullptr, nullptr, &collection_list);
+
+       path = static_cast<gchar *>(g_list_nth_data(collection_list, n));
+
+       if (path)
+               {
+               /* make a copy of it */
+               path = g_strdup(path);
+               collection_window_new(path);
+               g_free(path);
+               }
+
+       string_list_free(collection_list);
 }
 
 static void layout_menu_search_cb(GtkAction *, gpointer data)
@@ -1886,7 +1904,7 @@ static void layout_menu_recent_cb(GtkWidget *widget, gpointer)
        g_free(path);
 }
 
-static void layout_menu_recent_update(LayoutWindow *lw)
+static void layout_menu_collection_recent_update(LayoutWindow *lw)
 {
        GtkWidget *menu;
        GtkWidget *recent;
@@ -1934,6 +1952,62 @@ static void layout_menu_recent_update(LayoutWindow *lw)
        gtk_widget_set_sensitive(recent, (n != 0));
 }
 
+static void layout_menu_collection_open_update(LayoutWindow *lw)
+{
+       gboolean free_name = FALSE;
+       gchar *name;
+       gint n;
+       GList *collection_list = nullptr;
+       GList *work;
+       GtkWidget *item;
+       GtkWidget *menu;
+       GtkWidget *recent;
+
+       if (!lw->ui_manager) return;
+
+       collect_manager_list(&collection_list, nullptr, nullptr);
+
+       n = 0;
+
+       menu = gtk_menu_new();
+
+       work = collection_list;
+       while (work)
+               {
+               const gchar *filename = static_cast<gchar *>(work->data);
+
+               if (file_extension_match(filename, GQ_COLLECTION_EXT))
+                       {
+                       name = remove_extension_from_path(filename);
+                       free_name = TRUE;
+                       }
+               else
+                       {
+                       name = const_cast<gchar *>(filename);
+                       }
+
+               item = menu_item_add_simple(menu, name, G_CALLBACK(layout_menu_open_cb), lw);
+               if (free_name)
+                       {
+                       g_free(name);
+                       }
+               g_object_set_data(G_OBJECT(item), "recent_index", GINT_TO_POINTER(n));
+               work = work->next;
+               n++;
+               }
+
+       string_list_free(collection_list);
+
+       if (n == 0)
+               {
+               menu_item_add(menu, _("Empty"), nullptr, nullptr);
+               }
+
+       recent = gtk_ui_manager_get_widget(lw->ui_manager, "/MainMenu/FileMenu/OpenCollection");
+       gtk_menu_item_set_submenu(GTK_MENU_ITEM(recent), menu);
+       gtk_widget_set_sensitive(recent, (n != 0));
+}
+
 void layout_recent_update_all()
 {
        GList *work;
@@ -1944,7 +2018,8 @@ void layout_recent_update_all()
                auto lw = static_cast<LayoutWindow *>(work->data);
                work = work->next;
 
-               layout_menu_recent_update(lw);
+               layout_menu_collection_recent_update(lw);
+               layout_menu_collection_open_update(lw);
                }
 }
 
@@ -2511,7 +2586,7 @@ static GtkActionEntry menu_entries[] = {
   { "RenameWindow",    GQ_ICON_EDIT,           N_("Rename window"),    nullptr,        N_("Rename window"),    CB(layout_menu_window_rename_cb) },
   { "DeleteWindow",    GQ_ICON_DELETE,         N_("Delete window"),    nullptr,        N_("Delete window"),    CB(layout_menu_window_delete_cb) },
   { "NewCollection",   GQ_ICON_COLLECTION,     N_("_New collection"),                  "C",                    N_("New collection"),                   CB(layout_menu_new_cb) },
-  { "OpenCollection",  GQ_ICON_OPEN,           N_("_Open collection..."),              "O",                    N_("Open collection..."),               CB(layout_menu_open_cb) },
+  { "OpenCollection",  GQ_ICON_OPEN,           N_("_Open collection..."),              "O",                    N_("Open collection..."),               nullptr },
   { "OpenRecent",      nullptr,                        N_("Open recen_t"),                     nullptr,                        N_("Open recent collection"),                   nullptr },
   { "Search",          GQ_ICON_FIND,           N_("_Search..."),                       "F3",                   N_("Search..."),                        CB(layout_menu_search_cb) },
   { "FindDupes",       GQ_ICON_FIND,           N_("_Find duplicates..."),              "D",                    N_("Find duplicates..."),               CB(layout_menu_dupes_cb) },
@@ -3880,7 +3955,8 @@ void layout_util_sync(LayoutWindow *lw)
 {
        layout_util_sync_views(lw);
        layout_util_sync_thumb(lw);
-       layout_menu_recent_update(lw);
+       layout_menu_collection_recent_update(lw);
+       layout_menu_collection_open_update(lw);
 }
 
 /**
index 8fae7db..55c303d 100644 (file)
@@ -451,6 +451,10 @@ struct CollectionData
        gboolean changed; /**< contents changed since save flag */
 
        GHashTable *existence;
+
+       GtkWidget *dialog_name_entry;
+       gchar *collection_path; /**< Full path to collection including extension */
+       gint collection_append_index;
 };
 
 struct CollectTable