Changeset View
Changeset View
Standalone View
Standalone View
source/blender/editors/space_text/text_ops.c
| Context not available. | |||||
| /** \name Save Operator | /** \name Save Operator | ||||
| * \{ */ | * \{ */ | ||||
| static bool text_save_poll(bContext *C) | static bool text_resolve_conflict_poll(bContext *C) | ||||
| { | { | ||||
| Text *text = CTX_data_edit_text(C); | Text *text = CTX_data_edit_text(C); | ||||
| Context not available. | |||||
| BLI_strncpy(filepath, text->name, FILE_MAX); | BLI_strncpy(filepath, text->name, FILE_MAX); | ||||
| BLI_path_abs(filepath, BKE_main_blendfile_path(bmain)); | BLI_path_abs(filepath, BKE_main_blendfile_path(bmain)); | ||||
| if (BLI_exists(filepath) && !BLI_file_is_writable(filepath)) { | |||||
| BKE_reportf(reports, RPT_ERROR, "Cannot save text file, path \"%s\" is not writable", filepath); | |||||
| return; | |||||
| } | |||||
| fp = BLI_fopen(filepath, "w"); | fp = BLI_fopen(filepath, "w"); | ||||
| if (fp == NULL) { | if (fp == NULL) { | ||||
| BKE_reportf(reports, | BKE_reportf(reports, | ||||
| Context not available. | |||||
| return OPERATOR_FINISHED; | return OPERATOR_FINISHED; | ||||
| } | } | ||||
| static int text_save_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(event)) | |||||
| { | |||||
| Text *text = CTX_data_edit_text(C); | |||||
| if (text->name == NULL || (text->flags & TXT_ISMEM)) { | |||||
| WM_operator_name_call(C, "TEXT_OT_save_as", WM_OP_INVOKE_DEFAULT, NULL); | |||||
| return OPERATOR_CANCELLED; | |||||
| } | |||||
| else { | |||||
| return text_save_exec(C, op); | |||||
| } | |||||
| } | |||||
| void TEXT_OT_save(wmOperatorType *ot) | void TEXT_OT_save(wmOperatorType *ot) | ||||
| { | { | ||||
| /* identifiers */ | /* identifiers */ | ||||
| Context not available. | |||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = text_save_exec; | ot->exec = text_save_exec; | ||||
| ot->poll = text_save_poll; | ot->invoke = text_save_invoke; | ||||
| ot->poll = text_edit_poll; | |||||
| } | } | ||||
| /** \} */ | /** \} */ | ||||
| Context not available. | |||||
| /* api callbacks */ | /* api callbacks */ | ||||
| ot->exec = text_resolve_conflict_exec; | ot->exec = text_resolve_conflict_exec; | ||||
| ot->invoke = text_resolve_conflict_invoke; | ot->invoke = text_resolve_conflict_invoke; | ||||
| ot->poll = text_save_poll; | ot->poll = text_resolve_conflict_poll; | ||||
| /* properties */ | /* properties */ | ||||
| RNA_def_enum(ot->srna, | RNA_def_enum(ot->srna, | ||||
| Context not available. | |||||