diff options
author | Sayamindu Dasgupta <sayamindu@gmail.com> | 2009-03-26 22:44:43 (GMT) |
---|---|---|
committer | Sayamindu Dasgupta <sayamindu@gmail.com> | 2009-03-26 22:44:43 (GMT) |
commit | bec7f286f7a707af68f084f249cf84d98c52b5a4 (patch) | |
tree | 970e9c6256a9918728c9700424393ac23483ea94 | |
parent | a70120bfc9fde3259458b407fe2f672552adf100 (diff) |
Added method get_active_group_index() to get the currently active group index
-rw-r--r-- | pyxkb.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -222,6 +222,21 @@ pyxkbconfig_set_variants(PyObject *self, PyObject *args) return Py_BuildValue("b", ret_value); } +static PyObject * +pyxkbconfig_get_active_group_index(PyObject *self, PyObject *args) +{ + gint group_index; + XklState *state; + + /* I'm not sure why the following line is not working in initpyxkb() */ + xkl_engine_start_listen(engine, XKLL_TRACK_KEYBOARD_STATE); + state = xkl_engine_get_current_state(engine); + group_index = state->group; + xkl_engine_stop_listen(engine); + + return Py_BuildValue("i", group_index); +} + /* Method table */ static PyMethodDef pyxkb_methods[] = { @@ -245,6 +260,9 @@ static PyMethodDef pyxkb_methods[] = { "Sets layout"}, {"set_variants", pyxkbconfig_set_variants, METH_VARARGS, "Sets variants (must be valid for the active layout(s))"}, + {"get_active_group_index", pyxkbconfig_get_active_group_index, + METH_VARARGS, + "Gets the index number of the currently active group"}, {NULL, NULL, 0, NULL} }; |