[cheese] Handle photo/video moved to monitored directories
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] Handle photo/video moved to monitored directories
- Date: Mon, 3 Sep 2012 19:57:41 +0000 (UTC)
commit 2204b80e8f72f421cee347e3fe5f35ecf6b73ca5
Author: Raluca Elena Podiuc <ralucaelena1985 gmail com>
Date: Wed Jul 13 14:21:27 2011 +0300
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.
src/thumbview/cheese-thumb-view.c | 11 +++++++++--
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);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]