GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-tree-model.c
1 /*
2  * gnc-tree-model.c -- base implementation for a tree model in
3  * Gnucash. This only implements the object, not
4  * the model interface.
5  *
6  * Copyright (C) 2005 David Hampton <[email protected]>
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License as
10  * published by the Free Software Foundation; either version 2 of
11  * the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, contact:
20  *
21  * Free Software Foundation Voice: +1-617-542-5942
22  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652
23  * Boston, MA 02110-1301, USA [email protected]
24  */
25 
26 #include "config.h"
27 
28 #include <gtk/gtk.h>
29 #include <string.h>
30 
31 #include "gnc-tree-model.h"
32 #include "gnc-gobject-utils.h"
33 #include "gnc-engine.h"
34 
36 static QofLogModule log_module = GNC_MOD_GUI;
37 
39 static void gnc_tree_model_class_init (GncTreeModelClass *klass);
40 static void gnc_tree_model_init (GncTreeModel *model, GncTreeModelClass *klass);
41 static void gnc_tree_model_finalize (GObject *object);
42 
44 typedef struct GncTreeModelPrivate
45 {
46  gpointer dummy;
48 
49 #define GNC_TREE_MODEL_GET_PRIVATE(o) \
50  (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_TREE_MODEL, GncTreeModelPrivate))
51 
52 
53 /************************************************************/
54 /* g_object required functions */
55 /************************************************************/
56 
58 static GObjectClass *parent_class = NULL;
59 
60 GType
62 {
63  static GType gnc_tree_model_type = 0;
64 
65  if (gnc_tree_model_type == 0)
66  {
67  static const GTypeInfo our_info =
68  {
69  sizeof (GncTreeModelClass), /* class_size */
70  NULL, /* base_init */
71  NULL, /* base_finalize */
72  (GClassInitFunc) gnc_tree_model_class_init,
73  NULL, /* class_finalize */
74  NULL, /* class_data */
75  sizeof (GncTreeModel), /* */
76  0, /* n_preallocs */
77  (GInstanceInitFunc) gnc_tree_model_init
78  };
79 
80  //static const GInterfaceInfo tree_model_info = {
81  // (GInterfaceInitFunc) gnc_tree_model_tree_model_init,
82  // NULL,
83  // NULL
84  //};
85 
86  gnc_tree_model_type = g_type_register_static (G_TYPE_OBJECT,
87  GNC_TREE_MODEL_NAME,
88  &our_info, 0);
89 
90  //g_type_add_interface_static (gnc_tree_model_type,
91  // GTK_TYPE_TREE_MODEL,
92  // &tree_model_info);
93  }
94 
95  return gnc_tree_model_type;
96 }
97 
98 static void
99 gnc_tree_model_class_init (GncTreeModelClass *klass)
100 {
101  GObjectClass *o_class;
102 
103  parent_class = g_type_class_peek_parent (klass);
104 
105  o_class = G_OBJECT_CLASS (klass);
106 
107  /* GObject signals */
108  o_class->finalize = gnc_tree_model_finalize;
109 
110  g_type_class_add_private(klass, sizeof(GncTreeModelPrivate));
111 }
112 
113 static void
114 gnc_tree_model_init (GncTreeModel *model, GncTreeModelClass *klass)
115 {
116  ENTER("model %p", model);
117  gnc_gobject_tracking_remember(G_OBJECT(model), G_OBJECT_CLASS(klass));
118 
119  LEAVE(" ");
120 }
121 
122 static void
123 gnc_tree_model_finalize (GObject *object)
124 {
125  ENTER("model %p", object);
126  g_return_if_fail (object != NULL);
127  g_return_if_fail (GNC_IS_TREE_MODEL (object));
128 
130 
131  if (G_OBJECT_CLASS (parent_class)->finalize)
132  G_OBJECT_CLASS (parent_class)->finalize (object);
133  LEAVE(" ");
134 }
void gnc_gobject_tracking_remember(GObject *object, GObjectClass *klass)
void gnc_gobject_tracking_forget(GObject *object)
GType gnc_tree_model_get_type(void)
GtkTreeModel implementation for a generic gnucash tree.
#define ENTER(format, args...)
Definition: qoflog.h:261
Gobject helper routines.
All type declarations for the whole Gnucash engine.
#define LEAVE(format, args...)
Definition: qoflog.h:271
const gchar * QofLogModule
Definition: qofid.h:89