Mercurial > geeqie.yaz
changeset 1432:cf4029d10d38
improved notification system
author | nadvornik |
---|---|
date | Sat, 14 Mar 2009 17:21:35 +0000 |
parents | 7e180091e0b7 |
children | b4ad1d201279 |
files | src/cache_maint.c src/collect-io.c src/collect.c src/dupe.c src/filecache.c src/filedata.c src/histogram.c src/image.c src/img-view.c src/layout_image.c src/metadata.c src/search.c src/thumb.c src/typedefs.h src/view_dir.c src/view_file.c |
diffstat | 16 files changed, 40 insertions(+), 33 deletions(-) [+] |
line wrap: on
line diff
--- a/src/cache_maint.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/cache_maint.c Sat Mar 14 17:21:35 2009 +0000 @@ -621,7 +621,7 @@ void cache_notify_cb(FileData *fd, NotifyType type, gpointer data) { - if (type != NOTIFY_TYPE_CHANGE || !fd->change) return; + if (!(type & NOTIFY_CHANGE) || !fd->change) return; switch (fd->change->type) {
--- a/src/collect-io.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/collect-io.c Sat Mar 14 17:21:35 2009 +0000 @@ -934,7 +934,7 @@ void collect_manager_notify_cb(FileData *fd, NotifyType type, gpointer data) { - if (type != NOTIFY_TYPE_CHANGE || !fd->change) return; + if (!(type & NOTIFY_CHANGE) || !fd->change) return; switch (fd->change->type) {
--- a/src/collect.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/collect.c Sat Mar 14 17:21:35 2009 +0000 @@ -749,7 +749,7 @@ { CollectionData *cd = data; - if (type != NOTIFY_TYPE_CHANGE || !fd->change) return; + if (!(type & NOTIFY_CHANGE) || !fd->change) return; switch (fd->change->type) {
--- a/src/dupe.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/dupe.c Sat Mar 14 17:21:35 2009 +0000 @@ -3571,7 +3571,7 @@ { DupeWindow *dw = data; - if (type != NOTIFY_TYPE_CHANGE || !fd->change) return; + if (!(type & NOTIFY_CHANGE) || !fd->change) return; switch (fd->change->type) {
--- a/src/filecache.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/filecache.c Sat Mar 14 17:21:35 2009 +0000 @@ -181,7 +181,7 @@ { FileCacheData *fc = data; - if (type != NOTIFY_TYPE_INTERNAL) /* invalidate the entry on each file change */ + if (type & (NOTIFY_REREAD | NOTIFY_CHANGE)) /* invalidate the entry on each file change */ { file_cache_remove_fd(fc, fd); }
--- a/src/filedata.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/filedata.c Sat Mar 14 17:21:35 2009 +0000 @@ -243,7 +243,7 @@ if (fd->thumb_pixbuf) g_object_unref(fd->thumb_pixbuf); fd->thumb_pixbuf = NULL; file_data_increment_version(fd); - file_data_send_notification(fd, NOTIFY_TYPE_REREAD); + file_data_send_notification(fd, NOTIFY_REREAD); ret = TRUE; } @@ -295,7 +295,7 @@ file_data_disconnect_sidecar_file(fd, sfd); } if (sfd) file_data_check_sidecars(sfd); /* this will group the sidecars back together */ - file_data_send_notification(fd, NOTIFY_TYPE_REREAD); + file_data_send_notification(fd, NOTIFY_REREAD); } else { @@ -601,8 +601,8 @@ { FileData *parent = file_data_ref(fd->parent); file_data_disconnect_sidecar_file(parent, fd); - file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); - file_data_send_notification(parent, NOTIFY_TYPE_INTERNAL); + file_data_send_notification(fd, NOTIFY_GROUPING); + file_data_send_notification(parent, NOTIFY_GROUPING); file_data_unref(parent); } else if (fd->sidecar_files) @@ -614,9 +614,9 @@ FileData *sfd = work->data; work = work->next; file_data_disconnect_sidecar_file(fd, sfd); - file_data_send_notification(sfd, NOTIFY_TYPE_INTERNAL); + file_data_send_notification(sfd, NOTIFY_GROUPING); } - file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); + file_data_send_notification(fd, NOTIFY_GROUPING); file_data_check_sidecars((FileData *)sidecar_files->data); /* this will group the sidecars back together */ filelist_free(sidecar_files); } @@ -624,7 +624,7 @@ else { file_data_check_sidecars(fd); - file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); + file_data_send_notification(fd, NOTIFY_GROUPING); } } @@ -1151,7 +1151,7 @@ } file_data_increment_version(fd); - file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); + file_data_send_notification(fd, NOTIFY_MARKS); } gboolean file_data_filter_marks(FileData *fd, guint filter) @@ -1187,7 +1187,7 @@ { FileData *fd = value; file_data_increment_version(fd); - file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); + file_data_send_notification(fd, NOTIFY_MARKS); } gboolean file_data_register_mark_func(gint n, FileDataGetMarkFunc get_mark_func, FileDataSetMarkFunc set_mark_func, gpointer data, GDestroyNotify notify) @@ -1228,7 +1228,7 @@ fd->user_orientation = value; file_data_increment_version(fd); - file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); + file_data_send_notification(fd, NOTIFY_ORIENTATION); } @@ -2213,7 +2213,7 @@ } } file_data_increment_version(fd); - file_data_send_notification(fd, NOTIFY_TYPE_CHANGE); + file_data_send_notification(fd, NOTIFY_CHANGE); return TRUE; }
--- a/src/histogram.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/histogram.c Sat Mar 14 17:21:35 2009 +0000 @@ -320,7 +320,7 @@ void histogram_notify_cb(FileData *fd, NotifyType type, gpointer data) { - if (type != NOTIFY_TYPE_INTERNAL && fd->histmap) + if ((type & (NOTIFY_CHANGE || NOTIFY_REREAD)) && fd->histmap) { g_free(fd->histmap); fd->histmap = NULL;
--- a/src/image.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/image.c Sat Mar 14 17:21:35 2009 +0000 @@ -514,7 +514,7 @@ g_assert(fd->pixbuf); file_cache_put(image_get_cache(), fd, (gulong)gdk_pixbuf_get_rowstride(fd->pixbuf) * (gulong)gdk_pixbuf_get_height(fd->pixbuf)); - file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); /* to update histogram */ + file_data_send_notification(fd, NOTIFY_PIXBUF); /* to update histogram */ } static gint image_cache_get(ImageWindow *imd) @@ -1379,7 +1379,7 @@ imd->state == IMAGE_STATE_NONE /* loading not started, no need to reload */ ) return; - if (type == NOTIFY_TYPE_REREAD && fd == imd->image_fd) + if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE)) && fd == imd->image_fd) { image_reload(imd); }
--- a/src/img-view.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/img-view.c Sat Mar 14 17:21:35 2009 +0000 @@ -1702,7 +1702,7 @@ { ViewWindow *vw = data; - if (type != NOTIFY_TYPE_CHANGE || !fd->change) return; + if (!(type & NOTIFY_CHANGE) || !fd->change) return; switch (fd->change->type) {
--- a/src/layout_image.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/layout_image.c Sat Mar 14 17:21:35 2009 +0000 @@ -1879,7 +1879,7 @@ { LayoutWindow *lw = data; - if (type != NOTIFY_TYPE_CHANGE || !fd->change) return; + if (!(type & NOTIFY_CHANGE) || !fd->change) return; switch (fd->change->type) {
--- a/src/metadata.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/metadata.c Sat Mar 14 17:21:35 2009 +0000 @@ -80,7 +80,7 @@ metadata_write_queue = g_list_remove(metadata_write_queue, fd); file_data_increment_version(fd); - file_data_send_notification(fd, NOTIFY_TYPE_REREAD); + file_data_send_notification(fd, NOTIFY_REREAD); file_data_unref(fd); @@ -202,7 +202,7 @@ } metadata_write_queue_add(fd); file_data_increment_version(fd); - file_data_send_notification(fd, NOTIFY_TYPE_INTERNAL); + file_data_send_notification(fd, NOTIFY_METADATA); if (options->metadata.sync_grouped_files && metadata_check_key(group_keys, key)) {
--- a/src/search.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/search.c Sat Mar 14 17:21:35 2009 +0000 @@ -2945,7 +2945,7 @@ { SearchData *sd = data; - if (type != NOTIFY_TYPE_CHANGE || !fd->change) return; + if (!(type & NOTIFY_CHANGE) || !fd->change) return; switch (fd->change->type) {
--- a/src/thumb.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/thumb.c Sat Mar 14 17:21:35 2009 +0000 @@ -534,7 +534,7 @@ /* release thumb_pixbuf on file change - this forces reload. */ void thumb_notify_cb(FileData *fd, NotifyType type, gpointer data) { - if (type != NOTIFY_TYPE_INTERNAL && fd->thumb_pixbuf) + if ((type & (NOTIFY_REREAD | NOTIFY_CHANGE)) && fd->thumb_pixbuf) { g_object_unref(fd->thumb_pixbuf); fd->thumb_pixbuf = NULL;
--- a/src/typedefs.h Sat Mar 14 11:26:43 2009 +0000 +++ b/src/typedefs.h Sat Mar 14 17:21:35 2009 +0000 @@ -142,9 +142,14 @@ } NotifyPriority; typedef enum { - NOTIFY_TYPE_INTERNAL = 0, /* changed internal data only, like marks */ - NOTIFY_TYPE_REREAD, /* changed file size, date, etc., file name remains unchanged */ - NOTIFY_TYPE_CHANGE /* generic change described by fd->change */ + NOTIFY_MARKS = 1 << 1, /* changed marks */ + NOTIFY_PIXBUF = 1 << 2, /* image was read into fd->pixbuf */ + NOTIFY_HISTMAP = 1 << 3, /* histmap was read into fd->histmap */ + NOTIFY_ORIENTATION = 1 << 4, /* image was rotated */ + NOTIFY_METADATA = 1 << 5, /* changed image metadata, not yet written */ + NOTIFY_GROUPING = 1 << 6, /* change in fd->sidecar_files or fd->parent */ + NOTIFY_REREAD = 1 << 7, /* changed file size, date, etc., file name remains unchanged */ + NOTIFY_CHANGE = 1 << 8 /* generic change described by fd->change */ } NotifyType; typedef enum {
--- a/src/view_dir.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/view_dir.c Sat Mar 14 17:21:35 2009 +0000 @@ -1038,7 +1038,7 @@ refresh = (strcmp(base, vd->dir_fd->path) == 0); } - if (type == NOTIFY_TYPE_CHANGE && fd->change) + if ((type & NOTIFY_CHANGE) && fd->change) { if (!refresh && fd->change->dest) {
--- a/src/view_file.c Sat Mar 14 11:26:43 2009 +0000 +++ b/src/view_file.c Sat Mar 14 17:21:35 2009 +0000 @@ -824,10 +824,12 @@ ViewFile *vf = data; gboolean refresh; - if (vf->refresh_idle_id != -1) return; + NotifyType interested = NOTIFY_CHANGE | NOTIFY_REREAD | NOTIFY_GROUPING; + if (vf->marks_enabled) interested |= NOTIFY_MARKS | NOTIFY_METADATA; + /* FIXME: NOTIFY_METADATA should be checked by the keyword-to-mark functions and converted to NOTIFY_MARKS only if there was a change */ - if (!vf->dir_fd) return; - + if (!(type & interested) || vf->refresh_idle_id != -1 || !vf->dir_fd) return; + refresh = (fd == vf->dir_fd); if (!refresh) @@ -837,7 +839,7 @@ g_free(base); } - if (type == NOTIFY_TYPE_CHANGE && fd->change) + if ((type & NOTIFY_CHANGE) && fd->change) { if (!refresh && fd->change->dest) {