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
path: root/source
diff options
context:
space:
mode:
authorHarley Acheson <harley.acheson@gmail.com>2020-01-28 20:10:50 +0300
committerHarley Acheson <harley.acheson@gmail.com>2020-01-28 20:10:50 +0300
commit1af8e0cc6c47b43bf9c94a3f845961f4d22cb34e (patch)
tree71f58cda860c7aebb32c06d0795fbf386d99b78e /source
parenta5790b26563c216dce262586369fdca1061b4850 (diff)
UI: Windows Platform File Browser System List
Showing Windows special folder locations with icons in File Browser System list. https://developer.blender.org/D6405 Reviewed by Brecht Van Lommel
Diffstat (limited to 'source')
-rw-r--r--source/blender/editors/space_file/filelist.c28
-rw-r--r--source/blender/editors/space_file/fsmenu.c62
2 files changed, 67 insertions, 23 deletions
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index a567aeed826..fa904e0934b 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -947,15 +947,13 @@ ImBuf *filelist_geticon_image(struct FileList *filelist, const int index)
return filelist_geticon_image_ex(file->typeflag, file->relpath);
}
-static int filelist_geticon_ex(const int typeflag,
- const int blentype,
- const char *relpath,
- const bool is_main,
- const bool ignore_libdir)
+static int filelist_geticon_ex(FileDirEntry *file, const char *root, const bool is_main, const bool ignore_libdir)
{
+ const int typeflag = file->typeflag;
+
if ((typeflag & FILE_TYPE_DIR) &&
!(ignore_libdir && (typeflag & (FILE_TYPE_BLENDERLIB | FILE_TYPE_BLENDER)))) {
- if (FILENAME_IS_PARENT(relpath)) {
+ if (FILENAME_IS_PARENT(file->relpath)) {
return is_main ? ICON_FILE_PARENT : ICON_NONE;
}
else if (typeflag & FILE_TYPE_APPLICATIONBUNDLE) {
@@ -969,6 +967,20 @@ static int filelist_geticon_ex(const int typeflag,
* (e.g. when used over previews). */
return ICON_FILE_FOLDER;
}
+ else {
+ /* If this path is in System list then use that icon. */
+ struct FSMenu *fsmenu = ED_fsmenu_get();
+ FSMenuEntry *tfsm = ED_fsmenu_get_category(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS);
+ char fullpath[FILE_MAX_LIBEXTRA];
+ BLI_join_dirfile(fullpath, sizeof(fullpath), root, file->relpath);
+ BLI_add_slash(fullpath);
+ for (; tfsm; tfsm = tfsm->next) {
+ if (STREQ(tfsm->path, fullpath)) {
+ /* Never want a little folder inside a large one. */
+ return (tfsm->icon == ICON_FILE_FOLDER) ? ICON_NONE : tfsm->icon;
+ }
+ }
+ }
}
if (typeflag & FILE_TYPE_BLENDER) {
@@ -1014,7 +1026,7 @@ static int filelist_geticon_ex(const int typeflag,
return ICON_FILE_ARCHIVE;
}
else if (typeflag & FILE_TYPE_BLENDERLIB) {
- const int ret = UI_idcode_icon_get(blentype);
+ const int ret = UI_idcode_icon_get(file->blentype);
if (ret != ICON_NONE) {
return ret;
}
@@ -1026,7 +1038,7 @@ int filelist_geticon(struct FileList *filelist, const int index, const bool is_m
{
FileDirEntry *file = filelist_geticon_get_file(filelist, index);
- return filelist_geticon_ex(file->typeflag, file->blentype, file->relpath, is_main, false);
+ return filelist_geticon_ex(file, filelist->filelist.root, is_main, false);
}
/* ********** Main ********** */
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index da105da77ab..4458b38cd2f 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -31,6 +31,8 @@
#include "BLI_utildefines.h"
#include "BLI_blenlib.h"
+#include "BLT_translation.h"
+
#include "BKE_appdir.h"
#include "ED_fileselect.h"
@@ -270,7 +272,7 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu,
FSMenuCategory category,
const char *path,
const char *name,
- const int icon,
+ int icon,
FSMenuInsert flag)
{
FSMenuEntry *fsm_prev;
@@ -311,19 +313,22 @@ void fsmenu_insert_entry(struct FSMenu *fsmenu,
fsm_iter->path = BLI_strdup(path);
fsm_iter->save = (flag & FS_INSERT_SAVE) != 0;
- if ((category == FS_CATEGORY_RECENT) && (!name || !name[0])) {
- /* Special handling when adding new recent entry - check if dir exists in
- * some other categories, and try to use name from there if so. */
+ /* If entry is also in another list, use that icon and maybe name. */
+ if (ELEM(category, FS_CATEGORY_BOOKMARKS, FS_CATEGORY_RECENT)) {
+
FSMenuCategory cats[] = {
FS_CATEGORY_SYSTEM, FS_CATEGORY_SYSTEM_BOOKMARKS, FS_CATEGORY_BOOKMARKS};
int i = ARRAY_SIZE(cats);
+ if (category == FS_CATEGORY_BOOKMARKS) {
+ i--;
+ }
while (i--) {
FSMenuEntry *tfsm = ED_fsmenu_get_category(fsmenu, cats[i]);
-
for (; tfsm; tfsm = tfsm->next) {
if (STREQ(tfsm->path, fsm_iter->path)) {
- if (tfsm->name[0]) {
+ icon = tfsm->icon;
+ if (tfsm->name[0] && (!name || !name[0])) {
name = tfsm->name;
}
break;
@@ -485,6 +490,25 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename)
fclose(fp);
}
+#ifdef WIN32
+/* Add a Windows known folder path to the System list. */
+static void fsmenu_add_windows_folder(struct FSMenu *fsmenu,
+ REFKNOWNFOLDERID rfid,
+ const char *name,
+ const int icon,
+ FSMenuInsert flag)
+{
+ LPWSTR pPath;
+ char line[FILE_MAXDIR];
+ if (SHGetKnownFolderPath(rfid, 0, NULL, &pPath) == S_OK) {
+ BLI_strncpy_wchar_as_utf8(line, pPath, FILE_MAXDIR);
+ CoTaskMemFree(pPath);
+ BLI_add_slash(line);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, name, icon, flag);
+ }
+}
+#endif
+
void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
{
char line[FILE_MAXDIR];
@@ -541,16 +565,24 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
}
}
- /* Adding Desktop and My Documents */
+ /* Get Special Folder Locations. */
if (read_bookmarks) {
- SHGetSpecialFolderPathW(0, wline, CSIDL_PERSONAL, 0);
- BLI_strncpy_wchar_as_utf8(line, wline, FILE_MAXDIR);
- fsmenu_insert_entry(
- fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, ICON_DOCUMENTS, FS_INSERT_SORTED);
- SHGetSpecialFolderPathW(0, wline, CSIDL_DESKTOPDIRECTORY, 0);
- BLI_strncpy_wchar_as_utf8(line, wline, FILE_MAXDIR);
- fsmenu_insert_entry(
- fsmenu, FS_CATEGORY_SYSTEM_BOOKMARKS, line, NULL, ICON_DESKTOP, FS_INSERT_SORTED);
+ fsmenu_add_windows_folder(
+ fsmenu, &FOLDERID_Profile, IFACE_("Home"), ICON_HOME, FS_INSERT_LAST);
+ fsmenu_add_windows_folder(
+ fsmenu, &FOLDERID_Desktop, IFACE_("Desktop"), ICON_DESKTOP, FS_INSERT_LAST);
+ fsmenu_add_windows_folder(
+ fsmenu, &FOLDERID_Documents, IFACE_("Documents"), ICON_DOCUMENTS, FS_INSERT_LAST);
+ fsmenu_add_windows_folder(
+ fsmenu, &FOLDERID_Downloads, IFACE_("Downloads"), ICON_IMPORT, FS_INSERT_LAST);
+ fsmenu_add_windows_folder(
+ fsmenu, &FOLDERID_Music, IFACE_("Music"), ICON_FILE_SOUND, FS_INSERT_LAST);
+ fsmenu_add_windows_folder(
+ fsmenu, &FOLDERID_Pictures, IFACE_("Pictures"), ICON_FILE_IMAGE, FS_INSERT_LAST);
+ fsmenu_add_windows_folder(
+ fsmenu, &FOLDERID_Videos, IFACE_("Videos"), ICON_FILE_MOVIE, FS_INSERT_LAST);
+ fsmenu_add_windows_folder(
+ fsmenu, &FOLDERID_Fonts, IFACE_("Fonts"), ICON_FONTPREVIEW, FS_INSERT_LAST);
}
}
#else