GnuCash 2.4.99
gnc-tree-model.c
00001 /*
00002  * gnc-tree-model.c -- base implementation for a tree model in
00003  *                     Gnucash.  This only implements the object, not
00004  *                     the model interface.
00005  *
00006  * Copyright (C) 2005 David Hampton <hampton@employees.org>
00007  *
00008  * This program is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License as
00010  * published by the Free Software Foundation; either version 2 of
00011  * the License, or (at your option) any later version.
00012  *
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, contact:
00020  *
00021  * Free Software Foundation           Voice:  +1-617-542-5942
00022  * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652
00023  * Boston, MA  02110-1301,  USA       gnu@gnu.org
00024  */
00025 
00026 #include "config.h"
00027 
00028 #include <gtk/gtk.h>
00029 #include <string.h>
00030 
00031 #include "gnc-tree-model.h"
00032 #include "gnc-gobject-utils.h"
00033 #include "gnc-engine.h"
00034 
00036 static QofLogModule log_module = GNC_MOD_GUI;
00037 
00039 static void gnc_tree_model_class_init (GncTreeModelClass *klass);
00040 static void gnc_tree_model_init (GncTreeModel *model, GncTreeModelClass *klass);
00041 static void gnc_tree_model_finalize (GObject *object);
00042 
00044 typedef struct GncTreeModelPrivate
00045 {
00046     gpointer dummy;
00047 } GncTreeModelPrivate;
00048 
00049 #define GNC_TREE_MODEL_GET_PRIVATE(o)  \
00050    (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_TREE_MODEL, GncTreeModelPrivate))
00051 
00052 
00053 /************************************************************/
00054 /*               g_object required functions                */
00055 /************************************************************/
00056 
00058 static GObjectClass *parent_class = NULL;
00059 
00060 GType
00061 gnc_tree_model_get_type (void)
00062 {
00063     static GType gnc_tree_model_type = 0;
00064 
00065     if (gnc_tree_model_type == 0)
00066     {
00067         static const GTypeInfo our_info =
00068         {
00069             sizeof (GncTreeModelClass),          /* class_size */
00070             NULL,                                  /* base_init */
00071             NULL,                                  /* base_finalize */
00072             (GClassInitFunc) gnc_tree_model_class_init,
00073             NULL,                                  /* class_finalize */
00074             NULL,                                  /* class_data */
00075             sizeof (GncTreeModel),                 /* */
00076             0,                             /* n_preallocs */
00077             (GInstanceInitFunc) gnc_tree_model_init
00078         };
00079 
00080         //static const GInterfaceInfo tree_model_info = {
00081         //  (GInterfaceInitFunc) gnc_tree_model_tree_model_init,
00082         //  NULL,
00083         //  NULL
00084         //};
00085 
00086         gnc_tree_model_type = g_type_register_static (G_TYPE_OBJECT,
00087                               GNC_TREE_MODEL_NAME,
00088                               &our_info, 0);
00089 
00090         //g_type_add_interface_static (gnc_tree_model_type,
00091         //                               GTK_TYPE_TREE_MODEL,
00092         //                               &tree_model_info);
00093     }
00094 
00095     return gnc_tree_model_type;
00096 }
00097 
00098 static void
00099 gnc_tree_model_class_init (GncTreeModelClass *klass)
00100 {
00101     GObjectClass *o_class;
00102 
00103     parent_class = g_type_class_peek_parent (klass);
00104 
00105     o_class = G_OBJECT_CLASS (klass);
00106 
00107     /* GObject signals */
00108     o_class->finalize = gnc_tree_model_finalize;
00109 
00110     g_type_class_add_private(klass, sizeof(GncTreeModelPrivate));
00111 }
00112 
00113 static void
00114 gnc_tree_model_init (GncTreeModel *model, GncTreeModelClass *klass)
00115 {
00116     ENTER("model %p", model);
00117     gnc_gobject_tracking_remember(G_OBJECT(model), G_OBJECT_CLASS(klass));
00118 
00119     LEAVE(" ");
00120 }
00121 
00122 static void
00123 gnc_tree_model_finalize (GObject *object)
00124 {
00125     GncTreeModel *model;
00126     GncTreeModelPrivate *priv;
00127 
00128     ENTER("model %p", object);
00129     g_return_if_fail (object != NULL);
00130     g_return_if_fail (GNC_IS_TREE_MODEL (object));
00131 
00132     model = GNC_TREE_MODEL(object);
00133     priv = GNC_TREE_MODEL_GET_PRIVATE(model);
00134 
00135     gnc_gobject_tracking_forget(object);
00136 
00137     if (G_OBJECT_CLASS (parent_class)->finalize)
00138         G_OBJECT_CLASS (parent_class)->finalize (object);
00139     LEAVE(" ");
00140 }
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines