[beast: 3/5] BEAST: process Aida enum parameters by using Aida::EnumInfo
- From: Tim Janik <timj src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [beast: 3/5] BEAST: process Aida enum parameters by using Aida::EnumInfo
- Date: Fri, 20 Nov 2015 22:07:55 +0000 (UTC)
commit e3c0624dece2d35294de69ed20ce057cd0cd05ae
Author: Tim Janik <timj gnu org>
Date: Mon Nov 16 19:05:39 2015 +0100
BEAST: process Aida enum parameters by using Aida::EnumInfo
Signed-off-by: Tim Janik <timj gnu org>
beast-gtk/bstparam.cc | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/beast-gtk/bstparam.cc b/beast-gtk/bstparam.cc
index 59dff8e..8c7b6c6 100644
--- a/beast-gtk/bstparam.cc
+++ b/beast-gtk/bstparam.cc
@@ -403,7 +403,9 @@ aida_parameter_binding_set_value (GxkParam *param, const GValue *value)
case G_TYPE_STRING:
if (G_VALUE_TYPE (value) == SFI_TYPE_CHOICE) // sfi_pspec_choice
{
- any.set (Rapicorn::string_to_int (sfi_value_get_choice (value)));
+ const Rapicorn::Aida::EnumInfo &enum_info = *(const Rapicorn::Aida::EnumInfo*)
param->bdata[1].v_pointer;
+ assert_return (NULL != &enum_info);
+ any.set_enum (enum_info, enum_info.value_from_string (sfi_value_get_choice (value)));
}
else // sfi_pspec_string
any.set (g_value_get_string (value));
@@ -438,8 +440,10 @@ aida_parameter_binding_get_value (GxkParam *param, GValue *param_value)
case G_TYPE_STRING:
if (G_PARAM_SPEC_VALUE_TYPE (param->pspec) == SFI_TYPE_CHOICE) // sfi_pspec_choice
{
+ const Rapicorn::Aida::EnumInfo &enum_info = any.get_enum_info();
g_value_init (&value, SFI_TYPE_CHOICE);
- sfi_value_set_choice (&value, Rapicorn::string_from_int (any.get<int64>()).c_str());
+ sfi_value_set_choice (&value, enum_info.value_to_string (any.as_int64()).c_str());
+ param->bdata[1].v_pointer = (void*) &enum_info;
}
else // sfi_pspec_string
{
@@ -475,7 +479,8 @@ aida_parameter_binding_check_writable (GxkParam *param)
}
static GxkParamBinding aida_parameter_binding = {
- 1, NULL,
+ 2, // Aida::Parameter*, const Aida::EnumInfo*
+ NULL,
aida_parameter_binding_set_value,
aida_parameter_binding_get_value,
aida_parameter_binding_destroy,
@@ -487,6 +492,7 @@ bst_param_new_aida_parameter (GParamSpec *pspec, const Rapicorn::Aida::Parameter
{
GxkParam *param = gxk_param_new (pspec, &aida_parameter_binding, NULL);
param->bdata[0].v_pointer = new Rapicorn::Aida::Parameter (aparameter);
+ param->bdata[1].v_pointer = NULL;
gxk_param_set_size_group (param, param_size_group);
return param;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]