Back to index

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

Go to the source code of this file.

Functions

PyObject * gcompris_new_pyGcomprisBoardObject (GcomprisBoard *aboard)
static void pyGcomprisBoardType_dealloc (pyGcomprisBoardObject *self)
static PyObject * pyGcomprisBoardType_getattr (pyGcomprisBoardObject *self, char *name)
static int pyGcomprisBoardType_setattr (pyGcomprisBoardObject *self, char *name, PyObject *v)

Variables

staticforward PyTypeObject pyGcomprisBoardType
static PyMethodDef pyGcomprisBoardType_methods []

Function Documentation

PyObject* gcompris_new_pyGcomprisBoardObject ( GcomprisBoard *  aboard)

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

{
  pyGcomprisBoardObject* theboard = NULL;

  theboard = PyObject_New(pyGcomprisBoardObject, &pyGcomprisBoardType);
  if (theboard!=NULL)
    theboard->cdata = aboard;

  return (PyObject*)theboard;
}

Here is the caller graph for this function:

static void pyGcomprisBoardType_dealloc ( pyGcomprisBoardObject self) [static]

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

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

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

{
  if (self->cdata != NULL) {
    /* Board type */
    if(strcmp(name,"type")==0) return Py_BuildValue("s", self->cdata->type);
    if(strcmp(name,"board_ready")==0){
      if(self->cdata->board_ready){
       Py_INCREF(Py_True);
       return Py_True;
      } else {
       Py_INCREF(Py_False);
       return Py_False;
      }
    }

    if(strcmp(name,"disable_im_context")==0) return PyBool_FromLong(self->cdata->disable_im_context);

    /* Board specific mode */
    if(strcmp(name,"mode")==0) return Py_BuildValue("s", self->cdata->mode);

    /* Name of this Board */
    if(strcmp(name,"name")==0) return Py_BuildValue("s", self->cdata->name);
    if(strcmp(name,"title")==0) return Py_BuildValue("s", self->cdata->title);
    if(strcmp(name,"description")==0) return Py_BuildValue("s", self->cdata->description);
    if(strcmp(name,"icon_name")==0) return Py_BuildValue("s", self->cdata->icon_name);
    if(strcmp(name,"author")==0) return Py_BuildValue("s", self->cdata->author);
    if(strcmp(name,"boarddir")==0) return Py_BuildValue("s", self->cdata->boarddir);
    if(strcmp(name,"filename")==0) return Py_BuildValue("s", self->cdata->filename);
    if(strcmp(name,"difficulty")==0) return Py_BuildValue("s", self->cdata->difficulty);
    if(strcmp(name,"mandatory_sound_file")==0) return Py_BuildValue("s", self->cdata->mandatory_sound_file);

    /* Menu positionning */
    if(strcmp(name,"section")==0) return Py_BuildValue("s", self->cdata->section);
    if(strcmp(name,"menuposition")==0) return Py_BuildValue("s", self->cdata->menuposition);

    /* Help Information */
    if(strcmp(name,"prerequisite")==0) return Py_BuildValue("s", self->cdata->prerequisite);
    if(strcmp(name,"goal")==0) return Py_BuildValue("s", self->cdata->goal);
    if(strcmp(name,"manual")==0) return Py_BuildValue("s", self->cdata->manual);
    if(strcmp(name,"credit")==0) return Py_BuildValue("s", self->cdata->credit);

    /* Size of the window in which we have to run */
    if(strcmp(name,"width")==0) return Py_BuildValue("i", self->cdata->width);
    if(strcmp(name,"height")==0) return Py_BuildValue("i", self->cdata->height);

    /* Dynamic board information (status) */
    if(strcmp(name,"level")==0) return Py_BuildValue("i", self->cdata->level);
    if(strcmp(name,"maxlevel")==0) return Py_BuildValue("i", self->cdata->maxlevel);
    if(strcmp(name,"sublevel")==0) return Py_BuildValue("i", self->cdata->sublevel);
    if(strcmp(name,"number_of_sublevel")==0) return Py_BuildValue("i", self->cdata->number_of_sublevel);

    if(strcmp(name,"previous_level")==0)
      return gcompris_new_pyGcomprisBoardObject(self->cdata->previous_board);

    if(strcmp(name,"canvas")==0)
      return (PyObject*) pygobject_new((GObject*)self->cdata->canvas);

    if(strcmp(name,"is_configurable")==0){
      if (!self->cdata->plugin){
       gc_board_check_file(self->cdata);
       if (!self->cdata->plugin){
         g_warning("board %s/%s seems not working !", self->cdata->section, self->cdata->name);
         Py_INCREF(Py_False);
         return Py_False;
       }
      }

      if (self->cdata->plugin->config_start && self->cdata->plugin->config_stop){
       g_warning ("Board %s is configurable\n", self->cdata->name);
       Py_INCREF(Py_True);
       return Py_True;
      } else {
       Py_INCREF(Py_False);
       return Py_False;
      }
    }

    if(strcmp(name,"board_id")==0) return Py_BuildValue("i", self->cdata->board_id);

    if(strcmp(name,"section_id")==0) return Py_BuildValue("i", self->cdata->section_id);

    /* Other members are special one...
     * TODO: Does we need to write a BoardPlugin structure wrapper ?
     */
  }
  return Py_FindMethod(pyGcomprisBoardType_methods, (PyObject *)self, name);
}

Here is the call graph for this function:

static int pyGcomprisBoardType_setattr ( pyGcomprisBoardObject self,
char *  name,
PyObject *  v 
) [static]

Definition at line 132 of file py-gcompris-board.c.

{
  int value;

  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;
  }
  if (strcmp(name,"maxlevel")==0){
    value = PyInt_AsLong(v);
    if ( value < 0 ) return -1;
    self->cdata->maxlevel=value;
    return 0;
  }
  if (strcmp(name,"sublevel")==0){
    value = PyInt_AsLong(v);
    if ( value < 0 ) return -1;
    self->cdata->sublevel=value;
    return 0;
  }
  if (strcmp(name,"number_of_sublevel")==0){
    value = PyInt_AsLong(v);
    if ( value < 0 ) return -1;
    self->cdata->number_of_sublevel=value;
    return 0;
  }
  if (strcmp(name,"disable_im_context")==0){
    value = PyObject_IsTrue( v);
    self->cdata->disable_im_context = value;
    return 0;
  }
  /* Other members are supposed to be read only */

  return -1;
}

Variable Documentation

static PyTypeObject pyGcomprisBoardType
Initial value:
 {


 
  PyObject_HEAD_INIT(&PyType_Type)

  0,                                        
  "pyGcomprisBoard",                        
  sizeof(pyGcomprisBoardObject),            
  0,                                        
  
  (destructor)pyGcomprisBoardType_dealloc,  
  0,                                        
  (getattrfunc)pyGcomprisBoardType_getattr, 
  (setattrfunc)pyGcomprisBoardType_setattr, 
  0,                                        
  0,                                        
  0,                                        
  0,                                        
  0,                                        
  0,                                        
}

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

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

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