[gcompris] python binding: added the method gcompris.get_locale_name
- From: Bruno Coudoin <bcoudoin src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gcompris] python binding: added the method gcompris.get_locale_name
- Date: Wed, 10 Aug 2011 20:17:25 +0000 (UTC)
commit 5d3bdf9119a7ed7dd01fe89dac21bb90b6ce9086
Author: Bruno Coudoin <bruno coudoin free fr>
Date: Fri Aug 5 03:54:02 2011 +0200
python binding: added the method gcompris.get_locale_name
Now in the hangman, we use this methof to display the name of the current language.
docs/C/python.xml | 5 +++++
src/boards/py-mod-gcompris.c | 17 +++++++++++++++++
src/hangman-activity/hangman.py | 14 ++++++++++++++
3 files changed, 36 insertions(+), 0 deletions(-)
---
diff --git a/docs/C/python.xml b/docs/C/python.xml
index 1472da3..3e7e402 100644
--- a/docs/C/python.xml
+++ b/docs/C/python.xml
@@ -224,6 +224,11 @@ attribute is readeable and/or writable.</para>
<entry>return a string</entry>
</row>
<row>
+ <entry>gcompris.get_locale_name(locale)</entry>
+ <entry>gchar* gc_locale_get_name(gchar *locale)</entry>
+ <entry>returns the language name for the given locale (e.g French)</entry>
+ </row>
+ <row>
<entry>gcompris.set_locale(locale)</entry>
<entry>void gc_locale_set(gchar *locale)</entry>
<entry></entry>
diff --git a/src/boards/py-mod-gcompris.c b/src/boards/py-mod-gcompris.c
index fe423bc..96f8f98 100644
--- a/src/boards/py-mod-gcompris.c
+++ b/src/boards/py-mod-gcompris.c
@@ -368,6 +368,22 @@ py_gc_locale_set(PyObject* self, PyObject* args)
return Py_None;
}
+/* void gc_locale_get_name(gchar *locale); */
+static PyObject*
+py_gc_locale_get_name(PyObject* self, PyObject* args)
+{
+ gchar* locale;
+ /* Parse arguments */
+ if(!PyArg_ParseTuple(args, "s:gc_locale_get_name", &locale))
+ return NULL;
+
+ /* Call the corresponding C function */
+ gchar *result = gc_locale_get_name(locale);
+
+ /* Create and return the result */
+ return Py_BuildValue("s", result);
+}
+
/* char *gc_locale_get_user_default(void) */
static PyObject*
@@ -1633,6 +1649,7 @@ static PyMethodDef PythonGcomprisModule[] = {
{ "get_locale", py_gc_locale_get, METH_VARARGS, "gc_locale_get" },
{ "get_user_default_locale", py_gc_locale_get_user_default, METH_VARARGS, "gc_locale_get_user_default" },
{ "set_locale", py_gc_locale_set, METH_VARARGS, "gc_locale_set" },
+ { "get_locale_name", py_gc_locale_get_name, METH_VARARGS, "gc_locale_get_name" },
{ "set_cursor", py_gc_cursor_set, METH_VARARGS, "gc_cursor_set" },
{ "images_selector_start", py_gc_selector_images_start,
METH_VARARGS, "gc_selector_images_start" },
diff --git a/src/hangman-activity/hangman.py b/src/hangman-activity/hangman.py
index d176a6a..ab1ad36 100644
--- a/src/hangman-activity/hangman.py
+++ b/src/hangman-activity/hangman.py
@@ -95,10 +95,13 @@ class Gcompris_hangman:
self.rootitem = goocanvas.Group(parent =
self.backitem)
+ # Get the name of the language for the current locale
+ self.language = gcompris.gcompris_gettext( gcompris.get_locale_name(gcompris.get_locale()) )
self.wordlist = gcompris.get_wordlist("wordsgame/default-$LOCALE.xml")
if not self.wordlist:
# Fallback to english
self.wordlist = gcompris.get_wordlist("wordsgame/default-en.xml")
+ self.language = _("English")
if not self.wordlist:
gcompris.utils.dialog(_("Could not find the list of words."),
@@ -226,6 +229,17 @@ class Gcompris_hangman:
self.word[i],
self.get_equiv(self.word[i])))
+ # Display the language
+ goocanvas.Text(
+ parent = self.rootitem,
+ x = gcompris.BOARD_WIDTH / 2,
+ y = gcompris.BOARD_HEIGHT / 2 - 30,
+ text = self.language,
+ fill_color = "white",
+ anchor = gtk.ANCHOR_CENTER,
+ alignment = pango.ALIGN_CENTER
+ )
+
# Display the virtual keyboard
(group_vowels, y_vowels) = self.display_letter_set(self.vowels, 0,
0xFF6633AAL, 0xFF33CCBBL)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]