diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2012-01-11 09:51:40 +0100 |
---|---|---|
committer | Sergey V. Udaltsov <svu@gnome.org> | 2012-01-11 22:09:03 +0000 |
commit | b0ee2514b9c9de86b0d1a5928ec0ad915d3a8ad3 (patch) | |
tree | fea9898165d4321692879573ea9d6d6b344dc719 | |
parent | 9a7d915fec214494e796bcd54565ce9398354461 (diff) | |
download | libxklavier-b0ee2514b9c9de86b0d1a5928ec0ad915d3a8ad3.tar.gz |
Make xkl_engine_get_current_state() introspectable
Define boxed type for XklState and fix the return type transfer annotation.
Also add a small test to test_gi.py.
-rw-r--r-- | libxklavier/xkl_engine.h | 6 | ||||
-rw-r--r-- | libxklavier/xklavier_util.c | 14 | ||||
-rwxr-xr-x | tests/test_gi.py | 2 |
3 files changed, 21 insertions, 1 deletions
diff --git a/libxklavier/xkl_engine.h b/libxklavier/xkl_engine.h index 101350c..1421373 100644 --- a/libxklavier/xkl_engine.h +++ b/libxklavier/xkl_engine.h @@ -82,6 +82,10 @@ extern "C" { guint32 indicators; } XklState; +#define XKL_TYPE_STATE (xkl_state_get_type()) + + GType xkl_state_get_type (void) G_GNUC_CONST; + /** * The main Xklavier engine class */ @@ -326,7 +330,7 @@ extern "C" { * xkl_engine_get_current_state: * @engine: the engine * - * Returns: current state of the keyboard. + * Returns: (transfer none): current state of the keyboard. * Returned value is a statically allocated buffer, should not be freed. */ extern XklState *xkl_engine_get_current_state(XklEngine * engine); diff --git a/libxklavier/xklavier_util.c b/libxklavier/xklavier_util.c index 578f408..0891726 100644 --- a/libxklavier/xklavier_util.c +++ b/libxklavier/xklavier_util.c @@ -27,6 +27,20 @@ #include "xklavier_private.h" XklState * +_xkl_state_copy(XklState * state) +{ + XklState * copy; + + copy = g_new(XklState, 1); + copy->group = state->group; + copy->indicators = state->indicators; + + return copy; +} + +G_DEFINE_BOXED_TYPE (XklState, xkl_state, _xkl_state_copy, g_free); + +XklState * xkl_engine_get_current_state(XklEngine * engine) { return &xkl_engine_priv(engine, curr_state); diff --git a/tests/test_gi.py b/tests/test_gi.py index 0602fbd..25867f5 100755 --- a/tests/test_gi.py +++ b/tests/test_gi.py @@ -36,6 +36,8 @@ print('indicator names:', engine.get_indicators_names()) print('group names:', engine.get_groups_names()) print('default layout:', engine.get_groups_names()[engine.get_default_group()]) print('features: %X' % engine.get_features()) +st = engine.get_current_state() +print('current state: group: %i, indicators: %u' % (st.group, st.indicators)) # check ConfigItem ctor with data i = Xkl.ConfigItem() |