diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-01-28 22:34:57 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-01-28 22:34:57 +0400 |
commit | 5643c29fbeacf699b47e84b4d2abc9f20b23cb7c (patch) | |
tree | 0d2a4e649fb5ba5924e4efcd69479e22c8724499 /source | |
parent | 8c688a052c79e006b586598d2ac55a550cea3550 (diff) |
File Reading: add revert operator
Patch D247 by Evans Jahja with edits
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/windowmanager/intern/wm_operators.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/source/blender/windowmanager/intern/wm_operators.c b/source/blender/windowmanager/intern/wm_operators.c index ac23983d8ed..6f82361d64e 100644 --- a/source/blender/windowmanager/intern/wm_operators.c +++ b/source/blender/windowmanager/intern/wm_operators.c @@ -2309,6 +2309,38 @@ static void WM_OT_open_mainfile(wmOperatorType *ot) "Allow .blend file to execute scripts automatically, default available from system preferences"); } + +/* *************** revert file **************** */ + +static int wm_revert_mainfile_exec(bContext *C, wmOperator *op) +{ + bool success; + + success = wm_file_read_opwrap(C, G.main->name, op->reports, true); + + if (success) { + return OPERATOR_FINISHED; + } + else { + return OPERATOR_CANCELLED; + } +} + +static int wm_revert_mainfile_poll(bContext *UNUSED(C)) +{ + return G.relbase_valid; +} + +static void WM_OT_revert_mainfile(wmOperatorType *ot) +{ + ot->name = "Revert"; + ot->idname = "WM_OT_revert_mainfile"; + ot->description = "Reload the saved file"; + + ot->exec = wm_revert_mainfile_exec; + ot->poll = wm_revert_mainfile_poll; +} + /* **************** link/append *************** */ static int wm_link_append_poll(bContext *C) @@ -4367,6 +4399,7 @@ void wm_operatortype_init(void) WM_operatortype_append(WM_OT_window_fullscreen_toggle); WM_operatortype_append(WM_OT_quit_blender); WM_operatortype_append(WM_OT_open_mainfile); + WM_operatortype_append(WM_OT_revert_mainfile); WM_operatortype_append(WM_OT_link_append); WM_operatortype_append(WM_OT_recover_last_session); WM_operatortype_append(WM_OT_recover_auto_save); |