mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Add function to add the color background data function to account column
Some tree views based on GncTreeViewAccount specify there own columns and when displayed you can end up with the Account column background color set and the new ones uncolored which can look odd. Added a function to add the color data function to the new columns.
This commit is contained in:
parent
fc0e25e7b2
commit
5a7a8d8d9b
@ -680,6 +680,10 @@ gnc_set_default_gain_loss_account_widget(gnc_commodity *commodity)
|
|||||||
g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE,
|
g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE,
|
||||||
GINT_TO_POINTER(1));
|
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 =
|
col =
|
||||||
gnc_tree_view_add_toggle_column(GNC_TREE_VIEW(
|
gnc_tree_view_add_toggle_column(GNC_TREE_VIEW(
|
||||||
book_currency_data->default_gain_loss_account_widget),
|
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,
|
g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE,
|
||||||
GINT_TO_POINTER(1));
|
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(
|
gnc_tree_view_configure_columns (GNC_TREE_VIEW(
|
||||||
book_currency_data->default_gain_loss_account_widget));
|
book_currency_data->default_gain_loss_account_widget));
|
||||||
gnc_tree_view_set_show_column_menu(GNC_TREE_VIEW(
|
gnc_tree_view_set_show_column_menu(GNC_TREE_VIEW(
|
||||||
|
@ -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);
|
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 */
|
/* New View Creation */
|
||||||
/************************************************************/
|
/************************************************************/
|
||||||
@ -1743,6 +1755,7 @@ account_cell_property_data_func (GtkTreeViewColumn *tree_column,
|
|||||||
GtkTreeIter *s_iter,
|
GtkTreeIter *s_iter,
|
||||||
gpointer key)
|
gpointer key)
|
||||||
{
|
{
|
||||||
|
GncTreeViewAccount *view;
|
||||||
Account *account;
|
Account *account;
|
||||||
gchar *string = NULL;
|
gchar *string = NULL;
|
||||||
|
|
||||||
@ -1755,6 +1768,11 @@ account_cell_property_data_func (GtkTreeViewColumn *tree_column,
|
|||||||
string = "";
|
string = "";
|
||||||
|
|
||||||
g_object_set (G_OBJECT (cell), "text", string, "xalign", 0.0, NULL);
|
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);
|
renderer = gnc_tree_view_column_get_renderer(column);
|
||||||
g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
|
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,
|
gtk_tree_view_column_set_cell_data_func (column, renderer,
|
||||||
account_cell_property_data_func,
|
account_cell_property_data_func,
|
||||||
g_strdup(propname), g_free);
|
g_strdup(propname), g_free);
|
||||||
|
@ -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);
|
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);
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
/** @} */
|
/** @} */
|
||||||
|
@ -118,6 +118,9 @@ build_acct_tree(AccountPickerDialog *picker)
|
|||||||
_("Account ID"), "online-id");
|
_("Account ID"), "online-id");
|
||||||
g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
|
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_container_add(GTK_CONTAINER(picker->account_tree_sw),
|
||||||
GTK_WIDGET(picker->account_tree));
|
GTK_WIDGET(picker->account_tree));
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user