r14895 - gnucash/trunk - Add gnc_tree_model_account_types_set_mask and bind mask to the filter

Andreas Köhler andi5 at cvs.gnucash.org
Tue Sep 26 18:08:10 EDT 2006


Author: andi5
Date: 2006-09-26 18:08:09 -0400 (Tue, 26 Sep 2006)
New Revision: 14895
Trac: http://svn.gnucash.org/trac/changeset/14895

Modified:
   gnucash/trunk/
   gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.h
Log:
Add gnc_tree_model_account_types_set_mask and bind mask to the filter
model instead using it as data of the filter function, because those can
only be set once per filter.



Property changes on: gnucash/trunk
___________________________________________________________________
Name: svk:merge
   - 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/trunk:639
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13351
   + 3889ce50-311e-0410-a464-f059747ec5d1:/local/gnucash/trunk:641
d2ab10a8-8a95-4986-baff-8d511d9f15b2:/local/gnucash/trunk:13351

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.c	2006-09-26 22:07:55 UTC (rev 14894)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.c	2006-09-26 22:08:09 UTC (rev 14895)
@@ -35,6 +35,8 @@
 static QofLogModule log_module = GNC_MOD_GUI;
 static GtkTreeModel *account_types_tree_model = NULL;
 
+#define TYPE_MASK "type-mask"
+
 /* Functions for the type system */
 static void
 gnc_tree_model_account_types_class_init (GncTreeModelAccountTypesClass *klass);
@@ -153,13 +155,15 @@
 
 
 static gboolean
-gnc_tree_model_account_types_is_valid (GtkTreeModel *model, 
+gnc_tree_model_account_types_is_valid (GtkTreeModel *model,
                                        GtkTreeIter *iter, gpointer data)
 {
     GNCAccountType type;
-    guint32 valid_types = GPOINTER_TO_UINT (data);
+    GObject *f_model = G_OBJECT (data);
+    guint32 valid_types = GPOINTER_TO_UINT (g_object_get_data (
+                                                f_model, TYPE_MASK));
 
-    gtk_tree_model_get (model, iter, 
+    gtk_tree_model_get (model, iter,
                         GNC_TREE_MODEL_ACCOUNT_TYPES_COL_TYPE, &type, -1);
     return (valid_types & (1 << type)) ? TRUE : FALSE;
 }
@@ -176,15 +180,26 @@
 {
     GtkTreeModel *f_model;
 
-    f_model = gtk_tree_model_filter_new(gnc_tree_model_account_types_master(), 
+    f_model = gtk_tree_model_filter_new (gnc_tree_model_account_types_master (),
                                         NULL);
+    g_object_set_data (G_OBJECT (f_model), TYPE_MASK, GUINT_TO_POINTER (types));
     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);
+        f_model, NULL);
 
     return f_model;
 }
 
+void
+gnc_tree_model_account_types_set_mask (GtkTreeModel *f_model,
+                                       guint32 types)
+{
+    g_return_if_fail (f_model);
+
+    g_object_set_data (G_OBJECT (f_model), TYPE_MASK, GUINT_TO_POINTER (types));
+    gtk_tree_model_filter_refilter (GTK_TREE_MODEL_FILTER (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-09-26 22:07:55 UTC (rev 14894)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account-types.h	2006-09-26 22:08:09 UTC (rev 14895)
@@ -113,6 +113,10 @@
    Caller is responsible for ref/unref. */
 GtkTreeModel * gnc_tree_model_account_types_filter_using_mask (guint32 types);
 
+/* Update the set of the visibible account types in 'model' to 'types'. */
+void gnc_tree_model_account_types_set_mask (GtkTreeModel *f_model,
+                                            guint32 types);
+
 /* Return the bitmask of the account type enums reflecting the state
    of the tree selection.  If your view allows the selection of
    multiple account types, use must use this function to get the



More information about the gnucash-changes mailing list