diff --git a/lib/libqof/qof/gnc-numeric.c b/lib/libqof/qof/gnc-numeric.c index 319a31ccb5..31bb8c69b4 100644 --- a/lib/libqof/qof/gnc-numeric.c +++ b/lib/libqof/qof/gnc-numeric.c @@ -1263,6 +1263,40 @@ string_to_gnc_numeric(const gchar* str, gnc_numeric *n) return TRUE; } +/* ******************************************************************* + * GValue handling + ********************************************************************/ +static gpointer +gnc_numeric_boxed_copy_func( gpointer in_gnc_numeric ) +{ + gnc_numeric* newvalue; + + newvalue = g_malloc( sizeof( gnc_numeric ) ); + memcpy( newvalue, in_gnc_numeric, sizeof( gnc_numeric ) ); + + return newvalue; +} + +static void +gnc_numeric_boxed_free_func( gpointer in_gnc_numeric ) +{ + g_free( in_gnc_numeric ); +} + +GType +gnc_numeric_get_type( void ) +{ + static GType type = 0; + + if( type == 0 ) { + type = g_boxed_type_register_static( "gnc_numeric", + gnc_numeric_boxed_copy_func, + gnc_numeric_boxed_free_func ); + } + + return type; +} + /* ******************************************************************* * gnc_numeric misc testing ********************************************************************/ diff --git a/lib/libqof/qof/gnc-numeric.h b/lib/libqof/qof/gnc-numeric.h index 435f19835c..28983fa79d 100644 --- a/lib/libqof/qof/gnc-numeric.h +++ b/lib/libqof/qof/gnc-numeric.h @@ -50,6 +50,8 @@ See \ref gncnumericexample #ifndef GNC_NUMERIC_H #define GNC_NUMERIC_H +#include + struct _gnc_numeric { gint64 num; @@ -445,6 +447,13 @@ gnc_numeric gnc_numeric_convert_with_error(gnc_numeric in, gint64 denom, gnc_numeric gnc_numeric_reduce(gnc_numeric in); /** @} */ +/** @name GValue + @{ +*/ +GType gnc_numeric_get_type( void ); + +/** @} */ + /** @name Deprecated, backwards-compatible definitions @{ */