Back to index

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

Go to the source code of this file.

Functions

PyObject * gcompris_new_pyGcomprisGroupObject (GcomprisGroup *group)
static void pyGcomprisGroupType_dealloc (pyGcomprisGroupObject *self)
static PyObject * pyGcomprisGroupType_getattr (pyGcomprisGroupObject *self, char *name)
static int pyGcomprisGroupType_setattr (pyGcomprisGroupObject *self, char *name, PyObject *v)

Variables

staticforward PyTypeObject pyGcomprisGroupType
static PyMethodDef pyGcomprisGroupType_methods []

Function Documentation

PyObject* gcompris_new_pyGcomprisGroupObject ( GcomprisGroup *  group)

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

{
  pyGcomprisGroupObject* thegroup = NULL;

  thegroup = PyObject_New(pyGcomprisGroupObject, &pyGcomprisGroupType);
  if (thegroup!=NULL)
    thegroup->cdata = group;

  return (PyObject*)thegroup;
}

Here is the caller graph for this function:

static void pyGcomprisGroupType_dealloc ( pyGcomprisGroupObject self) [static]

Definition at line 27 of file py-gcompris-group.c.

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

Definition at line 42 of file py-gcompris-group.c.

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

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

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

      return pylist;
    }

  return Py_FindMethod(pyGcomprisGroupType_methods, (PyObject *)self, name);
}
static int pyGcomprisGroupType_setattr ( pyGcomprisGroupObject self,
char *  name,
PyObject *  v 
) [static]

Definition at line 70 of file py-gcompris-group.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 pyGcomprisGroupType
Initial value:
 {


 
  PyObject_HEAD_INIT(&PyType_Type)

  0,                                        
  "pyGcomprisGroup",                        
  sizeof(pyGcomprisGroupObject),            
  0,                                        
  
  (destructor)pyGcomprisGroupType_dealloc,  
  0,                                        
  (getattrfunc)pyGcomprisGroupType_getattr, 
  (setattrfunc)pyGcomprisGroupType_setattr, 
  0,                                        
  0,                                        
  0,                                        
  0,                                        
  0,                                        
  0,                                        
}

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

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

Definition at line 35 of file py-gcompris-group.c.