[gthumb] Use a REMOVED event when a file is removed from a catalog



commit 698ce26c686a04e563476d3a3f60ad7f2e6f3fc0
Author: Paolo Bacchilega <paobac src gnome org>
Date:   Sat Mar 6 17:01:27 2010 +0100

    Use a REMOVED event when a file is removed from a catalog
    
    If a file is deleted from disk it must be deleted from the catalogs
    as well, but if a file is removed from a catalog it's not deleted
    from disk.  For this reason we need to differentiate
    the two cases using REMOVED when removing a file from a catalog,
    and DELETE when deleting from disk.

 extensions/catalogs/actions.c |    2 +-
 gthumb/gth-browser.c          |    6 ++++++
 gthumb/gth-monitor.h          |    5 +++--
 gthumb/gth-source-tree.c      |    1 +
 4 files changed, 11 insertions(+), 3 deletions(-)
---
diff --git a/extensions/catalogs/actions.c b/extensions/catalogs/actions.c
index 7df490f..d7a77a0 100644
--- a/extensions/catalogs/actions.c
+++ b/extensions/catalogs/actions.c
@@ -90,7 +90,7 @@ catalog_save_done_cb (void     **buffer,
 		gth_monitor_folder_changed (gth_main_get_default_monitor (),
 					    catalog_file,
 					    files,
-					    GTH_MONITOR_EVENT_DELETED);
+					    GTH_MONITOR_EVENT_REMOVED);
 
 		_g_object_list_unref (files);
 		g_object_unref (catalog_file);
diff --git a/gthumb/gth-browser.c b/gthumb/gth-browser.c
index 7302dcb..acbbeec 100644
--- a/gthumb/gth-browser.c
+++ b/gthumb/gth-browser.c
@@ -2510,6 +2510,9 @@ folder_changed_cb (GthMonitor      *monitor,
 		}
 	}
 
+	if ((event == GTH_MONITOR_EVENT_REMOVED) && g_file_equal (parent, browser->priv->location->file))
+		event = GTH_MONITOR_EVENT_DELETED;
+
 	if (update_folder_tree || update_file_list) {
 		MonitorEventData *monitor_data;
 		gboolean          current_file_deleted = FALSE;
@@ -2577,6 +2580,9 @@ folder_changed_cb (GthMonitor      *monitor,
 			_gth_browser_update_statusbar_list_info (browser);
 			gth_browser_update_sensitivity (browser);
 			break;
+
+		default:
+			break;
 		}
 	}
 
diff --git a/gthumb/gth-monitor.h b/gthumb/gth-monitor.h
index 1d80e4c..e39fa29 100644
--- a/gthumb/gth-monitor.h
+++ b/gthumb/gth-monitor.h
@@ -32,8 +32,9 @@ G_BEGIN_DECLS
 
 typedef enum {
 	GTH_MONITOR_EVENT_CREATED = 0,
-	GTH_MONITOR_EVENT_DELETED,
-	GTH_MONITOR_EVENT_CHANGED
+	GTH_MONITOR_EVENT_DELETED,     /* used when a file or folder is deleted from disk */
+	GTH_MONITOR_EVENT_CHANGED,
+	GTH_MONITOR_EVENT_REMOVED      /* used when a file is removed from a catalog */
 } GthMonitorEvent;
 
 #define GTH_TYPE_MONITOR              (gth_monitor_get_type ())
diff --git a/gthumb/gth-source-tree.c b/gthumb/gth-source-tree.c
index c45ea82..f0a857d 100644
--- a/gthumb/gth-source-tree.c
+++ b/gthumb/gth-source-tree.c
@@ -264,6 +264,7 @@ monitor_folder_changed_cb (GthMonitor      *monitor,
 			break;
 
 		case GTH_MONITOR_EVENT_DELETED:
+		case GTH_MONITOR_EVENT_REMOVED:
 			gth_folder_tree_delete_children (GTH_FOLDER_TREE (source_tree), parent, list);
 			break;
 		}



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]