GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-dense-cal-model.c
1 /*
2  * gnc-dense-cal-model.c
3  *
4  * Copyright (C) 2006 Joshua Sled <[email protected]>
5  *
6  * This program is free software; you can redistribute it and/or modify it
7  * under the terms of version 2 and/or version 3 of the GNU General Public License as
8  * published by the Free Software Foundation.
9  *
10  * As a special exception, permission is granted to link the binary module
11  * resultant from this code with the OpenSSL project's "OpenSSL" library (or
12  * modified versions of it that use the same license as the "OpenSSL"
13  * library), and distribute the linked executable. You must obey the GNU
14  * General Public License in all respects for all of the code used other than
15  * "OpenSSL". If you modify this file, you may extend this exception to your
16  * version of the file, but you are not obligated to do so. If you do not
17  * wish to do so, delete this exception statement from your version of this
18  * file.
19  *
20  * This program is distributed in the hope that it will be useful,
21  * but WITHOUT ANY WARRANTY; without even the implied warranty of
22  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23  * GNU General Public License for more details.
24  *
25  * You should have received a copy of the GNU General Public License*
26  * along with this program; if not, contact:
27  *
28  * Free Software Foundation Voice: +1-617-542-5942
29  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
30  * Boston, MA 02110-1301, USA [email protected]
31  */
32 
33 
34 #include "config.h"
35 #include <glib.h>
36 #include <glib-object.h>
37 #include "gnc-dense-cal.h"
38 #include "gnc-dense-cal-model.h"
39 
40 enum { GDCM_ADDED, GDCM_UPDATE, GDCM_REMOVE, LAST_SIGNAL };
41 static guint gnc_dense_cal_model_signals[LAST_SIGNAL] = { 0 };
42 
43 static void
44 gnc_dense_cal_model_base_init(gpointer g_class)
45 {
46  static gboolean initialized = FALSE;
47 
48  if (!initialized)
49  {
50  gnc_dense_cal_model_signals[GDCM_ADDED]
51  = g_signal_new("added",
52  G_TYPE_FROM_CLASS(g_class),
53  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
54  0 /* default offset */,
55  NULL /* accumulator */,
56  NULL /* accum. data */,
57  g_cclosure_marshal_VOID__UINT,
58  G_TYPE_NONE /* return */,
59  1 /* n_params */,
60  G_TYPE_UINT /* param types */
61  );
62 
63  gnc_dense_cal_model_signals[GDCM_UPDATE]
64  = g_signal_new("update",
65  G_TYPE_FROM_CLASS(g_class),
66  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
67  0 /* default offset */,
68  NULL /* accumulator */,
69  NULL /* accum. data */,
70  g_cclosure_marshal_VOID__UINT,
71  G_TYPE_NONE /* return */,
72  1 /* n_params */,
73  G_TYPE_UINT /* param types */
74  );
75 
76  gnc_dense_cal_model_signals[GDCM_REMOVE]
77  = g_signal_new("removing",
78  G_TYPE_FROM_CLASS(g_class),
79  G_SIGNAL_RUN_LAST | G_SIGNAL_NO_RECURSE | G_SIGNAL_NO_HOOKS,
80  0 /* default offset */,
81  NULL /* accumulator */,
82  NULL /* accum. data */,
83  g_cclosure_marshal_VOID__UINT,
84  G_TYPE_NONE /* return */,
85  1 /* n_params */,
86  G_TYPE_UINT /* param types */
87  );
88 
89  initialized = TRUE;
90  }
91 }
92 
93 GType
94 gnc_dense_cal_model_get_type(void)
95 {
96  static GType type = 0;
97  if (type == 0)
98  {
99  static const GTypeInfo info =
100  {
101  sizeof(GncDenseCalModelIface),
102  gnc_dense_cal_model_base_init, /* base_init */
103  NULL, /* base_finalize */
104  NULL, /* class_init */
105  NULL, /* class_finalize */
106  NULL, /* class_data */
107  0,
108  0, /* n_preallocs */
109  NULL /* instance_init */
110  };
111  type = g_type_register_static(G_TYPE_INTERFACE, "GncDenseCalModel", &info, 0);
112  }
113  return type;
114 }
115 
116 GList*
117 gnc_dense_cal_model_get_contained(GncDenseCalModel *model)
118 {
119  return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_contained)(model);
120 }
121 
122 gchar*
123 gnc_dense_cal_model_get_name(GncDenseCalModel *model, guint tag)
124 {
125  return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_name)(model, tag);
126 }
127 
128 gchar*
129 gnc_dense_cal_model_get_info(GncDenseCalModel *model, guint tag)
130 {
131  return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_info)(model, tag);
132 }
133 
134 gint
135 gnc_dense_cal_model_get_instance_count(GncDenseCalModel *model, guint tag)
136 {
137  return (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_instance_count)(model, tag);
138 }
139 
140 void
141 gnc_dense_cal_model_get_instance(GncDenseCalModel *model, guint tag, gint instance_index, GDate *date)
142 {
143  (*GNC_DENSE_CAL_MODEL_GET_INTERFACE(model)->get_instance)(model, tag, instance_index, date);
144 }