2 * Copyright (C) 2008-2011 Robert Ancell.
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License as published by the Free Software
6 * Foundation, either version 2 of the License, or (at your option) any later
7 * version. See http://www.gnu.org/copyleft/gpl.html the full text of the
15 #include "mp-serializer.h"
16 #include "currency-manager.h" // FIXME: Move out of here
18 struct CurrencyPrivate
26 G_DEFINE_TYPE (Currency
, currency
, G_TYPE_OBJECT
);
30 currency_new(const gchar
*name
,
31 const gchar
*display_name
,
34 Currency
*currency
= g_object_new(currency_get_type(), NULL
);
36 currency
->priv
->name
= g_strdup(name
);
37 currency
->priv
->display_name
= g_strdup(display_name
);
38 currency
->priv
->symbol
= g_strdup(symbol
);
45 currency_get_name(Currency
*currency
)
47 g_return_val_if_fail (currency
!= NULL
, NULL
);
48 return currency
->priv
->name
;
53 currency_get_display_name(Currency
*currency
)
55 g_return_val_if_fail (currency
!= NULL
, NULL
);
56 return currency
->priv
->display_name
;
61 currency_get_symbol(Currency
*currency
)
63 g_return_val_if_fail (currency
!= NULL
, NULL
);
64 return currency
->priv
->symbol
;
69 currency_set_value(Currency
*currency
, MPNumber
*value
)
71 g_return_if_fail (currency
!= NULL
);
72 g_return_if_fail (value
!= NULL
);
73 mp_set_from_mp (value
, ¤cy
->priv
->value
);
78 currency_get_value(Currency
*currency
)
80 g_return_val_if_fail (currency
!= NULL
, NULL
);
81 return ¤cy
->priv
->value
;
86 currency_class_init(CurrencyClass
*klass
)
88 g_type_class_add_private(klass
, sizeof(CurrencyPrivate
));
93 currency_init(Currency
*currency
)
95 currency
->priv
= G_TYPE_INSTANCE_GET_PRIVATE(currency
, currency_get_type(), CurrencyPrivate
);