Back to index

gcompris  8.2.2
py-mod-skin.c
Go to the documentation of this file.
00001 #include <Python.h>
00002 #include <pygobject.h>
00003 #include "gcompris/gcompris.h"
00004 #include "py-mod-skin.h"
00005 #include "py-gcompris-board.h"
00006 
00007 /* All functions provided by this python module
00008  * wraps a gcompris function. Each "py_*" function wraps the
00009  * "*" C function.
00010  */
00011 
00012 
00013 /* gchar *gc_skin_image_get(gchar *imagename); */
00014 static PyObject*
00015 py_gc_skin_image_get(PyObject* self, PyObject* args)
00016 {
00017   gchar* imagename;
00018   gchar* result;
00019   PyObject* pyresult;
00020   /* Parse arguments */
00021   if(!PyArg_ParseTuple(args, "s:gc_skin_image_get", &imagename))
00022     return NULL;
00023 
00024   /* Call the corresponding C function */
00025   result = gc_skin_image_get(imagename);
00026 
00027   /* Create and return the result */
00028   pyresult = Py_BuildValue("s", result);
00029 
00030   g_free(result);
00031 
00032   return(pyresult);
00033 }
00034 
00035 
00036 /* GdkPixbuf *gc_skin_pixmap_load(char *pixmapfile); */
00037 static PyObject*
00038 py_gc_skin_pixmap_load(PyObject* self, PyObject* args)
00039 {
00040   char* pixmapfile;
00041   GdkPixbuf* result;
00042   PyObject* pyresult;
00043 
00044   /* Parse arguments */
00045   if(!PyArg_ParseTuple(args, "s:gc_skin_pixmap_load", &pixmapfile))
00046     return NULL;
00047 
00048   /* Call the corresponding C function */
00049   result = gc_skin_pixmap_load(pixmapfile);
00050 
00051   /* Create and return the result */
00052   pyresult = (PyObject*) pygobject_new((GObject*) result);
00053 
00054   gdk_pixbuf_unref(result);
00055 
00056   return(pyresult);
00057 }
00058 
00059 
00060 /* guint32 gc_skin_get_color_default(gchar* id, guint32 def); */
00061 static PyObject*
00062 py_gc_skin_get_color_default(PyObject* self, PyObject* args)
00063 {
00064   gchar* id;
00065   guint32 def;
00066   guint32 result;
00067 
00068   /* Parse arguments */
00069   if(!PyArg_ParseTuple(args, "sl:gc_skin_get_color_default", &id, &def))
00070     return NULL;
00071 
00072   /* Call the corresponding C function */
00073   result = gc_skin_get_color_default(id, def);
00074 
00075   /* Create and return the result */
00076   return PyLong_FromUnsignedLong(result);
00077 }
00078 
00079 
00080 /* gchar* gc_skin_get_font_default(gchar* id, gchar* def); */
00081 static PyObject*
00082 py_gc_skin_get_font_default(PyObject* self, PyObject* args)
00083 {
00084   gchar* id;
00085   gchar* def;
00086   gchar* result;
00087 
00088   /* Parse arguments */
00089   if(!PyArg_ParseTuple(args, "ss:gc_skin_get_font_default", &id, &def))
00090     return NULL;
00091 
00092   /* Call the corresponding C function */
00093   result = gc_skin_get_font_default(id, def);
00094 
00095   /* Create and return the result */
00096   return Py_BuildValue("s", result);
00097 }
00098 
00099 
00100 /* guint32 gc_skin_get_color(gchar* id); */
00101 static PyObject*
00102 py_gc_skin_get_color(PyObject* self, PyObject* args)
00103 {
00104   gchar* id;
00105   guint32 result;
00106 
00107   /* Parse arguments */
00108   if(!PyArg_ParseTuple(args, "s:gc_skin_get_color", &id))
00109     return NULL;
00110 
00111   /* Call the corresponding C function */
00112   result = gc_skin_get_color(id);
00113 
00114   /* Create and return the result */
00115   return PyLong_FromUnsignedLong(result);
00116 }
00117 
00118 
00119 /* gchar* gc_skin_get_font(gchar* id); */
00120 static PyObject*
00121 py_gc_skin_get_font(PyObject* self, PyObject* args)
00122 {
00123   gchar* id;
00124   gchar* result;
00125 
00126   /* Parse arguments */
00127   if(!PyArg_ParseTuple(args, "s:gc_skin_get_font_default", &id))
00128     return NULL;
00129 
00130   /* Call the corresponding C function */
00131   result = gc_skin_get_font(id);
00132 
00133   /* Create and return the result */
00134   return Py_BuildValue("s", result);
00135 }
00136 
00137 
00138 static PyMethodDef PythonGcomprisSkinModule[] = {
00139   { "image_to_skin",  py_gc_skin_image_get, METH_VARARGS, "gc_skin_image_get" },
00140   { "load_pixmap",  py_gc_skin_pixmap_load, METH_VARARGS, "gc_skin_pixmap_load" },
00141   { "get_color_default",  py_gc_skin_get_color_default, METH_VARARGS,
00142     "gc_skin_get_color_default" },
00143   { "get_font_default",  py_gc_skin_get_font_default, METH_VARARGS,
00144     "gc_skin_get_font_default" },
00145   { "get_color",  py_gc_skin_get_color, METH_VARARGS,
00146     "gc_skin_get_color" },
00147   { "get_font",  py_gc_skin_get_font, METH_VARARGS,
00148     "gc_skin_get_font" },
00149   { NULL, NULL, 0, NULL}
00150 };
00151 
00152 
00153 void python_gc_skin_module_init(void)
00154 {
00155   PyObject* module;
00156   module = Py_InitModule("_gcompris_skin", PythonGcomprisSkinModule);
00157 }
00158 
00159 /* Some usefull code parts ... */
00160 /*
00161 static PyObject*
00162 py_gcompris_(PyObject* self, PyObject* args)
00163 {
00164 */  /* Parse arguments */
00165 /*  if(!PyArg_ParseTuple(args, ":gcompris_"))
00166     return NULL;
00167 */
00168   /* Call the corresponding C function */
00169 /*  gcompris_();
00170 */
00171   /* Create and return the result */
00172 /*  Py_INCREF(Py_None);
00173   return Py_None;
00174 }
00175 */
00176 /*
00177   { "",  py_gcompris_, METH_VARARGS, "gcompris_" },
00178 */