summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRaluca Elena Podiuc <ralucaelena1985@gmail.com>2011-07-13 14:21:27 +0300
committerDavid King <amigadave@amigadave.com>2012-09-03 20:51:26 +0100
commit2204b80e8f72f421cee347e3fe5f35ecf6b73ca5 (patch)
tree013741c210a24ddd7ea66bdf90b6c7c6803de934 /src
parent46ec0d0ee07e544abc3eaae16543da5cb2613e48 (diff)
Handle photo/video moved to monitored directories
Camerabin2 creates a temporary file, writes data to it and in the end it moves it to the destination path. Without G_FILE_MONITOR_SEND_MOVED to g_file_monitor_directory, moves would be sent as DELETE + CREATE. Unfortunately, we would also get CREATE events when the temporary file was created. We cannot listen for CREATE events as temporary files would be CREATEd and then CHANGEd and the thumb-view creation code would work with bad data. By using G_FILE_MONITOR_SEND_MOVED we get a single event when the file is moved. As the file monitor ignores files with unknown extensions (as is the case for the temporary files created by camerabin2) we could only just append the new file. But because the user might also move a picture/video manually from the Pictures/Webcam or Videos/Webcam directories, removing the old file from the thumb-view keeps it up-to-date with the state of the file system. If camerabin2 switches away from the create-temp+move approach, to the camerabin one (create the destination file directly), we're prepared to handle that code with G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT.
Diffstat (limited to 'src')
-rw-r--r--src/thumbview/cheese-thumb-view.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/thumbview/cheese-thumb-view.c b/src/thumbview/cheese-thumb-view.c
index feaafcf..3ca6293 100644
--- a/src/thumbview/cheese-thumb-view.c
+++ b/src/thumbview/cheese-thumb-view.c
@@ -368,9 +368,16 @@ cheese_thumb_view_monitor_cb (GFileMonitor *file_monitor,
case G_FILE_MONITOR_EVENT_DELETED:
cheese_thumb_view_remove_item (thumb_view, file);
break;
+
+ case G_FILE_MONITOR_EVENT_MOVED:
+ cheese_thumb_view_remove_item (thumb_view, file);
+ cheese_thumb_view_append_item (thumb_view, other_file);
+ break;
+
case G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT:
cheese_thumb_view_append_item (thumb_view, file);
break;
+
default:
break;
}
@@ -727,7 +734,7 @@ cheese_thumb_view_start_monitoring_photo_path (CheeseThumbView *thumb_view, cons
/* connect signal to photo path */
file = g_file_new_for_path (path_photos);
- priv->photo_file_monitor = g_file_monitor_directory (file, 0, NULL, NULL);
+ priv->photo_file_monitor = g_file_monitor_directory (file, G_FILE_MONITOR_SEND_MOVED, NULL, NULL);
g_signal_connect (priv->photo_file_monitor, "changed", G_CALLBACK (cheese_thumb_view_monitor_cb), thumb_view);
g_object_unref (file);
@@ -746,7 +753,7 @@ cheese_thumb_view_start_monitoring_video_path (CheeseThumbView *thumb_view, cons
/* connect signal to video path */
file = g_file_new_for_path (path_videos);
- priv->video_file_monitor = g_file_monitor_directory (file, 0, NULL, NULL);
+ priv->video_file_monitor = g_file_monitor_directory (file, G_FILE_MONITOR_SEND_MOVED, NULL, NULL);
g_signal_connect (priv->video_file_monitor, "changed", G_CALLBACK (cheese_thumb_view_monitor_cb), thumb_view);
g_object_unref (file);