diff --git a/ChangeLog b/ChangeLog index 8d0efb6537..e5922f84ca 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2005-11-09 David Hampton + * src/gnome-utils/gnc-tree-view-account.[ch]: Add a function that + allow you to expand the account tree to show a specific account. + * src/report/report-system/report.scm: * src/business/business-reports/business-reports.scm: * src/gnome-utils/ui/gnc-main-window-ui.xml: diff --git a/src/gnome-utils/gnc-tree-view-account.c b/src/gnome-utils/gnc-tree-view-account.c index 033559b03d..ceb4639199 100644 --- a/src/gnome-utils/gnc-tree-view-account.c +++ b/src/gnome-utils/gnc-tree-view-account.c @@ -545,7 +545,6 @@ gnc_tree_view_account_new (gboolean show_root) g_free(path_string); \ } -#if 0 static GtkTreePath * gnc_tree_view_account_get_path_from_account (GncTreeViewAccount *view, Account *account) @@ -579,12 +578,11 @@ gnc_tree_view_account_get_path_from_account (GncTreeViewAccount *view, } /* convert back to a sorted path */ - s_path = gtk_tree_model_filter_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model), f_path); + s_path = gtk_tree_model_sort_convert_child_path_to_path (GTK_TREE_MODEL_SORT (s_model), f_path); gtk_tree_path_free(f_path); debug_path(LEAVE, s_path); return s_path; } -#endif static gboolean gnc_tree_view_account_get_iter_from_account (GncTreeViewAccount *view, @@ -1162,6 +1160,25 @@ gnc_tree_view_account_select_subaccounts (GncTreeViewAccount *view, return; } +void +gnc_tree_view_account_expand_to_account (GncTreeViewAccount *view, + Account *account) +{ + GtkTreePath *path; + + g_return_if_fail(view != NULL); + g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(view)); + ENTER("view %p, account %p", view, account); + + path = gnc_tree_view_account_get_path_from_account(view, account); + if (path) { + gtk_tree_view_expand_to_path(GTK_TREE_VIEW(view), path); + gtk_tree_path_free(path); + } + LEAVE(" "); +} + + /* * Retrieve the account currently under the cursor. */ diff --git a/src/gnome-utils/gnc-tree-view-account.h b/src/gnome-utils/gnc-tree-view-account.h index 09a355be94..84df9cf537 100644 --- a/src/gnome-utils/gnc-tree-view-account.h +++ b/src/gnome-utils/gnc-tree-view-account.h @@ -428,6 +428,16 @@ void gnc_tree_view_account_set_selected_accounts (GncTreeViewAccount *view, void gnc_tree_view_account_select_subaccounts (GncTreeViewAccount *view, Account *account); +/** This function forces the account tree expand whatever levels are + * necessary to make the specified account visible. + * + * @param view A pointer to an account tree view. + * + * @param account A pointer to the account to show. + */ +void gnc_tree_view_account_expand_to_account (GncTreeViewAccount *view, Account *account); + + /** @} */ /** @} */