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:
authorHenrik Aarnio <hjaarnio@gmail.com>2013-11-22 17:35:34 +0400
committerBrecht Van Lommel <brechtvanlommel@gmail.com>2013-11-22 17:48:46 +0400
commit9c5fb7b2e7ecb0271371cd729808da44c3bc1bc3 (patch)
tree60782e733753c780d2608f2ceca3197b71d612fb /source/blender/editors
parente3a79258d17e6cdca26120eab7a2c48c7c4d4a0f (diff)
Fix T37485: autocomplete while appending and autocomplete folder behaviour.
This adds functionality to tab-autocomplete folders in the file browser file field, and the ability to autocomplete .blend files and their sub folders while linking. If only one match of a blend or a folder is found, it is opened, which applies to wildcards in the file field now. Reviewed By: elubie, brecht Differential Revision: http://developer.blender.org/D20
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/space_file/file_draw.c2
-rw-r--r--source/blender/editors/space_file/file_intern.h1
-rw-r--r--source/blender/editors/space_file/file_ops.c59
-rw-r--r--source/blender/editors/space_file/filesel.c6
-rw-r--r--source/blender/editors/space_file/space_file.c1
5 files changed, 64 insertions, 5 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index c4e6ca97418..1ec2e3c804b 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -188,7 +188,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
uiButSetFlag(but, UI_BUT_NO_UTF8);
if ((params->flag & FILE_DIRSEL_ONLY) == 0) {
- but = uiDefBut(block, TEX, B_FS_FILENAME, "",
+ but = uiDefButTextO(block, TEX, "FILE_OT_filename", 0, "",
min_x, line2_y, line2_w - chan_offs, btn_h,
params->file, 0.0, (float)FILE_MAXFILE, 0, 0,
TIP_(overwrite_alert ? N_("File name, overwrite existing") : N_("File name")));
diff --git a/source/blender/editors/space_file/file_intern.h b/source/blender/editors/space_file/file_intern.h
index d01286442be..134fe0ac6bc 100644
--- a/source/blender/editors/space_file/file_intern.h
+++ b/source/blender/editors/space_file/file_intern.h
@@ -73,6 +73,7 @@ void FILE_OT_cancel(struct wmOperatorType *ot);
void FILE_OT_parent(struct wmOperatorType *ot);
void FILE_OT_directory_new(struct wmOperatorType *ot);
void FILE_OT_directory(struct wmOperatorType *ot);
+void FILE_OT_filename(struct wmOperatorType *ot);
void FILE_OT_previous(struct wmOperatorType *ot);
void FILE_OT_next(struct wmOperatorType *ot);
void FILE_OT_refresh(struct wmOperatorType *ot);
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index a97b3b1d719..ebc232e3ef1 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -32,6 +32,8 @@
#include "BLI_utildefines.h"
#include "BLI_fileops_types.h"
+#include "BLO_readfile.h"
+
#include "BKE_context.h"
#include "BKE_screen.h"
#include "BKE_global.h"
@@ -1240,13 +1242,31 @@ int file_directory_exec(bContext *C, wmOperator *UNUSED(unused))
return OPERATOR_FINISHED;
}
+static int file_filename_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event))
+{
+ SpaceFile *sfile = CTX_wm_space_file(C);
+
+ if (sfile->params) {
+ file_expand_directory(C);
+
+ return file_filename_exec(C, op);
+ }
+
+ return OPERATOR_CANCELLED;
+}
+
int file_filename_exec(bContext *C, wmOperator *UNUSED(unused))
{
SpaceFile *sfile = CTX_wm_space_file(C);
char matched_file[FILE_MAX];
+ char filepath[sizeof(sfile->params->dir)];
+
if (sfile->params) {
+ int matches = 0;
matched_file[0] = '\0';
- if (file_select_match(sfile, sfile->params->file, matched_file)) {
+ filepath[0] = '\0';
+
+ if (matches = file_select_match(sfile, sfile->params->file, matched_file)) {
/* int i, numfiles = filelist_numfiles(sfile->files); */ /* XXX UNUSED */
sfile->params->file[0] = '\0';
/* replace the pattern (or filename that the user typed in, with the first selected file of the match */
@@ -1254,6 +1274,31 @@ int file_filename_exec(bContext *C, wmOperator *UNUSED(unused))
WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
}
+
+ if (matches == 1) {
+
+ BLI_join_dirfile(filepath, sizeof(sfile->params->dir), sfile->params->dir, sfile->params->file);
+
+ /* if directory, open it and empty filename field */
+ if (BLI_is_dir(filepath)) {
+ BLI_cleanup_dir(G.main->name, filepath);
+ BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir));
+ sfile->params->file[0] = '\0';
+ file_change_dir(C, 1);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL);
+ }
+ else if (sfile->params->type == FILE_LOADLIB){
+ char tdir[FILE_MAX], tgroup[FILE_MAX];
+ BLI_add_slash(filepath);
+ if (BLO_is_a_library(filepath, tdir, tgroup)) {
+ BLI_cleanup_dir(G.main->name, filepath);
+ BLI_strncpy(sfile->params->dir, filepath, sizeof(sfile->params->dir));
+ sfile->params->file[0] = '\0';
+ file_change_dir(C, 0);
+ WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_LIST, NULL);
+ }
+ }
+ }
}
return OPERATOR_FINISHED;
@@ -1281,6 +1326,18 @@ void FILE_OT_directory(struct wmOperatorType *ot)
ot->poll = file_directory_poll; /* <- important, handler is on window level */
}
+void FILE_OT_filename(struct wmOperatorType *ot)
+{
+ /* identifiers */
+ ot->name = "Enter File Name";
+ ot->description = "Enter a file name";
+ ot->idname = "FILE_OT_filename";
+
+ /* api callbacks */
+ ot->invoke = file_filename_invoke;
+ ot->exec = file_filename_exec;
+}
+
void FILE_OT_refresh(struct wmOperatorType *ot)
{
/* identifiers */
diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c
index c6e1541352d..3cda5dd5e80 100644
--- a/source/blender/editors/space_file/filesel.c
+++ b/source/blender/editors/space_file/filesel.c
@@ -627,7 +627,7 @@ int file_select_match(struct SpaceFile *sfile, const char *pattern, char *matche
if (!match) {
BLI_strncpy(matched_file, file->relname, FILE_MAX);
}
- match = 1;
+ match++;
}
}
@@ -700,13 +700,13 @@ bool autocomplete_file(struct bContext *C, char *str, void *UNUSED(arg_v))
for (i = 0; i < nentries; ++i) {
struct direntry *file = filelist_file(sfile->files, i);
- if (file && S_ISREG(file->type)) {
+ if (file && (S_ISREG(file->type) || S_ISDIR(file->type))) {
autocomplete_do_name(autocpl, file->relname);
}
}
match = autocomplete_end(autocpl, str);
}
- return match != AUTOCOMPLETE_NO_MATCH;
+ return match == AUTOCOMPLETE_FULL_MATCH;
}
void ED_fileselect_clear(struct wmWindowManager *wm, struct SpaceFile *sfile)
diff --git a/source/blender/editors/space_file/space_file.c b/source/blender/editors/space_file/space_file.c
index 1a8565a58b1..0bc2d073e0a 100644
--- a/source/blender/editors/space_file/space_file.c
+++ b/source/blender/editors/space_file/space_file.c
@@ -396,6 +396,7 @@ static void file_operatortypes(void)
WM_operatortype_append(FILE_OT_rename);
WM_operatortype_append(FILE_OT_smoothscroll);
WM_operatortype_append(FILE_OT_directory);
+ WM_operatortype_append(FILE_OT_filename);
}
/* NOTE: do not add .blend file reading on this level */