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

python bindings, fix name (gcompris_get_locales_list) and bug.

parent 646f4f89
2005-08-17 Yves Combe <yves@ycombe.net>
python bindings, fix name (gcompris_get_locales_list) and bug.
* src/boards/colors.c: (colors_config_start):
* src/boards/py-mod-gcompris.c: (py_gcompris_combo_locales),
(py_gcompris_get_locales_list):
* src/boards/python/pythontest.py:
* src/gcompris/board_config.c: (gcompris_get_locales_list),
(gcompris_combo_locales):
* src/gcompris/board_config.h:
* src/gcompris/gcompris.c: (gcompris_set_locale):
2005-08-17 Yves Combe <yves@ycombe.net>
pass gcompris_combo_box init and returned values to string.
......
......@@ -172,7 +172,7 @@ colors_config_start(GcomprisBoard *agcomprisBoard,
g_hash_table_destroy( table);
GList *locales = gcompris_locales_list();
GList *locales = gcompris_get_locales_list();
GList *locale = locales;
gchar *actual_lang = g_strdup(gcompris_get_locale());
......
......@@ -1296,6 +1296,46 @@ py_gcompris_separator(PyObject* self, PyObject* args)
}
static PyObject*
py_gcompris_combo_locales(PyObject* self, PyObject* args)
{
gchar *key;
gchar *init;
/* Parse arguments */
if(!PyArg_ParseTuple(args, "ss:gcompris_radio_buttons", &key, &init))
return NULL;
return (PyObject *)pygobject_new((GObject*) \
gcompris_combo_locales( key, init));
}
static PyObject*
py_gcompris_get_locales_list(PyObject* self, PyObject* args)
{
PyObject *pylist;
GList *result, *list ;
/* Parse arguments */
if(!PyArg_ParseTuple(args, ":gcompris.get_locales_list"))
return NULL;
/* Call the corresponding C function */
result = gcompris_get_locales_list();
pylist = PyList_New(0);
for (list = result; list != NULL; list = list->next){
PyList_Append( pylist, PyString_FromString(list->data));
}
Py_INCREF(pylist);
return pylist;
}
/****************************************************/
......@@ -1347,6 +1387,8 @@ static PyMethodDef PythonGcomprisModule[] = {
{ "radio_buttons", py_gcompris_radio_buttons, METH_VARARGS, "gcompris_radio_buttons" },
{ "spin_int", py_gcompris_spin_int, METH_VARARGS, "gcompris_spin_int" },
{ "separator", py_gcompris_separator, METH_VARARGS, "gcompris_separator" },
{ "combo_locales", py_gcompris_combo_locales, METH_VARARGS, "gcompris_combo_locales" },
{ "get_locales_list", py_gcompris_get_locales_list, METH_VARARGS, "gcompris_get_locales_list" },
{ NULL, NULL, 0, NULL}
};
......
......@@ -396,6 +396,10 @@ class Gcompris_pythontest:
self.init_conf_str('pattern', 'circle')
)
print gcompris.get_locales_list()
gcompris.combo_locales('locale', 'fr')
# Get value from config_dict or value passed
def init_conf(self, key, value):
if self.config_dict.has_key(key):
......
/* gcompris - board_config.c
*
* Time-stamp: <2005/08/17 00:04:43 yves>
* Time-stamp: <2005/08/17 01:29:47 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -489,13 +489,14 @@ GtkHSeparator *gcompris_separator()
/* L10n */
/***********************************************/
GList *gcompris_locales_list(){
GList *gcompris_get_locales_list(){
gchar *textdomain;
GDir *textdomain_dir;
GError **error;
textdomain = bindtextdomain ("gcompris", NULL);
GError **error = NULL;
//textdomain = bindtextdomain ("gcompris", NULL);
textdomain = PACKAGE_LOCALE_DIR;
GList *locales = NULL;
textdomain_dir = g_dir_open (textdomain, 0, error);
......@@ -517,8 +518,6 @@ GList *gcompris_locales_list(){
g_free(catalog);
}
g_free(textdomain);
g_dir_close (textdomain_dir);
return locales;
......@@ -526,8 +525,8 @@ GList *gcompris_locales_list(){
GtkComboBox *gcompris_combo_locales(gchar *key, gchar *init)
{
gcompris_combo_box(_("Select the language\n to use in the board"),
gcompris_locales_list(),
return gcompris_combo_box(_("Select the language to use in the board"),
gcompris_get_locales_list(),
key,
init);
}
......
/* gcompris - board_config.h
*
* Time-stamp: <2005/08/16 23:25:14 yves>
* Time-stamp: <2005/08/17 01:06:21 yves>
*
* Copyright (C) 2001 Pascal Georges
*
......@@ -64,7 +64,7 @@ GtkSpinButton *gcompris_spin_int(const gchar *label,
GtkHSeparator *gcompris_separator();
GList *gcompris_locales_list();
GList *gcompris_get_locales_list();
GtkComboBox *gcompris_combo_locales(gchar *key, gchar *init);
......
/* gcompris - gcompris.c
*
* Time-stamp: <2005/08/16 00:43:08 yves>
* Time-stamp: <2005/08/17 01:08:31 yves>
*
* Copyright (C) 2000-2003 Bruno Coudoin
*
......@@ -802,7 +802,7 @@ void gcompris_set_locale(gchar *locale)
gcompris_locale = g_strdup(setlocale(LC_MESSAGES, locale));
if (!gcompris_locale)
gcompris_locale = g_strdup(locale);
setlocale("LC_ALL", "");
setlocale(LC_ALL, "");
#endif
if(gcompris_locale!=NULL && strcmp(locale, gcompris_locale))
......
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