Added transform function for string to int
authorJohn Darrington <john@darrington.wattle.id.au>
Sat, 19 Mar 2016 06:38:26 +0000 (07:38 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Sat, 19 Mar 2016 06:38:26 +0000 (07:38 +0100)
src/ui/gui/widgets.c

index 50b07a5cec03f889595581e343a3107c73256d01..c66c42a58f18f974d9b625c8a12da4666b791644 100644 (file)
@@ -128,6 +128,16 @@ tx_string_to_double (const GValue *src, GValue *dest)
 }
 
 
+static void
+tx_string_to_int (const GValue *src, GValue *dest)
+{
+  const gchar *str = g_value_get_string (src);
+  gint x = atoi (str);
+  g_value_set_int (dest, x);
+}
+
+
+
 GType align_enum_type;
 GType measure_enum_type;
 GType role_enum_type;
@@ -140,6 +150,7 @@ static void
 preregister_misc (void)
 {
   g_value_register_transform_func (G_TYPE_STRING, G_TYPE_DOUBLE, tx_string_to_double);
+  g_value_register_transform_func (G_TYPE_STRING, G_TYPE_INT, tx_string_to_int);
 
   align_enum_type = g_enum_register_static ("PsppAlignment", align);
   measure_enum_type = g_enum_register_static ("PsppMeasure", measure);