GNOME Bugzilla – Bug 693329
Add items when files added to Pictures/cache directory
Last modified: 2013-03-01 11:32:22 UTC
Created attachment 235403 [details] [review] Add items when added to pictures/cache Monitor the pictures directory and cache directory for any new files added or removed. Re-purposes the add/remove api that was no longer used.
Review of attachment 235403 [details] [review]: ::: panels/background/bg-pictures-source.c @@ +127,3 @@ + { + g_object_unref (bg_source->priv->picture_dir_monitor); + bg_source->priv->picture_dir_monitor = NULL; Use g_clear_object to clear the reference. @@ +133,3 @@ + { + g_object_unref (bg_source->priv->cache_dir_monitor); + bg_source->priv->cache_dir_monitor = NULL; Same as above. @@ +382,3 @@ gboolean bg_pictures_source_remove (BgPicturesSource *bg_source, + const char *uri) Alignment is slightly wrong here. @@ +568,3 @@ + BgPicturesSource *self) +{ + if (!bg_pictures_source_is_known (self, g_file_get_uri (file))) The return value of g_file_get_uri needs to be freed. @@ +571,3 @@ + { + /* sync up the ref count so we can re-use the add_single_item code path */ + g_object_ref (file); Probably best to move this and the explanation up to to where add_single_item is called. @@ +636,3 @@ + G_FILE_MONITOR_NONE, + NULL, + NULL); g_file_monitor_directory can return NULL on error, so this should be checked before attempting to connect the signal. @@ +656,3 @@ + G_FILE_MONITOR_NONE, + NULL, + NULL); Same as above.
Created attachment 235695 [details] [review] background: Monitor the Pictures and cache directory for new files Updated patch
Review of attachment 235695 [details] [review]: ::: panels/background/bg-pictures-source.c @@ +595,3 @@ + switch (event_type) + { + case G_FILE_MONITOR_EVENT_CREATED: You don't want to use created here. New files might get opened before they're done writing, and you don't check for changed. You likely want G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT
G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT fires three times if a file is overwritten. I am checking before add_single_file to see if the file exists in the "known_items" hash table, but it seems there isn't anything ever being added to that in the first place.. I could fix the inserting as well but not sure what the side effects are.
Created attachment 235810 [details] [review] background: Monitor the Pictures and cache directory for new files Change to using G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT. This required the known_items table to be re-instated. There is a bit of clean up to do in bg-pictures-source which I'll open a separate bug/patch about, would be good to do this on top of this patch and #691800
Review of attachment 235810 [details] [review]: Looks good other than that. ::: panels/background/bg-pictures-source.c @@ +553,3 @@ + G_FILE_QUERY_INFO_NONE, + G_PRIORITY_LOW, + NULL, Needs to use a GCancellable here, so we can cancel any queries when exiting the panel.
Created attachment 236771 [details] [review] background: Monitor the Pictures and cache directory for new files Added cancellable to file monitors
Review of attachment 236771 [details] [review]: Feel free to commit after making those changes. ::: panels/background/bg-pictures-source.c @@ +125,3 @@ } + if (bg_source->priv->picture_dir_monitor) You don't need to do "if..." with g_clear_object. @@ +128,3 @@ + g_clear_object (&bg_source->priv->picture_dir_monitor); + + if (bg_source->priv->cache_dir_monitor) Ditto.
Created attachment 237445 [details] [review] background: Monitor the Pictures and cache directory for new files fix up patch
Attachment 237445 [details] pushed as ce409d4 - background: Monitor the Pictures and cache directory for new files