used new notification in cache_maint
authorVladimir Nadvornik <nadvornik@suse.cz>
Fri, 6 Jun 2008 22:34:15 +0000 (22:34 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Fri, 6 Jun 2008 22:34:15 +0000 (22:34 +0000)
src/cache_maint.c
src/cache_maint.h
src/main.c
src/utilops.c

index fd7a58c..5ab56fa 100644 (file)
@@ -520,7 +520,7 @@ static void cache_file_move(const gchar *src, const gchar *dest)
                }
 }
 
-void cache_maint_moved(FileData *fd)
+static void cache_maint_moved(FileData *fd)
 {
        gchar *base;
        mode_t mode = 0755;
@@ -579,7 +579,7 @@ static void cache_file_remove(const gchar *path)
                }
 }
 
-void cache_maint_removed(FileData *fd)
+static void cache_maint_removed(FileData *fd)
 {
        gchar *buf;
 
@@ -599,7 +599,7 @@ void cache_maint_removed(FileData *fd)
                thumb_std_maint_removed(fd->path);
 }
 
-void cache_maint_copied(FileData *fd)
+static void cache_maint_copied(FileData *fd)
 {
        gchar *dest_base;
        gchar *src_cache;
@@ -625,6 +625,28 @@ void cache_maint_copied(FileData *fd)
        g_free(src_cache);
 }
 
+void cache_notify_cb(FileData *fd, NotifyType type, gpointer data)
+{
+       if (!fd->change) return;
+       
+       switch(fd->change->type)
+               {
+               case FILEDATA_CHANGE_MOVE:
+               case FILEDATA_CHANGE_RENAME:
+                       cache_maint_moved(fd);
+                       break;
+               case FILEDATA_CHANGE_COPY:
+                       cache_maint_copied(fd);
+                       break;
+               case FILEDATA_CHANGE_DELETE:
+                       cache_maint_removed(fd);
+                       break;
+               case FILEDATA_CHANGE_UNSPECIFIED:
+                       break;
+               }
+}
+
+
 /*
  *-------------------------------------------------------------------
  * new cache maintenance utilities
index 9517f26..341b1d4 100644 (file)
@@ -22,9 +22,7 @@ gint cache_maintain_home_dir(const gchar *dir, gint recursive, gint clear);
 gint cache_maintain_dir(const gchar *dir, gint recursive, gint clear);
 #endif
 
-void cache_maint_moved(FileData *fd);
-void cache_maint_removed(FileData *fd);
-void cache_maint_copied(FileData *fd);
+void cache_notify_cb(FileData *fd, NotifyType type, gpointer data);
 
 
 void cache_manager_show(void);
index 034383c..69693ad 100644 (file)
@@ -27,6 +27,7 @@
 #include "ui_bookmark.h"
 #include "ui_fileops.h"
 #include "ui_utildlg.h"
+#include "cache_maint.h"
 
 #include <gdk/gdkkeysyms.h> /* for keyboard values */
 
@@ -679,6 +680,10 @@ int main(int argc, char *argv[])
 #if 1
        log_printf("%s %s, This is an alpha release.\n", GQ_APPNAME, VERSION);
 #endif
+
+       /* register global notify functions */
+       file_data_register_notify_func(cache_notify_cb, NULL, NOTIFY_PRIORITY_HIGH);
+
        parse_command_line_for_debug_option(argc, argv);
 
        options = init_options(NULL);
index 5cc662e..d2dff23 100644 (file)
@@ -243,7 +243,6 @@ void file_data_notify_ci(FileData *fd)
        switch (type)
                {
                case FILEDATA_CHANGE_MOVE:
-                       cache_maint_moved(fd);
                        collection_maint_renamed(fd);
 
                        layout_maint_moved(fd, NULL);
@@ -252,10 +251,8 @@ void file_data_notify_ci(FileData *fd)
                        search_maint_renamed(fd);
                        break;
                case FILEDATA_CHANGE_COPY:
-                       cache_maint_copied(fd);
                        break;
                case FILEDATA_CHANGE_RENAME:
-                       cache_maint_moved(fd);
                        collection_maint_renamed(fd);
 
                        layout_maint_renamed(fd);
@@ -270,7 +267,6 @@ void file_data_notify_ci(FileData *fd)
                        search_maint_removed(fd);
 
                        collection_maint_removed(fd);
-                       cache_maint_removed(fd);
                        break;
                case FILEDATA_CHANGE_UNSPECIFIED:
                        /* FIXME */