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:
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/file_draw.c2
-rw-r--r--source/blender/editors/space_file/file_ops.c3
-rw-r--r--source/blender/editors/space_file/filelist.c20
-rw-r--r--source/blender/editors/space_file/filelist.h18
-rw-r--r--source/blender/editors/space_file/fsmenu.c47
-rw-r--r--source/blender/editors/space_file/space_file.c2
6 files changed, 64 insertions, 28 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index fd9a9ff9ab1..f407d82aa5e 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -560,7 +560,7 @@ void file_draw_list(const bContext *C, ARegion *ar)
filelist_cache_previews_update(files);
/* Handle preview timer here, since it's filelist_file_cache_block() and filelist_cache_previews_update()
- * which controlls previews task. */
+ * which controls previews task. */
{
const bool previews_running = filelist_cache_previews_running(files);
// printf("%s: preview task: %d\n", __func__, previews_running);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index 81bc585db82..429b643a807 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1301,7 +1301,7 @@ void file_operator_to_sfile(bContext *C, SpaceFile *sfile, wmOperator *op)
}
/* we could check for relative_path property which is used when converting
- * in the other direction but doesnt hurt to do this every time */
+ * in the other direction but doesn't hurt to do this every time */
BLI_path_abs(sfile->params->dir, BKE_main_blendfile_path(bmain));
/* XXX, files and dirs updates missing, not really so important though */
@@ -1714,7 +1714,6 @@ static int filepath_drop_exec(bContext *C, wmOperator *op)
void FILE_OT_filepath_drop(wmOperatorType *ot)
{
ot->name = "File Selector Drop";
- ot->description = "";
ot->idname = "FILE_OT_filepath_drop";
ot->exec = filepath_drop_exec;
diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c
index 09e2660a762..368fc8be35c 100644
--- a/source/blender/editors/space_file/filelist.c
+++ b/source/blender/editors/space_file/filelist.c
@@ -215,7 +215,7 @@ typedef struct FileListInternEntry {
int blentype; /* ID type, in case typeflag has FILE_TYPE_BLENDERLIB set. */
char *relpath;
- char *name; /* not striclty needed, but used during sorting, avoids to have to recompute it there... */
+ char *name; /* not strictly needed, but used during sorting, avoids to have to recompute it there... */
BLI_stat_t st;
} FileListInternEntry;
@@ -236,7 +236,7 @@ typedef struct FileListEntryCache {
/* This one gathers all entries from both block and misc caches. Used for easy bulk-freing. */
ListBase cached_entries;
- /* Block cache: all entries between start and end index. used for part of the list on diplay. */
+ /* Block cache: all entries between start and end index. used for part of the list on display. */
FileDirEntry **block_entries;
int block_start_index, block_end_index, block_center_index, block_cursor;
@@ -1516,7 +1516,7 @@ static FileDirEntry *filelist_file_ex(struct FileList *filelist, const int index
return cache->block_entries[idx];
}
- if ((ret = BLI_ghash_lookup(cache->misc_entries, SET_INT_IN_POINTER(index)))) {
+ if ((ret = BLI_ghash_lookup(cache->misc_entries, POINTER_FROM_INT(index)))) {
return ret;
}
@@ -1529,11 +1529,11 @@ static FileDirEntry *filelist_file_ex(struct FileList *filelist, const int index
/* Else, we have to add new entry to 'misc' cache - and possibly make room for it first! */
ret = filelist_file_create_entry(filelist, index);
old_index = cache->misc_entries_indices[cache->misc_cursor];
- if ((old = BLI_ghash_popkey(cache->misc_entries, SET_INT_IN_POINTER(old_index), NULL))) {
+ if ((old = BLI_ghash_popkey(cache->misc_entries, POINTER_FROM_INT(old_index), NULL))) {
BLI_ghash_remove(cache->uuids, old->uuid, NULL, NULL);
filelist_file_release_entry(filelist, old);
}
- BLI_ghash_insert(cache->misc_entries, SET_INT_IN_POINTER(index), ret);
+ BLI_ghash_insert(cache->misc_entries, POINTER_FROM_INT(index), ret);
BLI_ghash_insert(cache->uuids, ret->uuid, ret);
cache->misc_entries_indices[cache->misc_cursor] = index;
@@ -1628,7 +1628,7 @@ static bool filelist_file_cache_block_create(FileList *filelist, const int start
FileDirEntry *entry;
/* That entry might have already been requested and stored in misc cache... */
- if ((entry = BLI_ghash_popkey(cache->misc_entries, SET_INT_IN_POINTER(idx), NULL)) == NULL) {
+ if ((entry = BLI_ghash_popkey(cache->misc_entries, POINTER_FROM_INT(idx), NULL)) == NULL) {
entry = filelist_file_create_entry(filelist, idx);
BLI_ghash_insert(cache->uuids, entry->uuid, entry);
}
@@ -2064,7 +2064,7 @@ unsigned int filelist_entry_select_set(
{
/* Default NULL pointer if not found is fine here! */
void **es_p = BLI_ghash_lookup_p(filelist->selection_state, entry->uuid);
- unsigned int entry_flag = es_p ? GET_UINT_FROM_POINTER(*es_p) : 0;
+ unsigned int entry_flag = es_p ? POINTER_AS_UINT(*es_p) : 0;
const unsigned int org_entry_flag = entry_flag;
BLI_assert(entry);
@@ -2090,7 +2090,7 @@ unsigned int filelist_entry_select_set(
if (entry_flag != org_entry_flag) {
if (es_p) {
if (entry_flag) {
- *es_p = SET_UINT_IN_POINTER(entry_flag);
+ *es_p = POINTER_FROM_UINT(entry_flag);
}
else {
BLI_ghash_remove(filelist->selection_state, entry->uuid, MEM_freeN, NULL);
@@ -2099,7 +2099,7 @@ unsigned int filelist_entry_select_set(
else if (entry_flag) {
void *key = MEM_mallocN(sizeof(entry->uuid), __func__);
memcpy(key, entry->uuid, sizeof(entry->uuid));
- BLI_ghash_insert(filelist->selection_state, key, SET_UINT_IN_POINTER(entry_flag));
+ BLI_ghash_insert(filelist->selection_state, key, POINTER_FROM_UINT(entry_flag));
}
}
@@ -2139,7 +2139,7 @@ unsigned int filelist_entry_select_get(FileList *filelist, FileDirEntry *entry,
((check == CHECK_FILES) && !(entry->typeflag & FILE_TYPE_DIR)))
{
/* Default NULL pointer if not found is fine here! */
- return GET_UINT_FROM_POINTER(BLI_ghash_lookup(filelist->selection_state, entry->uuid));
+ return POINTER_AS_UINT(BLI_ghash_lookup(filelist->selection_state, entry->uuid));
}
return 0;
diff --git a/source/blender/editors/space_file/filelist.h b/source/blender/editors/space_file/filelist.h
index 76845c44226..6d898ee2fe9 100644
--- a/source/blender/editors/space_file/filelist.h
+++ b/source/blender/editors/space_file/filelist.h
@@ -56,12 +56,12 @@ typedef enum FileCheckType {
CHECK_ALL = 3
} FileCheckType;
-struct ListBase * folderlist_new(void);
+struct ListBase *folderlist_new(void);
void folderlist_free(struct ListBase *folderlist);
-struct ListBase * folderlist_duplicate(ListBase *folderlist);
+struct ListBase *folderlist_duplicate(ListBase *folderlist);
void folderlist_popdir(struct ListBase *folderlist, char *dir);
void folderlist_pushdir(struct ListBase *folderlist, const char *dir);
-const char * folderlist_peeklastdir(struct ListBase *folderdist);
+const char *folderlist_peeklastdir(struct ListBase *folderdist);
int folderlist_clear_next(struct SpaceFile *sfile);
@@ -77,24 +77,24 @@ void filelist_filter(struct FileList *filelist);
void filelist_init_icons(void);
void filelist_free_icons(void);
void filelist_imgsize(struct FileList *filelist, short w, short h);
-struct ImBuf * filelist_getimage(struct FileList *filelist, const int index);
-struct ImBuf * filelist_geticon_image(struct FileList *filelist, const int index);
+struct ImBuf *filelist_getimage(struct FileList *filelist, const int index);
+struct ImBuf *filelist_geticon_image(struct FileList *filelist, const int index);
int filelist_geticon(struct FileList *filelist, const int index, const bool is_main);
-struct FileList * filelist_new(short type);
+struct FileList *filelist_new(short type);
void filelist_clear(struct FileList *filelist);
void filelist_clear_ex(struct FileList *filelist, const bool do_cache, const bool do_selection);
void filelist_free(struct FileList *filelist);
-const char * filelist_dir(struct FileList *filelist);
+const char *filelist_dir(struct FileList *filelist);
bool filelist_is_dir(struct FileList *filelist, const char *path);
void filelist_setdir(struct FileList *filelist, char *r_dir);
int filelist_files_ensure(struct FileList *filelist);
int filelist_empty(struct FileList *filelist);
-FileDirEntry * filelist_file(struct FileList *filelist, int index);
+FileDirEntry *filelist_file(struct FileList *filelist, int index);
int filelist_file_findpath(struct FileList *filelist, const char *file);
-FileDirEntry * filelist_entry_find_uuid(struct FileList *filelist, const int uuid[4]);
+FileDirEntry *filelist_entry_find_uuid(struct FileList *filelist, const int uuid[4]);
void filelist_file_cache_slidingwindow_set(struct FileList *filelist, size_t window_size);
bool filelist_file_cache_block(struct FileList *filelist, const int index);
diff --git a/source/blender/editors/space_file/fsmenu.c b/source/blender/editors/space_file/fsmenu.c
index 70df086b32d..359cce45baa 100644
--- a/source/blender/editors/space_file/fsmenu.c
+++ b/source/blender/editors/space_file/fsmenu.c
@@ -59,6 +59,7 @@
#ifdef __linux__
#include <mntent.h>
+#include "BLI_fileops_types.h"
#endif
#include "fsmenu.h" /* include ourselves */
@@ -439,7 +440,7 @@ void fsmenu_read_bookmarks(struct FSMenu *fsmenu, const char *filename)
line[len - 1] = '\0';
}
/* don't do this because it can be slow on network drives,
- * having a bookmark from a drive thats ejected or so isn't
+ * having a bookmark from a drive that's ejected or so isn't
* all _that_ bad */
#if 0
if (BLI_exists(line))
@@ -598,13 +599,22 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
fp = setmntent(MOUNTED, "r");
if (fp == NULL) {
- fprintf(stderr, "could not get a list of mounted filesystemts\n");
+ fprintf(stderr, "could not get a list of mounted filesystems\n");
}
else {
while ((mnt = getmntent(fp))) {
- /* not sure if this is right, but seems to give the relevant mnts */
- if (!STREQLEN(mnt->mnt_fsname, "/dev", 4))
+ if (STRPREFIX(mnt->mnt_dir, "/boot")) {
+ /* Hide share not usable to the user. */
continue;
+ }
+ else if (!STRPREFIX(mnt->mnt_fsname, "/dev")) {
+ continue;
+ }
+ else if (STRPREFIX(mnt->mnt_fsname, "/dev/loop")) {
+ /* The dev/loop* entries are SNAPS used by desktop environment
+ * (Gnome) no need for them to show up in the list. */
+ continue;
+ }
len = strlen(mnt->mnt_dir);
if (len && mnt->mnt_dir[len - 1] != '/') {
@@ -618,8 +628,35 @@ void fsmenu_read_system(struct FSMenu *fsmenu, int read_bookmarks)
found = 1;
}
if (endmntent(fp) == 0) {
- fprintf(stderr, "could not close the list of mounted filesystemts\n");
+ fprintf(stderr, "could not close the list of mounted filesystems\n");
+ }
+ }
+ /* Check gvfs shares. */
+ const char * const xdg_runtime_dir = BLI_getenv("XDG_RUNTIME_DIR");
+ if (xdg_runtime_dir != NULL) {
+ struct direntry *dir;
+ char name[FILE_MAX];
+ BLI_join_dirfile(name, sizeof(name), xdg_runtime_dir, "gvfs/");
+ const uint dir_len = BLI_filelist_dir_contents(name, &dir);
+ for (uint i = 0; i < dir_len; i++) {
+ if ((dir[i].type & S_IFDIR)) {
+ const char *dirname = dir[i].relname;
+ if (dirname[0] != '.') {
+ /* Dir names contain a lot of unwanted text.
+ * Assuming every entry ends with the share name */
+ const char *label = strstr(dirname, "share=");
+ if (label != NULL) {
+ /* Move pointer so "share=" is trimmed off or use full dirname as label. */
+ const char *label_test = label + 6;
+ label = *label_test ? label_test : dirname;
+ }
+ BLI_snprintf(line, sizeof(line), "%s%s/", name, dirname);
+ fsmenu_insert_entry(fsmenu, FS_CATEGORY_SYSTEM, line, label, FS_INSERT_SORTED);
+ found = 1;
+ }
+ }
}
+ BLI_filelist_free(dir, dir_len);
}
#endif
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 7bab5e34d40..b0dea1eb31b 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -386,7 +386,7 @@ static void file_main_region_draw(const bContext *C, ARegion *ar)
v2d->keepofs |= V2D_LOCKOFS_Y;
/* XXX this happens on scaling down Screen (like from startup.blend) */
- /* view2d has no type specific for filewindow case, which doesnt scroll vertically */
+ /* view2d has no type specific for filewindow case, which doesn't scroll vertically */
if (v2d->cur.ymax < 0) {
v2d->cur.ymin -= v2d->cur.ymax;
v2d->cur.ymax = 0;