Save Collection window geometry
authorColin Clark <colin.clark@cclark.uk>
Sun, 10 Sep 2017 18:24:20 +0000 (19:24 +0100)
committerColin Clark <colin.clark@cclark.uk>
Sun, 10 Sep 2017 18:24:20 +0000 (19:24 +0100)
Previously collection window geometry was preserved only when an
explicit save was made.
This patch ensures the window position is always saved, unless the
window has unsaved data.

src/collect-table.c
src/collect.c

index 3eed2e0..75be016 100644 (file)
@@ -2502,6 +2502,16 @@ static void collection_table_destroy(GtkWidget *widget, gpointer data)
 {
        CollectTable *ct = data;
 
+       /* If there is no unsaved data, save the window geometry
+        */
+       if (!ct->cd->changed)
+               {
+               if (!collection_save(ct->cd, ct->cd->path))
+                       {
+                       log_printf("failed saving to collection path: %s\n", ct->cd->path);
+                       }
+               }
+
        if (ct->popup)
                {
                g_signal_handlers_disconnect_matched(G_OBJECT(ct->popup), G_SIGNAL_MATCH_DATA,
index 358091b..94cfab1 100644 (file)
@@ -1194,19 +1194,39 @@ void collection_window_close_by_collection(CollectionData *cd)
        if (cw) collection_window_close_final(cw);
 }
 
+/**
+ * @brief Check if any Collection windows have unsaved data
+ * @returns TRUE if unsaved data exists
+ * 
+ * Also saves window geometry for Collection windows that have
+ * no unsaved data
+ */
 gboolean collection_window_modified_exists(void)
 {
        GList *work;
+       gboolean ret;
+
+       ret = FALSE;
 
        work = collection_window_list;
        while (work)
                {
                CollectWindow *cw = work->data;
-               if (cw->cd->changed) return TRUE;
+               if (cw->cd->changed)
+                       {
+                       ret = TRUE;
+                       }
+               else
+                       {
+                       if (!collection_save(cw->table->cd, cw->table->cd->path))
+                               {
+                               log_printf("failed saving to collection path: %s\n", cw->table->cd->path);
+                               }
+                       }
                work = work->next;
                }
 
-       return FALSE;
+       return ret;
 }
 
 static gboolean collection_window_delete(GtkWidget *widget, GdkEvent *event, gpointer data)