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:
authorJulian Eisel <eiseljulian@gmail.com>2019-09-06 02:22:35 +0300
committerJulian Eisel <eiseljulian@gmail.com>2019-09-06 02:31:45 +0300
commit9972d6c3062010bea514c9e382b0a99275d63a89 (patch)
treed142b202d8f7c02b3991e8e6aa9064195bc7ebce /source/blender/editors/space_file
parent4c4a8bf588c52e05f868a89938fa09e6f25ba1d8 (diff)
UI: Bring back features for file path button
Adds back auto-completion and auto-creation (inserting a non-existing file-path would create it) for the file path button. The second feature was left out knowingly, but seems there are reasonable use cases for it. We can't add these features to the button in the Python script, we have to call into C. So using a template to do that. Note that this is based on the old file browser code, I've copied over the TODO comment.
Diffstat (limited to 'source/blender/editors/space_file')
-rw-r--r--source/blender/editors/space_file/file_draw.c46
1 files changed, 46 insertions, 0 deletions
diff --git a/source/blender/editors/space_file/file_draw.c b/source/blender/editors/space_file/file_draw.c
index 0083fc244d8..722cb885614 100644
--- a/source/blender/editors/space_file/file_draw.c
+++ b/source/blender/editors/space_file/file_draw.c
@@ -71,6 +71,52 @@
#include "file_intern.h" // own include
+void ED_file_path_button(bScreen *screen,
+ const SpaceFile *sfile,
+ FileSelectParams *params,
+ uiBlock *block)
+{
+ PointerRNA params_rna_ptr;
+ uiBut *but;
+
+ RNA_pointer_create(&screen->id, &RNA_FileSelectParams, params, &params_rna_ptr);
+
+ /* callbacks for operator check functions */
+ UI_block_func_set(block, file_draw_check_cb, NULL, NULL);
+
+ but = uiDefButR(block,
+ UI_BTYPE_TEXT,
+ -1,
+ "",
+ 0,
+ 0,
+ UI_UNIT_X * 10,
+ UI_UNIT_Y,
+ &params_rna_ptr,
+ "directory",
+ 0,
+ 0.0f,
+ (float)FILE_MAX,
+ 0.0f,
+ 0.0f,
+ TIP_("File path"));
+
+ BLI_assert(!UI_but_flag_is_set(but, UI_BUT_UNDO));
+ BLI_assert(!UI_but_is_utf8(but));
+
+ UI_but_func_complete_set(but, autocomplete_directory, NULL);
+ UI_but_funcN_set(but, file_directory_enter_handle, NULL, but);
+
+ /* TODO, directory editing is non-functional while a library is loaded
+ * until this is properly supported just disable it. */
+ if (sfile && sfile->files && filelist_lib(sfile->files)) {
+ UI_but_flag_enable(but, UI_BUT_DISABLED);
+ }
+
+ /* clear func */
+ UI_block_func_set(block, NULL, NULL, NULL);
+}
+
/* Dummy helper - we need dynamic tooltips here. */
static char *file_draw_tooltip_func(bContext *UNUSED(C), void *argN, const char *UNUSED(tip))
{