== filebrowser ==
authorAndrea Weikert <elubie@gmx.net>
Sun, 21 Oct 2012 14:47:16 +0000 (14:47 +0000)
committerAndrea Weikert <elubie@gmx.net>
Sun, 21 Oct 2012 14:47:16 +0000 (14:47 +0000)
* Separated bookmarks managed by the OS (System Bookmarks) and bookmarks managed by Blender (Bookmarks).
* Added user pref to hide (or show) system bookmarks to allow users doing a video tutorial for example to hide their private system bookmarks
This feature should help especially MAC users who reported excessively long list of bookmarks which were added to Blender.

release/scripts/startup/bl_ui/space_userpref.py
source/blender/editors/space_file/file_panels.c
source/blender/editors/space_file/fsmenu.c
source/blender/editors/space_file/fsmenu.h
source/blender/makesdna/DNA_userdef_types.h
source/blender/makesrna/intern/rna_userdef.c

index 85ea4985715ddc1ecbfcbf524215de56b8cf6fa1..dfb4a419a0c6fdfcabc5e3848306e9d4e89717a1 100644 (file)
@@ -823,6 +823,7 @@ class USERPREF_PT_file(Panel):
         col.prop(paths, "use_filter_files")
         col.prop(paths, "show_hidden_files_datablocks")
         col.prop(paths, "hide_recent_locations")
+        col.prop(paths, "hide_system_bookmarks")
         col.prop(paths, "show_thumbnails")
 
         col.separator()
index a7054909aaa8d69f1607937307926799953934cc..fb5210380b3cb1bea5459729ecb6135c98bcc307 100644 (file)
@@ -135,6 +135,16 @@ static void file_panel_system(const bContext *C, Panel *pa)
                file_panel_category(C, pa, FS_CATEGORY_SYSTEM, &sfile->systemnr, ICON_DISK_DRIVE, 0);
 }
 
+static void file_panel_system_bookmarks(const bContext *C, Panel *pa)
+{
+       SpaceFile *sfile = CTX_wm_space_file(C);
+
+       if (sfile && !(U.uiflag & USER_HIDE_SYSTEM_BOOKMARKS) ) {
+               file_panel_category(C, pa, FS_CATEGORY_SYSTEM_BOOKMARKS, &sfile->systemnr, ICON_BOOKMARKS, 0);
+       }
+
+}
+
 static void file_panel_bookmarks(const bContext *C, Panel *pa)
 {
        SpaceFile *sfile = CTX_wm_space_file(C);
@@ -212,6 +222,12 @@ void file_panels_register(ARegionType *art)
        pt->draw = file_panel_system;
        BLI_addtail(&art->paneltypes, pt);
 
+       pt = MEM_callocN(sizeof(PanelType), "spacetype file system bookmarks");
+       strcpy(pt->idname, "FILE_PT_system_bookmarks");
+       strcpy(pt->label, N_("System Bookmarks"));
+       pt->draw = file_panel_system_bookmarks;
+       BLI_addtail(&art->paneltypes, pt);
+
        pt = MEM_callocN(sizeof(PanelType), "spacetype file bookmarks");
        strcpy(pt->idname, "FILE_PT_bookmarks");
        strcpy(pt->label, N_("Bookmarks"));
index 66cda3082ea879ef9028b71e8b28ebe8b3c5678e..c57bfaeeb2c5a7ebec7f9e8cb0e13374b204bf7c 100644 (file)
@@ -80,9 +80,9 @@ struct _FSMenuEntry {
 
 typedef struct FSMenu {
        FSMenuEntry *fsmenu_system;
+       FSMenuEntry *fsmenu_system_bookmarks;
        FSMenuEntry *fsmenu_bookmarks;
        FSMenuEntry *fsmenu_recent;
-
 } FSMenu;
 
 static FSMenu *g_fsmenu = NULL;
@@ -103,6 +103,9 @@ static FSMenuEntry *fsmenu_get_category(struct FSMenu *fsmenu, FSMenuCategory ca
                case FS_CATEGORY_SYSTEM:
                        fsm_head = fsmenu->fsmenu_system;
                        break;
+               case FS_CATEGORY_SYSTEM_BOOKMARKS:
+                       fsm_head = fsmenu->fsmenu_system_bookmarks;
+                       break;
                case FS_CATEGORY_BOOKMARKS:
                        fsm_head = fsmenu->fsmenu_bookmarks;
                        break;
@@ -119,6 +122,9 @@ static void fsmenu_set_category(struct FSMenu *fsmenu, FSMenuCategory category,
                case FS_CATEGORY_SYSTEM:
                        fsmenu->fsmenu_system = fsm_head;
                        break;
+               case FS_CATEGORY_SYSTEM_BOOKMARKS:
+                       fsmenu->fsmenu_system_bookmarks = fsm_head;
+                       break;
                case FS_CATEGORY_BOOKMARKS:
                        fsmenu->fsmenu_bookmarks = fsm_head;
                        break;
@@ -336,9 +342,9 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
                /* Adding Desktop and My Documents */
                if (read_bookmarks) {
                        SHGetSpecialFolderPath(0, line, CSIDL_PERSONAL, 0);
-                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                        SHGetSpecialFolderPath(0, line, CSIDL_DESKTOPDIRECTORY, 0);
-                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                }
        }
 #else
@@ -361,7 +367,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
                        FSRefMakePath(&dir, path, FILE_MAX);
                        if (strcmp((char *)path, "/home") && strcmp((char *)path, "/net")) {
                                /* /net and /home are meaningless on OSX, home folders are stored in /Users */
-                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED);
+                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, (char *)path, FS_INSERT_SORTED);
                        }
                }
 
