From 4d0f30f4750cf2d000ecbd8a347e2e4da5474fc3 Mon Sep 17 00:00:00 2001 From: Ton Roosendaal Date: Fri, 13 Feb 2009 13:04:48 +0000 Subject: 2.5 Feature restored: save file for the first time automatically names it untitled.blend, prevents to accidentally save over last saved file. --- source/blender/windowmanager/intern/wm_operators.c | 29 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 5 deletions(-) (limited to 'source/blender/windowmanager') diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index eb0d9d312e9..8372aa17208 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -353,6 +353,19 @@ static void WM_OT_open_recentfile(wmOperatorType *ot) /* ********* main file *********** */ +static void untitled(char *name) +{ + if (G.save_over == 0 && strlen(name) < FILE_MAX-16) { + char *c= BLI_last_slash(name); + + if (c) + strcpy(&c[1], "untitled.blend"); + else + strcpy(name, "untitled.blend"); + } +} + + static int wm_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event) { SpaceFile *sfile; @@ -363,7 +376,7 @@ static int wm_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event) /* settings for filebrowser */ sfile= (SpaceFile*)CTX_wm_space_data(C); sfile->op = op; - // XXX replace G.sce + ED_fileselect_set_params(sfile, FILE_BLENDER, "Load", G.sce, 0, 0, 0); /* screen and area have been reset already in ED_screen_full_newspace */ @@ -403,14 +416,17 @@ static void WM_OT_open_mainfile(wmOperatorType *ot) static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event) { SpaceFile *sfile; + char name[FILE_MAX]; ED_screen_full_newspace(C, CTX_wm_area(C), SPACE_FILE); /* settings for filebrowser */ sfile= (SpaceFile*)CTX_wm_space_data(C); sfile->op = op; - // XXX replace G.sce - ED_fileselect_set_params(sfile, FILE_BLENDER, "Save As", G.sce, 0, 0, 0); + + BLI_strncpy(name, G.sce, FILE_MAX); + untitled(name); + ED_fileselect_set_params(sfile, FILE_BLENDER, "Save As", name, 0, 0, 0); /* screen and area have been reset already in ED_screen_full_newspace */ @@ -449,9 +465,12 @@ static void WM_OT_save_as_mainfile(wmOperatorType *ot) static int wm_save_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *event) { + char name[FILE_MAX]; - RNA_string_set(op->ptr, "filename", G.sce); - uiPupMenuSaveOver(C, op, G.sce); + BLI_strncpy(name, G.sce, FILE_MAX); + untitled(name); + RNA_string_set(op->ptr, "filename", name); + uiPupMenuSaveOver(C, op, name); return OPERATOR_RUNNING_MODAL; } -- cgit v1.2.3