File Reading: add revert operator
Patch D247 by Evans Jahja with edits
This commit is contained in:
@@ -104,6 +104,7 @@ class INFO_MT_file(Menu):
|
|||||||
layout.operator("wm.read_homefile", text="New", icon='NEW')
|
layout.operator("wm.read_homefile", text="New", icon='NEW')
|
||||||
layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
|
layout.operator("wm.open_mainfile", text="Open...", icon='FILE_FOLDER')
|
||||||
layout.menu("INFO_MT_file_open_recent", icon='OPEN_RECENT')
|
layout.menu("INFO_MT_file_open_recent", icon='OPEN_RECENT')
|
||||||
|
layout.operator("wm.revert_mainfile", icon='FILE_REFRESH')
|
||||||
layout.operator("wm.recover_last_session", icon='RECOVER_LAST')
|
layout.operator("wm.recover_last_session", icon='RECOVER_LAST')
|
||||||
layout.operator("wm.recover_auto_save", text="Recover Auto Save...", icon='RECOVER_AUTO')
|
layout.operator("wm.recover_auto_save", text="Recover Auto Save...", icon='RECOVER_AUTO')
|
||||||
|
|
||||||
|
|||||||
@@ -2309,6 +2309,38 @@ static void WM_OT_open_mainfile(wmOperatorType *ot)
|
|||||||
"Allow .blend file to execute scripts automatically, default available from system preferences");
|
"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 *************** */
|
/* **************** link/append *************** */
|
||||||
|
|
||||||
static int wm_link_append_poll(bContext *C)
|
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_window_fullscreen_toggle);
|
||||||
WM_operatortype_append(WM_OT_quit_blender);
|
WM_operatortype_append(WM_OT_quit_blender);
|
||||||
WM_operatortype_append(WM_OT_open_mainfile);
|
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_link_append);
|
||||||
WM_operatortype_append(WM_OT_recover_last_session);
|
WM_operatortype_append(WM_OT_recover_last_session);
|
||||||
WM_operatortype_append(WM_OT_recover_auto_save);
|
WM_operatortype_append(WM_OT_recover_auto_save);
|
||||||
|
|||||||
Reference in New Issue
Block a user