Revision: 1528
          http://geeqie.svn.sourceforge.net/geeqie/?rev=1528&view=rev
Author:   nadvornik
Date:     2009-03-14 17:21:35 +0000 (Sat, 14 Mar 2009)

Log Message:
-----------
improved notification system

Modified Paths:
--------------
    trunk/src/cache_maint.c
    trunk/src/collect-io.c
    trunk/src/collect.c
    trunk/src/dupe.c
    trunk/src/filecache.c
    trunk/src/filedata.c
    trunk/src/histogram.c
    trunk/src/image.c
    trunk/src/img-view.c
    trunk/src/layout_image.c
    trunk/src/metadata.c
    trunk/src/search.c
    trunk/src/thumb.c
    trunk/src/typedefs.h
    trunk/src/view_dir.c
    trunk/src/view_file.c

Modified: trunk/src/cache_maint.c
===================================================================
--- trunk/src/cache_maint.c     2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/cache_maint.c     2009-03-14 17:21:35 UTC (rev 1528)
@@ -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)
                {

Modified: trunk/src/collect-io.c
===================================================================
--- trunk/src/collect-io.c      2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/collect-io.c      2009-03-14 17:21:35 UTC (rev 1528)
@@ -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)
                {

Modified: trunk/src/collect.c
===================================================================
--- trunk/src/collect.c 2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/collect.c 2009-03-14 17:21:35 UTC (rev 1528)
@@ -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)
                {

Modified: trunk/src/dupe.c
===================================================================
--- trunk/src/dupe.c    2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/dupe.c    2009-03-14 17:21:35 UTC (rev 1528)
@@ -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)
                {

Modified: trunk/src/filecache.c
===================================================================
--- trunk/src/filecache.c       2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/filecache.c       2009-03-14 17:21:35 UTC (rev 1528)
@@ -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);
                }

Modified: trunk/src/filedata.c
===================================================================
--- trunk/src/filedata.c        2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/filedata.c        2009-03-14 17:21:35 UTC (rev 1528)
@@ -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;
 }

Modified: trunk/src/histogram.c
===================================================================
--- trunk/src/histogram.c       2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/histogram.c       2009-03-14 17:21:35 UTC (rev 1528)
@@ -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;

Modified: trunk/src/image.c
===================================================================
--- trunk/src/image.c   2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/image.c   2009-03-14 17:21:35 UTC (rev 1528)
@@ -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);
                }

Modified: trunk/src/img-view.c
===================================================================
--- trunk/src/img-view.c        2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/img-view.c        2009-03-14 17:21:35 UTC (rev 1528)
@@ -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)
                {

Modified: trunk/src/layout_image.c
===================================================================
--- trunk/src/layout_image.c    2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/layout_image.c    2009-03-14 17:21:35 UTC (rev 1528)
@@ -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)
                {

Modified: trunk/src/metadata.c
===================================================================
--- trunk/src/metadata.c        2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/metadata.c        2009-03-14 17:21:35 UTC (rev 1528)
@@ -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))
                {

Modified: trunk/src/search.c
===================================================================
--- trunk/src/search.c  2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/search.c  2009-03-14 17:21:35 UTC (rev 1528)
@@ -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)
                {

Modified: trunk/src/thumb.c
===================================================================
--- trunk/src/thumb.c   2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/thumb.c   2009-03-14 17:21:35 UTC (rev 1528)
@@ -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;

Modified: trunk/src/typedefs.h
===================================================================
--- trunk/src/typedefs.h        2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/typedefs.h        2009-03-14 17:21:35 UTC (rev 1528)
@@ -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 {

Modified: trunk/src/view_dir.c
===================================================================
--- trunk/src/view_dir.c        2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/view_dir.c        2009-03-14 17:21:35 UTC (rev 1528)
@@ -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)
                                {

Modified: trunk/src/view_file.c
===================================================================
--- trunk/src/view_file.c       2009-03-14 11:26:43 UTC (rev 1527)
+++ trunk/src/view_file.c       2009-03-14 17:21:35 UTC (rev 1528)
@@ -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)
                        {


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Apps built with the Adobe(R) Flex(R) framework and Flex Builder(TM) are
powering Web 2.0 with engaging, cross-platform capabilities. Quickly and
easily build your RIAs with Flex Builder, the Eclipse(TM)based development
software that enables intelligent coding and step-through debugging.
Download the free 60 day trial. http://p.sf.net/sfu/www-adobe-com
_______________________________________________
Geeqie-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/geeqie-svn

Reply via email to