diff options
Diffstat (limited to 'source/blender/windowmanager/intern/wm_operators.c')
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 79 |
1 files changed, 62 insertions, 17 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index cc5967ab23a..7a97ebf0de7 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -972,7 +972,7 @@ static int wm_open_mainfile_exec(bContext *C, wmOperator *op) WM_read_file(C, path, op->reports); - return 0; + return OPERATOR_FINISHED; } static void WM_OT_open_mainfile(wmOperatorType *ot) @@ -1154,12 +1154,9 @@ static void WM_OT_link_append(wmOperatorType *ot) static int wm_recover_last_session_exec(bContext *C, wmOperator *op) { - char scestr[FILE_MAX], filename[FILE_MAX]; - int save_over; + char filename[FILE_MAX]; - /* back up some values */ - BLI_strncpy(scestr, G.sce, sizeof(scestr)); - save_over = G.save_over; + G.fileflags |= G_FILE_RECOVER; // XXX wm in context is not set correctly after WM_read_file -> crash // do it before for now, but is this correct with multiple windows? @@ -1169,11 +1166,9 @@ static int wm_recover_last_session_exec(bContext *C, wmOperator *op) BLI_make_file_string("/", filename, btempdir, "quit.blend"); WM_read_file(C, filename, op->reports); - /* restore */ - G.save_over = save_over; - BLI_strncpy(G.sce, scestr, sizeof(G.sce)); + G.fileflags &= ~G_FILE_RECOVER; - return 0; + return OPERATOR_FINISHED; } static void WM_OT_recover_last_session(wmOperatorType *ot) @@ -1186,6 +1181,52 @@ static void WM_OT_recover_last_session(wmOperatorType *ot) ot->poll= WM_operator_winactive; } +/* *************** recover auto save **************** */ + +static int wm_recover_auto_save_exec(bContext *C, wmOperator *op) +{ + char path[FILE_MAX]; + + RNA_string_get(op->ptr, "path", path); + + G.fileflags |= G_FILE_RECOVER; + + // XXX wm in context is not set correctly after WM_read_file -> crash + // do it before for now, but is this correct with multiple windows? + WM_event_add_notifier(C, NC_WINDOW, NULL); + + /* load file */ + WM_read_file(C, path, op->reports); + + G.fileflags &= ~G_FILE_RECOVER; + + return OPERATOR_FINISHED; +} + +static int wm_recover_auto_save_invoke(bContext *C, wmOperator *op, wmEvent *event) +{ + char filename[FILE_MAX]; + + wm_autosave_location(filename); + RNA_string_set(op->ptr, "path", filename); + WM_event_add_fileselect(C, op); + + return OPERATOR_RUNNING_MODAL; +} + +static void WM_OT_recover_auto_save(wmOperatorType *ot) +{ + ot->name= "Recover Auto Save"; + ot->idname= "WM_OT_recover_auto_save"; + ot->description="Open an automatically saved file to recover it."; + + ot->exec= wm_recover_auto_save_exec; + ot->invoke= wm_recover_auto_save_invoke; + ot->poll= WM_operator_winactive; + + WM_operator_properties_filesel(ot, BLENDERFILE, FILE_BLENDER); +} + /* *************** save file as **************** */ static void untitled(char *name) @@ -1229,10 +1270,9 @@ static int wm_save_as_mainfile_invoke(bContext *C, wmOperator *op, wmEvent *even static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) { char path[FILE_MAX]; - int compress; + int fileflags; save_set_compress(op); - compress= RNA_boolean_get(op->ptr, "compress"); if(RNA_property_is_set(op->ptr, "path")) RNA_string_get(op->ptr, "path", path); @@ -1241,7 +1281,15 @@ static int wm_save_as_mainfile_exec(bContext *C, wmOperator *op) untitled(path); } - WM_write_file(C, path, compress, op->reports); + fileflags= G.fileflags; + + /* set compression flag */ + if(RNA_boolean_get(op->ptr, "compress")) + fileflags |= G_FILE_COMPRESS; + else + fileflags &= ~G_FILE_COMPRESS; + + WM_write_file(C, path, fileflags, op->reports); WM_event_add_notifier(C, NC_WM|ND_FILESAVE, NULL); @@ -2173,7 +2221,7 @@ void wm_operatortype_init(void) WM_operatortype_append(WM_OT_open_mainfile); WM_operatortype_append(WM_OT_link_append); WM_operatortype_append(WM_OT_recover_last_session); - WM_operatortype_append(WM_OT_jobs_timer); + WM_operatortype_append(WM_OT_recover_auto_save); WM_operatortype_append(WM_OT_save_as_mainfile); WM_operatortype_append(WM_OT_save_mainfile); WM_operatortype_append(WM_OT_redraw_timer); @@ -2188,9 +2236,6 @@ void wm_window_keymap(wmKeyConfig *keyconf) wmKeyMap *keymap= WM_keymap_find(keyconf, "Window", 0, 0); wmKeyMapItem *km; - /* items to make WM work */ - WM_keymap_verify_item(keymap, "WM_OT_jobs_timer", TIMERJOBS, KM_ANY, KM_ANY, 0); - /* note, this doesn't replace existing keymap items */ WM_keymap_verify_item(keymap, "WM_OT_window_duplicate", WKEY, KM_PRESS, KM_CTRL|KM_ALT, 0); #ifdef __APPLE__ |