From 09be1f99341b8dbf9004828204e98aed8bec7ddc Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Sun, 8 Jan 2012 18:02:42 +0100 Subject: [PATCH 5/6] Add setters for XklConfigRec string arrays Add xkl_config_rec_set_{layouts,variants,options}() setters, as language bindings cannot directly manipulate the string arrays. --- libxklavier/xkl_config_rec.h | 42 ++++++++++++++++++++++++++++++++++++++++++ libxklavier/xklavier_props.c | 24 ++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 0 deletions(-) diff --git a/libxklavier/xkl_config_rec.h b/libxklavier/xkl_config_rec.h index 0658d04..1b837f3 100644 --- a/libxklavier/xkl_config_rec.h +++ b/libxklavier/xkl_config_rec.h @@ -239,6 +239,48 @@ extern "C" { extern gboolean xkl_config_rec_equals(XklConfigRec * data1, XklConfigRec * data2); +/** + * xkl_config_rec_set_layouts: + * @data: record to change + * @new_layouts: (array zero-terminated=1) (transfer none): zero terminated + * list of new layout names. + * + * Sets a new layout list. + * + * Frees the previous layout list. This is primarily useful for bindings, in C + * you can manipulate the @layouts record member directly. + */ + extern void xkl_config_rec_set_layouts(XklConfigRec * data, + const gchar ** new_layouts); + +/** + * xkl_config_rec_set_variants: + * @data: record to change + * @new_variants: (transfer none) (array zero-terminated=1): zero terminated + * list of new variant names. + * + * Sets a new variant list. + * + * Frees the previous variant list. This is primarily useful for bindings, in C + * you can manipulate the @variants record member directly. + */ + extern void xkl_config_rec_set_variants(XklConfigRec * data, + const gchar ** new_variants); + +/** + * xkl_config_rec_set_options: + * @data: record to change + * @new_options: (transfer none) (array zero-terminated=1): zero terminated + * list of new option names. + * + * Sets a new option list. + * + * Frees the previous option list. This is primarily useful for bindings, in C + * you can manipulate the @options record member directly. + */ + extern void xkl_config_rec_set_options(XklConfigRec * data, + const gchar ** new_options); + #ifdef __cplusplus } #endif /* __cplusplus */ diff --git a/libxklavier/xklavier_props.c b/libxklavier/xklavier_props.c index 160e847..74e8c26 100644 --- a/libxklavier/xklavier_props.c +++ b/libxklavier/xklavier_props.c @@ -177,6 +177,30 @@ xkl_config_rec_equals(XklConfigRec * data1, XklConfigRec * data2) } void +xkl_config_rec_set_layouts(XklConfigRec * data, + const gchar ** new_layouts) +{ + g_strfreev (data->layouts); + data->layouts = g_strdupv ((gchar**) new_layouts); +} + +void +xkl_config_rec_set_variants(XklConfigRec * data, + const gchar ** new_variants) +{ + g_strfreev (data->variants); + data->variants = g_strdupv ((gchar**) new_variants); +} + +void +xkl_config_rec_set_options(XklConfigRec * data, + const gchar ** new_options) +{ + g_strfreev (data->options); + data->options = g_strdupv ((gchar**) new_options); +} + +void xkl_config_rec_init(XklConfigRec * data) { /* clear the structure VarDefsPtr... */ -- 1.7.7.3