Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2012-05-18 16:49:25 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2012-05-18 16:49:25 +0400
commitadb567f6b3f21f820e6b40d8530b374ee5cc2d7a (patch)
tree01f2146e98f6a6a258f7e117e182006a4abcfc60 /source/blender/editors
parent3e83fd441d84617855dfdcfab50fd8f4fb041f00 (diff)
File browser: list of system directories is now refreshed on pressing the refresh
button or opening the file browser, in case e.g. a USB stick was inserted. Patch #31211 by Julien Duroure.
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_file/file_ops.c4
-rw-r--r--source/blender/editors/space_file/fsmenu.c73
-rw-r--r--source/blender/editors/space_file/fsmenu.h5
-rw-r--r--source/blender/editors/space_file/space_file.c5
4 files changed, 55 insertions, 32 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 3ff9c3c0520..9629fd7da0c 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -820,9 +820,13 @@ void FILE_OT_parent(struct wmOperatorType *ot)
static int file_refresh_exec(bContext *C, wmOperator *UNUSED(unused))
{
SpaceFile *sfile= CTX_wm_space_file(C);
+ struct FSMenu* fsmenu = fsmenu_get();
ED_fileselect_clear(C, sfile);
+ /* refresh system directory menu */
+ fsmenu_refresh_system_category(fsmenu);
+
WM_event_add_notifier(C, NC_SPACE|ND_SPACE_FILE_LIST, NULL);
return OPERATOR_FINISHED;
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index 50261175852..a91b3669219 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -295,7 +295,7 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename)
fclose(fp);
}
-void fsmenu_read_system(struct FSMenu *fsmenu)
+void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
{
char line[256];
#ifdef WIN32
@@ -319,10 +319,12 @@ void fsmenu_read_system(struct FSMenu *fsmenu)
}
/* Adding Desktop and My Documents */
- SHGetSpecialFolderPath(0, line, CSIDL_PERSONAL, 0);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
- SHGetSpecialFolderPath(0, line, CSIDL_DESKTOPDIRECTORY, 0);
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ if (read_bookmarks) {
+ SHGetSpecialFolderPath(0, line, CSIDL_PERSONAL, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ SHGetSpecialFolderPath(0, line, CSIDL_DESKTOPDIRECTORY, 0);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ }
}
#else
#ifdef __APPLE__
@@ -352,7 +354,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu)
* assume they are the standard ones
* TODO : replace hardcoded paths with proper BLI_get_folder calls */
home = getenv("HOME");
- if (home) {
+ if (read_bookmarks && home) {
BLI_snprintf(line, 256, "%s/", home);
fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
BLI_snprintf(line, 256, "%s/Desktop/", home);
@@ -437,32 +439,34 @@ void fsmenu_read_system(struct FSMenu *fsmenu)
}
/* Finally get user favorite places */
- list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL);
- pathesArray = LSSharedFileListCopySnapshot(list, &seed);
- pathesCount = CFArrayGetCount(pathesArray);
-
- for (i = 0; i < pathesCount; i++) {
- itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i);
-
- err = LSSharedFileListItemResolve(itemRef,
- kLSSharedFileListNoUserInteraction |
- kLSSharedFileListDoNotMountVolumes,
- &cfURL, NULL);
- if (err != noErr)
- continue;
-
- pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle);
+ if(read_bookmarks) {
+ list = LSSharedFileListCreate(NULL, kLSSharedFileListFavoriteItems, NULL);
+ pathesArray = LSSharedFileListCopySnapshot(list, &seed);
+ pathesCount = CFArrayGetCount(pathesArray);
- if (!CFStringGetCString(pathString, line, 256, kCFStringEncodingASCII))
- continue;
- fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+ for (i = 0; i < pathesCount; i++) {
+ itemRef = (LSSharedFileListItemRef)CFArrayGetValueAtIndex(pathesArray, i);
+
+ err = LSSharedFileListItemResolve(itemRef,
+ kLSSharedFileListNoUserInteraction |
+ kLSSharedFileListDoNotMountVolumes,
+ &cfURL, NULL);
+ if (err != noErr)
+ continue;
+
+ pathString = CFURLCopyFileSystemPath(cfURL, kCFURLPOSIXPathStyle);
+
+ if (!CFStringGetCString(pathString, line, 256, kCFStringEncodingASCII))
+ continue;
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
+
+ CFRelease(pathString);
+ CFRelease(cfURL);
+ }
- CFRelease(pathString);
- CFRelease(cfURL);
+ CFRelease(pathesArray);
+ CFRelease(list);
}
-
- CFRelease(pathesArray);
- CFRelease(list);
#endif /* OSX 10.5+ */
}
#else
@@ -470,7 +474,7 @@ void fsmenu_read_system(struct FSMenu *fsmenu)
{
const char *home = getenv("HOME");
- if (home) {
+ if (read_bookmarks && home) {
BLI_snprintf(line, FILE_MAXDIR, "%s/", home);
fsmenu_insert_entry(fsmenu, FS_CATEGORY_BOOKMARKS, line, 1, 0);
BLI_snprintf(line, FILE_MAXDIR, "%s/Desktop/", home);
@@ -537,6 +541,15 @@ static void fsmenu_free_category(struct FSMenu *fsmenu, FSMenuCategory category)
}
}
+void fsmenu_refresh_system_category(struct FSMenu *fsmenu)
+{
+ fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM);
+ fsmenu_set_category(fsmenu, FS_CATEGORY_SYSTEM, NULL);
+
+ /* Add all entries to system category */
+ fsmenu_read_system(fsmenu, FALSE);
+}
+
void fsmenu_free(struct FSMenu *fsmenu)
{
fsmenu_free_category(fsmenu, FS_CATEGORY_SYSTEM);
diff --git a/source/blender/editors/space_file/fsmenu.h b/source/blender/editors/space_file/fsmenu.h
index c926a4f382c..e5b3d54ac9f 100644
--- a/source/blender/editors/space_file/fsmenu.h
+++ b/source/blender/editors/space_file/fsmenu.h
@@ -74,10 +74,13 @@ void fsmenu_write_file (struct FSMenu* fsmenu, const char *filename);
void fsmenu_read_bookmarks (struct FSMenu* fsmenu, const char *filename);
/** adds system specific directories */
-void fsmenu_read_system (struct FSMenu* fsmenu);
+void fsmenu_read_system (struct FSMenu* fsmenu, int read_bookmarks);
/** Free's all the memory associated with the fsmenu */
void fsmenu_free (struct FSMenu* fsmenu);
+ /** Refresh system directory menu */
+void fsmenu_refresh_system_category (struct FSMenu* fsmenu);
+
#endif
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index dac5d1e1347..a90daa7e1e9 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -151,6 +151,9 @@ static void file_init(struct wmWindowManager *UNUSED(wm), ScrArea *sa)
SpaceFile *sfile= (SpaceFile*)sa->spacedata.first;
//printf("file_init\n");
+ /* refresh system directory list */
+ fsmenu_refresh_system_category(fsmenu_get());
+
if (sfile->layout) sfile->layout->dirty= TRUE;
}
@@ -613,7 +616,7 @@ void ED_file_init(void)
{
char *cfgdir = BLI_get_folder(BLENDER_USER_CONFIG, NULL);
- fsmenu_read_system(fsmenu_get());
+ fsmenu_read_system(fsmenu_get(), TRUE);
if (cfgdir) {
char name[FILE_MAX];