# HG changeset patch # User nadvornik # Date 1229970565 0 # Node ID 31402ecb2aed0cacd698accbe15d042ca6e90b4f # Parent bbec86370ef4a0be4a42e7f75b1843aaae031752 write metadata after timeout, image change or dir change diff -r bbec86370ef4 -r 31402ecb2aed src/layout.c --- 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; } diff -r bbec86370ef4 -r 31402ecb2aed src/layout_util.c --- 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 /* 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) diff -r bbec86370ef4 -r 31402ecb2aed src/main.c --- 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 /* 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(); diff -r bbec86370ef4 -r 31402ecb2aed src/metadata.c --- 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; diff -r bbec86370ef4 -r 31402ecb2aed src/metadata.h --- 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);