@@ -371,26 +377,26 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
                home = getenv("HOME");
                if (read_bookmarks && home) {
                        BLI_snprintf(line, 256, "%s/", home);
-                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                        BLI_snprintf(line, 256, "%s/Desktop/", home);
                        if (BLI_exists(line)) {
-                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                        }
                        BLI_snprintf(line, 256, "%s/Documents/", home);
                        if (BLI_exists(line)) {
-                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                        }
                        BLI_snprintf(line, 256, "%s/Pictures/", home);
                        if (BLI_exists(line)) {
-                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                        }
                        BLI_snprintf(line, 256, "%s/Music/", home);
                        if (BLI_exists(line)) {
-                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                        }
                        BLI_snprintf(line, 256, "%s/Movies/", home);
                        if (BLI_exists(line)) {
-                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                        }
                }
 #else
@@ -423,7 +429,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
                        
                        if (!CFStringGetCString(pathString, line, 256, kCFStringEncodingASCII))
                                continue;
-                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, FS_INSERT_SORTED);
+                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                        
                        CFRelease(pathString);
                        CFRelease(cfURL);
@@ -450,7 +456,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
                        
                        
                        FSRefMakePath(&dir, path, FILE_MAX);
-                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, (char *)path, FS_INSERT_SORTED);
+                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, (char *)path, FS_INSERT_SORTED);
                }
                
                /* Finally get user favorite places */
@@ -473,7 +479,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
                                
                                if (!CFStringGetCString(pathString, line, 256, kCFStringEncodingASCII))
                                        continue;
-                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                                
                                CFRelease(pathString);
                                CFRelease(cfURL);
@@ -491,10 +497,10 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
 
                if (read_bookmarks && home) {
                        BLI_snprintf(line, FILE_MAXDIR, "%s/", home);
-                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+                       fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                        BLI_snprintf(line, FILE_MAXDIR, "%s/Desktop/", home);
                        if (BLI_exists(line)) {
-                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, FS_INSERT_SORTED);
+                               fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, FS_INSERT_SORTED);
                        }
                }
 
@@ -564,13 +570,17 @@ void fsmenu_refresh_system_category(struct FSMenu *fsmenu)
        fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM);
        fsmenu_set_category(fsmenu, FS_CATEGORY_SYSTEM, NULL);
 
+       fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS);
+       fsmenu_set_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, NULL);
+
        /* Add all entries to system category */
-       fsmenu_read_system(fsmenu, FALSE);
+       fsmenu_read_system(fsmenu, TRUE);
 }
 
 void fsmenu_free(struct FSMenu *fsmenu)
 {
        fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM);
+       fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS);
        fsmenu_free_category(fsmenu, FS_CATEGORY_BOOKMARKS);
        fsmenu_free_category(fsmenu, FS_CATEGORY_RECENT);
        MEM_freeN(fsmenu);
index 30730578085d1b26ed47a4ce949c7678a184f044..1b69eb09fce851bfcea5c4521bf647d2d0f6b042 100644 (file)
@@ -39,6 +39,7 @@
 
 typedef enum FSMenuCategory {
        FS_CATEGORY_SYSTEM,
+       FS_CATEGORY_SYSTEM_BOOKMARKS,
        FS_CATEGORY_BOOKMARKS,
        FS_CATEGORY_RECENT
 } FSMenuCategory;
index 89b1208e8001855e9910c42c9e7bb251bda3f7fb..2256968da5683eda5fea2d7308d5f7928be949c8 100644 (file)
@@ -532,7 +532,8 @@ typedef enum eUserpref_UI_Flag {
        USER_SPLASH_DISABLE             = (1 << 27),
        USER_HIDE_RECENT                = (1 << 28),
        USER_SHOW_THUMBNAILS    = (1 << 29),
-       USER_QUIT_PROMPT                = (1 << 30)
+       USER_QUIT_PROMPT                = (1 << 30),
+       USER_HIDE_SYSTEM_BOOKMARKS = (1 << 31)
 } eUserpref_UI_Flag;
 
 /* Auto-Keying mode */
index 64992eda954478b54c61d94a728aa15b013f990a..baa892ecdc8cd41d7cc584515bb319e29b7d788e 100644 (file)
@@ -3511,6 +3511,10 @@ static void rna_def_userdef_filepaths(BlenderRNA *brna)
        RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_HIDE_RECENT);
        RNA_def_property_ui_text(prop, "Hide Recent Locations", "Hide recent locations in the file selector");
 
+       prop = RNA_def_property(srna, "hide_system_bookmarks", PROP_BOOLEAN, PROP_NONE);
+       RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_HIDE_SYSTEM_BOOKMARKS);
+       RNA_def_property_ui_text(prop, "Hide System Bookmarks", "Hide system bookmarks in the file selector");
+
        prop = RNA_def_property(srna, "show_thumbnails", PROP_BOOLEAN, PROP_NONE);
        RNA_def_property_boolean_sdna(prop, NULL, "uiflag", USER_SHOW_THUMBNAILS);
        RNA_def_property_ui_text(prop, "Show Thumbnails", "Open in thumbnail view for images and movies");