diff --git a/source/blender/python/api2_2x/Font.c b/source/blender/python/api2_2x/Font.c index d5381730433..142ee038bff 100644 --- a/source/blender/python/api2_2x/Font.c +++ b/source/blender/python/api2_2x/Font.c @@ -66,12 +66,15 @@ struct PyMethodDef M_Font_methods[] = { }; /*--------------- Python BPy_Font methods declarations:-------------------*/ -static PyObject *Font_pack( BPy_Font * self, PyObject * args ); +static PyObject *Font_pack( BPy_Font * self ); +static PyObject *Font_unpack( BPy_Font * self, PyObject * args ); /*--------------- Python BPy_Font methods table:--------------------------*/ static PyMethodDef BPy_Font_methods[] = { - {"pack", ( PyCFunction ) Font_pack, METH_VARARGS, - "() - pack/unpack Font"}, + {"pack", ( PyCFunction ) Font_pack, METH_NOARGS, + "() - pack this Font"}, + {"unpack", ( PyCFunction ) Font_unpack, METH_VARARGS, + "(mode) - unpack this packed font"}, {NULL, NULL, 0, NULL} }; @@ -227,7 +230,6 @@ static int Font_setName( BPy_Font * self, PyObject * value ) static int Font_setFilename( BPy_Font * self, PyObject * value ) { char *name = NULL; - int namelen = 0; /* max len is FILE_MAXDIR = 160 chars like done in DNA_image_types.h */ @@ -244,19 +246,28 @@ static int Font_setFilename( BPy_Font * self, PyObject * value ) /*--------------- BPy_Font.pack()---------------------------------*/ -static PyObject *Font_pack( BPy_Font * self, PyObject * args ) +static PyObject *Font_pack( BPy_Font * self ) { - int pack= 0; - if( !PyArg_ParseTuple( args, "i", &pack ) ) + if( !self->font->packedfile ) + self->font->packedfile = newPackedFile(self->font->name); + return EXPP_incr_ret( Py_None ); +} + +/*--------------- BPy_Font.unpack()---------------------------------*/ +static PyObject *Font_unpack( BPy_Font * self, PyObject * args ) +{ + int mode= 0; + VFont *font= self->font; + + if( !PyArg_ParseTuple( args, "i", &mode ) ) return ( EXPP_ReturnPyObjError ( PyExc_AttributeError, - "expected int argument" ) ); - if( pack && !self->font->packedfile ) - self->font->packedfile = newPackedFile(self->font->name); - else if (self->font->packedfile) - if (unpackVFont(self->font, PF_ASK) == RET_OK) - G.fileflags &= ~G_AUTOPACK; + "expected int argument from Blender.UnpackModes" ) ); + if (font->packedfile) + if (unpackVFont(font, mode) == RET_ERROR) + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "error unpacking font" ); return EXPP_incr_ret( Py_None ); } diff --git a/source/blender/python/api2_2x/Sound.c b/source/blender/python/api2_2x/Sound.c index 2b7316b4045..7dddb348472 100644 --- a/source/blender/python/api2_2x/Sound.c +++ b/source/blender/python/api2_2x/Sound.c @@ -444,25 +444,19 @@ static PyObject *Sound_unpack( BPy_Sound * self, PyObject * args ) int mode; if( !PyArg_ParseTuple( args, "i", &mode ) ) return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected 1 integer" ); + "expected an integer from Blender.UnpackModes" ); - if (!sound_sample_is_null(sound)) - { + if (!sound_sample_is_null(sound)) { bSample *sample = sound_find_sample(sound); - if (sample->packedfile==NULL) - return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "sound not packed" ); - if (unpackSample(sample, mode) == RET_ERROR) - return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "error unpacking sound" ); - } - else - { - return EXPP_ReturnPyObjError( PyExc_RuntimeError, - "sound has no samples" ); + if (sample->packedfile) { + if (unpackSample(sample, mode) == RET_ERROR) + return EXPP_ReturnPyObjError( PyExc_RuntimeError, + "error unpacking sound"); + } + } else { + return EXPP_ReturnPyObjError( PyExc_RuntimeError, "sound has no samples" ); } Py_RETURN_NONE; - } /* pack sound */ diff --git a/source/blender/python/api2_2x/doc/Font.py b/source/blender/python/api2_2x/doc/Font.py index 8b029a24a26..dc980c042b6 100644 --- a/source/blender/python/api2_2x/doc/Font.py +++ b/source/blender/python/api2_2x/doc/Font.py @@ -45,14 +45,25 @@ class Font: ====================== This object gives access Blender's B{Font} objects @ivar name: The Font name. - @ivar filename: The filename of the file loaded into this Font. - @ivar packed: The packed status of this font. + @ivar filename: The filename (path) of the file loaded into this Font. + @ivar packed: Boolean, True when the sample is packed (readonly). @ivar users: The number of users this font has (read only) """ - def pack(value): + + def pack(): """ - Get the name of this Text3d object. - @type value: int - @param value: 0 to unpack, 1 to pack. - @rtype: None + Packs the sound into the current blend file. + @note: An error will be raised if the sound is alredy packed or the filename path does not exist. + @returns: nothing + @rtype: none + """ + + def unpack(mode): + """ + Unpacks the sound to the samples filename. + @param mode: One of the values in Blender.UnpackModes dict. + @note: An error will be raised if the sound is not packed or the filename path does not exist. + @returns: nothing + @rtype: none + @type mode: int """