diff options
author | Julian Eisel <eiseljulian@gmail.com> | 2019-09-02 17:37:50 +0300 |
---|---|---|
committer | Julian Eisel <eiseljulian@gmail.com> | 2019-09-02 17:39:39 +0300 |
commit | 99acf30eddd78b90c6795a672aa6c3c41ca2bddc (patch) | |
tree | 1c3bbb93e6b7dea78f68222d45d30af41b248f9a /source | |
parent | aa0db0038ed82066db531938d660de730f987117 (diff) |
Gray out number increment/decrement button for file open operations
The buttons are shown in the file browser context menu.
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/editors/space_file/file_ops.c | 13 | ||||
-rw-r--r-- | source/blender/editors/space_file/filesel.c | 4 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_space_types.h | 3 | ||||
-rw-r--r-- | source/blender/windowmanager/intern/wm_operator_props.c | 11 |
4 files changed, 29 insertions, 2 deletions
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 6d474ef7ccb..f51854eb61a 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -2361,6 +2361,17 @@ void FILE_OT_bookmark_toggle(struct wmOperatorType *ot) ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ } +static bool file_filenum_poll(bContext *C) +{ + SpaceFile *sfile = CTX_wm_space_file(C); + + if (!ED_operator_file_active(C)) { + return false; + } + + return (sfile->params->action_type == FILE_SAVE); +} + /** * Looks for a string of digits within name (using BLI_stringdec) and adjusts it by add. */ @@ -2418,7 +2429,7 @@ void FILE_OT_filenum(struct wmOperatorType *ot) /* api callbacks */ ot->exec = file_filenum_exec; - ot->poll = ED_operator_file_active; /* <- important, handler is on window level */ + ot->poll = file_filenum_poll; /* props */ RNA_def_int(ot->srna, "increment", 1, -100, 100, "Increment", "", -100, 100); diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 261e4936564..3223fe0c6ce 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -271,6 +271,10 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->sort = FILE_SORT_ALPHA; } + if ((prop = RNA_struct_find_property(op->ptr, "action_type"))) { + params->action_type = RNA_property_enum_get(op->ptr, prop); + } + if (params->display == FILE_DEFAULTDISPLAY) { if (params->display_previous == FILE_DEFAULTDISPLAY) { if (U.uiflag & USER_SHOW_THUMBNAILS) { diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 5415b26c936..2fc42e904c2 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -679,7 +679,8 @@ typedef struct FileSelectParams { short display_previous; /** Details toggles (file size, creation date, etc.) */ char details_flags; - char _pad2; + /* The type of file action (opening or saving) */ + char action_type; /* eFileSel_Action */ /** Filter when (flags & FILE_FILTER) is true. */ int filter; diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c index 8efef043b79..663e4adf06b 100644 --- a/source/blender/windowmanager/intern/wm_operator_props.c +++ b/source/blender/windowmanager/intern/wm_operator_props.c @@ -78,6 +78,14 @@ void WM_operator_properties_filesel(wmOperatorType *ot, {FILE_IMGDISPLAY, "THUMBNAIL", ICON_IMGDISPLAY, "Thumbnails", "Display files as thumbnails"}, {0, NULL, 0, NULL, NULL}, }; + static const EnumPropertyItem file_action_types[] = { + {FILE_OPENFILE, + "OPENFILE", + 0, + "Open", + "Use the file browser for opening files or a directory"}, + {FILE_SAVE, "SAVE", 0, "Save", "Use the file browser for saving a file"}, + }; if (flag & WM_FILESEL_FILEPATH) { RNA_def_string_file_path(ot->srna, "filepath", NULL, FILE_MAX, "File Path", "Path to file"); @@ -195,6 +203,9 @@ void WM_operator_properties_filesel(wmOperatorType *ot, prop = RNA_def_enum( ot->srna, "sort_method", rna_enum_file_sort_items, sort, "File sorting mode", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); + + prop = RNA_def_enum(ot->srna, "action_type", file_action_types, action, "Action Type", ""); + RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } static void wm_operator_properties_select_action_ex(wmOperatorType *ot, |