--- a/src/fr-places-sidebar.c +++ b/src/fr-places-sidebar.c @@ -256,25 +256,19 @@ // Special directories, added if not present in the bookmarks. - location = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_DOCUMENTS)); - add_location_if_not_present (ctx, private, location); - g_object_unref (location); - - location = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_PICTURES)); - add_location_if_not_present (ctx, private, location); - g_object_unref (location); - - location = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_MUSIC)); - add_location_if_not_present (ctx, private, location); - g_object_unref (location); - - location = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_DOWNLOAD)); - add_location_if_not_present (ctx, private, location); - g_object_unref (location); - - location = g_file_new_for_path (g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS)); - add_location_if_not_present (ctx, private, location); - g_object_unref (location); + const GUserDirectory directories[] = { + G_USER_DIRECTORY_DOCUMENTS, G_USER_DIRECTORY_PICTURES, + G_USER_DIRECTORY_MUSIC, G_USER_DIRECTORY_DOWNLOAD, + G_USER_DIRECTORY_VIDEOS + }; + for (guint i = 0; i < G_N_ELEMENTS (directories); i++) { + const char *path = g_get_user_special_dir (directories[i]); + if (path == NULL) + continue; + location = g_file_new_for_path (path); + add_location_if_not_present (ctx, private, location); + g_object_unref (location); + } // Root