== file browser ==
[#33080] Backup icons - further integration Contributed by Georg Kronthaler, many thanks! * enables display of correct file icon on splash screen and in Open Recent menu * exposes filter_backup in the python api * enables setting BLENDERFILE_BACKUP as active filter in file browser from wm_operators.c (and from .blend in case this setting will be saved in the future) * adds a comment to slightly misleading function name file_is_blend_backup() * Updates icon for backup files to be more consistent with icon for .blend files
This commit is contained in:
Binary file not shown.
Before Width: | Height: | Size: 223 KiB After Width: | Height: | Size: 223 KiB |
Binary file not shown.
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 14 KiB |
@@ -744,6 +744,7 @@ void filelist_setfilter_types(struct FileList *filelist, const char *filter_glob
|
|||||||
BLI_strncpy(filelist->filter_glob, filter_glob, sizeof(filelist->filter_glob));
|
BLI_strncpy(filelist->filter_glob, filter_glob, sizeof(filelist->filter_glob));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* would recognize .blend as well */
|
||||||
static int file_is_blend_backup(const char *str)
|
static int file_is_blend_backup(const char *str)
|
||||||
{
|
{
|
||||||
short a, b;
|
short a, b;
|
||||||
|
@@ -164,6 +164,8 @@ short ED_fileselect_set_params(SpaceFile *sfile)
|
|||||||
params->filter = 0;
|
params->filter = 0;
|
||||||
if (RNA_struct_find_property(op->ptr, "filter_blender"))
|
if (RNA_struct_find_property(op->ptr, "filter_blender"))
|
||||||
params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0;
|
params->filter |= RNA_boolean_get(op->ptr, "filter_blender") ? BLENDERFILE : 0;
|
||||||
|
if (RNA_struct_find_property(op->ptr, "filter_backup"))
|
||||||
|
params->filter |= RNA_boolean_get(op->ptr, "filter_backup") ? BLENDERFILE_BACKUP : 0;
|
||||||
if (RNA_struct_find_property(op->ptr, "filter_image"))
|
if (RNA_struct_find_property(op->ptr, "filter_image"))
|
||||||
params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0;
|
params->filter |= RNA_boolean_get(op->ptr, "filter_image") ? IMAGEFILE : 0;
|
||||||
if (RNA_struct_find_property(op->ptr, "filter_movie"))
|
if (RNA_struct_find_property(op->ptr, "filter_movie"))
|
||||||
|
@@ -58,6 +58,7 @@
|
|||||||
#include "UI_view2d.h"
|
#include "UI_view2d.h"
|
||||||
|
|
||||||
#include "info_intern.h" /* own include */
|
#include "info_intern.h" /* own include */
|
||||||
|
#include "BLO_readfile.h"
|
||||||
|
|
||||||
/* ******************** default callbacks for info space ***************** */
|
/* ******************** default callbacks for info space ***************** */
|
||||||
|
|
||||||
@@ -271,11 +272,16 @@ static void info_header_listener(ARegion *ar, wmNotifier *wmn)
|
|||||||
static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
|
static void recent_files_menu_draw(const bContext *UNUSED(C), Menu *menu)
|
||||||
{
|
{
|
||||||
struct RecentFile *recent;
|
struct RecentFile *recent;
|
||||||
|
char file [FILE_MAX];
|
||||||
uiLayout *layout = menu->layout;
|
uiLayout *layout = menu->layout;
|
||||||
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
|
uiLayoutSetOperatorContext(layout, WM_OP_EXEC_REGION_WIN);
|
||||||
if (G.recent_files.first) {
|
if (G.recent_files.first) {
|
||||||
for (recent = G.recent_files.first; (recent); recent = recent->next) {
|
for (recent = G.recent_files.first; (recent); recent = recent->next) {
|
||||||
uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
|
BLI_split_file_part(recent->filepath, file, sizeof(file));
|
||||||
|
if (BLO_has_bfile_extension(file))
|
||||||
|
uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
|
||||||
|
else
|
||||||
|
uiItemStringO(layout, BLI_path_basename(recent->filepath), ICON_FILE_BACKUP, "WM_OT_open_mainfile", "filepath", recent->filepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@@ -903,6 +903,8 @@ void WM_operator_properties_filesel(wmOperatorType *ot, int filter, short type,
|
|||||||
|
|
||||||
prop = RNA_def_boolean(ot->srna, "filter_blender", (filter & BLENDERFILE), "Filter .blend files", "");
|
prop = RNA_def_boolean(ot->srna, "filter_blender", (filter & BLENDERFILE), "Filter .blend files", "");
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||||
|
prop = RNA_def_boolean(ot->srna, "filter_backup", (filter & BLENDERFILE_BACKUP), "Filter .blend files", "");
|
||||||
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||||
prop = RNA_def_boolean(ot->srna, "filter_image", (filter & IMAGEFILE), "Filter image files", "");
|
prop = RNA_def_boolean(ot->srna, "filter_image", (filter & IMAGEFILE), "Filter image files", "");
|
||||||
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
RNA_def_property_flag(prop, PROP_HIDDEN | PROP_SKIP_SAVE);
|
||||||
prop = RNA_def_boolean(ot->srna, "filter_movie", (filter & MOVIEFILE), "Filter movie files", "");
|
prop = RNA_def_boolean(ot->srna, "filter_movie", (filter & MOVIEFILE), "Filter movie files", "");
|
||||||
@@ -1332,6 +1334,7 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
|
|||||||
int i;
|
int i;
|
||||||
MenuType *mt = WM_menutype_find("USERPREF_MT_splash", TRUE);
|
MenuType *mt = WM_menutype_find("USERPREF_MT_splash", TRUE);
|
||||||
char url[96];
|
char url[96];
|
||||||
|
char file [FILE_MAX];
|
||||||
|
|
||||||
#ifndef WITH_HEADLESS
|
#ifndef WITH_HEADLESS
|
||||||
extern char datatoc_splash_png[];
|
extern char datatoc_splash_png[];
|
||||||
@@ -1419,7 +1422,11 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
|
|||||||
|
|
||||||
uiItemL(col, IFACE_("Recent"), ICON_NONE);
|
uiItemL(col, IFACE_("Recent"), ICON_NONE);
|
||||||
for (recent = G.recent_files.first, i = 0; (i < 5) && (recent); recent = recent->next, i++) {
|
for (recent = G.recent_files.first, i = 0; (i < 5) && (recent); recent = recent->next, i++) {
|
||||||
uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
|
BLI_split_file_part(recent->filepath, file, sizeof(file));
|
||||||
|
if (BLO_has_bfile_extension(file))
|
||||||
|
uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BLEND, "WM_OT_open_mainfile", "filepath", recent->filepath);
|
||||||
|
else
|
||||||
|
uiItemStringO(col, BLI_path_basename(recent->filepath), ICON_FILE_BACKUP, "WM_OT_open_mainfile", "filepath", recent->filepath);
|
||||||
}
|
}
|
||||||
|
|
||||||
uiItemS(col);
|
uiItemS(col);
|
||||||
|
Reference in New Issue
Block a user