GC's Account is a now a GObject defined, need be reviwed the initializarion and destruction methods

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gobject-engine-dev1@15729 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Daniel Espinosa
2007-03-17 01:15:37 +00:00
parent 781897dcdd
commit daee335f9b
4 changed files with 154 additions and 5 deletions

View File

@@ -48,6 +48,130 @@ static QofLogModule log_module = GNC_MOD_ACCOUNT;
static gchar account_separator[8] = ".";
gunichar account_uc_separator = ':';
/* GObject declarations */
static void gnc_account_class_init(GncAccountClass *klass);
static void gnc_account_init(Account *sp);
static void gnc_account_finalize(GObject *object);
static void gnc_account_set_property (GObject *object, guint param_id, const GValue *value, GParamSpec *pspec);
static void gnc_account_get_property (GObject *object, guint property_id, GValue *value, GParamSpec *pspec);
struct _GncAccountPrivate
{
};
typedef struct _GncAccountSignal GncAccountSignal;
typedef enum _GncAccountSignalType GncAccountSignalType;
enum _GncAccountSignalType {
/* Signals */
FIRST_SIGNAL,
LAST_SIGNAL
};
/* properties */
enum
{
PROP_0
};
struct _GncAccountSignal {
Account *object;
};
static guint gnc_account_signals[LAST_SIGNAL] = { 0 };
static GObjectClass *parent_class = NULL;
GType
gnc_account_get_type(void)
{
static GType type = 0;
if(type == 0) {
static const GTypeInfo our_info = {
sizeof (GncAccountClass),
NULL,
NULL,
(GClassInitFunc)gnc_account_class_init,
NULL,
NULL,
sizeof (Account),
0,
(GInstanceInitFunc)gnc_account_init,
};
type = g_type_register_static(G_TYPE_OBJECT,
"GncAccount", &our_info, 0);
}
return type;
}
static void
gnc_account_class_init(GncAccountClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
parent_class = g_type_class_peek_parent(klass);
object_class->finalize = gnc_account_finalize;
object_class->set_property = gnc_account_set_property;
object_class->get_property = gnc_account_get_property;
/* Install properties */
/* Create signals here:*/
}
static void
gnc_account_init(Account *acc)
{
}
static void
gnc_account_finalize(GObject *object)
{
}
static void
gnc_account_set_property (GObject *object,
guint param_id,
const GValue *value,
GParamSpec *pspec)
{
Account *obj;
obj = GNC_ACCOUNT (object);
switch (param_id) {
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID(object,param_id,pspec);
break;
}
}
static void
gnc_account_get_property (GObject *object,
guint property_id,
GValue *value,
GParamSpec *pspec)
{
Account *obj;
obj = GNC_ACCOUNT(object);
switch (property_id) {
default:
/* We don't have any other property... */
G_OBJECT_WARN_INVALID_PROPERTY_ID(object,property_id,pspec);
break;
}
}
/********************************************************************\
* Because I can't use C++ for this project, doesn't mean that I *
* can't pretend to! These functions perform actions on the *

View File

@@ -46,6 +46,32 @@
#define XACC_ACCOUNT_H
#include "qof.h"
#include "gnc-engine.h"
#include <glib-object.h>
/* GObject declarations */
#define GNC_TYPE_ACCOUNT (gnc_account_get_type ())
#define GNC_ACCOUNT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_ACCOUNT, Account))
#define GNC_ACCOUNT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_ACCOUNT, AccountClass))
#define GNC_IS_ACCOUNT(o) (G_TYPE_CHECK_INSTANCE_TYPE ((o), GNC_TYPE_ACCOUNT))
#define GNC_IS_ACCOUNT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE ((k), GNC_TYPE_ACCOUNT))
#define GNC_ACCOUNT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS ((o), GNC_TYPE_ACCOUNT, AccountClass))
typedef struct _GncAccountClass GncAccountClass;
//typedef struct _GncAccount Account;
typedef struct _GncAccountPrivate GncAccountPrivate;
struct _GncAccountClass {
GObjectClass parent_class;
/* virtual table */
/* Add Signal Functions Here */
};
GType gnc_account_get_type (void);
/*******/
typedef gnc_numeric (*xaccGetBalanceFn)( const Account *account );
@@ -59,9 +85,6 @@ typedef gnc_numeric (*xaccGetBalanceAsOfDateFn) (
typedef void (*AccountCb)(Account *a, gpointer data);
typedef gpointer (*AccountCb2)(Account *a, gpointer data);
#define GNC_IS_ACCOUNT(obj) (QOF_CHECK_TYPE((obj), GNC_ID_ACCOUNT))
#define GNC_ACCOUNT(obj) (QOF_CHECK_CAST((obj), GNC_ID_ACCOUNT, Account))
/** The account types are used to determine how the transaction data
* in the account is displayed. These values can be safely changed
* from one release to the next. Note that if values are added,

View File

@@ -53,8 +53,10 @@
*/
/** \struct Account */
struct account_s
struct _GncAccount
{
GObject object;
QofInstance inst;
/* The accountName is an arbitrary string assigned by the user.

View File

@@ -130,7 +130,7 @@
* defined in the private header AccountP.h, but no one outside the
* engine should include that file. Instead, access that data only
* through the functions in Account.h .*/
typedef struct account_s Account;
typedef struct _GncAccount Account;
/** @brief Split in Gnucash.
* A "split" is more commonly refered to as a "entry" in a