Back to index

gcompris  8.2.2
Functions | Variables
py-gcompris-profile.c File Reference
#include "py-gcompris-profile.h"
#include <pygobject.h>

Go to the source code of this file.

Functions

PyObject * gcompris_new_pyGcomprisProfileObject (GcomprisProfile *profile)
static void pyGcomprisProfileType_dealloc (pyGcomprisProfileObject *self)
static PyObject * pyGcomprisProfileType_getattr (pyGcomprisProfileObject *self, char *name)
static int pyGcomprisProfileType_setattr (pyGcomprisProfileObject *self, char *name, PyObject *v)

Variables

staticforward PyTypeObject pyGcomprisProfileType
static PyMethodDef pyGcomprisProfileType_methods []

Function Documentation

Definition at line 13 of file py-gcompris-profile.c.

{
  if (!profile)
    return Py_None;

  pyGcomprisProfileObject* theprofile = NULL;

  theprofile = PyObject_New(pyGcomprisProfileObject, &pyGcomprisProfileType);
  if (theprofile!=NULL)
    theprofile->cdata = profile;

  return (PyObject*)theprofile;
}

Here is the caller graph for this function:

static void pyGcomprisProfileType_dealloc ( pyGcomprisProfileObject self) [static]

Definition at line 30 of file py-gcompris-profile.c.

{
  self->cdata = NULL;
  PyObject_DEL(self);
}
static PyObject* pyGcomprisProfileType_getattr ( pyGcomprisProfileObject self,
char *  name 
) [static]

Definition at line 45 of file py-gcompris-profile.c.

{
    /* int */
    if(strcmp(name,"profile_id")==0) return Py_BuildValue("i", self->cdata->profile_id);
    /* int */
    if(strcmp(name,"name")==0) return Py_BuildValue("s", self->cdata->name);
    /* int */
    if(strcmp(name,"directory")==0) return Py_BuildValue("s", self->cdata->directory);
    /* int */
    if(strcmp(name,"description")==0) return Py_BuildValue("s", self->cdata->description);

    /* list */
    if(strcmp(name,"group_ids")==0){
      PyObject *pylist;
      GList *list;

      pylist = PyList_New(0);
      for (list = self->cdata->group_ids; list !=NULL; list = list->next)
       PyList_Append(pylist, Py_BuildValue("i", *((int *)list->data)));

      return pylist;
    }

    /* list */
    if(strcmp(name,"activities")==0){
      PyObject *pylist;
      GList *list;

      pylist = PyList_New(0);
      for (list = self->cdata->activities; list !=NULL; list = list->next)
       PyList_Append(pylist, Py_BuildValue("i", *((int *)list->data)));

      return pylist;
    }

  return Py_FindMethod(pyGcomprisProfileType_methods, (PyObject *)self, name);
}
static int pyGcomprisProfileType_setattr ( pyGcomprisProfileObject self,
char *  name,
PyObject *  v 
) [static]

Definition at line 85 of file py-gcompris-profile.c.

{
  if (self->cdata==NULL) return -1;
  if (v==NULL) return -1;

  /*  if (strcmp(name,"level")==0){
    value = (int) PyInt_AsLong(v);
    if ( value < 0 ) return -1;
    self->cdata->level=value;
    return 0;
    } */
  /* members are supposed to be read only */

  return -1;
}

Variable Documentation

static PyTypeObject pyGcomprisProfileType
Initial value:
 {


 
  PyObject_HEAD_INIT(&PyType_Type)

  0,                                        
  "pyGcomprisProfile",                        
  sizeof(pyGcomprisProfileObject),            
  0,                                        
  
  (destructor)pyGcomprisProfileType_dealloc,  
  0,                                        
  (getattrfunc)pyGcomprisProfileType_getattr, 
  (setattrfunc)pyGcomprisProfileType_setattr, 
  0,                                        
  0,                                        
  0,                                        
  0,                                        
  0,                                        
  0,                                        
}

Definition at line 4 of file py-gcompris-profile.c.

PyMethodDef pyGcomprisProfileType_methods[] [static]
Initial value:
 {
        {NULL,          NULL}           
}

Definition at line 38 of file py-gcompris-profile.c.