changeset 2595:7b75f6d95758

Save Collection window geometry 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.
author Colin Clark <colin.clark@cclark.uk>
date Sun, 10 Sep 2017 19:24:20 +0100
parents 6af5b8db48bb
children 9c435c86a296
files src/collect-table.c src/collect.c
diffstat 2 files changed, 32 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/collect-table.c	Sun Sep 10 11:11:00 2017 +0100
+++ b/src/collect-table.c	Sun Sep 10 19:24:20 2017 +0100
@@ -2502,6 +2502,16 @@
 {
 	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,
--- a/src/collect.c	Sun Sep 10 11:11:00 2017 +0100
+++ b/src/collect.c	Sun Sep 10 19:24:20 2017 +0100
@@ -1194,19 +1194,39 @@
 	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)