Cleanup: UI messages of copy/paste in 3DView.

Remove references to buffer or temp file, some other minor edits.
This commit is contained in:
Bastien Montagne
2019-03-25 10:19:56 +01:00
parent 94388d69bb
commit 14b60c3a1c

View File

@@ -65,31 +65,34 @@ static int view3d_copybuffer_exec(bContext *C, wmOperator *op)
{ {
Main *bmain = CTX_data_main(C); Main *bmain = CTX_data_main(C);
char str[FILE_MAX]; char str[FILE_MAX];
int num_copied = 0;
BKE_copybuffer_begin(bmain); BKE_copybuffer_begin(bmain);
/* context, selection, could be generalized */ /* context, selection, could be generalized */
CTX_DATA_BEGIN (C, Object *, ob, selected_objects) CTX_DATA_BEGIN (C, Object *, ob, selected_objects)
{ {
BKE_copybuffer_tag_ID(&ob->id); if ((ob->id.tag & LIB_TAG_DOIT) == 0) {
BKE_copybuffer_tag_ID(&ob->id);
num_copied++;
}
} }
CTX_DATA_END; CTX_DATA_END;
BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer.blend"); BLI_make_file_string("/", str, BKE_tempdir_base(), "copybuffer.blend");
BKE_copybuffer_save(bmain, str, op->reports); BKE_copybuffer_save(bmain, str, op->reports);
BKE_report(op->reports, RPT_INFO, "Copied selected objects to buffer"); BKE_reportf(op->reports, RPT_INFO, "Copied %d selected objects", num_copied);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
static void VIEW3D_OT_copybuffer(wmOperatorType *ot) static void VIEW3D_OT_copybuffer(wmOperatorType *ot)
{ {
/* identifiers */ /* identifiers */
ot->name = "Copy Selection to Buffer"; ot->name = "Copy Objects";
ot->idname = "VIEW3D_OT_copybuffer"; ot->idname = "VIEW3D_OT_copybuffer";
ot->description = "Selected objects are saved in a temp file"; ot->description = "Selected objects are copied to the clipboard";
/* api callbacks */ /* api callbacks */
ot->exec = view3d_copybuffer_exec; ot->exec = view3d_copybuffer_exec;
@@ -110,13 +113,13 @@ static int view3d_pastebuffer_exec(bContext *C, wmOperator *op)
const int num_pasted = BKE_copybuffer_paste(C, str, flag, op->reports, FILTER_ID_OB); const int num_pasted = BKE_copybuffer_paste(C, str, flag, op->reports, FILTER_ID_OB);
if (num_pasted == 0) { if (num_pasted == 0) {
BKE_report(op->reports, RPT_INFO, "No buffer to paste from"); BKE_report(op->reports, RPT_INFO, "No objects to paste");
return OPERATOR_CANCELLED; return OPERATOR_CANCELLED;
} }
WM_event_add_notifier(C, NC_WINDOW, NULL); WM_event_add_notifier(C, NC_WINDOW, NULL);
BKE_reportf(op->reports, RPT_INFO, "%d objects pasted from buffer", num_pasted); BKE_reportf(op->reports, RPT_INFO, "%d objects pasted", num_pasted);
return OPERATOR_FINISHED; return OPERATOR_FINISHED;
} }
@@ -125,9 +128,9 @@ static void VIEW3D_OT_pastebuffer(wmOperatorType *ot)
{ {
/* identifiers */ /* identifiers */
ot->name = "Paste Selection from Buffer"; ot->name = "Paste Objects";
ot->idname = "VIEW3D_OT_pastebuffer"; ot->idname = "VIEW3D_OT_pastebuffer";
ot->description = "Contents of copy buffer gets pasted"; ot->description = "Objects from the clipboard are pasted";
/* api callbacks */ /* api callbacks */
ot->exec = view3d_pastebuffer_exec; ot->exec = view3d_pastebuffer_exec;
@@ -137,7 +140,8 @@ static void VIEW3D_OT_pastebuffer(wmOperatorType *ot)
ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO; ot->flag = OPTYPE_REGISTER | OPTYPE_UNDO;
RNA_def_boolean(ot->srna, "autoselect", true, "Select", "Select pasted objects"); RNA_def_boolean(ot->srna, "autoselect", true, "Select", "Select pasted objects");
RNA_def_boolean(ot->srna, "active_collection", true, "Active Collection", "Put pasted objects on the active collection"); RNA_def_boolean(ot->srna, "active_collection", true,
"Active Collection", "Put pasted objects in the active collection");
} }
/* ************************** registration **********************************/ /* ************************** registration **********************************/