Bump version number
[gcalctool.git] / src / currency.c
blobea81761cc284ab3eeaea17f4bf75668885715e39
1 /*
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
8 * license.
9 */
11 #include <string.h>
12 #include <stdarg.h>
14 #include "currency.h"
15 #include "mp-serializer.h"
16 #include "currency-manager.h" // FIXME: Move out of here
18 struct CurrencyPrivate
20 gchar *name;
21 gchar *display_name;
22 gchar *symbol;
23 MPNumber value;
26 G_DEFINE_TYPE (Currency, currency, G_TYPE_OBJECT);
29 Currency *
30 currency_new(const gchar *name,
31 const gchar *display_name,
32 const gchar *symbol)
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);
40 return currency;
44 const gchar *
45 currency_get_name(Currency *currency)
47 g_return_val_if_fail (currency != NULL, NULL);
48 return currency->priv->name;
52 const gchar *
53 currency_get_display_name(Currency *currency)
55 g_return_val_if_fail (currency != NULL, NULL);
56 return currency->priv->display_name;
60 const gchar *
61 currency_get_symbol(Currency *currency)
63 g_return_val_if_fail (currency != NULL, NULL);
64 return currency->priv->symbol;
68 void
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, &currency->priv->value);
77 const MPNumber *
78 currency_get_value(Currency *currency)
80 g_return_val_if_fail (currency != NULL, NULL);
81 return &currency->priv->value;
85 static void
86 currency_class_init(CurrencyClass *klass)
88 g_type_class_add_private(klass, sizeof(CurrencyPrivate));
92 static void
93 currency_init(Currency *currency)
95 currency->priv = G_TYPE_INSTANCE_GET_PRIVATE(currency, currency_get_type(), CurrencyPrivate);