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
20 /** \file
21 * \ingroup RNA
22 */
23
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
rna_VectorFont_pack(VFont * vfont,Main * bmain,ReportList * reports)35 static void rna_VectorFont_pack(VFont *vfont, Main *bmain, ReportList *reports)
36 {
37 vfont->packedfile = BKE_packedfile_new(
38 reports, vfont->filepath, ID_BLEND_PATH(bmain, &vfont->id));
39 }
40
rna_VectorFont_unpack(VFont * vfont,Main * bmain,ReportList * reports,int method)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
RNA_api_vfont(StructRNA * srna)54 void RNA_api_vfont(StructRNA *srna)
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");
60 RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
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");
64 RNA_def_function_flag(func, FUNC_USE_MAIN | FUNC_USE_REPORTS);
65 RNA_def_enum(
66 func, "method", rna_enum_unpack_method_items, PF_USE_LOCAL, "method", "How to unpack");
67 }
68
69 #endif
70