mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug 797485 - Show account hidden column on CoA.
To make it easier to change the hidden property on multiple accounts, a new column can be added to the CoA to toggle the account hidden property. This only makes sense if the 'View->Filter By...' other tab has been accessed to enable showing of hidden accounts first.
This commit is contained in:
@@ -418,6 +418,7 @@ gnc_tree_model_account_get_column_type (GtkTreeModel *tree_model, int index)
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL_PERIOD:
|
||||
return G_TYPE_STRING;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_HIDDEN:
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER:
|
||||
return G_TYPE_BOOLEAN;
|
||||
|
||||
@@ -944,6 +945,11 @@ gnc_tree_model_account_get_value (GtkTreeModel *tree_model,
|
||||
g_value_set_string (value, xaccAccountGetLastNum (account));
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_HIDDEN:
|
||||
g_value_init (value, G_TYPE_BOOLEAN);
|
||||
g_value_set_boolean (value, xaccAccountGetHidden (account));
|
||||
break;
|
||||
|
||||
case GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER:
|
||||
g_value_init (value, G_TYPE_BOOLEAN);
|
||||
g_value_set_boolean (value, xaccAccountGetPlaceholder (account));
|
||||
|
||||
@@ -79,6 +79,7 @@ typedef enum
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_NOTES,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO_SUB_ACCT,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_HIDDEN,
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER,
|
||||
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_LAST_VISIBLE = GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER,
|
||||
|
||||
@@ -207,6 +207,31 @@ gnc_tree_view_account_finalize (GObject *object)
|
||||
/************************************************************
|
||||
* Callbacks *
|
||||
************************************************************/
|
||||
static void
|
||||
gnc_tree_view_account_hidden_toggled (GtkCellRendererToggle *cell,
|
||||
const gchar *s_path_str,
|
||||
gpointer user_data)
|
||||
{
|
||||
GncTreeViewAccount *tree_view;
|
||||
GtkTreePath *s_path;
|
||||
Account *account;
|
||||
gboolean hidden;
|
||||
|
||||
/* Change the requested account */
|
||||
tree_view = user_data;
|
||||
s_path = gtk_tree_path_new_from_string (s_path_str);
|
||||
account = gnc_tree_view_account_get_account_from_path (tree_view, s_path);
|
||||
if (account)
|
||||
{
|
||||
hidden = !gtk_cell_renderer_toggle_get_active (cell); // hasn't changed yet.
|
||||
xaccAccountSetHidden (account, hidden);
|
||||
}
|
||||
|
||||
/* Clean up */
|
||||
gtk_tree_path_free (s_path);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
gnc_tree_view_account_placeholder_toggled (GtkCellRendererToggle *cell,
|
||||
const gchar *s_path_str,
|
||||
@@ -423,6 +448,29 @@ sort_by_total_value (GtkTreeModel *f_model,
|
||||
f_model, f_iter_a, f_iter_b, user_data);
|
||||
}
|
||||
|
||||
static gint
|
||||
sort_by_hidden (GtkTreeModel *f_model,
|
||||
GtkTreeIter *f_iter_a,
|
||||
GtkTreeIter *f_iter_b,
|
||||
gpointer user_data)
|
||||
{
|
||||
const Account *account_a, *account_b;
|
||||
gboolean flag_a, flag_b;
|
||||
|
||||
/* Find the accounts */
|
||||
sort_cb_setup (f_model, f_iter_a, f_iter_b, &account_a, &account_b);
|
||||
|
||||
/* Get the placeholder flags. */
|
||||
flag_a = xaccAccountGetHidden (account_a);
|
||||
flag_b = xaccAccountGetHidden (account_b);
|
||||
|
||||
if (flag_a > flag_b)
|
||||
return -1;
|
||||
else if (flag_a < flag_b)
|
||||
return 1;
|
||||
return xaccAccountOrder (account_a, account_b);
|
||||
}
|
||||
|
||||
static gint
|
||||
sort_by_placeholder (GtkTreeModel *f_model,
|
||||
GtkTreeIter *f_iter_a,
|
||||
@@ -902,6 +950,14 @@ gnc_tree_view_account_new_with_root (Account *root, gboolean show_root)
|
||||
GTK_TREE_VIEW(view),
|
||||
NULL);
|
||||
|
||||
gnc_tree_view_add_toggle_column (view, _("Hidden"),
|
||||
C_("Column header for 'Hidden'", "H"),
|
||||
"hidden",
|
||||
GNC_TREE_MODEL_ACCOUNT_COL_HIDDEN,
|
||||
GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
|
||||
sort_by_hidden,
|
||||
gnc_tree_view_account_hidden_toggled);
|
||||
|
||||
gnc_tree_view_add_toggle_column(view, _("Placeholder"),
|
||||
C_("Column header for 'Placeholder'", "P"),
|
||||
"placeholder",
|
||||
|
||||
Reference in New Issue
Block a user