diff options
30 files changed, 157 insertions, 91 deletions
diff --git a/source/blender/editors/curve/editfont.c b/source/blender/editors/curve/editfont.c index 1e5984ee14c..1eb35b2c647 100644 --- a/source/blender/editors/curve/editfont.c +++ b/source/blender/editors/curve/editfont.c @@ -626,7 +626,7 @@ void FONT_OT_text_paste_from_file(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /** \} */ @@ -2160,7 +2160,7 @@ void FONT_OT_open(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /** \} */ diff --git a/source/blender/editors/io/io_alembic.c b/source/blender/editors/io/io_alembic.c index 292d8e6066c..70125ff35fc 100644 --- a/source/blender/editors/io/io_alembic.c +++ b/source/blender/editors/io/io_alembic.c @@ -292,7 +292,7 @@ void WM_OT_alembic_export(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_int(ot->srna, "start", @@ -677,7 +677,7 @@ void WM_OT_alembic_import(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_float( ot->srna, diff --git a/source/blender/editors/io/io_cache.c b/source/blender/editors/io/io_cache.c index 045a293f71b..b73b8abccfe 100644 --- a/source/blender/editors/io/io_cache.c +++ b/source/blender/editors/io/io_cache.c @@ -134,7 +134,7 @@ void CACHEFILE_OT_open(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /* ***************************** Reload Operator **************************** */ diff --git a/source/blender/editors/io/io_collada.c b/source/blender/editors/io/io_collada.c index 54ef5e6b8c5..af505043e6a 100644 --- a/source/blender/editors/io/io_collada.c +++ b/source/blender/editors/io/io_collada.c @@ -507,7 +507,7 @@ void WM_OT_collada_export(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_enum(func, "prop_bc_export_ui_section", @@ -828,7 +828,7 @@ void WM_OT_collada_import(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_boolean(ot->srna, "import_units", diff --git a/source/blender/editors/io/io_usd.c b/source/blender/editors/io/io_usd.c index 45ea52bdebc..0eadb38abb5 100644 --- a/source/blender/editors/io/io_usd.c +++ b/source/blender/editors/io/io_usd.c @@ -185,7 +185,7 @@ void WM_OT_usd_export(struct wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_boolean(ot->srna, "selected_objects_only", diff --git a/source/blender/editors/object/object_modifier.c b/source/blender/editors/object/object_modifier.c index 17dc8f46796..ce08c5926f2 100644 --- a/source/blender/editors/object/object_modifier.c +++ b/source/blender/editors/object/object_modifier.c @@ -1906,7 +1906,7 @@ void OBJECT_OT_multires_external_save(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); edit_modifier_properties(ot); } diff --git a/source/blender/editors/object/object_volume.c b/source/blender/editors/object/object_volume.c index c5dc7f9f24d..5aa61139468 100644 --- a/source/blender/editors/object/object_volume.c +++ b/source/blender/editors/object/object_volume.c @@ -184,7 +184,7 @@ void OBJECT_OT_volume_import(wmOperatorType *ot) WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILES | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_boolean( ot->srna, diff --git a/source/blender/editors/physics/rigidbody_world.c b/source/blender/editors/physics/rigidbody_world.c index 42f270874e3..f2e2d7589df 100644 --- a/source/blender/editors/physics/rigidbody_world.c +++ b/source/blender/editors/physics/rigidbody_world.c @@ -210,5 +210,5 @@ void RIGIDBODY_OT_world_export(wmOperatorType *ot) FILE_SAVE, FILE_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } diff --git a/source/blender/editors/screen/screendump.c b/source/blender/editors/screen/screendump.c index 5d0ae292ffa..7d7a3340dc3 100644 --- a/source/blender/editors/screen/screendump.c +++ b/source/blender/editors/screen/screendump.c @@ -249,7 +249,7 @@ void SCREEN_OT_screenshot(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_boolean(ot->srna, "full", 1, diff --git a/source/blender/editors/sound/sound_ops.c b/source/blender/editors/sound/sound_ops.c index 8bf14f85b89..8e2bb6a4813 100644 --- a/source/blender/editors/sound/sound_ops.c +++ b/source/blender/editors/sound/sound_ops.c @@ -171,7 +171,7 @@ static void SOUND_OT_open(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_boolean(ot->srna, "cache", false, "Cache", "Cache the sound in memory"); RNA_def_boolean(ot->srna, "mono", false, "Mono", "Merge all the sound's channels into one"); } @@ -198,7 +198,7 @@ static void SOUND_OT_open_mono(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_boolean(ot->srna, "cache", false, "Cache", "Cache the sound in memory"); RNA_def_boolean(ot->srna, "mono", true, "Mono", "Mixdown the sound to mono"); } @@ -722,7 +722,7 @@ static void SOUND_OT_mixdown(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); #ifdef WITH_AUDASPACE RNA_def_int( ot->srna, diff --git a/source/blender/editors/space_buttons/buttons_ops.c b/source/blender/editors/space_buttons/buttons_ops.c index 87cf8507dd4..8bdc2ed993f 100644 --- a/source/blender/editors/space_buttons/buttons_ops.c +++ b/source/blender/editors/space_buttons/buttons_ops.c @@ -378,7 +378,7 @@ void BUTTONS_OT_file_browse(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /* Second operator, only difference from BUTTONS_OT_file_browse is WM_FILESEL_DIRECTORY. */ @@ -405,7 +405,7 @@ void BUTTONS_OT_directory_browse(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /** \} */ diff --git a/source/blender/editors/space_clip/clip_ops.c b/source/blender/editors/space_clip/clip_ops.c index 26fa5b8a06c..1b962a92be5 100644 --- a/source/blender/editors/space_clip/clip_ops.c +++ b/source/blender/editors/space_clip/clip_ops.c @@ -329,7 +329,7 @@ void CLIP_OT_open(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_RELPATH | WM_FILESEL_FILES | WM_FILESEL_DIRECTORY, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /** \} */ diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c index 7cfd749d013..93367ad3d3c 100644 --- a/source/blender/editors/space_file/file_ops.c +++ b/source/blender/editors/space_file/file_ops.c @@ -1351,18 +1351,17 @@ static int file_column_sort_ui_context_invoke(bContext *C, if (column_type != COLUMN_NONE) { const FileAttributeColumn *column = &sfile->layout->attribute_columns[column_type]; - if (column->sort_type != FILE_SORT_NONE) { - if (sfile->params->sort == column->sort_type) { - /* Already sorting by selected column -> toggle sort invert (three state logic). */ - sfile->params->flag ^= FILE_SORT_INVERT; - } - else { - sfile->params->sort = column->sort_type; - sfile->params->flag &= ~FILE_SORT_INVERT; - } - - WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); + BLI_assert(column->sort_type != FILE_SORT_DEFAULT); + if (sfile->params->sort == column->sort_type) { + /* Already sorting by selected column -> toggle sort invert (three state logic). */ + sfile->params->flag ^= FILE_SORT_INVERT; } + else { + sfile->params->sort = column->sort_type; + sfile->params->flag &= ~FILE_SORT_INVERT; + } + + WM_event_add_notifier(C, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); } } diff --git a/source/blender/editors/space_file/filelist.c b/source/blender/editors/space_file/filelist.c index 465f05246ca..24b8d4deca0 100644 --- a/source/blender/editors/space_file/filelist.c +++ b/source/blender/editors/space_file/filelist.c @@ -583,7 +583,7 @@ static int compare_extension(void *user_data, const void *a1, const void *a2) void filelist_sort(struct FileList *filelist) { - if ((filelist->flags & FL_NEED_SORTING) && (filelist->sort != FILE_SORT_NONE)) { + if (filelist->flags & FL_NEED_SORTING) { void *sort_cb = NULL; switch (filelist->sort) { @@ -599,7 +599,7 @@ void filelist_sort(struct FileList *filelist) case FILE_SORT_EXTENSION: sort_cb = compare_extension; break; - case FILE_SORT_NONE: /* Should never reach this point! */ + case FILE_SORT_DEFAULT: default: BLI_assert(0); break; @@ -1562,7 +1562,6 @@ void filelist_free(struct FileList *filelist) memset(&filelist->filter_data, 0, sizeof(filelist->filter_data)); filelist->flags &= ~(FL_NEED_SORTING | FL_NEED_FILTERING); - filelist->sort = FILE_SORT_NONE; } void filelist_freelib(struct FileList *filelist) diff --git a/source/blender/editors/space_file/filesel.c b/source/blender/editors/space_file/filesel.c index 5d90403937a..15c6972c5f5 100644 --- a/source/blender/editors/space_file/filesel.c +++ b/source/blender/editors/space_file/filesel.c @@ -267,15 +267,16 @@ short ED_fileselect_set_params(SpaceFile *sfile) params->display = RNA_property_enum_get(op->ptr, prop); } + if (params->display == FILE_DEFAULTDISPLAY) { + params->display = U_default.file_space_data.display_type; + } + if ((prop = RNA_struct_find_property(op->ptr, "sort_method"))) { params->sort = RNA_property_enum_get(op->ptr, prop); } - else { - params->sort = U_default.file_space_data.sort_type; - } - if (params->display == FILE_DEFAULTDISPLAY) { - params->display = U_default.file_space_data.display_type; + if (params->sort == FILE_SORT_DEFAULT) { + params->sort = U_default.file_space_data.sort_type; } if (is_relative_path) { @@ -327,8 +328,9 @@ short ED_fileselect_set_params(SpaceFile *sfile) return 1; } -/* The subset of FileSelectParams.flag items we store into preferences. */ -#define PARAMS_FLAGS_REMEMBERED (FILE_HIDE_DOT | FILE_SORT_INVERT) +/* The subset of FileSelectParams.flag items we store into preferences. Note that FILE_SORT_ALPHA + * may also be remembered, but only conditionally. */ +#define PARAMS_FLAGS_REMEMBERED (FILE_HIDE_DOT) void ED_fileselect_window_params_get(const wmWindow *win, int win_size[2], bool *is_maximized) { @@ -341,6 +343,22 @@ void ED_fileselect_window_params_get(const wmWindow *win, int win_size[2], bool *is_maximized = WM_window_is_maximized(win); } +static bool file_select_use_default_display_type(const SpaceFile *sfile) +{ + PropertyRNA *prop; + return (sfile->op == NULL) || + !(prop = RNA_struct_find_property(sfile->op->ptr, "display_type")) || + (RNA_property_enum_get(sfile->op->ptr, prop) == FILE_DEFAULTDISPLAY); +} + +static bool file_select_use_default_sort_type(const SpaceFile *sfile) +{ + PropertyRNA *prop; + return (sfile->op == NULL) || + !(prop = RNA_struct_find_property(sfile->op->ptr, "sort_method")) || + (RNA_property_enum_get(sfile->op->ptr, prop) == FILE_SORT_DEFAULT); +} + void ED_fileselect_set_params_from_userdef(SpaceFile *sfile) { wmOperator *op = sfile->op; @@ -352,12 +370,6 @@ void ED_fileselect_set_params_from_userdef(SpaceFile *sfile) return; } - if (!RNA_struct_property_is_set(op->ptr, "display_type")) { - sfile->params->display = sfile_udata->display_type; - } - if (!RNA_struct_property_is_set(op->ptr, "sort_method")) { - sfile->params->sort = sfile_udata->sort_type; - } sfile->params->thumbnail_size = sfile_udata->thumbnail_size; sfile->params->details_flags = sfile_udata->details_flags; sfile->params->filter_id = sfile_udata->filter_id; @@ -365,6 +377,16 @@ void ED_fileselect_set_params_from_userdef(SpaceFile *sfile) /* Combine flags we take from params with the flags we take from userdef. */ sfile->params->flag = (sfile->params->flag & ~PARAMS_FLAGS_REMEMBERED) | (sfile_udata->flag & PARAMS_FLAGS_REMEMBERED); + + if (file_select_use_default_display_type(sfile)) { + sfile->params->display = sfile_udata->display_type; + } + if (file_select_use_default_sort_type(sfile)) { + sfile->params->sort = sfile_udata->sort_type; + /* For the default sorting, also take invert flag from userdef. */ + sfile->params->flag = (sfile->params->flag & ~FILE_SORT_INVERT) | + (sfile_udata->flag & FILE_SORT_INVERT); + } } /** @@ -381,13 +403,24 @@ void ED_fileselect_params_to_userdef(SpaceFile *sfile, UserDef_FileSpaceData *sfile_udata_new = &U.file_space_data; UserDef_FileSpaceData sfile_udata_old = U.file_space_data; - sfile_udata_new->display_type = sfile->params->display; sfile_udata_new->thumbnail_size = sfile->params->thumbnail_size; - sfile_udata_new->sort_type = sfile->params->sort; sfile_udata_new->details_flags = sfile->params->details_flags; sfile_udata_new->flag = sfile->params->flag & PARAMS_FLAGS_REMEMBERED; sfile_udata_new->filter_id = sfile->params->filter_id; + /* In some rare cases, operators ask for a specific display or sort type (e.g. chronological + * sorting for "Recover Auto Save"). So the settings are optimized for a specific operation. + * Don't let that change the userdef memory for more general cases. */ + if (file_select_use_default_display_type(sfile)) { + sfile_udata_new->display_type = sfile->params->display; + } + if (file_select_use_default_sort_type(sfile)) { + sfile_udata_new->sort_type = sfile->params->sort; + /* In this case also remember the invert flag. */ + sfile_udata_new->flag = (sfile_udata_new->flag & ~FILE_SORT_INVERT) | + (sfile->params->flag & FILE_SORT_INVERT); + } + if (temp_win_size && !is_maximized) { sfile_udata_new->temp_win_sizex = temp_win_size[0]; sfile_udata_new->temp_win_sizey = temp_win_size[1]; diff --git a/source/blender/editors/space_graph/graph_edit.c b/source/blender/editors/space_graph/graph_edit.c index 0f3dda6f905..07af1606226 100644 --- a/source/blender/editors/space_graph/graph_edit.c +++ b/source/blender/editors/space_graph/graph_edit.c @@ -2090,7 +2090,7 @@ void GRAPH_OT_sound_bake(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_float(ot->srna, "low", 0.0f, diff --git a/source/blender/editors/space_image/image_ops.c b/source/blender/editors/space_image/image_ops.c index 0cdd3f4f204..6f511d30aa9 100644 --- a/source/blender/editors/space_image/image_ops.c +++ b/source/blender/editors/space_image/image_ops.c @@ -1486,7 +1486,7 @@ void IMAGE_OT_open(wmOperatorType *ot) WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILES | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_boolean( ot->srna, @@ -1638,7 +1638,7 @@ void IMAGE_OT_replace(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /** \} */ @@ -2038,7 +2038,7 @@ void IMAGE_OT_save_as(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /** \} */ diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c index 0544a2cbefa..1435b95c9bf 100644 --- a/source/blender/editors/space_info/info_ops.c +++ b/source/blender/editors/space_info/info_ops.c @@ -516,7 +516,7 @@ void FILE_OT_find_missing_files(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_DIRECTORY, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /********************* report box operator *********************/ diff --git a/source/blender/editors/space_node/node_add.c b/source/blender/editors/space_node/node_add.c index f8382a17c59..508c0a47e21 100644 --- a/source/blender/editors/space_node/node_add.c +++ b/source/blender/editors/space_node/node_add.c @@ -404,7 +404,7 @@ void NODE_OT_add_file(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_string(ot->srna, "name", "Image", MAX_ID_NAME - 2, "Name", "Data-block name to assign"); } diff --git a/source/blender/editors/space_sequencer/sequencer_add.c b/source/blender/editors/space_sequencer/sequencer_add.c index 42abc97bebe..7cf5218cfaa 100644 --- a/source/blender/editors/space_sequencer/sequencer_add.c +++ b/source/blender/editors/space_sequencer/sequencer_add.c @@ -725,7 +725,7 @@ void SEQUENCER_OT_movie_strip_add(struct wmOperatorType *ot) WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES | WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_boolean(ot->srna, "sound", true, "Sound", "Load sound with the movie"); RNA_def_boolean(ot->srna, @@ -780,7 +780,7 @@ void SEQUENCER_OT_sound_strip_add(struct wmOperatorType *ot) WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH | WM_FILESEL_FILES | WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME); RNA_def_boolean(ot->srna, "cache", false, "Cache", "Cache the sound in memory"); RNA_def_boolean(ot->srna, "mono", false, "Mono", "Merge all the sound's channels into one"); @@ -972,7 +972,7 @@ void SEQUENCER_OT_image_strip_add(struct wmOperatorType *ot) WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILES | WM_FILESEL_SHOW_PROPS | WM_FILESEL_DIRECTORY, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); sequencer_generic_props__internal(ot, SEQPROP_STARTFRAME | SEQPROP_ENDFRAME); RNA_def_boolean(ot->srna, diff --git a/source/blender/editors/space_sequencer/sequencer_edit.c b/source/blender/editors/space_sequencer/sequencer_edit.c index 92449126d2c..e405864432a 100644 --- a/source/blender/editors/space_sequencer/sequencer_edit.c +++ b/source/blender/editors/space_sequencer/sequencer_edit.c @@ -3919,7 +3919,7 @@ void SEQUENCER_OT_change_path(struct wmOperatorType *ot) WM_FILESEL_DIRECTORY | WM_FILESEL_RELPATH | WM_FILESEL_FILEPATH | WM_FILESEL_FILES, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_boolean(ot->srna, "use_placeholders", false, @@ -4064,7 +4064,7 @@ void SEQUENCER_OT_export_subtitles(struct wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /** \} */ diff --git a/source/blender/editors/space_text/text_ops.c b/source/blender/editors/space_text/text_ops.c index 1ca7222e02d..7c592519384 100644 --- a/source/blender/editors/space_text/text_ops.c +++ b/source/blender/editors/space_text/text_ops.c @@ -416,7 +416,7 @@ void TEXT_OT_open(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); /* TODO: relative_path. */ + FILE_SORT_DEFAULT); /* TODO: relative_path. */ RNA_def_boolean( ot->srna, "internal", 0, "Make Internal", "Make text file internal after loading"); } @@ -751,7 +751,7 @@ void TEXT_OT_save_as(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); /* XXX TODO, relative_path. */ + FILE_SORT_DEFAULT); /* XXX TODO, relative_path. */ } /** \} */ diff --git a/source/blender/editors/space_view3d/view3d_edit.c b/source/blender/editors/space_view3d/view3d_edit.c index 7ec6bddd6a3..6e24dfd1db9 100644 --- a/source/blender/editors/space_view3d/view3d_edit.c +++ b/source/blender/editors/space_view3d/view3d_edit.c @@ -4828,7 +4828,7 @@ void VIEW3D_OT_background_image_add(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /** \} */ diff --git a/source/blender/makesdna/DNA_space_types.h b/source/blender/makesdna/DNA_space_types.h index 8eb52bb776b..95cc0317a46 100644 --- a/source/blender/makesdna/DNA_space_types.h +++ b/source/blender/makesdna/DNA_space_types.h @@ -760,7 +760,13 @@ typedef struct SpaceFile { /* FileSelectParams.display */ enum eFileDisplayType { + /** Internal (not exposed to users): Keep whatever display type was used during the last File + * Browser use, or the default if no such record is found. Use this unless there's a good reason + * to set a specific display type. */ FILE_DEFAULTDISPLAY = 0, + + /* User selectable choices. */ + FILE_VERTICALDISPLAY = 1, FILE_HORIZONTALDISPLAY = 2, FILE_IMGDISPLAY = 3, @@ -768,7 +774,13 @@ enum eFileDisplayType { /* FileSelectParams.sort */ enum eFileSortType { - FILE_SORT_NONE = 0, + /** Internal (not exposed to users): Sort by whatever was sorted by during the last File Browser + * use, or the default if no such record is found. Use this unless there's a good reason to set a + * specific sort order. */ + FILE_SORT_DEFAULT = 0, + + /* User selectable choices. */ + FILE_SORT_ALPHA = 1, FILE_SORT_EXTENSION = 2, FILE_SORT_TIME = 3, diff --git a/source/blender/makesrna/RNA_enum_types.h b/source/blender/makesrna/RNA_enum_types.h index 831e8dc424d..a94466e30c2 100644 --- a/source/blender/makesrna/RNA_enum_types.h +++ b/source/blender/makesrna/RNA_enum_types.h @@ -61,6 +61,7 @@ extern const EnumPropertyItem rna_enum_space_type_items[]; extern const EnumPropertyItem rna_enum_space_image_mode_items[]; extern const EnumPropertyItem rna_enum_space_image_mode_all_items[]; extern const EnumPropertyItem rna_enum_space_action_mode_items[]; +extern const EnumPropertyItem rna_enum_fileselect_params_sort_items[]; extern const EnumPropertyItem rna_enum_region_type_items[]; extern const EnumPropertyItem rna_enum_object_modifier_type_items[]; extern const EnumPropertyItem rna_enum_constraint_type_items[]; @@ -190,8 +191,6 @@ extern const EnumPropertyItem rna_enum_shading_type_items[]; extern const EnumPropertyItem rna_enum_navigation_mode_items[]; -extern const EnumPropertyItem rna_enum_file_sort_items[]; - extern const EnumPropertyItem rna_enum_node_socket_in_out_items[]; extern const EnumPropertyItem rna_enum_node_math_items[]; diff --git a/source/blender/makesrna/intern/rna_space.c b/source/blender/makesrna/intern/rna_space.c index 70c7bf0a81e..203b8459ae6 100644 --- a/source/blender/makesrna/intern/rna_space.c +++ b/source/blender/makesrna/intern/rna_space.c @@ -308,6 +308,22 @@ static const EnumPropertyItem multiview_camera_items[] = { #undef V3D_S3D_CAMERA_S3D #undef V3D_S3D_CAMERA_VIEWS +const EnumPropertyItem rna_enum_fileselect_params_sort_items[] = { + {FILE_SORT_ALPHA, "FILE_SORT_ALPHA", ICON_NONE, "Name", "Sort the file list alphabetically"}, + {FILE_SORT_EXTENSION, + "FILE_SORT_EXTENSION", + ICON_NONE, + "Extension", + "Sort the file list by extension/type"}, + {FILE_SORT_TIME, + "FILE_SORT_TIME", + ICON_NONE, + "Modified Date", + "Sort files by modification time"}, + {FILE_SORT_SIZE, "FILE_SORT_SIZE", ICON_NONE, "Size", "Sort files by size"}, + {0, NULL, 0, NULL, NULL}, +}; + #ifndef RNA_RUNTIME static const EnumPropertyItem stereo3d_eye_items[] = { {STEREO_LEFT_ID, "LEFT_EYE", ICON_NONE, "Left Eye"}, @@ -464,22 +480,6 @@ static const EnumPropertyItem fileselectparams_recursion_level_items[] = { {0, NULL, 0, NULL, NULL}, }; -const EnumPropertyItem rna_enum_file_sort_items[] = { - {FILE_SORT_ALPHA, "FILE_SORT_ALPHA", ICON_NONE, "Name", "Sort the file list alphabetically"}, - {FILE_SORT_EXTENSION, - "FILE_SORT_EXTENSION", - ICON_NONE, - "Extension", - "Sort the file list by extension/type"}, - {FILE_SORT_TIME, - "FILE_SORT_TIME", - ICON_NONE, - "Modified Date", - "Sort files by modification time"}, - {FILE_SORT_SIZE, "FILE_SORT_SIZE", ICON_NONE, "Size", "Sort files by size"}, - {0, NULL, 0, NULL, NULL}, -}; - static const EnumPropertyItem rna_enum_curve_display_handle_items[] = { {CURVE_HANDLE_NONE, "NONE", 0, "None", ""}, {CURVE_HANDLE_SELECTED, "SELECTED", 0, "Selected", ""}, @@ -5827,7 +5827,7 @@ static void rna_def_fileselect_params(BlenderRNA *brna) prop = RNA_def_property(srna, "sort_method", PROP_ENUM, PROP_NONE); RNA_def_property_enum_sdna(prop, NULL, "sort"); - RNA_def_property_enum_items(prop, rna_enum_file_sort_items); + RNA_def_property_enum_items(prop, rna_enum_fileselect_params_sort_items); RNA_def_property_ui_text(prop, "Sort", ""); RNA_def_property_update(prop, NC_SPACE | ND_SPACE_FILE_PARAMS, NULL); diff --git a/source/blender/windowmanager/intern/wm_event_system.c b/source/blender/windowmanager/intern/wm_event_system.c index a6b8eb9d3fd..ee0c7df99e7 100644 --- a/source/blender/windowmanager/intern/wm_event_system.c +++ b/source/blender/windowmanager/intern/wm_event_system.c @@ -1736,7 +1736,7 @@ void WM_event_remove_handlers(bContext *C, ListBase *handlers) wmWindow *win = CTX_wm_window(C); if (handler->is_fileselect) { - /* Exit File Browsers refering to this handler/operator. */ + /* Exit File Browsers referring to this handler/operator. */ LISTBASE_FOREACH (wmWindow *, temp_win, &wm->windows) { ScrArea *file_area = ED_fileselect_handler_area_find(temp_win, handler->op); if (!file_area) { diff --git a/source/blender/windowmanager/intern/wm_files.c b/source/blender/windowmanager/intern/wm_files.c index 19e4adde19c..4706287a3a9 100644 --- a/source/blender/windowmanager/intern/wm_files.c +++ b/source/blender/windowmanager/intern/wm_files.c @@ -2482,7 +2482,7 @@ void WM_OT_open_mainfile(wmOperatorType *ot) FILE_OPENFILE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_boolean( ot->srna, "load_ui", true, "Load UI", "Load user interface setup in the .blend file"); @@ -2804,7 +2804,7 @@ void WM_OT_save_as_mainfile(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_boolean(ot->srna, "compress", false, "Compress", "Write compressed .blend file"); RNA_def_boolean(ot->srna, "relative_remap", @@ -2874,7 +2874,7 @@ void WM_OT_save_mainfile(wmOperatorType *ot) FILE_SAVE, WM_FILESEL_FILEPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); RNA_def_boolean(ot->srna, "compress", false, "Compress", "Write compressed .blend file"); RNA_def_boolean(ot->srna, "relative_remap", diff --git a/source/blender/windowmanager/intern/wm_files_link.c b/source/blender/windowmanager/intern/wm_files_link.c index cfbc037d19c..49ac250d9a3 100644 --- a/source/blender/windowmanager/intern/wm_files_link.c +++ b/source/blender/windowmanager/intern/wm_files_link.c @@ -598,7 +598,7 @@ void WM_OT_link(wmOperatorType *ot) WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_RELPATH | WM_FILESEL_FILES | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); wm_link_append_properties_common(ot, true); } @@ -622,7 +622,7 @@ void WM_OT_append(wmOperatorType *ot) WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_FILES | WM_FILESEL_SHOW_PROPS, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); wm_link_append_properties_common(ot, false); RNA_def_boolean(ot->srna, @@ -1172,7 +1172,7 @@ void WM_OT_lib_relocate(wmOperatorType *ot) WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_FILES | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } static int wm_lib_reload_exec(bContext *C, wmOperator *op) @@ -1202,7 +1202,7 @@ void WM_OT_lib_reload(wmOperatorType *ot) WM_FILESEL_FILEPATH | WM_FILESEL_DIRECTORY | WM_FILESEL_FILENAME | WM_FILESEL_RELPATH, FILE_DEFAULTDISPLAY, - FILE_SORT_ALPHA); + FILE_SORT_DEFAULT); } /** \} */ diff --git a/source/blender/windowmanager/intern/wm_operator_props.c b/source/blender/windowmanager/intern/wm_operator_props.c index 62294d70306..87716a61c39 100644 --- a/source/blender/windowmanager/intern/wm_operator_props.c +++ b/source/blender/windowmanager/intern/wm_operator_props.c @@ -48,6 +48,30 @@ void WM_operator_properties_confirm_or_exec(wmOperatorType *ot) RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } +/** + * Extends rna_enum_fileselect_params_sort_items with a default item for operators to use. + */ +static const EnumPropertyItem *wm_operator_properties_filesel_sort_items_itemf( + struct bContext *UNUSED(C), PointerRNA *UNUSED(ptr), PropertyRNA *UNUSED(prop), bool *r_free) +{ + EnumPropertyItem *items; + const EnumPropertyItem default_item = { + FILE_SORT_DEFAULT, + "DEFAULT", + 0, + "Default", + "Automatically determine sort method for files", + }; + int totitem = 0; + + RNA_enum_item_add(&items, &totitem, &default_item); + RNA_enum_items_add(&items, &totitem, rna_enum_fileselect_params_sort_items); + RNA_enum_item_end(&items, &totitem); + *r_free = true; + + return items; +} + /* default properties for fileselect */ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, @@ -204,8 +228,8 @@ void WM_operator_properties_filesel(wmOperatorType *ot, prop = RNA_def_enum(ot->srna, "display_type", file_display_items, display, "Display Type", ""); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); - prop = RNA_def_enum( - ot->srna, "sort_method", rna_enum_file_sort_items, sort, "File sorting mode", ""); + prop = RNA_def_enum(ot->srna, "sort_method", DummyRNA_NULL_items, sort, "File sorting mode", ""); + RNA_def_enum_funcs(prop, wm_operator_properties_filesel_sort_items_itemf); RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE); } |