Back to index

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

Go to the source code of this file.

Functions

PyObject * gcompris_new_pyGcomprisWordlistObject (GcomprisWordlist *wordlist)
static void pyGcomprisWordlistType_dealloc (pyGcomprisWordlistObject *self)
static PyObject * pyGcomprisWordlistType_getattr (pyGcomprisWordlistObject *self, char *name)
static int pyGcomprisWordlistType_setattr (pyGcomprisWordlistObject *self, char *name, PyObject *v)

Variables

staticforward PyTypeObject pyGcomprisWordlistType
static PyMethodDef pyGcomprisWordlistType_methods []

Function Documentation

Definition at line 15 of file py-gcompris-wordlist.c.

{
  pyGcomprisWordlistObject* thewordlist = NULL;

  thewordlist = PyObject_New(pyGcomprisWordlistObject, &pyGcomprisWordlistType);
  if (thewordlist!=NULL)
    thewordlist->cdata = wordlist;

  return (PyObject*)thewordlist;
}

Here is the caller graph for this function:

static void pyGcomprisWordlistType_dealloc ( pyGcomprisWordlistObject self) [static]

Definition at line 29 of file py-gcompris-wordlist.c.

{
  gc_wordlist_free((GcomprisWordlist *)self->cdata);
  self->cdata = NULL;
  PyObject_DEL(self);
}

Here is the call graph for this function:

static PyObject* pyGcomprisWordlistType_getattr ( pyGcomprisWordlistObject self,
char *  name 
) [static]

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

{
  if (self->cdata != NULL) {
    /* Wordlist filename */
    if(strcmp(name,"filename")==0) return Py_BuildValue("s", self->cdata->filename);
    if(strcmp(name,"locale")==0) return Py_BuildValue("z", self->cdata->locale);
    if(strcmp(name,"description")==0) return Py_BuildValue("z", self->cdata->description);

    /* list */
    if(strcmp(name,"words")==0){
      PyObject *pydict;
      PyObject *pylist;
      gint level;
      GSList *words;
      GSList *list, *list_words;

      pydict = PyDict_New();

      for (list = self->cdata->levels_words; list !=NULL; list = list->next){
       level =  ((LevelWordlist *)  list)->level;
       words = ((LevelWordlist *)  list)->words;

       pylist = PyList_New(0);
       for (list_words = words; list_words !=NULL; list_words = list_words->next){
         PyList_Append(pylist, Py_BuildValue("s", (gchar *)list->data));
       }

       PyDict_SetItem( pydict, PyInt_FromLong(   (long) level), pylist);

      return pydict;
      }
    }
  }

  return Py_FindMethod(pyGcomprisWordlistType_methods, (PyObject *)self, name);

}
static int pyGcomprisWordlistType_setattr ( pyGcomprisWordlistObject self,
char *  name,
PyObject *  v 
) [static]

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

{
  /* members are supposed to be read only */

  return -1;
}

Variable Documentation

static PyTypeObject pyGcomprisWordlistType
Initial value:
 {


 
  PyObject_HEAD_INIT(&PyType_Type)

  0,                                        
  "pyGcomprisWordlist",                        
  sizeof(pyGcomprisWordlistObject),            
  0,                                        
  
  (destructor)pyGcomprisWordlistType_dealloc,  
  0,                                        
  (getattrfunc)pyGcomprisWordlistType_getattr, 
  (setattrfunc)pyGcomprisWordlistType_setattr, 
  0,                                        
  0,                                        
  0,                                        
  0,                                        
  0,                                        
  0,                                        
}

Definition at line 6 of file py-gcompris-wordlist.c.

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

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