From 065958f8d9e7afc2d48742f459308cf20b993dc3 Mon Sep 17 00:00:00 2001 From: Martin Pitt Date: Sun, 8 Jan 2012 14:27:40 +0100 Subject: [PATCH 3/6] Add XklConfigItem setters Add xkl_config_item_set_{name,short_description,description}() setters, to allow setting those fields through GI bindings. E. g. Python has a hard time assigning to a fixed-length static gchar array. --- configure.ac | 2 +- libxklavier/xkl_config_item.h | 37 +++++++++++++++++++++++++++++++++++++ libxklavier/xklavier_props.c | 30 ++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+), 1 deletions(-) diff --git a/configure.ac b/configure.ac index d4c1745..a414c20 100644 --- a/configure.ac +++ b/configure.ac @@ -20,7 +20,7 @@ m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) dnl for DLL dnl http://sources.redhat.com/autobook/autobook/autobook_91.html -VERSION_INFO=17:0:1 +VERSION_INFO=17:1:2 AC_SUBST(VERSION_INFO) # Check for programs diff --git a/libxklavier/xkl_config_item.h b/libxklavier/xkl_config_item.h index 0095c70..4bd2768 100644 --- a/libxklavier/xkl_config_item.h +++ b/libxklavier/xkl_config_item.h @@ -133,6 +133,43 @@ extern "C" { extern XklConfigItem *xkl_config_item_new(void); /** + * xkl_config_item_set_name: + * + * @item: the XklConfigItem object to be changed + * @name: (transfer none) (allow-none): Name (max. 32 characters); can be NULL. + * + * Change the @name field of a XklConfigItem. This is mostly useful for + * language bindings, in C you can manipulate the member directly. + */ + extern void xkl_config_item_set_name(XklConfigItem * item, + const gchar * name); + +/** + * xkl_config_item_set_short_description: + * + * @item: the XklConfigItem object to be changed + * @short_description: (transfer none) (allow-none): Short Description (max. 10 + * characters); can be NULL. + * + * Change the @short_description field of a XklConfigItem. This is mostly useful for + * language bindings, in C you can manipulate the member directly. + */ + extern void xkl_config_item_set_short_description(XklConfigItem * item, + const gchar * short_description); +/** + * xkl_config_item_set_description: + * + * @item: the XklConfigItem object to be changed + * @description: (transfer none) (allow-none): Description (max. 192 + * characters); can be NULL. + * + * Change the @description field of a XklConfigItem. This is mostly useful for + * language bindings, in C you can manipulate the member directly. + */ + extern void xkl_config_item_set_description(XklConfigItem * item, + const gchar * description); + +/** * xkl_get_country_name: * @code: ISO 3166 Alpha 2 code: 2 chars, uppercase (US, RU, FR, ...) * diff --git a/libxklavier/xklavier_props.c b/libxklavier/xklavier_props.c index 2abe6bc..3ff7336 100644 --- a/libxklavier/xklavier_props.c +++ b/libxklavier/xklavier_props.c @@ -54,6 +54,36 @@ xkl_config_item_new(void) (xkl_config_item_get_type(), NULL)); } +void +xkl_config_item_set_name(XklConfigItem * item, + const gchar * name) +{ + if (name != NULL) + strncpy (item->name, name, XKL_MAX_CI_SHORT_DESC_LENGTH-1); + else + item->name[0] = '\0'; +} + +void +xkl_config_item_set_short_description(XklConfigItem * item, + const gchar * short_description) +{ + if (short_description != NULL) + strncpy (item->short_description, short_description, XKL_MAX_CI_DESC_LENGTH-1); + else + item->short_description[0] = '\0'; +} + +void +xkl_config_item_set_description(XklConfigItem * item, + const gchar * description) +{ + if (description != NULL) + strncpy (item->description, description, XKL_MAX_CI_NAME_LENGTH-1); + else + item->description[0] = '\0'; +} + G_DEFINE_TYPE(XklConfigRec, xkl_config_rec, G_TYPE_OBJECT) static void -- 1.7.7.3