[Gnucash-changes] r12900 - gnucash/trunk - Filter out deprecated
account types from the account types treemodel.
Chris Shoemaker
chris at cvs.gnucash.org
Thu Jan 19 13:02:20 EST 2006
Author: chris
Date: 2006-01-19 13:02:18 -0500 (Thu, 19 Jan 2006)
New Revision: 12900
Trac: http://svn.gnucash.org/trac/changeset/12900
Modified:
gnucash/trunk/AUTHORS
gnucash/trunk/src/engine/Account.c
gnucash/trunk/src/engine/Account.h
gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.c
gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.h
Log:
Filter out deprecated account types from the account types treemodel.
Patch by Eskil Bylund <eskil.bylund at gmail.com>
Modified: gnucash/trunk/AUTHORS
===================================================================
--- gnucash/trunk/AUTHORS 2006-01-19 17:58:02 UTC (rev 12899)
+++ gnucash/trunk/AUTHORS 2006-01-19 18:02:18 UTC (rev 12900)
@@ -105,6 +105,7 @@
Christopher B. Browne <cbbrowne at hex.net> for perl, lots of scheme and documentation updates
Johan Buret <johanburet at free.fr> french translation
Thomas Bushnell <tb at becket.net> fix for file backups
+Eskil Bylund <eskil.bylund at gmail.com> account type deprecation
Paul Campbell <kemitix at users.sourceforge.net> reconcile children patch
Conrad Canterford <conrad at mail.watersprite.com.au> register bug fix
Bill Carlson <wwc at wwcnet.nu> performance improvements
Modified: gnucash/trunk/src/engine/Account.c
===================================================================
--- gnucash/trunk/src/engine/Account.c 2006-01-19 17:58:02 UTC (rev 12899)
+++ gnucash/trunk/src/engine/Account.c 2006-01-19 18:02:18 UTC (rev 12900)
@@ -2322,6 +2322,17 @@
return compatible;
}
+guint32
+xaccAccountTypesValid(void)
+{
+ guint32 mask = (1 << NUM_ACCOUNT_TYPES) - 1;
+ mask &= ~(1 << CURRENCY); /* DEPRECATED */
+
+ return mask;
+}
+
+
+
/********************************************************************\
\********************************************************************/
Modified: gnucash/trunk/src/engine/Account.h
===================================================================
--- gnucash/trunk/src/engine/Account.h 2006-01-19 17:58:02 UTC (rev 12899)
+++ gnucash/trunk/src/engine/Account.h 2006-01-19 18:02:18 UTC (rev 12900)
@@ -96,8 +96,7 @@
* three columns: price, number of shares, and
* value. Note: Since version 1.7.0, this account is
* no longer needed to exchange currencies between
- * accounts, so this type will probably become
- * deprecated sometime in the future. */
+ * accounts, so this type is DEPRECATED. */
INCOME = 8, /**< Income accounts are used to denote income */
EXPENSE = 9,/**< Expense accounts are used to denote expenses. */
@@ -495,6 +494,11 @@
* of type child_type as children. */
gboolean xaccAccountTypesCompatible (GNCAccountType parent_type,
GNCAccountType child_type);
+
+/* Returns the bitmask of the account type enums that are valid. */
+guint32 xaccAccountTypesValid(void);
+
+
/** @} */
/* ------------------ */
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.c 2006-01-19 17:58:02 UTC (rev 12899)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.c 2006-01-19 18:02:18 UTC (rev 12900)
@@ -2,9 +2,9 @@
* gnc-tree-model-account-types.c -- GtkTreeModel implementation
* to display account types in a GtkTreeView.
*
- * Copyright (C) 2003 Jan Arne Petersen
- * Copyright (C) 2005, Chris Shoemaker <c.shoemaker at cox.net>
- * Author: Jan Arne Petersen <jpetersen at uni-bonn.de>
+ * Copyright (C) 2003 Jan Arne Petersen <jpetersen at uni-bonn.de>
+ * Copyright (C) 2005, 2006 Chris Shoemaker <c.shoemaker at cox.net>
+ * Copyright (C) 2006 Eskil Bylund <eskil.bylund at gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -47,54 +47,14 @@
static void
gnc_tree_model_account_types_tree_model_init (GtkTreeModelIface * iface);
-/*
-static guint
-gnc_tree_model_account_types_get_flags (GtkTreeModel * tree_model);
-static int
-gnc_tree_model_account_types_get_n_columns (GtkTreeModel * tree_model);
-static GType
-gnc_tree_model_account_types_get_column_type (GtkTreeModel * tree_model,
- int index);
-static gboolean
-gnc_tree_model_account_types_get_iter (GtkTreeModel * tree_model,
- GtkTreeIter * iter, GtkTreePath * path);
-static GtkTreePath *
-gnc_tree_model_account_types_get_path (GtkTreeModel * tree_model,
- GtkTreeIter * iter);
-static void
-gnc_tree_model_account_types_get_value (GtkTreeModel * tree_model,
- GtkTreeIter * iter, int column,
- GValue * value);
-static gboolean
-gnc_tree_model_account_types_iter_next (GtkTreeModel * tree_model,
- GtkTreeIter * iter);
-static gboolean
-gnc_tree_model_account_types_iter_children (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- GtkTreeIter * parent);
-static gboolean
-gnc_tree_model_account_types_iter_has_child (GtkTreeModel * tree_model,
- GtkTreeIter * iter);
-static int
-gnc_tree_model_account_types_iter_n_children (GtkTreeModel * tree_model,
- GtkTreeIter * iter);
-static gboolean
-gnc_tree_model_account_types_iter_nth_child (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- GtkTreeIter * parent, int n);
-static gboolean
-gnc_tree_model_account_types_iter_parent (GtkTreeModel * tree_model,
- GtkTreeIter * iter,
- GtkTreeIter * child);
-*/
-
typedef struct GncTreeModelAccountTypesPrivate
{
guint32 selected;
} GncTreeModelAccountTypesPrivate;
#define GNC_TREE_MODEL_ACCOUNT_TYPES_GET_PRIVATE(o) \
- (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, GncTreeModelAccountTypesPrivate))
+ (G_TYPE_INSTANCE_GET_PRIVATE ((o), GNC_TYPE_TREE_MODEL_ACCOUNT_TYPES, \
+ GncTreeModelAccountTypesPrivate))
static GObjectClass *parent_class = NULL;
@@ -193,6 +153,39 @@
}
+static gboolean
+gnc_tree_model_account_types_is_valid (GtkTreeModel *model,
+ GtkTreeIter *iter, gpointer data)
+{
+ GNCAccountType type;
+ guint32 valid_types = GPOINTER_TO_UINT (data);
+
+ gtk_tree_model_get (model, iter,
+ GNC_TREE_MODEL_ACCOUNT_TYPES_COL_TYPE, &type, -1);
+ return (valid_types & (1 << type)) ? TRUE : FALSE;
+}
+
+GtkTreeModel *
+gnc_tree_model_account_types_valid (void)
+{
+ return gnc_tree_model_account_types_filter_using_mask(
+ xaccAccountTypesValid());
+}
+
+GtkTreeModel *
+gnc_tree_model_account_types_filter_using_mask (guint32 types)
+{
+ GtkTreeModel *f_model;
+
+ f_model = gtk_tree_model_filter_new(gnc_tree_model_account_types_master(),
+ NULL);
+ gtk_tree_model_filter_set_visible_func (
+ GTK_TREE_MODEL_FILTER (f_model), gnc_tree_model_account_types_is_valid,
+ GUINT_TO_POINTER (types), NULL);
+
+ return f_model;
+}
+
guint32
gnc_tree_model_account_types_get_selected (GncTreeModelAccountTypes * model)
{
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.h 2006-01-19 17:58:02 UTC (rev 12899)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.h 2006-01-19 18:02:18 UTC (rev 12900)
@@ -2,9 +2,9 @@
* gnc-tree-model-account-types.h -- GtkTreeModel implementation
* to display account types in a GtkTreeView.
*
- * Copyright (C) 2003 Jan Arne Petersen
- * Copyright (C) 2005, Chris Shoemaker <c.shoemaker at cox.net>
- * Author: Jan Arne Petersen <jpetersen at uni-bonn.de>
+ * Copyright (C) 2003 Jan Arne Petersen <jpetersen at uni-bonn.de>
+ * Copyright (C) 2005, 2006 Chris Shoemaker <c.shoemaker at cox.net>
+ * Copyright (C) 2006 Eskil Bylund <eskil.bylund at gmail.com>
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License as
@@ -28,7 +28,8 @@
/** @addtogroup GuiTreeModel
* @{ */
/** @file gnc-tree-model-account-types.h
- * @brief GtkTreeModel implementation to display account types in a GtkTreeView.
+ * @brief GtkTreeModel implementation to display account types in a
+ * GtkTreeView.
* @author Copyright (C) 2003 Jan Arne Petersen
* @author: Jan Arne Petersen <jpetersen at uni-bonn.de>
*
@@ -93,9 +94,23 @@
/* Get the static GtkTreeModel representing the list of all possible
account types. You may not modify this model, but you can use if
- for multiple views. */
+ for multiple views. You probably want gnc_tree_model_types_valid(). */
GtkTreeModel * gnc_tree_model_account_types_master(void);
+/* Returns a GtkTreeModelFilter that wraps the model. Deprecated
+ account types will be filtered. Use this instead of
+ gnc_tree_model_account_types_master. Caller is responsible for
+ ref/unref. */
+GtkTreeModel * gnc_tree_model_account_types_valid (void);
+
+/* Returns a GtkTreeModelFilter that wraps the model. Only account
+ types specified by the 'types' bitmask are visible. To force the
+ visibility of deprecated account types, pass
+ (xaccAccountTypesValid() & (1 << MY_DEPRECATED_ACCOUNT_TYPE)).
+
+ Caller is responsible for ref/unref. */
+GtkTreeModel * gnc_tree_model_account_types_filter_using_mask (guint32 types);
+
/* Return the bitmask of the account type enums reflecting the state
of the tree selection */
guint32 gnc_tree_model_account_types_get_selection(GtkTreeView *view);
More information about the gnucash-changes
mailing list