diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-03-26 15:24:52 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-03-26 15:24:52 +0400 |
commit | 31673f0a8c5b98b3a837d5003ca1275080354bee (patch) | |
tree | 6ca72c74b43094e4262674afdd7e1d00568a9f24 | |
parent | 59f0b2fb436c06592ffa4ea09ce74edc60f5fc40 (diff) |
removed commenst from space.c
removed .load() from bpy.*dataseq* - Use .new(filename='') instead as discussed at the meeting.
-rw-r--r-- | source/blender/python/api2_2x/Main.c | 108 | ||||
-rw-r--r-- | source/blender/src/space.c | 14 |
2 files changed, 64 insertions, 58 deletions
diff --git a/source/blender/python/api2_2x/Main.c b/source/blender/python/api2_2x/Main.c index 3531a6a4427..276d0b04660 100644 --- a/source/blender/python/api2_2x/Main.c +++ b/source/blender/python/api2_2x/Main.c @@ -389,14 +389,71 @@ Mesh *add_mesh__internal(char *name) return mesh; } -PyObject *MainSeq_new(BPy_MainSeq *self, PyObject * args) +/* used for new and load */ +PyObject *MainSeq_new(BPy_MainSeq *self, PyObject * args, PyObject *kwd) { ID *id = NULL; - char *name, *ipo_type; + char *name=NULL, *filename=NULL, *ipo_type; int img_width=256, img_height=256; short ipo_code = 0; int user_count = 0; + /* Load from file */ + if ( ( self->type==ID_IM || self->type==ID_VF || + self->type==ID_SO || self->type==ID_TXT) && + ( PyTuple_Size( args ) < 3 )) + { + static char *kwlist[] = {"name", "filename", NULL}; + + if(PyArg_ParseTupleAndKeywords(args, kwd, "|ss", kwlist, &name, &filename) && filename ) { + PyObject *ret; + + if (strlen(filename) > FILE_MAXDIR + FILE_MAXFILE - 1) + return ( EXPP_ReturnPyObjError( PyExc_IOError, + "filename too long" ) ); + + if (self->type == ID_IM) { + Image *img = BKE_add_image_file( filename ); + if (!img) + return ( EXPP_ReturnPyObjError( PyExc_IOError, + "couldn't load image" ) ); + ret = Image_CreatePyObject( img ); + + } else if (self->type == ID_VF) { + VFont *vf = load_vfont (filename); + if (!vf) + return EXPP_ReturnPyObjError( PyExc_IOError, + "couldn't load font" ); + ret = Font_CreatePyObject(vf); + + } else if (self->type == ID_SO) { + bSound *snd = sound_new_sound( filename ); + if (!snd) + return EXPP_ReturnPyObjError( PyExc_IOError, + "couldn't load sound" ); + ret = Sound_CreatePyObject(snd); + + } else if (self->type == ID_TXT) { + Text *txt = NULL; + txt = add_text( filename ); + if( !txt ) + return EXPP_ReturnPyObjError( PyExc_IOError, + "couldn't load text" ); + ret = Text_CreatePyObject(txt); + } + + if (!ret) + return EXPP_ReturnPyObjError( PyExc_IOError, + "couldn't create pyobject on load, unknown error" ); + if (name) { + ID *id = ((BPy_GenericLib *)ret)->id; + rename_id( id, name ); + } + return ret; + } + } + + /* New Data */ if (self->type == ID_IM) { /* Image, accepts width and height*/ if( !PyArg_ParseTuple( args, "s|ii", &name, &img_width, &img_height ) ) @@ -523,49 +580,6 @@ PyObject *MainSeq_new(BPy_MainSeq *self, PyObject * args) return GetPyObjectFromID(id); } -PyObject *MainSeq_load(BPy_MainSeq *self, PyObject * args) -{ - - char *filename; - - if( !PyArg_ParseTuple( args, "s", &filename ) ) - return EXPP_ReturnPyObjError( PyExc_TypeError, - "expected a filename" ); - - switch (self->type) { - case ID_IM: - { - Image *img = BKE_add_image_file( filename ); - if (!img) - return ( EXPP_ReturnPyObjError( PyExc_IOError, - "couldn't load image" ) ); - - return Image_CreatePyObject( img ); - } - case ID_VF: - { - VFont *vf = load_vfont (filename); - if (!vf) - return EXPP_ReturnPyObjError( PyExc_IOError, - "couldn't load font" ); - - return Font_CreatePyObject(vf); - } - case ID_SO: - { - bSound *snd = sound_new_sound( filename ); - if (!snd) - return EXPP_ReturnPyObjError( PyExc_IOError, - "couldn't load sound" ); - - return Sound_CreatePyObject(snd); - } - default: - return EXPP_ReturnPyObjError( PyExc_TypeError, - "Can only load image, sound and font types"); - } -} - PyObject *MainSeq_unlink(BPy_MainSeq *self, PyObject * args) { @@ -673,10 +687,8 @@ static PyGetSetDef MainSeq_getseters[] = { }; static struct PyMethodDef BPy_MainSeq_methods[] = { - {"new", (PyCFunction)MainSeq_new, METH_VARARGS, + {"new", (PyCFunction)MainSeq_new, METH_VARARGS | METH_KEYWORDS, "(name) - Create a new object in this scene from the obdata given and return a new object"}, - {"load", (PyCFunction)MainSeq_load, METH_VARARGS, - "(filename) - loads the given filename for image, font and sound types"}, {"unlink", (PyCFunction)MainSeq_unlink, METH_VARARGS, "unlinks the object from the scene"}, {NULL, NULL, 0, NULL} diff --git a/source/blender/src/space.c b/source/blender/src/space.c index 1db3b23541b..e71fd9fa25d 100644 --- a/source/blender/src/space.c +++ b/source/blender/src/space.c @@ -171,7 +171,7 @@ /* maybe we need this defined somewhere else */ extern void StartKetsjiShell(ScrArea *area, char* startscenename, struct Main* maggie, struct SpaceIpo* sipo,int always_use_expand_framing); -extern void StartKetsjiShellSimulation(ScrArea *area, char* startscenename, struct Main* maggie, struct SpaceIpo* sipo,int always_use_expand_framing);//rcruiz +extern void StartKetsjiShellSimulation(ScrArea *area, char* startscenename, struct Main* maggie, struct SpaceIpo* sipo,int always_use_expand_framing);/*rcruiz*/ /** * When the mipmap setting changes, we want to redraw the view right @@ -339,13 +339,7 @@ void handle_view3d_around() } void handle_view3d_lock() -{ - - //if (G.vd) printf("1\n"); - //if (G.vd->scenelock) printf("2\n"); - //if (curarea->spacetype) printf("3\n"); - //if (curarea->spacetype) printf("4\n"); - +{ if (G.vd != NULL && curarea != NULL ) { if(G.vd->localview==0 && G.vd->scenelock && curarea->spacetype==SPACE_VIEW3D) { @@ -1468,10 +1462,10 @@ static void winqreadview3dspace(ScrArea *sa, void *spacedata, BWinEvent *evt) break; case TABKEY: - // Shift-Tabe handling (other cases are in toets) + /* Shift-Tabe handling (other cases are in toets) */ if (G.qual == LR_SHIFTKEY) { - // Snap toggle (only edit mesh right now) + /* Snap toggle (only edit mesh right now) */ if (G.obedit && G.obedit->type==OB_MESH) { G.vd->flag2 ^= V3D_TRANSFORM_SNAP; |