1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
--- 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
|