Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSayamindu Dasgupta <sayamindu@gmail.com>2009-03-29 21:13:59 (GMT)
committer Sayamindu Dasgupta <sayamindu@gmail.com>2009-03-29 21:13:59 (GMT)
commit35eebe958797aec143ddb15a02fb010a4d7ad677 (patch)
treefaf133d819f0e88ab14f7e39bea3c72ecc16d883
parent35bdff681e2c81dd7a78ac459b9b508451dae3a0 (diff)
Added methods for getting list of countries and languages, and for getting variants based on the two
-rw-r--r--pyxkb.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/pyxkb.c b/pyxkb.c
index 1b585c7..53bd47a 100644
--- a/pyxkb.c
+++ b/pyxkb.c
@@ -39,6 +39,23 @@ append_to_list_cb(XklConfigRegistry * config,
Py_BuildValue("(s,s)", item->name, item->description));
}
+static void
+append_to_list_withsubitem_cb(XklConfigRegistry * config,
+ const XklConfigItem * item,
+ const XklConfigItem * subitem, gpointer data)
+{
+ PyObject *list;
+
+ list = data;
+ if (subitem)
+ PyList_Append(list,
+ Py_BuildValue("((s, s), (s,s))", item->name,
+ item->description, subitem->name,
+ subitem->description));
+}
+
+
+
static PyObject *
pyxkbconfig_get_layouts(PyObject *self, PyObject *args)
{
@@ -68,6 +85,63 @@ pyxkbconfig_get_variants_for_layout(PyObject *self, PyObject *args)
}
static PyObject *
+pyxkbconfig_get_countries(PyObject *self, PyObject *args)
+{
+ PyObject *country_list;
+
+ country_list = PyList_New(0);
+ xkl_config_registry_foreach_country(config, append_to_list_cb,
+ country_list);
+
+ return country_list;
+}
+
+static PyObject *
+pyxkbconfig_get_variants_for_country(PyObject *self, PyObject *args)
+{
+ const gchar *country;
+ PyObject *variant_list;
+
+ variant_list = PyList_New(0);
+ if (!PyArg_ParseTuple(args, "s", &country))
+ return NULL;
+ xkl_config_registry_foreach_country_variant(config, country,
+ append_to_list_withsubitem_cb,
+ variant_list);
+
+ return variant_list;
+}
+
+static PyObject *
+pyxkbconfig_get_languages(PyObject *self, PyObject *args)
+{
+ PyObject *language_list;
+
+ language_list = PyList_New(0);
+ xkl_config_registry_foreach_language(config, append_to_list_cb,
+ language_list);
+
+ return language_list;
+}
+
+static PyObject *
+pyxkbconfig_get_variants_for_language(PyObject *self, PyObject *args)
+{
+ const gchar *language;
+ PyObject *variant_list;
+
+ variant_list = PyList_New(0);
+ if (!PyArg_ParseTuple(args, "s", &language))
+ return NULL;
+ xkl_config_registry_foreach_language_variant(config, language,
+ append_to_list_withsubitem_cb,
+ variant_list);
+
+ return variant_list;
+}
+
+
+static PyObject *
pyxkbconfig_get_models(PyObject *self, PyObject *args)
{
PyObject *model_list;
@@ -267,6 +341,14 @@ static PyMethodDef pyxkb_methods[] = {
"Returns list of available layouts"},
{"get_variants_for_layout", pyxkbconfig_get_variants_for_layout,
METH_VARARGS, "Returns list of available variants for layout"},
+ {"get_countries", pyxkbconfig_get_countries, METH_VARARGS,
+ "Returns list of available countries"},
+ {"get_variants_for_country", pyxkbconfig_get_variants_for_country,
+ METH_VARARGS, "Returns list of available variants for country"},
+ {"get_languages", pyxkbconfig_get_languages, METH_VARARGS,
+ "Returns list of available languages"},
+ {"get_variants_for_language", pyxkbconfig_get_variants_for_language,
+ METH_VARARGS, "Returns list of available variants for language"},
{"get_models", pyxkbconfig_get_models, METH_VARARGS,
"Returns list of available models"},
{"get_current_model", pyxkbconfig_get_current_model, METH_VARARGS,