changeset 1214:31402ecb2aed

write metadata after timeout, image change or dir change
author nadvornik
date Mon, 22 Dec 2008 18:29:25 +0000
parents bbec86370ef4
children 2b57c3d43f72
files src/layout.c src/layout_util.c src/main.c src/metadata.c src/metadata.h
diffstat 5 files changed, 32 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/layout.c	Mon Dec 22 18:15:26 2008 +0000
+++ b/src/layout.c	Mon Dec 22 18:29:25 2008 +0000
@@ -32,6 +32,7 @@
 #include "ui_misc.h"
 #include "ui_tabcomp.h"
 #include "window.h"
+#include "metadata.h"
 
 #ifdef HAVE_LIRC
 #include "lirc.h"
@@ -1045,6 +1046,9 @@
 		layout_image_set_index(lw, 0);
 		}
 
+	if (options->metadata.confirm_on_dir_change)
+		metadata_write_queue_confirm();
+
 	return TRUE;
 }
 
--- a/src/layout_util.c	Mon Dec 22 18:15:26 2008 +0000
+++ b/src/layout_util.c	Mon Dec 22 18:29:25 2008 +0000
@@ -43,6 +43,7 @@
 #include "utilops.h"
 #include "view_dir.h"
 #include "window.h"
+#include "metadata.h"
 
 #include <gdk/gdkkeysyms.h> /* for keyboard values */
 
@@ -2036,6 +2037,10 @@
 {
 	layout_bar_info_new_image(lw);
 	layout_bar_exif_new_image(lw);
+
+	/* this should be called here to handle the metadata edited in bars */
+	if (options->metadata.confirm_on_image_change)
+		metadata_write_queue_confirm();
 }
 
 void layout_bars_new_selection(LayoutWindow *lw, gint count)
--- a/src/main.c	Mon Dec 22 18:15:26 2008 +0000
+++ b/src/main.c	Mon Dec 22 18:29:25 2008 +0000
@@ -30,6 +30,7 @@
 #include "ui_utildlg.h"
 #include "cache_maint.h"
 #include "thumb.h"
+#include "metadata.h"
 
 #include <gdk/gdkkeysyms.h> /* for keyboard values */
 
@@ -648,6 +649,8 @@
 {
 	layout_image_full_screen_stop(NULL);
 
+	if (metadata_write_queue_confirm()) return;
+
 	if (exit_confirm_dlg()) return;
 
 	exit_program_final();
--- a/src/metadata.c	Mon Dec 22 18:15:26 2008 +0000
+++ b/src/metadata.c	Mon Dec 22 18:29:25 2008 +0000
@@ -123,7 +123,16 @@
 	metadata_write_queue = g_list_prepend(metadata_write_queue, fd);
 	file_data_ref(fd);
 
-	if (metadata_write_idle_id == -1) metadata_write_idle_id = g_idle_add(metadata_write_queue_idle_cb, NULL);
+	if (metadata_write_idle_id != -1) 
+		{
+		g_source_remove(metadata_write_idle_id);
+		metadata_write_idle_id = -1;
+		}
+	
+	if (options->metadata.confirm_timeout > 0)
+		{
+		metadata_write_idle_id = g_timeout_add(options->metadata.confirm_timeout * 1000, metadata_write_queue_idle_cb, NULL);
+		}
 }
 
 
@@ -161,7 +170,7 @@
 }
 
 
-static gboolean metadata_write_queue_idle_cb(gpointer data)
+gboolean metadata_write_queue_confirm()
 {
 	GList *work;
 	GList *to_approve = NULL;
@@ -184,11 +193,18 @@
 	file_util_write_metadata(NULL, to_approve, NULL);
 	
 	filelist_free(to_approve);
+	
+	return (metadata_write_queue != NULL);
+}
 
+static gboolean metadata_write_queue_idle_cb(gpointer data)
+{
+	metadata_write_queue_confirm();
 	metadata_write_idle_id = -1;
 	return FALSE;
 }
 
+
 gboolean metadata_write_exif(FileData *fd, FileData *sfd)
 {
 	gboolean success;
--- a/src/metadata.h	Mon Dec 22 18:15:26 2008 +0000
+++ b/src/metadata.h	Mon Dec 22 18:29:25 2008 +0000
@@ -16,6 +16,8 @@
 gboolean metadata_write_queue_remove(FileData *fd);
 gboolean metadata_write_queue_remove_list(GList *list);
 gboolean metadata_write_perform(FileData *fd);
+gboolean metadata_write_queue_confirm(void);
+
 
 
 gint metadata_write(FileData *fd, GList *keywords, const gchar *comment);