diff --git a/src/gnome-utils/dialog-options.c b/src/gnome-utils/dialog-options.c index a6bed1d473..a3ac41fe3c 100644 --- a/src/gnome-utils/dialog-options.c +++ b/src/gnome-utils/dialog-options.c @@ -680,6 +680,10 @@ gnc_set_default_gain_loss_account_widget(gnc_commodity *commodity) g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1)); + // add the color background data function to the column + gnc_tree_view_account_column_add_color (GNC_TREE_VIEW_ACCOUNT( + book_currency_data->default_gain_loss_account_widget), col); + col = gnc_tree_view_add_toggle_column(GNC_TREE_VIEW( book_currency_data->default_gain_loss_account_widget), @@ -696,6 +700,10 @@ gnc_set_default_gain_loss_account_widget(gnc_commodity *commodity) g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1)); + // add the color background data function to the column + gnc_tree_view_account_column_add_color (GNC_TREE_VIEW_ACCOUNT( + book_currency_data->default_gain_loss_account_widget), col); + gnc_tree_view_configure_columns (GNC_TREE_VIEW( book_currency_data->default_gain_loss_account_widget)); gnc_tree_view_set_show_column_menu(GNC_TREE_VIEW( diff --git a/src/gnome-utils/gnc-tree-view-account.c b/src/gnome-utils/gnc-tree-view-account.c index 83fdf388f0..5914ce7eb5 100644 --- a/src/gnome-utils/gnc-tree-view-account.c +++ b/src/gnome-utils/gnc-tree-view-account.c @@ -659,6 +659,18 @@ gnc_tree_view_account_color_update (gpointer gsettings, gchar *key, gpointer use priv->show_account_color = gnc_prefs_get_bool(GNC_PREFS_GROUP_GENERAL, key); } +/** Add the account color background data function to the GncTreeViewAccount column to + * show or not the column background in the account color. + */ +void +gnc_tree_view_account_column_add_color (GncTreeViewAccount *view, GtkTreeViewColumn *col) +{ + GtkCellRenderer *renderer = gnc_tree_view_column_get_renderer(col); + + gtk_tree_view_column_set_cell_data_func (col, renderer, acc_color_data_func, + GTK_TREE_VIEW(view), NULL); +} + /************************************************************/ /* New View Creation */ /************************************************************/ @@ -1743,6 +1755,7 @@ account_cell_property_data_func (GtkTreeViewColumn *tree_column, GtkTreeIter *s_iter, gpointer key) { + GncTreeViewAccount *view; Account *account; gchar *string = NULL; @@ -1755,6 +1768,11 @@ account_cell_property_data_func (GtkTreeViewColumn *tree_column, string = ""; g_object_set (G_OBJECT (cell), "text", string, "xalign", 0.0, NULL); + + view = g_object_get_data(G_OBJECT(tree_column), "tree-view"); + + if (GNC_IS_TREE_VIEW_ACCOUNT (view)) + acc_color_data_func (tree_column, cell, s_model, s_iter, view); } @@ -1778,6 +1796,9 @@ gnc_tree_view_account_add_property_column (GncTreeViewAccount *view, renderer = gnc_tree_view_column_get_renderer(column); g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL); + // add a pointer to the view to make it easier to access in data_func + g_object_set_data(G_OBJECT(column), "tree-view", (gpointer)view); + gtk_tree_view_column_set_cell_data_func (column, renderer, account_cell_property_data_func, g_strdup(propname), g_free); diff --git a/src/gnome-utils/gnc-tree-view-account.h b/src/gnome-utils/gnc-tree-view-account.h index 0ebfc97d58..b6381f2b15 100644 --- a/src/gnome-utils/gnc-tree-view-account.h +++ b/src/gnome-utils/gnc-tree-view-account.h @@ -471,6 +471,11 @@ void gnc_tree_view_account_select_subaccounts (GncTreeViewAccount *view, */ void gnc_tree_view_account_expand_to_account (GncTreeViewAccount *view, Account *account); +/** Add the account color background data function to the GncTreeViewAccount column to + * show or not the column background in the account color. + */ +void gnc_tree_view_account_column_add_color (GncTreeViewAccount *view, GtkTreeViewColumn *col); + /** @} */ /** @} */ diff --git a/src/import-export/import-account-matcher.c b/src/import-export/import-account-matcher.c index 13c955761f..9d4034af51 100644 --- a/src/import-export/import-account-matcher.c +++ b/src/import-export/import-account-matcher.c @@ -118,6 +118,9 @@ build_acct_tree(AccountPickerDialog *picker) _("Account ID"), "online-id"); g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1)); + // the color background data function is part of the add_property_column + // function which will color the background based on preference setting + gtk_container_add(GTK_CONTAINER(picker->account_tree_sw), GTK_WIDGET(picker->account_tree));