reuse of filter by... for budgets

Chris Shoemaker c.shoemaker at cox.net
Fri Dec 30 16:42:23 EST 2005


David,
        I really like the filter by dialog for the accounts page.  I
want to use the same thing for the budget page.

Here's my plan for factoring it out:

  * typedef and export the "fd" struct as something like "FilterDialog"
  * factor the middle chunk out of
gnc_plugin_page_account_tree_cmd_view_filter_by(), leaving the arg
checking at the beginning, the signal connection at the end, and a call
to factored out chunk in the middle, taking at least &priv->fd and the
page as arguments.

Then there's the issue of the callbacks.  I could copy them and change
the PageAccountTree arguments to PageBudget argument.  But, I think
it's better to just change the callbacks to take the "fd" struct
instead of the whole page.  The only non-"fd" thing the callbacks use
is for triggering the refilter.  We'd have to use some other mechanism
for that, like adding callback and user_data fields to the fd struct;
then each page would register itself and its own refilter callback
with the filter dialog.

Hmm.. wait a sec.  Both pages would be registering the same callback:
gnc_tree_view_account_refilter.  So maybe there's no need to register
a callback, just the tree_view to use as an argument.  That can just
go into the fd struct.

Yeah, that seems generic.  So, the gppat_filter functions would become
something like:

void account_filter_...(..., FilterDialog *fd)
{
 ...
 gnc_tree_view_account_refilter(GNC_TREE_VIEW_ACCOUNT(fd->tree_view));
 ...
}


and there'd be a:

GtkWidget * 
// ^^^^^^  for returning the dialog
account_filter_dialog_create(FilterDialog *fd, GncPluginPage *page);

Then both the account page and the budget page can have a
gnc_plugin_page_{foo}_cmd_view_filter_by_cmd() that calls
account_filter_dialog_create(&priv->fd, page) after filling in their own
tree view as the fd->tree_view field.

I'll prototype this by copying functions into gnc-plugin-page-budget.c
and then factoring it out just there.  If it works there, maybe all
these callbacks and the dialog creation should move to some
"gnc_tree_view_account_types" home.

Any thoughts?

-chris


More information about the gnucash-devel mailing list