[Gnucash-changes] r12214 - gnucash/trunk/src/gnome - Generalizing
Account Filter By... (step 5)
Chris Shoemaker
chris at cvs.gnucash.org
Fri Dec 30 19:22:45 EST 2005
Author: chris
Date: 2005-12-30 19:22:42 -0500 (Fri, 30 Dec 2005)
New Revision: 12214
Trac: http://svn.gnucash.org/trac/changeset/12214
Modified:
gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c
gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.h
gnucash/trunk/src/gnome/gnc-plugin-page-budget.c
Log:
Generalizing Account Filter By... (step 5)
export the account-tree's account filter function
populate the account-tree's account filter struct with the right tree-view.
And finally... reuse all this generalized functionality in
the budget plugin page. Nice!
Modified: gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c 2005-12-31 00:00:49 UTC (rev 12213)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.c 2005-12-31 00:22:42 UTC (rev 12214)
@@ -451,6 +451,7 @@
gtk_widget_show (GTK_WIDGET (tree_view));
gtk_container_add (GTK_CONTAINER (scrolled_window), GTK_WIDGET(tree_view));
+ priv->fd.tree_view = priv->tree_view;
gnc_tree_view_account_set_filter (
GNC_TREE_VIEW_ACCOUNT(tree_view),
gnc_plugin_page_account_tree_filter_accounts, &priv->fd, NULL);
@@ -1433,7 +1434,7 @@
LEAVE("types 0x%x", fd->visible_types);
}
-/** The Filter dialog was closed. CHeck to see if this was done via
+/** The Filter dialog was closed. Check to see if this was done via
* the OK button. If so, make the changes permanent. If not, revert
* any changes.
*
Modified: gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.h
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.h 2005-12-31 00:00:49 UTC (rev 12213)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-account-tree.h 2005-12-31 00:22:42 UTC (rev 12214)
@@ -79,7 +79,11 @@
void
account_filter_dialog_create(AccountFilterDialog *fd, GncPluginPage *page);
+gboolean
+gnc_plugin_page_account_tree_filter_accounts (Account *account,
+ gpointer user_data);
+
/* function prototypes */
/** Retrieve the type number for an "account tree" plugin page.
Modified: gnucash/trunk/src/gnome/gnc-plugin-page-budget.c
===================================================================
--- gnucash/trunk/src/gnome/gnc-plugin-page-budget.c 2005-12-31 00:00:49 UTC (rev 12213)
+++ gnucash/trunk/src/gnome/gnc-plugin-page-budget.c 2005-12-31 00:22:42 UTC (rev 12214)
@@ -68,11 +68,14 @@
#include "gnc-recurrence.h"
#include "Recurrence.h"
#include "gnc-tree-model-account-types.h"
+#include "gnc-plugin-page-account-tree.h" // just until filter funcs find a home
+
/* This static indicates the debugging module that this .o belongs to. */
static QofLogModule log_module = GNC_MOD_BUDGET;
#define PLUGIN_PAGE_BUDGET_CM_CLASS "plugin-page-budget"
+//#define GCONF_SECTION "window/pages/budget"
/************************************************************
* Prototypes *
@@ -96,6 +99,8 @@
GtkTreeSelection *selection, GncPluginPageBudget *page);
static void gnc_plugin_page_budget_view_refresh (GncPluginPageBudget *page);
+static void gnc_plugin_page_budget_cmd_view_filter_by (
+ GtkAction *action, GncPluginPageBudget *page);
/* Command Callbacks */
static void gnc_plugin_page_budget_cmd_open_account(
@@ -134,6 +139,11 @@
NULL,
N_("Estimate a budget value for the selected cells"),
G_CALLBACK (gnc_plugin_page_budget_cmd_estimate_budget) },
+
+ /* View menu */
+ { "ViewFilterByAction", NULL, N_("_Filter By..."), NULL, NULL,
+ G_CALLBACK (gnc_plugin_page_budget_cmd_view_filter_by) },
+
};
static guint gnc_plugin_page_budget_n_actions =
@@ -171,6 +181,7 @@
GList *period_col_list;
guint32 acct_types;
+ AccountFilterDialog fd;
} GncPluginPageBudgetPrivate;
#define GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(o) \
@@ -289,6 +300,10 @@
g_free (label);
}
+ /* Visisble types */
+ priv->fd.visible_types = -1; /* Start with all types */
+ priv->fd.hide_zero_total = FALSE;
+
LEAVE("page %p, priv %p, action group %p",
plugin_page, priv, action_group);
}
@@ -397,6 +412,11 @@
gtk_widget_show (GTK_WIDGET (tree_view));
gtk_container_add (GTK_CONTAINER (scrolled_window),
GTK_WIDGET(tree_view));
+ priv->fd.tree_view = priv->tree_view;
+ gnc_tree_view_account_set_filter(
+ GNC_TREE_VIEW_ACCOUNT(tree_view),
+ gnc_plugin_page_account_tree_filter_accounts,
+ &priv->fd, NULL);
priv->component_id =
gnc_register_gui_component(PLUGIN_PAGE_BUDGET_CM_CLASS,
@@ -624,10 +644,6 @@
d, "AccountTypesTreeView"));
sel_mask = gnc_tree_model_account_types_get_selection(tv);
priv->acct_types = sel_mask;
- gnc_tree_view_account_set_filter(
- GNC_TREE_VIEW_ACCOUNT(priv->tree_view),
- gnc_tree_view_account_filter_by_type_selection,
- GUINT_TO_POINTER(sel_mask), NULL);
LEAVE(" ");
return TRUE;
}
@@ -918,3 +934,19 @@
gnc_plugin_page_budget_refresh_col_titles(page);
}
+
+static void
+gnc_plugin_page_budget_cmd_view_filter_by (GtkAction *action,
+ GncPluginPageBudget *page)
+{
+ GncPluginPageBudgetPrivate *priv;
+
+ g_return_if_fail(GNC_IS_PLUGIN_PAGE_BUDGET(page));
+ ENTER("(action %p, page %p)", action, page);
+
+ priv = GNC_PLUGIN_PAGE_BUDGET_GET_PRIVATE(page);
+ priv->fd.tree_view = priv->tree_view;
+ account_filter_dialog_create(&priv->fd, GNC_PLUGIN_PAGE(page));
+
+ LEAVE(" ");
+}
More information about the gnucash-changes
mailing list