favorite-vfs-file-monitor.c: When handling folder updates, send out
removals before additions.
When a favorited folder is moved to a different location, its uri
in favorites:/// won't change, since it's based only on the basename.
Sending removes first makes sure both operations occur - if additions
are sent first, they will be ignored because their apparent uri hasn't
changed, so we'll end up just removing the file from the view.
Michael Webster
3 years ago
205 | 205 | XAppFavoriteInfo *info = (XAppFavoriteInfo *) ptr_a; |
206 | 206 | const gchar *uri = (gchar *) ptr_b; |
207 | 207 | |
208 | // GCompareFunc returns 0 when there's a match. | |
208 | 209 | return g_strcmp0 (info->uri, uri); |
209 | 210 | } |
210 | 211 | |
251 | 252 | { |
252 | 253 | added = g_list_prepend (added, new_info); |
253 | 254 | } |
255 | } | |
256 | ||
257 | for (iter = removed; iter != NULL; iter = iter->next) | |
258 | { | |
259 | XAppFavoriteInfo *removed_info = (XAppFavoriteInfo *) iter->data; | |
260 | ||
261 | GFile *file = _favorite_vfs_file_new_for_info (removed_info); | |
262 | ||
263 | g_file_monitor_emit_event (G_FILE_MONITOR (monitor), | |
264 | file, | |
265 | NULL, | |
266 | G_FILE_MONITOR_EVENT_DELETED); | |
267 | g_file_monitor_emit_event (G_FILE_MONITOR (monitor), | |
268 | file, | |
269 | NULL, | |
270 | G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT); | |
271 | g_object_unref (file); | |
254 | 272 | } |
255 | 273 | |
256 | 274 | for (iter = added; iter != NULL; iter = iter->next) |
270 | 288 | g_object_unref (file); |
271 | 289 | } |
272 | 290 | |
273 | for (iter = removed; iter != NULL; iter = iter->next) | |
274 | { | |
275 | XAppFavoriteInfo *removed_info = (XAppFavoriteInfo *) iter->data; | |
276 | ||
277 | GFile *file = _favorite_vfs_file_new_for_info (removed_info); | |
278 | ||
279 | g_file_monitor_emit_event (G_FILE_MONITOR (monitor), | |
280 | file, | |
281 | NULL, | |
282 | G_FILE_MONITOR_EVENT_DELETED); | |
283 | g_file_monitor_emit_event (G_FILE_MONITOR (monitor), | |
284 | file, | |
285 | NULL, | |
286 | G_FILE_MONITOR_EVENT_CHANGES_DONE_HINT); | |
287 | g_object_unref (file); | |
288 | } | |
289 | ||
290 | 291 | g_list_free (added); |
291 | 292 | g_list_free (removed); |
292 | 293 |