summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRaluca Elena Podiuc <ralucaelena1985@gmail.com>2011-07-13 14:21:27 +0300
committerOleksij Rempel <bug-track@fisher-privat.net>2012-03-24 09:34:43 +0100
commit6fff4fdf65c05caf08109c90d3dec484a8b1fdb5 (patch)
tree8d990b7ac8fa2bb5be85283693d9557d5c438a25
parent931436063d729b8546a4677d08876f4711ac240b (diff)
downloadcheese-6fff4fdf65c05caf08109c90d3dec484a8b1fdb5.tar.gz
thumb-view: 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.
-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 5c06ff3d..97dadcf0 100644
--- a/src/thumbview/cheese-thumb-view.c
+++ b/src/thumbview/cheese-thumb-view.c
@@ -356,9 +356,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;
}
@@ -697,7 +704,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);
@@ -716,7 +723,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);