mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Flesh out the model to include all the necessary columns. Make it
look like the original account tree. Add a new view to contain the common code for all users of the gnc-tree-model-account.c file. git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/branches/gnucash-gnome2-dev@9161 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
@@ -58,6 +58,7 @@ libgncmod_gnome_utils_la_SOURCES = \
|
||||
gnc-tree-model-example-account.c \
|
||||
gnc-tree-model-price.c \
|
||||
gnc-tree-model-selection.c \
|
||||
gnc-tree-view-account.c \
|
||||
gncmod-gnome-utils.c \
|
||||
gtkselect.c \
|
||||
misc-gnome-utils.c \
|
||||
@@ -103,6 +104,7 @@ gncinclude_HEADERS = \
|
||||
gnc-tree-model-example-account.h \
|
||||
gnc-tree-model-price.h \
|
||||
gnc-tree-model-selection.h \
|
||||
gnc-tree-view-account.h \
|
||||
gtkselect.h \
|
||||
misc-gnome-utils.h \
|
||||
print-session.h \
|
||||
@@ -153,6 +155,7 @@ glade_DATA = \
|
||||
dialog-query-list.glade \
|
||||
exchange-dialog.glade \
|
||||
gnc-date-format.glade \
|
||||
preferences.glade \
|
||||
transfer.glade
|
||||
|
||||
EXTRA_DIST = \
|
||||
|
||||
@@ -11,13 +11,21 @@
|
||||
#include "gnc-component-manager.h"
|
||||
#include "Account.h"
|
||||
#include "Group.h"
|
||||
#include "gnc-commodity.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-ui-util.h"
|
||||
|
||||
#define TREE_MODEL_ACCOUNT_CM_CLASS "tree-model-account"
|
||||
|
||||
/** Static Globals *******************************************************/
|
||||
static short module = MOD_GUI;
|
||||
static GList *active_models = NULL;
|
||||
|
||||
/** Declarations *********************************************************/
|
||||
static void gnc_tree_model_account_class_init (GncTreeModelAccountClass *klass);
|
||||
static void gnc_tree_model_account_init (GncTreeModelAccount *model);
|
||||
static void gnc_tree_model_account_finalize (GObject *object);
|
||||
static void gnc_tree_model_account_dispose (GObject *object);
|
||||
static void gnc_tree_model_account_destroy (GtkObject *object);
|
||||
|
||||
static void gnc_tree_model_account_tree_model_init (GtkTreeModelIface *iface);
|
||||
static guint gnc_tree_model_account_get_flags (GtkTreeModel *tree_model);
|
||||
@@ -52,19 +60,18 @@ static gboolean gnc_tree_model_account_iter_parent (GtkTreeModel *tree_model,
|
||||
|
||||
static gpointer account_row_inserted (Account *account,
|
||||
gpointer data);
|
||||
static void gnc_tree_model_account_refresh_handler (GHashTable *changes,
|
||||
gpointer data);
|
||||
static void gnc_tree_model_account_refresh (GncTreeModelAccount *model);
|
||||
|
||||
void gnc_tree_model_account_event_handler (GUID *entity, QofIdType type,
|
||||
GNCEngineEventType event_type,
|
||||
gpointer user_data);
|
||||
|
||||
struct GncTreeModelAccountPrivate
|
||||
{
|
||||
AccountGroup *root;
|
||||
Account *toplevel;
|
||||
gint component_id;
|
||||
gint event_handler_id;
|
||||
};
|
||||
|
||||
static GObjectClass *parent_class = NULL;
|
||||
static GtkObjectClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
gnc_tree_model_account_get_type (void)
|
||||
@@ -73,14 +80,14 @@ gnc_tree_model_account_get_type (void)
|
||||
|
||||
if (gnc_tree_model_account_type == 0) {
|
||||
static const GTypeInfo our_info = {
|
||||
sizeof (GncTreeModelAccountClass),
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GncTreeModelAccountClass), /* class_size */
|
||||
NULL, /* base_init */
|
||||
NULL, /* base_finalize */
|
||||
(GClassInitFunc) gnc_tree_model_account_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GncTreeModelAccount),
|
||||
0,
|
||||
NULL, /* class_finalize */
|
||||
NULL, /* class_data */
|
||||
sizeof (GncTreeModelAccount), /* */
|
||||
0, /* n_preallocs */
|
||||
(GInstanceInitFunc) gnc_tree_model_account_init
|
||||
};
|
||||
|
||||
@@ -90,7 +97,7 @@ gnc_tree_model_account_get_type (void)
|
||||
NULL
|
||||
};
|
||||
|
||||
gnc_tree_model_account_type = g_type_register_static (G_TYPE_OBJECT,
|
||||
gnc_tree_model_account_type = g_type_register_static (GTK_TYPE_OBJECT,
|
||||
"GncTreeModelAccount",
|
||||
&our_info, 0);
|
||||
|
||||
@@ -105,18 +112,25 @@ gnc_tree_model_account_get_type (void)
|
||||
static void
|
||||
gnc_tree_model_account_class_init (GncTreeModelAccountClass *klass)
|
||||
{
|
||||
GObjectClass *object_class = G_OBJECT_CLASS (klass);
|
||||
GObjectClass *o_class;
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
object_class->finalize = gnc_tree_model_account_finalize;
|
||||
object_class->dispose = gnc_tree_model_account_dispose;
|
||||
o_class = G_OBJECT_CLASS (klass);
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
/* GObject signals */
|
||||
o_class->finalize = gnc_tree_model_account_finalize;
|
||||
|
||||
/* GtkObject signals */
|
||||
object_class->destroy = gnc_tree_model_account_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tree_model_account_init (GncTreeModelAccount *model)
|
||||
{
|
||||
|
||||
ENTER("model %p", model);
|
||||
while (model->stamp == 0) {
|
||||
model->stamp = g_random_int ();
|
||||
}
|
||||
@@ -124,6 +138,7 @@ gnc_tree_model_account_init (GncTreeModelAccount *model)
|
||||
model->priv = g_new0 (GncTreeModelAccountPrivate, 1);
|
||||
model->priv->root = NULL;
|
||||
model->priv->toplevel = NULL;
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -131,52 +146,68 @@ gnc_tree_model_account_finalize (GObject *object)
|
||||
{
|
||||
GncTreeModelAccount *model;
|
||||
|
||||
ENTER("model %p", object);
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (object));
|
||||
|
||||
model = GNC_TREE_MODEL_ACCOUNT (object);
|
||||
|
||||
g_return_if_fail (model->priv != NULL);
|
||||
|
||||
g_free (model->priv);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->finalize (object);
|
||||
if (G_OBJECT_CLASS (parent_class)->finalize)
|
||||
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tree_model_account_dispose (GObject *object)
|
||||
gnc_tree_model_account_destroy (GtkObject *object)
|
||||
{
|
||||
GncTreeModelAccount *model;
|
||||
|
||||
ENTER("model %p", object);
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (object));
|
||||
|
||||
model = GNC_TREE_MODEL_ACCOUNT (object);
|
||||
|
||||
gnc_unregister_gui_component (model->priv->component_id);
|
||||
active_models = g_list_remove (active_models, model);
|
||||
|
||||
G_OBJECT_CLASS (parent_class)->dispose (object);
|
||||
if (model->priv->event_handler_id) {
|
||||
gnc_engine_unregister_event_handler (model->priv->event_handler_id);
|
||||
model->priv->event_handler_id = 0;
|
||||
}
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
GtkTreeModel *
|
||||
gnc_tree_model_account_new (AccountGroup *group)
|
||||
{
|
||||
GncTreeModelAccount *model;
|
||||
GncTreeModelAccountPrivate *priv;
|
||||
GList *item;
|
||||
|
||||
ENTER("group %p", group);
|
||||
for (item = active_models; item; item = g_list_next(item)) {
|
||||
model = (GncTreeModelAccount *)item->data;
|
||||
if (model->priv->root == group) {
|
||||
LEAVE("returning existing model %p", model);
|
||||
return GTK_TREE_MODEL(model);
|
||||
}
|
||||
}
|
||||
|
||||
model = g_object_new (GNC_TYPE_TREE_MODEL_ACCOUNT,
|
||||
NULL);
|
||||
|
||||
model->priv->root = group;
|
||||
priv = model->priv;
|
||||
priv->root = group;
|
||||
|
||||
model->priv->component_id = gnc_register_gui_component (TREE_MODEL_ACCOUNT_CM_CLASS,
|
||||
gnc_tree_model_account_refresh_handler,
|
||||
NULL,
|
||||
model);
|
||||
|
||||
gnc_gui_component_watch_entity_type (model->priv->component_id,
|
||||
GNC_ID_ACCOUNT,
|
||||
GNC_EVENT_MODIFY | GNC_EVENT_DESTROY);
|
||||
priv->event_handler_id =
|
||||
gnc_engine_register_event_handler (gnc_tree_model_account_event_handler, model);
|
||||
|
||||
active_models = g_list_append (active_models, model);
|
||||
LEAVE("model %p", model);
|
||||
return GTK_TREE_MODEL (model);
|
||||
}
|
||||
|
||||
@@ -187,9 +218,11 @@ gnc_tree_model_account_set_root (GncTreeModelAccount *model,
|
||||
GtkTreePath *path;
|
||||
gint i;
|
||||
|
||||
ENTER("model %p, group %p", model, group);
|
||||
g_return_if_fail (model != NULL);
|
||||
g_return_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model));
|
||||
|
||||
DEBUG("old root %p", model->priv->root);
|
||||
if (model->priv->root != NULL) {
|
||||
path = gtk_tree_path_new_first ();
|
||||
if (model->priv->toplevel != NULL) {
|
||||
@@ -206,6 +239,7 @@ gnc_tree_model_account_set_root (GncTreeModelAccount *model,
|
||||
if (model->priv->root != NULL) {
|
||||
xaccGroupForEachAccount (model->priv->root, account_row_inserted, model, TRUE);
|
||||
}
|
||||
LEAVE("new root %p", model->priv->root);
|
||||
}
|
||||
|
||||
Account *
|
||||
@@ -228,8 +262,10 @@ gnc_tree_model_account_set_toplevel (GncTreeModelAccount *model,
|
||||
gint i;
|
||||
GtkTreeIter iter;
|
||||
|
||||
ENTER("model %p, toplevel %p", model, toplevel);
|
||||
g_return_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model));
|
||||
|
||||
DEBUG("old toplevel %p", model->priv->toplevel);
|
||||
if (model->priv->toplevel != NULL) {
|
||||
path = gtk_tree_path_new_first ();
|
||||
gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
|
||||
@@ -254,6 +290,7 @@ gnc_tree_model_account_set_toplevel (GncTreeModelAccount *model,
|
||||
if (model->priv->root != NULL) {
|
||||
xaccGroupForEachAccount (model->priv->root, account_row_inserted, model, TRUE);
|
||||
}
|
||||
LEAVE("new toplevel %p", model->priv->root);
|
||||
}
|
||||
|
||||
Account *
|
||||
@@ -272,8 +309,10 @@ gnc_tree_model_account_get_iter_from_account (GncTreeModelAccount *model,
|
||||
AccountGroup *group;
|
||||
gint i;
|
||||
|
||||
ENTER("model %p, account %p, iter %p", model, account, iter);
|
||||
g_return_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model));
|
||||
g_return_if_fail (account != NULL);
|
||||
g_return_if_fail (iter != NULL);
|
||||
|
||||
iter->user_data = account;
|
||||
iter->stamp = model->stamp;
|
||||
@@ -294,8 +333,29 @@ gnc_tree_model_account_get_iter_from_account (GncTreeModelAccount *model,
|
||||
|
||||
iter->user_data2 = group;
|
||||
iter->user_data3 = GINT_TO_POINTER (i);
|
||||
LEAVE("iter [stamp:%x data:%p, %p, %d]", iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
}
|
||||
|
||||
GtkTreePath *
|
||||
gnc_tree_model_account_get_path_from_account (GncTreeModelAccount *model,
|
||||
Account *account)
|
||||
{
|
||||
GtkTreeIter tree_iter;
|
||||
GtkTreePath *tree_path;
|
||||
|
||||
ENTER("model %p, account %p", model, account);
|
||||
g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model), NULL);
|
||||
g_return_val_if_fail (account != NULL, NULL);
|
||||
|
||||
gnc_tree_model_account_get_iter_from_account (model, account, &tree_iter);
|
||||
tree_path = gtk_tree_model_get_path (GTK_TREE_MODEL(model), &tree_iter);
|
||||
if (tree_path) {
|
||||
gchar *path_string = gtk_tree_path_to_string(tree_path);
|
||||
LEAVE("path (2) %s", path_string);
|
||||
g_free(path_string);
|
||||
}
|
||||
return tree_path;
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
@@ -335,15 +395,41 @@ gnc_tree_model_account_get_column_type (GtkTreeModel *tree_model,
|
||||
g_return_val_if_fail ((index < GNC_TREE_MODEL_ACCOUNT_NUM_COLUMNS) && (index >= 0), G_TYPE_INVALID);
|
||||
|
||||
switch (index) {
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_TYPE:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_NAME:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_TYPE:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_CODE:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_PRESENT:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_BALANCE:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_CLEARED:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_TOTAL:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_NOTES:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM:
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL:
|
||||
return G_TYPE_STRING;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER:
|
||||
return G_TYPE_BOOLEAN;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT:
|
||||
return G_TYPE_FLOAT;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
return G_TYPE_INVALID;
|
||||
@@ -361,6 +447,11 @@ gnc_tree_model_account_get_iter (GtkTreeModel *tree_model,
|
||||
gint i = 0, *indices;
|
||||
GtkTreePath *path_copy;
|
||||
|
||||
{
|
||||
gchar *path_string = gtk_tree_path_to_string(path);
|
||||
ENTER("model %p, iter %p, path %s", tree_model, iter, path_string);
|
||||
g_free(path_string);
|
||||
}
|
||||
g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (tree_model), FALSE);
|
||||
|
||||
model = GNC_TREE_MODEL_ACCOUNT (tree_model);
|
||||
@@ -377,12 +468,15 @@ gnc_tree_model_account_get_iter (GtkTreeModel *tree_model,
|
||||
iter->user_data3 = GINT_TO_POINTER (0);
|
||||
iter->stamp = model->stamp;
|
||||
|
||||
LEAVE("iter (1) [stamp:%x data:%p, %p, %d]", iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
if (model->priv->root == NULL)
|
||||
if (model->priv->root == NULL) {
|
||||
LEAVE("failed (2)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
children = model->priv->root;
|
||||
|
||||
@@ -392,6 +486,7 @@ gnc_tree_model_account_get_iter (GtkTreeModel *tree_model,
|
||||
if (indices[i] >= xaccGroupGetNumAccounts (group)) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (3)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -402,6 +497,7 @@ gnc_tree_model_account_get_iter (GtkTreeModel *tree_model,
|
||||
if (account == NULL || group == NULL) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (4)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -410,6 +506,7 @@ gnc_tree_model_account_get_iter (GtkTreeModel *tree_model,
|
||||
iter->user_data2 = group;
|
||||
iter->user_data3 = GINT_TO_POINTER (indices[i - 1]);
|
||||
|
||||
LEAVE("iter (5) [stamp:%x data:%p, %p, %d]", iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -424,13 +521,17 @@ gnc_tree_model_account_get_path (GtkTreeModel *tree_model,
|
||||
gint i;
|
||||
gboolean found, finished = FALSE;
|
||||
|
||||
ENTER("model %p, iter [stamp:%x data:%p, %p, %d]", model,
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model), NULL);
|
||||
g_return_val_if_fail (iter != NULL, NULL);
|
||||
g_return_val_if_fail (iter->user_data != NULL, NULL);
|
||||
g_return_val_if_fail (iter->stamp == model->stamp, NULL);
|
||||
|
||||
if (model->priv->root == NULL)
|
||||
if (model->priv->root == NULL) {
|
||||
LEAVE("failed (1)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
account = (Account *) iter->user_data;
|
||||
group = (AccountGroup *) iter->user_data2;
|
||||
@@ -441,6 +542,11 @@ gnc_tree_model_account_get_path (GtkTreeModel *tree_model,
|
||||
if (account == model->priv->toplevel) {
|
||||
gtk_tree_path_append_index (path, 0);
|
||||
|
||||
{
|
||||
gchar *path_string = gtk_tree_path_to_string(path);
|
||||
LEAVE("path (2) %s", path_string);
|
||||
g_free(path_string);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
}
|
||||
@@ -458,6 +564,7 @@ gnc_tree_model_account_get_path (GtkTreeModel *tree_model,
|
||||
|
||||
if (!found) {
|
||||
gtk_tree_path_free (path);
|
||||
LEAVE("failed (3)");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -471,6 +578,11 @@ gnc_tree_model_account_get_path (GtkTreeModel *tree_model,
|
||||
gtk_tree_path_prepend_index (path, 0);
|
||||
}
|
||||
|
||||
{
|
||||
gchar *path_string = gtk_tree_path_to_string(path);
|
||||
LEAVE("path (4) %s", path_string);
|
||||
g_free(path_string);
|
||||
}
|
||||
return path;
|
||||
}
|
||||
|
||||
@@ -482,7 +594,11 @@ gnc_tree_model_account_get_value (GtkTreeModel *tree_model,
|
||||
{
|
||||
GncTreeModelAccount *model = GNC_TREE_MODEL_ACCOUNT (tree_model);
|
||||
Account *account;
|
||||
gboolean negative; /* used to set "defecit style" aka red numbers */
|
||||
gchar *string;
|
||||
|
||||
//ENTER("model %p, iter [stamp:%x data:%p, %p, %d], col %d", tree_model,
|
||||
// iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3), column);
|
||||
g_return_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model));
|
||||
g_return_if_fail (iter != NULL);
|
||||
g_return_if_fail (iter->user_data != NULL);
|
||||
@@ -491,45 +607,171 @@ gnc_tree_model_account_get_value (GtkTreeModel *tree_model,
|
||||
account = (Account *) iter->user_data;
|
||||
|
||||
switch (column) {
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_NAME:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, xaccAccountGetName (account));
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_TYPE:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
|
||||
g_value_set_string (value,
|
||||
xaccAccountGetTypeStr (xaccAccountGetType (account)));
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_NAME:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
|
||||
g_value_set_string (value, xaccAccountGetName (account));
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_CODE:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
|
||||
g_value_set_string (value, xaccAccountGetCode (account));
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value,
|
||||
gnc_commodity_get_fullname(xaccAccountGetCommodity (account)));
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
|
||||
g_value_set_string (value, xaccAccountGetDescription (account));
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_PRESENT:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetPresentBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_report_balance(xaccAccountGetPresentBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetPresentBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_static_string (value, negative ? "red" : "black");
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_BALANCE:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_report_balance(xaccAccountGetBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_static_string (value, negative ? "red" : "black");
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_CLEARED:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetClearedBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_report_balance(xaccAccountGetClearedBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetClearedBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_static_string (value, negative ? "red" : "black");
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetReconciledBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_report_balance(xaccAccountGetReconciledBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetReconciledBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_static_string (value, negative ? "red" : "black");
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetProjectedMinimumBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_report_balance(xaccAccountGetProjectedMinimumBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetProjectedMinimumBalanceInCurrency,
|
||||
account, FALSE, &negative);
|
||||
g_value_set_static_string (value, negative ? "red" : "black");
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_TOTAL:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetBalanceInCurrency,
|
||||
account, TRUE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_report_balance(xaccAccountGetBalanceInCurrency,
|
||||
account, TRUE, &negative);
|
||||
g_value_set_string_take_ownership (value, string);
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
string = gnc_ui_account_get_print_balance(xaccAccountGetBalanceInCurrency,
|
||||
account, TRUE, &negative);
|
||||
g_value_set_static_string (value, negative ? "red" : "black");
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_NOTES:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
|
||||
g_value_set_string (value, xaccAccountGetNotes (account));
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
g_value_set_string (value, gnc_ui_account_get_tax_info_string (account));
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM:
|
||||
g_value_init (value, G_TYPE_STRING);
|
||||
|
||||
g_value_set_string (value, xaccAccountGetLastNum (account));
|
||||
break;
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER:
|
||||
g_value_init (value, G_TYPE_BOOLEAN);
|
||||
|
||||
g_value_set_boolean (value, xaccAccountGetPlaceholder (account));
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT:
|
||||
g_value_init (value, G_TYPE_FLOAT);
|
||||
g_value_set_float (value, 1.0);
|
||||
break;
|
||||
|
||||
default:
|
||||
g_assert_not_reached ();
|
||||
}
|
||||
//LEAVE(" ");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
@@ -541,6 +783,8 @@ gnc_tree_model_account_iter_next (GtkTreeModel *tree_model,
|
||||
AccountGroup *group;
|
||||
gint i;
|
||||
|
||||
ENTER("model %p, iter [stamp:%x data:%p, %p, %d]", tree_model,
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (model), FALSE);
|
||||
g_return_val_if_fail (iter != NULL, FALSE);
|
||||
g_return_val_if_fail (iter->user_data != NULL, FALSE);
|
||||
@@ -548,7 +792,7 @@ gnc_tree_model_account_iter_next (GtkTreeModel *tree_model,
|
||||
|
||||
if (iter->user_data == model->priv->toplevel) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (1)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -557,7 +801,7 @@ gnc_tree_model_account_iter_next (GtkTreeModel *tree_model,
|
||||
|
||||
if (i > xaccGroupGetNumAccounts (group) - 2) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (2)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -565,7 +809,7 @@ gnc_tree_model_account_iter_next (GtkTreeModel *tree_model,
|
||||
|
||||
if (account == NULL) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (3)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -573,6 +817,8 @@ gnc_tree_model_account_iter_next (GtkTreeModel *tree_model,
|
||||
iter->user_data2 = group;
|
||||
iter->user_data3 = GINT_TO_POINTER (i + 1);
|
||||
|
||||
LEAVE("iter [stamp:%x data:%p, %p, %d]",
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -585,6 +831,14 @@ gnc_tree_model_account_iter_children (GtkTreeModel *tree_model,
|
||||
Account *account;
|
||||
AccountGroup *group;
|
||||
|
||||
if (parent) {
|
||||
ENTER("model %p, iter [stamp:%x data:%p, %p, %d], parent [stamp:%x data:%p, %p, %d]", tree_model,
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3),
|
||||
parent->stamp, parent->user_data, parent->user_data2, GPOINTER_TO_INT(parent->user_data3));
|
||||
} else {
|
||||
ENTER("model %p, iter [stamp:%x data:%p, %p, %d], parent (null)", tree_model,
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
}
|
||||
g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (tree_model), FALSE);
|
||||
|
||||
model = GNC_TREE_MODEL_ACCOUNT (tree_model);
|
||||
@@ -595,7 +849,8 @@ gnc_tree_model_account_iter_children (GtkTreeModel *tree_model,
|
||||
iter->user_data2 = NULL;
|
||||
iter->user_data3 = GINT_TO_POINTER (0);
|
||||
iter->stamp = model->stamp;
|
||||
|
||||
LEAVE("iter (1) [stamp:%x data:%p, %p, %d]",
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
} else if (parent->user_data == model->priv->toplevel) {
|
||||
parent = NULL;
|
||||
@@ -604,7 +859,7 @@ gnc_tree_model_account_iter_children (GtkTreeModel *tree_model,
|
||||
|
||||
if (model->priv->root == NULL || xaccGroupGetNumAccounts (model->priv->root) == 0) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (1)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -613,7 +868,7 @@ gnc_tree_model_account_iter_children (GtkTreeModel *tree_model,
|
||||
|
||||
if (account == NULL) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (2)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -621,7 +876,8 @@ gnc_tree_model_account_iter_children (GtkTreeModel *tree_model,
|
||||
iter->user_data2 = model->priv->root;
|
||||
iter->user_data3 = GINT_TO_POINTER (0);
|
||||
iter->stamp = model->stamp;
|
||||
|
||||
LEAVE("iter (2) [stamp:%x data:%p, %p, %d]",
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -633,7 +889,7 @@ gnc_tree_model_account_iter_children (GtkTreeModel *tree_model,
|
||||
|
||||
if (group == NULL || xaccGroupGetNumAccounts (group) == 0) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (3)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -641,7 +897,7 @@ gnc_tree_model_account_iter_children (GtkTreeModel *tree_model,
|
||||
|
||||
if (account == NULL) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (4)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -649,7 +905,8 @@ gnc_tree_model_account_iter_children (GtkTreeModel *tree_model,
|
||||
iter->user_data2 = group;
|
||||
iter->user_data3 = GINT_TO_POINTER (0);
|
||||
iter->stamp = model->stamp;
|
||||
|
||||
LEAVE("iter (3) [stamp:%x data:%p, %p, %d]",
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -660,6 +917,8 @@ gnc_tree_model_account_iter_has_child (GtkTreeModel *tree_model,
|
||||
GncTreeModelAccount *model;
|
||||
AccountGroup *group;
|
||||
|
||||
ENTER("model %p, iter [stamp:%x data:%p, %p, %d]", tree_model,
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (tree_model), FALSE);
|
||||
|
||||
model = GNC_TREE_MODEL_ACCOUNT (tree_model);
|
||||
@@ -675,9 +934,11 @@ gnc_tree_model_account_iter_has_child (GtkTreeModel *tree_model,
|
||||
}
|
||||
|
||||
if (group == NULL || xaccGroupGetNumAccounts (group) == 0) {
|
||||
LEAVE("no");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
LEAVE("yes");
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -688,14 +949,18 @@ gnc_tree_model_account_iter_n_children (GtkTreeModel *tree_model,
|
||||
GncTreeModelAccount *model;
|
||||
AccountGroup *group;
|
||||
|
||||
ENTER("model %p, iter [stamp:%x data:%p, %p, %d]", tree_model,
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (tree_model), FALSE);
|
||||
|
||||
model = GNC_TREE_MODEL_ACCOUNT (tree_model);
|
||||
|
||||
if (iter == NULL) {
|
||||
if (model->priv->toplevel != NULL) {
|
||||
LEAVE("count is 1");
|
||||
return 1;
|
||||
} else {
|
||||
LEAVE("count is %d", xaccGroupGetNumAccounts (model->priv->root));
|
||||
return xaccGroupGetNumAccounts (model->priv->root);
|
||||
}
|
||||
}
|
||||
@@ -710,6 +975,7 @@ gnc_tree_model_account_iter_n_children (GtkTreeModel *tree_model,
|
||||
group = xaccAccountGetChildren ((Account *) iter->user_data);
|
||||
}
|
||||
|
||||
LEAVE("count is %d", xaccGroupGetNumAccounts (group));
|
||||
return xaccGroupGetNumAccounts (group);
|
||||
}
|
||||
|
||||
@@ -723,6 +989,16 @@ gnc_tree_model_account_iter_nth_child (GtkTreeModel *tree_model,
|
||||
Account *account;
|
||||
AccountGroup *group;
|
||||
|
||||
if (parent) {
|
||||
ENTER("model %p, iter [stamp:%x data:%p, %p, %d], parent [stamp:%x data:%p, %p, %d], n %d",
|
||||
tree_model,
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3),
|
||||
parent->stamp, parent->user_data, parent->user_data2, GPOINTER_TO_INT(parent->user_data3), n);
|
||||
} else {
|
||||
ENTER("model %p, iter [stamp:%x data:%p, %p, %d], parent (null), n %d",
|
||||
tree_model,
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3), n);
|
||||
}
|
||||
g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (tree_model), FALSE);
|
||||
|
||||
model = GNC_TREE_MODEL_ACCOUNT (tree_model);
|
||||
@@ -731,14 +1007,15 @@ gnc_tree_model_account_iter_nth_child (GtkTreeModel *tree_model,
|
||||
if (model->priv->toplevel != NULL) {
|
||||
if (n > 0) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (1)");
|
||||
return FALSE;
|
||||
} else {
|
||||
iter->user_data = model->priv->toplevel;
|
||||
iter->user_data2 = NULL;
|
||||
iter->user_data3 = GINT_TO_POINTER (0);
|
||||
iter->stamp = model->stamp;
|
||||
|
||||
LEAVE("iter (1) [stamp:%x data:%p, %p, %d]",
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -747,7 +1024,7 @@ gnc_tree_model_account_iter_nth_child (GtkTreeModel *tree_model,
|
||||
|
||||
if (account == NULL) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (2)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -755,7 +1032,8 @@ gnc_tree_model_account_iter_nth_child (GtkTreeModel *tree_model,
|
||||
iter->user_data2 = model->priv->root;
|
||||
iter->user_data3 = GINT_TO_POINTER (n);
|
||||
iter->stamp = model->stamp;
|
||||
|
||||
LEAVE("iter (2) [stamp:%x data:%p, %p, %d]",
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -770,7 +1048,7 @@ gnc_tree_model_account_iter_nth_child (GtkTreeModel *tree_model,
|
||||
|
||||
if (group == NULL || xaccGroupGetNumAccounts (group) <= n) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (3)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -778,7 +1056,7 @@ gnc_tree_model_account_iter_nth_child (GtkTreeModel *tree_model,
|
||||
|
||||
if (account == NULL) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (4)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -786,7 +1064,8 @@ gnc_tree_model_account_iter_nth_child (GtkTreeModel *tree_model,
|
||||
iter->user_data2 = group;
|
||||
iter->user_data3 = GINT_TO_POINTER (n);
|
||||
iter->stamp = model->stamp;
|
||||
|
||||
LEAVE("iter (3) [stamp:%x data:%p, %p, %d]",
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -800,6 +1079,16 @@ gnc_tree_model_account_iter_parent (GtkTreeModel *tree_model,
|
||||
AccountGroup *group;
|
||||
gint i;
|
||||
|
||||
if (child) {
|
||||
ENTER("model %p, iter [stamp:%x data:%p, %p, %d], child [stamp:%x data:%p, %p, %d]",
|
||||
tree_model,
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3),
|
||||
child->stamp, child->user_data, child->user_data2, GPOINTER_TO_INT(child->user_data3));
|
||||
} else {
|
||||
ENTER("model %p, iter [stamp:%x data:%p, %p, %d], child (null)",
|
||||
tree_model,
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
}
|
||||
g_return_val_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (tree_model), FALSE);
|
||||
|
||||
model = GNC_TREE_MODEL_ACCOUNT (tree_model);
|
||||
@@ -812,7 +1101,7 @@ gnc_tree_model_account_iter_parent (GtkTreeModel *tree_model,
|
||||
|
||||
if (account == model->priv->toplevel) {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (1)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -825,11 +1114,12 @@ gnc_tree_model_account_iter_parent (GtkTreeModel *tree_model,
|
||||
iter->user_data2 = NULL;
|
||||
iter->user_data3 = GINT_TO_POINTER (0);
|
||||
iter->stamp = model->stamp;
|
||||
|
||||
LEAVE("iter (1) [stamp:%x data:%p, %p, %d]",
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
} else {
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (2)");
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
@@ -840,7 +1130,8 @@ gnc_tree_model_account_iter_parent (GtkTreeModel *tree_model,
|
||||
iter->user_data2 = group;
|
||||
iter->user_data3 = GINT_TO_POINTER (i);
|
||||
iter->stamp = model->stamp;
|
||||
|
||||
LEAVE("iter (2) [stamp:%x data:%p, %p, %d]",
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -850,11 +1141,12 @@ gnc_tree_model_account_iter_parent (GtkTreeModel *tree_model,
|
||||
iter->user_data2 = NULL;
|
||||
iter->user_data3 = GINT_TO_POINTER (0);
|
||||
iter->stamp = model->stamp;
|
||||
|
||||
LEAVE("iter (2) [stamp:%x data:%p, %p, %d]",
|
||||
iter->stamp, iter->user_data, iter->user_data2, GPOINTER_TO_INT(iter->user_data3));
|
||||
return TRUE;
|
||||
}
|
||||
iter->stamp = 0;
|
||||
|
||||
LEAVE("failed (3)");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -865,6 +1157,7 @@ account_row_inserted (Account *account,
|
||||
GtkTreePath *path;
|
||||
GtkTreeIter iter;
|
||||
|
||||
ENTER("account %p, model %p", account, data);
|
||||
gnc_tree_model_account_get_iter_from_account (GNC_TREE_MODEL_ACCOUNT (data), account, &iter);
|
||||
|
||||
path = gtk_tree_model_get_path (GTK_TREE_MODEL (data), &iter);
|
||||
@@ -873,35 +1166,20 @@ account_row_inserted (Account *account,
|
||||
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
LEAVE(" ");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tree_model_account_refresh_handler (GHashTable *changes, gpointer user_data)
|
||||
void gnc_tree_model_account_event_handler (GUID *entity, QofIdType type,
|
||||
GNCEngineEventType event_type,
|
||||
gpointer user_data)
|
||||
{
|
||||
g_return_if_fail (GNC_IS_TREE_MODEL_ACCOUNT (user_data));
|
||||
GncTreeModelAccount *model;
|
||||
|
||||
gnc_tree_model_account_refresh (GNC_TREE_MODEL_ACCOUNT (user_data));
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tree_model_account_refresh (GncTreeModelAccount *model)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
gint i;
|
||||
|
||||
if (model->priv->root == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
path = gtk_tree_path_new_first ();
|
||||
if (model->priv->toplevel != NULL) {
|
||||
gtk_tree_path_append_index (path, 0);
|
||||
}
|
||||
for (i = 0; i < xaccGroupGetNumAccounts (model->priv->root); i++) {
|
||||
gtk_tree_model_row_deleted (GTK_TREE_MODEL (model), path);
|
||||
}
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
xaccGroupForEachAccount (model->priv->root, account_row_inserted, model, TRUE);
|
||||
g_return_if_fail(GNC_IS_TREE_MODEL_ACCOUNT(user_data));
|
||||
|
||||
model = (GncTreeModelAccount *)user_data;
|
||||
do {
|
||||
model->stamp++;
|
||||
} while (model->stamp == 0);
|
||||
}
|
||||
|
||||
@@ -22,15 +22,38 @@ G_BEGIN_DECLS
|
||||
#define GNC_TREE_MODEL_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_MODEL_ACCOUNT, GncTreeModelAccountClass))
|
||||
|
||||
typedef enum {
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_TYPE,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_TYPE_PIXBUF,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_NAME,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_TYPE,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_CODE,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_PRESENT,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_BALANCE,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_CLEARED,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_TOTAL,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_NOTES,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
|
||||
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY,
|
||||
|
||||
/* internal hidden columns */
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
|
||||
|
||||
GNC_TREE_MODEL_ACCOUNT_NUM_COLUMNS
|
||||
} GncTreeModelAccountColumn;
|
||||
|
||||
@@ -38,7 +61,7 @@ typedef enum {
|
||||
typedef struct GncTreeModelAccountPrivate GncTreeModelAccountPrivate;
|
||||
|
||||
typedef struct {
|
||||
GObject parent;
|
||||
GtkObject parent;
|
||||
|
||||
GncTreeModelAccountPrivate *priv;
|
||||
|
||||
@@ -46,7 +69,7 @@ typedef struct {
|
||||
} GncTreeModelAccount;
|
||||
|
||||
typedef struct {
|
||||
GObjectClass parent;
|
||||
GtkObjectClass parent;
|
||||
} GncTreeModelAccountClass;
|
||||
|
||||
/* function prototypes */
|
||||
@@ -63,6 +86,8 @@ void gnc_tree_model_account_set_toplevel (GncTreeModelAccount
|
||||
Account *toplevel);
|
||||
Account *gnc_tree_model_account_get_toplevel (GncTreeModelAccount *model);
|
||||
|
||||
GtkTreePath *gnc_tree_model_account_get_path_from_account (GncTreeModelAccount *model,
|
||||
Account *account);
|
||||
void gnc_tree_model_account_get_iter_from_account (GncTreeModelAccount *model,
|
||||
Account *account,
|
||||
GtkTreeIter *iter);
|
||||
|
||||
442
src/gnome-utils/gnc-tree-view-account.c
Normal file
442
src/gnome-utils/gnc-tree-view-account.c
Normal file
@@ -0,0 +1,442 @@
|
||||
/********************************************************************\
|
||||
* gnc-tree-view-account.c -- GtkTreeView implementation to display *
|
||||
* accounts in a GtkTreeView. *
|
||||
* Copyright (C) 2003 David Hampton <hampton@employees.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gtk/gtk.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "gnc-tree-model-account.h"
|
||||
#include "gnc-tree-view-account.h"
|
||||
|
||||
#include "Account.h"
|
||||
#include "Group.h"
|
||||
#include "gnc-commodity.h"
|
||||
#include "gnc-component-manager.h"
|
||||
#include "gnc-engine-util.h"
|
||||
#include "gnc-icons.h"
|
||||
#include "gnc-ui-util.h"
|
||||
#include "messages.h"
|
||||
|
||||
#define TREE_VIEW_ACCOUNT_CM_CLASS "tree-view-account"
|
||||
|
||||
/* This static indicates the debugging module that this .o belongs to. */
|
||||
static short module = MOD_GUI;
|
||||
|
||||
static void gnc_tree_view_account_class_init (GncTreeViewAccountClass *klass);
|
||||
static void gnc_tree_view_account_init (GncTreeViewAccount *view);
|
||||
static void gnc_tree_view_account_finalize (GObject *object);
|
||||
static void gnc_tree_view_account_destroy (GtkObject *object);
|
||||
|
||||
#if 0
|
||||
static void gnc_tree_model_account_refresh_handler (GHashTable *changes,
|
||||
gpointer data);
|
||||
static void gnc_tree_model_account_refresh (GncTreeModelAccount *model);
|
||||
#endif
|
||||
|
||||
struct GncTreeViewAccountPrivate
|
||||
{
|
||||
AccountViewInfo avi;
|
||||
gboolean has_filter;
|
||||
};
|
||||
|
||||
typedef struct _gnc_tree_view_account_default {
|
||||
GncTreeModelAccountColumn column;
|
||||
GncTreeModelAccountColumn color_column;
|
||||
gboolean auto_resize;
|
||||
gfloat x_alignment;
|
||||
const char *pref_name;
|
||||
const char *field_name;
|
||||
} gnc_tree_view_account_default;
|
||||
static gnc_tree_view_account_default gnc_tree_view_account_defaults[] = {
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_NAME, 0, TRUE, 0.0, "name", N_("Account Name")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_TYPE, 0, FALSE, 0.0, "type", N_("Type")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY, 0, FALSE, 0.0, "commodity", N_("Commodity")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_CODE, 0, FALSE, 0.0, "code", N_("Account Code")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION, 0, TRUE, 0.0, "description", N_("Description")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_PRESENT, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT, TRUE, 1.0, "present", N_("Present")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT, TRUE, 1.0, "present_report", N_("Present (Report)")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_BALANCE, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE, TRUE, 1.0, "balance", N_("Balance")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE, TRUE, 1.0, "balance_report", N_("Balance (Report)")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_CLEARED, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED, TRUE, 1.0, "cleared", N_("Cleared")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED, TRUE, 1.0, "cleared_report", N_("Cleared (Report)")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED, TRUE, 1.0, "reconciled", N_("Reconciled")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED, TRUE, 1.0, "reconciled_report", N_("Reconciled (Report)")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN, TRUE, 1.0, "future_min", N_("Future Minimum")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN, TRUE, 1.0, "future_min_report", N_("Future Minimum (Report)")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_TOTAL, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL, TRUE, 1.0, "total", N_("Total")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT, GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL, TRUE, 1.0, "total_report", N_("Total (Report)")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_NOTES, 0, FALSE, 0.0, "notes", N_("Notes")},
|
||||
{GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO, 0, FALSE, 0.0, "tax-info", N_("Tax Info")},
|
||||
};
|
||||
|
||||
|
||||
static GObjectClass *parent_class = NULL;
|
||||
|
||||
GType
|
||||
gnc_tree_view_account_get_type (void)
|
||||
{
|
||||
static GType gnc_tree_view_account_type = 0;
|
||||
|
||||
if (gnc_tree_view_account_type == 0) {
|
||||
static const GTypeInfo our_info = {
|
||||
sizeof (GncTreeViewAccountClass),
|
||||
NULL,
|
||||
NULL,
|
||||
(GClassInitFunc) gnc_tree_view_account_class_init,
|
||||
NULL,
|
||||
NULL,
|
||||
sizeof (GncTreeViewAccount),
|
||||
0,
|
||||
(GInstanceInitFunc) gnc_tree_view_account_init
|
||||
};
|
||||
|
||||
gnc_tree_view_account_type = g_type_register_static (GTK_TYPE_TREE_VIEW,
|
||||
"GncTreeViewAccount",
|
||||
&our_info, 0);
|
||||
}
|
||||
|
||||
return gnc_tree_view_account_type;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tree_view_account_class_init (GncTreeViewAccountClass *klass)
|
||||
{
|
||||
GObjectClass *o_class;
|
||||
GtkObjectClass *object_class;
|
||||
|
||||
parent_class = g_type_class_peek_parent (klass);
|
||||
|
||||
o_class = G_OBJECT_CLASS (klass);
|
||||
object_class = GTK_OBJECT_CLASS (klass);
|
||||
|
||||
/* GObject signals */
|
||||
o_class->finalize = gnc_tree_view_account_finalize;
|
||||
|
||||
/* GtkObject signals */
|
||||
object_class->destroy = gnc_tree_view_account_destroy;
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tree_view_account_init (GncTreeViewAccount *view)
|
||||
{
|
||||
ENTER(" ");
|
||||
view->priv = g_new0 (GncTreeViewAccountPrivate, 1);
|
||||
|
||||
gnc_init_account_view_info(&view->priv->avi);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tree_view_account_finalize (GObject *object)
|
||||
{
|
||||
GncTreeViewAccount *account_view;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (object));
|
||||
|
||||
ENTER("view %p", object);
|
||||
account_view = GNC_TREE_VIEW_ACCOUNT (object);
|
||||
g_free (account_view->priv);
|
||||
|
||||
if (G_OBJECT_CLASS (parent_class)->finalize)
|
||||
(* G_OBJECT_CLASS (parent_class)->finalize) (object);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tree_view_account_destroy (GtkObject *object)
|
||||
{
|
||||
GncTreeViewAccount *account_view;
|
||||
|
||||
g_return_if_fail (object != NULL);
|
||||
g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (object));
|
||||
|
||||
ENTER("view %p", object);
|
||||
account_view = GNC_TREE_VIEW_ACCOUNT (object);
|
||||
|
||||
if (GTK_OBJECT_CLASS (parent_class)->destroy)
|
||||
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tree_view_update_column_visibility_internal (GncTreeViewAccount *account_view)
|
||||
{
|
||||
GtkTreeView *tree_view;
|
||||
GtkTreeViewColumn *column;
|
||||
gint i;
|
||||
|
||||
ENTER(" ");
|
||||
tree_view = GTK_TREE_VIEW (account_view);
|
||||
|
||||
for (i = 0; i < NUM_ACCOUNT_FIELDS; i++) {
|
||||
DEBUG("setting column %d to %s", i, account_view->priv->avi.show_field[i] ? "visible" : "invisible");
|
||||
column = gtk_tree_view_get_column (tree_view, i);
|
||||
gtk_tree_view_column_set_visible (column, account_view->priv->avi.show_field[i]);
|
||||
}
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
static GtkTreeView *
|
||||
gnc_tree_view_account_new_internal (gboolean filterable)
|
||||
{
|
||||
GncTreeViewAccount *account_view;
|
||||
GtkTreeView *tree_view;
|
||||
GtkTreeModel *model, *filter_model;
|
||||
GtkCellRenderer *renderer;
|
||||
GtkTreeViewColumn *column;
|
||||
gint i;
|
||||
|
||||
ENTER(" ");
|
||||
account_view = g_object_new (GNC_TYPE_TREE_VIEW_ACCOUNT, NULL);
|
||||
tree_view = GTK_TREE_VIEW (account_view);
|
||||
|
||||
model = gnc_tree_model_account_new (gnc_book_get_group (gnc_get_current_book ()));
|
||||
if (filterable) {
|
||||
filter_model = egg_tree_model_filter_new (model, NULL);
|
||||
gtk_tree_view_set_model (tree_view, filter_model);
|
||||
} else {
|
||||
gtk_tree_view_set_model (tree_view, model);
|
||||
}
|
||||
gtk_object_sink(GTK_OBJECT(model));
|
||||
account_view->priv->has_filter = filterable;
|
||||
|
||||
/* Set column visibilities */
|
||||
gnc_tree_view_init_default_visibility(&account_view->priv->avi);
|
||||
|
||||
/* Account name */
|
||||
column = gtk_tree_view_column_new ();
|
||||
gtk_tree_view_column_set_title (column, gettext(gnc_tree_view_account_defaults[0].field_name));
|
||||
renderer = gtk_cell_renderer_pixbuf_new ();
|
||||
g_object_set (renderer, "stock-id", GNC_STOCK_ACCOUNT, NULL);
|
||||
gtk_tree_view_column_pack_start (column, renderer, FALSE);
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
gtk_tree_view_column_pack_start (column, renderer, FALSE);
|
||||
gtk_tree_view_column_add_attribute (column,
|
||||
renderer,
|
||||
"text", gnc_tree_view_account_defaults[0].column);
|
||||
gtk_tree_view_append_column (tree_view, column);
|
||||
gtk_tree_view_column_set_resizable (column, TRUE);
|
||||
gtk_tree_view_set_expander_column (tree_view, column);
|
||||
|
||||
/* All other columns */
|
||||
for (i = 1; i < NUM_ACCOUNT_FIELDS; i++) {
|
||||
renderer = gtk_cell_renderer_text_new ();
|
||||
column = gtk_tree_view_column_new_with_attributes (gettext(gnc_tree_view_account_defaults[i].field_name),
|
||||
renderer,
|
||||
"text", gnc_tree_view_account_defaults[i].column,
|
||||
NULL);
|
||||
if (gnc_tree_view_account_defaults[i].color_column)
|
||||
gtk_tree_view_column_add_attribute (column, renderer,
|
||||
"foreground", gnc_tree_view_account_defaults[i].color_column);
|
||||
if (gnc_tree_view_account_defaults[i].x_alignment)
|
||||
gtk_tree_view_column_add_attribute (column, renderer,
|
||||
"xalign", GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT);
|
||||
|
||||
gtk_tree_view_append_column (tree_view, column);
|
||||
gtk_tree_view_column_set_sizing (column,
|
||||
gnc_tree_view_account_defaults[i].auto_resize
|
||||
? GTK_TREE_VIEW_COLUMN_AUTOSIZE
|
||||
: GTK_TREE_VIEW_COLUMN_FIXED);
|
||||
gtk_tree_view_column_set_visible (column, account_view->priv->avi.show_field[i]);
|
||||
gtk_tree_view_column_set_alignment (column, gnc_tree_view_account_defaults[i].x_alignment);
|
||||
gtk_tree_view_column_set_min_width (column, 50 /* DRH - Should be based on title width */);
|
||||
gtk_tree_view_column_set_resizable (column, TRUE);
|
||||
}
|
||||
|
||||
#if 0
|
||||
priv->component_id = gnc_register_gui_component (TREE_MODEL_ACCOUNT_CM_CLASS,
|
||||
gnc_tree_model_account_refresh_handler,
|
||||
NULL,
|
||||
model);
|
||||
|
||||
gnc_gui_component_watch_entity_type (priv->component_id,
|
||||
GNC_ID_ACCOUNT,
|
||||
GNC_EVENT_CREATE | GNC_EVENT_DESTROY);
|
||||
#endif
|
||||
|
||||
LEAVE("%p", tree_view);
|
||||
return tree_view;
|
||||
}
|
||||
|
||||
GtkTreeView *
|
||||
gnc_tree_view_account_new (void)
|
||||
{
|
||||
return gnc_tree_view_account_new_internal (FALSE);
|
||||
}
|
||||
|
||||
GtkTreeView *
|
||||
gnc_tree_view_account_new_filterable (void)
|
||||
{
|
||||
return gnc_tree_view_account_new_internal (TRUE);
|
||||
}
|
||||
|
||||
/********************************************************************\
|
||||
* gnc_init_account_view_info *
|
||||
* initialize an account view info structure with default values *
|
||||
* *
|
||||
* Args: avi - structure to initialize *
|
||||
* Returns: nothing *
|
||||
\********************************************************************/
|
||||
void
|
||||
gnc_tree_view_init_default_visibility(AccountViewInfo *avi)
|
||||
{
|
||||
int i;
|
||||
|
||||
for (i = 0; i < NUM_ACCOUNT_FIELDS; i++)
|
||||
avi->show_field[i] = FALSE;
|
||||
|
||||
avi->show_field[ACCOUNT_NAME] = TRUE;
|
||||
avi->show_field[ACCOUNT_DESCRIPTION] = TRUE;
|
||||
avi->show_field[ACCOUNT_TOTAL] = TRUE;
|
||||
}
|
||||
|
||||
void
|
||||
gnc_tree_view_update_column_visibility (GncTreeViewAccount *account_view,
|
||||
AccountViewInfo *avi)
|
||||
{
|
||||
GncTreeViewAccountPrivate *priv;
|
||||
|
||||
ENTER("%p", account_view);
|
||||
g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(account_view));
|
||||
priv = account_view->priv;
|
||||
|
||||
priv->avi = *avi;
|
||||
|
||||
gnc_tree_view_update_column_visibility_internal (account_view);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
static gint
|
||||
gnc_tree_view_account_pref_name_to_field (const char *pref_name)
|
||||
{
|
||||
gint i;
|
||||
g_return_val_if_fail ((pref_name != NULL), GNC_TREE_MODEL_ACCOUNT_COL_NAME);
|
||||
|
||||
for (i = 0; i < NUM_ACCOUNT_FIELDS; i++)
|
||||
if (safe_strcmp(gnc_tree_view_account_defaults[i].pref_name, pref_name) == 0)
|
||||
return i;
|
||||
return(GNC_TREE_MODEL_ACCOUNT_COL_NAME);
|
||||
}
|
||||
|
||||
void
|
||||
gnc_tree_view_account_configure_columns (GncTreeViewAccount *account_view, GSList *list)
|
||||
{
|
||||
AccountViewInfo new_avi;
|
||||
AccountFieldCode field;
|
||||
GSList *node;
|
||||
|
||||
ENTER(" ");
|
||||
memset (&new_avi, 0, sizeof(new_avi));
|
||||
|
||||
for (node = list; node != NULL; node = node->next)
|
||||
{
|
||||
field = gnc_tree_view_account_pref_name_to_field(node->data);
|
||||
if (field < NUM_ACCOUNT_FIELDS)
|
||||
new_avi.show_field[field] = TRUE;
|
||||
}
|
||||
|
||||
new_avi.show_field[ACCOUNT_NAME] = TRUE;
|
||||
|
||||
gnc_tree_view_update_column_visibility (account_view, &new_avi);
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
void
|
||||
gnc_tree_view_account_set_filter (GncTreeViewAccount *account_view,
|
||||
EggTreeModelFilterVisibleFunc func,
|
||||
gpointer data,
|
||||
GtkDestroyNotify destroy)
|
||||
{
|
||||
GtkTreeModel *filter_model;
|
||||
|
||||
g_return_if_fail (account_view->priv->has_filter == TRUE);
|
||||
|
||||
filter_model = gtk_tree_view_get_model (GTK_TREE_VIEW (account_view));
|
||||
egg_tree_model_filter_set_visible_func (EGG_TREE_MODEL_FILTER (filter_model),
|
||||
func, data, destroy);
|
||||
}
|
||||
|
||||
gboolean
|
||||
gnc_tree_view_account_get_selected_account (GncTreeViewAccount *view,
|
||||
Account **account)
|
||||
{
|
||||
GtkTreeSelection *selection;
|
||||
GtkTreeModel *model;
|
||||
GtkTreeIter iter, child_iter;
|
||||
|
||||
g_return_val_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (view), FALSE);
|
||||
|
||||
selection = gtk_tree_view_get_selection (GTK_TREE_VIEW(view));
|
||||
if (!gtk_tree_selection_get_selected (selection, &model, &iter))
|
||||
return FALSE;
|
||||
|
||||
if (!view->priv->has_filter) {
|
||||
*account = iter.user_data;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
egg_tree_model_filter_convert_iter_to_child_iter (EGG_TREE_MODEL_FILTER (model),
|
||||
&child_iter, &iter);
|
||||
account = child_iter.user_data;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void
|
||||
gnc_tree_view_account_refresh_handler (GHashTable *changes, gpointer user_data)
|
||||
{
|
||||
ENTER("changes %p, view %p", changes, user_data);
|
||||
g_return_if_fail (GNC_IS_TREE_VIEW_ACCOUNT (user_data));
|
||||
|
||||
gnc_tree_view_account_refresh (GNC_TREE_VIEW_ACCOUNT (user_data));
|
||||
LEAVE(" ");
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_tree_view_account_refresh (GncTreeViewAccount *view)
|
||||
{
|
||||
GtkTreePath *path;
|
||||
gint i;
|
||||
|
||||
ENTER("view %p", view);
|
||||
if (view->priv->root == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
path = gtk_tree_path_new_first ();
|
||||
if (view->priv->toplevel != NULL) {
|
||||
gtk_tree_path_append_index (path, 0);
|
||||
}
|
||||
for (i = 0; i < xaccGroupGetNumAccounts (view->priv->root); i++) {
|
||||
gtk_tree_view_row_deleted (GTK_TREE_VIEW (view), path);
|
||||
}
|
||||
gtk_tree_path_free (path);
|
||||
|
||||
xaccGroupForEachAccount (view->priv->root, account_row_inserted, view, TRUE);
|
||||
LEAVE(" ");
|
||||
}
|
||||
#endif
|
||||
|
||||
79
src/gnome-utils/gnc-tree-view-account.h
Normal file
79
src/gnome-utils/gnc-tree-view-account.h
Normal file
@@ -0,0 +1,79 @@
|
||||
/********************************************************************\
|
||||
* gnc-tree-view-account.h -- GtkTreeView implementation to display *
|
||||
* accounts in a GtkTreeView. *
|
||||
* Copyright (C) 2003 David Hampton <hampton@employees.org> *
|
||||
* *
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
#ifndef __GNC_TREE_VIEW_ACCOUNT_H
|
||||
#define __GNC_TREE_VIEW_ACCOUNT_H
|
||||
|
||||
#include <gtk/gtktreemodel.h>
|
||||
#include <gtk/gtktreeview.h>
|
||||
|
||||
#include "gnc-account-tree.h"
|
||||
#include "Group.h"
|
||||
#include "eggtreemodelfilter.h"
|
||||
|
||||
G_BEGIN_DECLS
|
||||
|
||||
/* type macros */
|
||||
#define GNC_TYPE_TREE_VIEW_ACCOUNT (gnc_tree_view_account_get_type ())
|
||||
#define GNC_TREE_VIEW_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GNC_TYPE_TREE_VIEW_ACCOUNT, GncTreeViewAccount))
|
||||
#define GNC_TREE_VIEW_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GNC_TYPE_TREE_VIEW_ACCOUNT, GncTreeViewAccountClass))
|
||||
#define GNC_IS_TREE_VIEW_ACCOUNT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GNC_TYPE_TREE_VIEW_ACCOUNT))
|
||||
#define GNC_IS_TREE_VIEW_ACCOUNT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GNC_TYPE_TREE_VIEW_ACCOUNT))
|
||||
#define GNC_TREE_VIEW_ACCOUNT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GNC_TYPE_TREE_VIEW_ACCOUNT, GncTreeViewAccountClass))
|
||||
|
||||
/* typedefs & structures */
|
||||
typedef struct GncTreeViewAccountPrivate GncTreeViewAccountPrivate;
|
||||
|
||||
typedef struct {
|
||||
GtkTreeView parent;
|
||||
|
||||
GncTreeViewAccountPrivate *priv;
|
||||
|
||||
int stamp;
|
||||
} GncTreeViewAccount;
|
||||
|
||||
typedef struct {
|
||||
GtkTreeViewClass parent;
|
||||
} GncTreeViewAccountClass;
|
||||
|
||||
/* function prototypes */
|
||||
GType gnc_tree_view_account_get_type (void);
|
||||
|
||||
GtkTreeView *gnc_tree_view_account_new (void);
|
||||
GtkTreeView *gnc_tree_view_account_new_filterable (void);
|
||||
|
||||
void gnc_tree_view_update_column_visibility (GncTreeViewAccount *account_view,
|
||||
AccountViewInfo *avi);
|
||||
void gnc_tree_view_init_default_visibility (AccountViewInfo *avi);
|
||||
void gnc_tree_view_account_configure_columns (GncTreeViewAccount *account_view, GSList *list);
|
||||
void gnc_tree_view_account_set_filter (GncTreeViewAccount *account_view,
|
||||
EggTreeModelFilterVisibleFunc func,
|
||||
gpointer data,
|
||||
GtkDestroyNotify destroy);
|
||||
gboolean gnc_tree_view_account_get_selected_account (GncTreeViewAccount *view,
|
||||
Account **account);
|
||||
|
||||
G_END_DECLS
|
||||
|
||||
#endif /* __GNC_TREE_VIEW_ACCOUNT_H */
|
||||
Reference in New Issue
Block a user