Blender  V2.93
rna_vfont_api.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2015 by the Blender Foundation.
17  * All rights reserved.
18  */
19 
24 #include "DNA_packedFile_types.h"
25 
26 #include "RNA_define.h"
27 #include "RNA_enum_types.h"
28 
29 #include "BKE_packedFile.h"
30 
31 #include "rna_internal.h"
32 
33 #ifdef RNA_RUNTIME
34 
35 static void rna_VectorFont_pack(VFont *vfont, Main *bmain, ReportList *reports)
36 {
38  reports, vfont->filepath, ID_BLEND_PATH(bmain, &vfont->id));
39 }
40 
41 static void rna_VectorFont_unpack(VFont *vfont, Main *bmain, ReportList *reports, int method)
42 {
43  if (!vfont->packedfile) {
44  BKE_report(reports, RPT_ERROR, "Font not packed");
45  }
46  else {
47  /* reports its own error on failure */
48  BKE_packedfile_unpack_vfont(bmain, reports, vfont, method);
49  }
50 }
51 
52 #else
53 
55 {
56  FunctionRNA *func;
57 
58  func = RNA_def_function(srna, "pack", "rna_VectorFont_pack");
59  RNA_def_function_ui_description(func, "Pack the font into the current blend file");
61 
62  func = RNA_def_function(srna, "unpack", "rna_VectorFont_unpack");
63  RNA_def_function_ui_description(func, "Unpack the font to the samples filename");
66  func, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "method", "How to unpack");
67 }
68 
69 #endif
int BKE_packedfile_unpack_vfont(struct Main *bmain, struct ReportList *reports, struct VFont *vfont, enum ePF_FileStatus how)
Definition: packedFile.c:579
struct PackedFile * BKE_packedfile_new(struct ReportList *reports, const char *filename, const char *basepath)
Definition: packedFile.c:192
@ PF_USE_LOCAL
void BKE_report(ReportList *reports, ReportType type, const char *message)
Definition: report.c:104
#define ID_BLEND_PATH(_bmain, _id)
Definition: DNA_ID.h:419
@ FUNC_USE_REPORTS
Definition: RNA_types.h:578
@ FUNC_USE_MAIN
Definition: RNA_types.h:576
FunctionRNA * RNA_def_function(StructRNA *srna, const char *identifier, const char *call)
Definition: rna_define.c:4262
void RNA_def_function_ui_description(FunctionRNA *func, const char *description)
Definition: rna_define.c:4337
void RNA_def_function_flag(FunctionRNA *func, int flag)
Definition: rna_define.c:4332
PropertyRNA * RNA_def_enum(StructOrFunctionRNA *cont_, const char *identifier, const EnumPropertyItem *items, int default_value, const char *ui_name, const char *ui_description)
Definition: rna_define.c:3771
const EnumPropertyItem rna_enum_unpack_method_items[]
void RNA_api_vfont(StructRNA *srna)
Definition: rna_vfont_api.c:54
Definition: BKE_main.h:116
char filepath[1024]
struct PackedFile * packedfile