Commit c8938e7b authored by Yves Combe's avatar Yves Combe
Browse files

python binding for gcompris_combo_locales_asset...

python binding for gcompris_combo_locales_asset gcompris_get_locales_asset_list gcompris_get_asset_file_locale.
fix gcompris_get_asset_file binding, it now can accept some None arguments.
sample in pythontest as usual.
parent 230a9218
2005-08-19 Yves Combe,,, <yves@ycombe.net>
python binding for gcompris_combo_locales_asset gcompris_get_locales_asset_list gcompris_get_asset_file_locale.
fix gcompris_get_asset_file binding, it now can accept some None arguments.
sample in pythontest as usual.
* src/boards/py-mod-gcompris.c: (py_gcompris_combo_locales_asset),
(py_gcompris_get_locales_asset_list):
* src/boards/py-mod-utils.c: (py_gcompris_get_asset_file),
(py_gcompris_get_asset_file_locale):
* src/boards/python/pythontest.py:
2005-08-19 Yves Combe,,, <yves@ycombe.net>
Add cache in assetml.c to optimize speed.
......
......@@ -1335,6 +1335,65 @@ py_gcompris_get_locales_list(PyObject* self, PyObject* args)
}
static PyObject*
py_gcompris_combo_locales_asset(PyObject* self, PyObject* args)
{
gchar *key;
gchar *init;
gchar *label;
gchar *dataset;
gchar* categories;
gchar* mimetype;
gchar *file;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "ssszzzz:gcompris_combo_locales",
&label,
&key,
&init,
&dataset,
&categories,
&mimetype,
&file))
return NULL;
return (PyObject *)pygobject_new((GObject*) \
gcompris_combo_locales_asset( label, key, init, dataset, categories, mimetype, file ));
}
static PyObject*
py_gcompris_get_locales_asset_list(PyObject* self, PyObject* args)
{
PyObject *pylist;
GList *result, *list ;
gchar *dataset;
gchar* categories;
gchar* mimetype;
gchar *file;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "zzzz:gcompris.get_locales_asset_list",
&dataset,
&categories,
&mimetype,
&file))
return NULL;
/* Call the corresponding C function */
result = gcompris_get_locales_asset_list( dataset, categories, mimetype, file);
pylist = PyList_New(0);
for (list = result; list != NULL; list = list->next){
PyList_Append( pylist, PyString_FromString(list->data));
}
Py_INCREF(pylist);
return pylist;
}
static PyObject*
py_gcompris_gettext(PyObject* self, PyObject* args)
......@@ -1439,6 +1498,8 @@ static PyMethodDef PythonGcomprisModule[] = {
{ "gcompris_gettext", py_gcompris_gettext, METH_VARARGS, "gcompris_gettext" },
{ "change_locale", py_gcompris_change_locale, METH_VARARGS, "gcompris_change_locale" },
{ "reset_locale", py_gcompris_reset_locale, METH_VARARGS, "gcompris_reset_locale" },
{ "combo_locales_asset", py_gcompris_combo_locales_asset, METH_VARARGS, "gcompris_combo_locales_asset" },
{ "get_locales_asset_list", py_gcompris_get_locales_asset_list, METH_VARARGS, "gcompris_get_locales_asset_list" },
{ NULL, NULL, 0, NULL}
};
......
......@@ -288,7 +288,7 @@ py_gcompris_get_asset_file(PyObject* self, PyObject* args)
gchar* result;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "ssss:gcompris_get_asset_file", &dataset, &categories, &mimetype, &name))
if(!PyArg_ParseTuple(args, "zzzs:gcompris_get_asset_file", &dataset, &categories, &mimetype, &name))
return NULL;
/* Call the corresponding C function */
......@@ -389,6 +389,29 @@ py_gcompris_canvas_get_property(PyObject* self, PyObject* args)
}
/* gchar *gcompris_get_asset_file_locale(gchar *dataset, gchar* categories, */
/* gchar* mimetype, gchar* file, gchar *locale); */
static PyObject*
py_gcompris_get_asset_file_locale(PyObject* self, PyObject* args)
{
gchar* dataset;
gchar* categories;
gchar* mimetype;
gchar* name;
gchar *locale;
gchar* result;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "zzzsz:gcompris_get_asset_file_locale", &dataset, &categories, &mimetype, &name, &locale))
return NULL;
/* Call the corresponding C function */
result = gcompris_get_asset_file_locale(dataset, categories, mimetype, name, locale);
/* Create and return the result */
return Py_BuildValue("s", result);
}
static PyMethodDef PythonGcomprisUtilsModule[] = {
{ "load_pixmap", py_gcompris_load_pixmap, METH_VARARGS, "gcompris_load_pixmap" },
{ "set_image_focus", py_gcompris_set_image_focus, METH_VARARGS, "gcompris_set_image_focus" },
......@@ -407,6 +430,7 @@ static PyMethodDef PythonGcomprisUtilsModule[] = {
{ "filename_pass", py_gcompris_filename_pass, METH_VARARGS, "gcompris_filename_pass" },
{ "canvas_set_property", py_gcompris_canvas_set_property, METH_VARARGS, "gcompris_canvas_set_property" },
{ "canvas_get_property", py_gcompris_canvas_get_property, METH_VARARGS, "gcompris_canvas_get_property" },
{ "get_asset_file_locale", py_gcompris_get_asset_file_locale, METH_VARARGS, "gcompris_get_asset_file_locale" },
{ NULL, NULL, 0, NULL}
};
......
......@@ -366,7 +366,7 @@ class Gcompris_pythontest:
self.main_vbox = gcompris.configuration_window ( \
_('<b>%s</b> configuration\n for profile <b>%s</b>') % ('Pythontest', profile.name ),
self.apply_callback
self.ok_callback
)
# toggle box
......@@ -410,26 +410,55 @@ class Gcompris_pythontest:
patterns,
self.config_dict['pattern']
)
print "List of locales shown in gcompris.combo_locale :"
print gcompris.get_locales_list()
gcompris.separator()
gcompris.combo_locales('locale', self.config_dict['locale'])
gcompris.separator()
print "List of locales shown in gcompris.combo_locales_asset :"
locales_purple = gcompris.get_locales_asset_list( "gcompris colors", None, "audio/x-ogg", "purple.ogg")
print locales_purple
label = gtk.Label()
label.set_markup('<i>-- unused, but here for test --</i>')
label.show()
self.main_vbox.pack_start (label, False, False, 8)
gcompris.combo_locales_asset( _("Select sound locale"), "locale_asset", self.config_dict['locale_asset'], "gcompris colors", None, "audio/x-ogg", "purple.ogg" )
print gcompris.utils.get_asset_file ("gcompris colors", None, "audio/x-ogg", "purple.ogg")
print gcompris.utils.get_asset_file_locale ("gcompris colors", None, "audio/x-ogg", "purple.ogg", None)
for lang in locales_purple:
print gcompris.utils.get_asset_file_locale ("gcompris colors", None, "audio/x-ogg", "purple.ogg", lang)
def color_disable(self, button):
self.color_choice.set_sensitive(not button.get_active())
def apply_callback(self, table):
# Callback when the "OK" button is clicked in configuration window
# this get all the _changed_ values
def ok_callback(self, table):
print _('Keys and values returned by PythonTest config window:')
if (len(table) == 0):
print '%20s' % 'None'
for key,value in table.iteritems():
print '%20s:%20s ' % (key, value)
gcompris.set_board_conf(self.configuring_profile, self.gcomprisBoard, key, value)
def init_config(self):
default_config = { 'disable_line' : 'True',
'color_line' : 'red',
'distance_circle' : '100',
'pattern' : 'circle',
'locale' : 'NULL'
'locale' : 'NULL',
'locale_asset' : 'NULL'
}
return default_config
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment