used new notification in dupe.c
authorVladimir Nadvornik <nadvornik@suse.cz>
Sat, 7 Jun 2008 07:45:08 +0000 (07:45 +0000)
committerVladimir Nadvornik <nadvornik@suse.cz>
Sat, 7 Jun 2008 07:45:08 +0000 (07:45 +0000)
src/dupe.c
src/dupe.h
src/utilops.c

index 4694e96..d25dee8 100644 (file)
@@ -82,6 +82,8 @@ static GtkWidget *dupe_menu_popup_second(DupeWindow *dw, DupeItem *di);
 
 static void dupe_dnd_init(DupeWindow *dw);
 
+static void dupe_notify_cb(FileData *fd, NotifyType type, gpointer data);
+
 /*
  * ------------------------------------------------------------------
  * Window updates
@@ -3081,6 +3083,8 @@ void dupe_window_close(DupeWindow *dw)
 
        dupe_list_free(dw->second_list);
 
+       file_data_unregister_notify_func(dupe_notify_cb, dw);
+
        g_free(dw);
 }
 
@@ -3273,6 +3277,8 @@ DupeWindow *dupe_window_new(DupeMatchType match_mask)
 
        dupe_window_list = g_list_append(dupe_window_list, dw);
 
+       file_data_register_notify_func(dupe_notify_cb, dw, NOTIFY_PRIORITY_MEDIUM);
+
        return dw;
 }
 
@@ -3556,31 +3562,25 @@ static void dupe_dnd_init(DupeWindow *dw)
  *-------------------------------------------------------------------
  */
 
-void dupe_maint_removed(FileData *fd)
-{
-       GList *work;
-
-       work = dupe_window_list;
-       while (work)
-               {
-               DupeWindow *dw = work->data;
-               work = work->next;
-
-               while (dupe_item_remove_by_path(dw, fd->path));
-               }
-}
-
-void dupe_maint_renamed(FileData *fd)
+static void dupe_notify_cb(FileData *fd, NotifyType type, gpointer data)
 {
-       GList *work;
+       DupeWindow *dw = data;
 
-       work = dupe_window_list;
-       while (work)
+       if (!fd->change) return;
+       
+       switch(fd->change->type)
                {
-               DupeWindow *dw = work->data;
-               work = work->next;
-
-               dupe_item_update_fd(dw, fd);
+               case FILEDATA_CHANGE_MOVE:
+               case FILEDATA_CHANGE_RENAME:
+                       dupe_item_update_fd(dw, fd);
+                       break;
+               case FILEDATA_CHANGE_COPY:
+                       break;
+               case FILEDATA_CHANGE_DELETE:
+                       while (dupe_item_remove_by_path(dw, fd->path));
+                       break;
+               case FILEDATA_CHANGE_UNSPECIFIED:
+                       break;
                }
 
 }
index 4376640..7b4262b 100644 (file)
@@ -120,10 +120,6 @@ void dupe_window_close(DupeWindow *dw);
 void dupe_window_add_collection(DupeWindow *dw, CollectionData *collection);
 void dupe_window_add_files(DupeWindow *dw, GList *list, gint recurse);
 
-void dupe_maint_removed(FileData *fd);
-void dupe_maint_renamed(FileData *fd);
-
-
 /* cell max with/height hack utility */
 void cell_renderer_height_override(GtkCellRenderer *renderer);
 
index d2dff23..eb4a9f2 100644 (file)
@@ -247,7 +247,6 @@ void file_data_notify_ci(FileData *fd)
 
                        layout_maint_moved(fd, NULL);
                        view_window_maint_moved(fd);
-                       dupe_maint_renamed(fd);
                        search_maint_renamed(fd);
                        break;
                case FILEDATA_CHANGE_COPY:
@@ -257,13 +256,11 @@ void file_data_notify_ci(FileData *fd)
 
                        layout_maint_renamed(fd);
                        view_window_maint_moved(fd);
-                       dupe_maint_renamed(fd);
                        search_maint_renamed(fd);
                        break;
                case FILEDATA_CHANGE_DELETE:
                        layout_maint_removed(fd, NULL);
                        view_window_maint_removed(fd, NULL);
-                       dupe_maint_removed(fd);
                        search_maint_removed(fd);
 
                        collection_maint_removed(fd);