diff options
author | Martin Pitt <martin.pitt@ubuntu.com> | 2012-01-08 14:27:40 +0100 |
---|---|---|
committer | Sergey V. Udaltsov <svu@gnome.org> | 2012-01-10 23:16:58 +0000 |
commit | 52322041a47047681760fa5ee2cee11991d82e90 (patch) | |
tree | b0b56ab279b15a065278745c13583aaca5da6b10 | |
parent | e8a5cd198eb61f36c196e75d1da599e6b11c0b87 (diff) | |
download | libxklavier-52322041a47047681760fa5ee2cee11991d82e90.tar.gz |
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.
-rw-r--r-- | configure.ac | 2 | ||||
-rw-r--r-- | libxklavier/xkl_config_item.h | 37 | ||||
-rw-r--r-- | 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 |