r22359 - gnucash/trunk/src/gnome-utils - Bug #682660 - Add Account background colour to Account page.

Geert Janssens gjanssens at code.gnucash.org
Wed Sep 5 09:34:12 EDT 2012


Author: gjanssens
Date: 2012-09-05 09:34:12 -0400 (Wed, 05 Sep 2012)
New Revision: 22359
Trac: http://svn.gnucash.org/trac/changeset/22359

Modified:
   gnucash/trunk/src/gnome-utils/gnc-main-window.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
   gnucash/trunk/src/gnome-utils/gnc-tree-model-account.h
   gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c
   gnucash/trunk/src/gnome-utils/gnc-tree-view-account.h
   gnucash/trunk/src/gnome-utils/gnc-tree-view.c
   gnucash/trunk/src/gnome-utils/gnc-tree-view.h
   gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade
Log:
Bug #682660 - Add Account background colour to Account page.

Author: Robert Fewell <14ubobit at gmail.com>

Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c	2012-09-05 10:45:04 UTC (rev 22358)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c	2012-09-05 13:34:12 UTC (rev 22359)
@@ -91,6 +91,7 @@
 #define KEY_TAB_NEXT_RECENT	"tab_next_recent"
 #define KEY_TAB_POSITION	"tab_position"
 #define KEY_TAB_WIDTH           "tab_width"
+#define KEY_TAB_COLOR           "show_account_color_tabs"
 
 #define GNC_MAIN_WINDOW_NAME "GncMainWindow"
 
@@ -115,6 +116,7 @@
 
 static void gnc_main_window_setup_window (GncMainWindow *window);
 static void gnc_window_main_window_init (GncWindowIface *iface);
+static gboolean main_window_find_tab_event (GncMainWindow *window, GncPluginPage *page, GtkWidget **event_p);
 #ifndef MAC_INTEGRATION
 static void gnc_main_window_update_all_menu_items (void);
 #endif
@@ -165,7 +167,7 @@
 typedef struct GncMainWindowPrivate
 {
     /** The dock (vbox) at the top of the window containing the
-     *  menubar and toolbar.  These items are generated bu the UI
+     *  menubar and toolbar.  These items are generated by the UI
      *  manager and stored here when the UI manager provides them
      *  to the main window. */
     GtkWidget *menu_dock;
@@ -174,6 +176,8 @@
     GtkWidget *toolbar;
     /** The notebook containing all the pages in this window. */
     GtkWidget *notebook;
+    /** Show account color as background on tabs */
+    gboolean show_color_tabs;
     /** A pointer to the status bar at the bottom edge of the
      *  window.  This pointer provides easy access for
      *  updating/showing/hiding the status bar. */
@@ -1750,6 +1754,74 @@
 }
 
 
+/** Show/hide the account color on the tab of a notebook page.
+ *
+ *  @internal
+ *
+ *  @param page The GncPluginPage whose notebook tab should be updated.
+ *
+ *  @param user_data GncMainWindow.
+ */
+static void
+gnc_main_window_update_tab_color_one_page (GncPluginPage *page,
+        gpointer user_data)
+{
+    GncMainWindow        *window = user_data;
+    GncMainWindowPrivate *priv;
+    const gchar          *color_string;
+    GdkColor              tab_color;
+    GtkWidget            *event_box;
+
+    ENTER("page %p", page);
+
+    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
+
+    /* Get the event box to update the tab */
+    main_window_find_tab_event(window, page, &event_box);
+
+    color_string = gnc_plugin_page_get_page_color(page);
+    if (color_string == NULL) color_string = "";
+    if (gdk_color_parse(color_string, &tab_color) && priv->show_color_tabs)
+    {
+        gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, &tab_color);
+        gtk_widget_modify_bg(event_box, GTK_STATE_ACTIVE, &tab_color);
+    }
+    else
+    {
+        gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, NULL);
+        gtk_widget_modify_bg(event_box, GTK_STATE_ACTIVE, NULL);
+    }
+    LEAVE(" ");
+}
+
+
+/** Show/hide the account color on tabs.
+ *
+ *  @internal
+ *
+ *  @param entry A pointer to the GConfEntry which describes the new
+ *  state of whether the account color should be visible on notebook tabs.
+ *
+ *  @param user_data GncMainWindow.
+ */
+static void
+gnc_main_window_update_tab_color (GConfEntry *entry, gpointer user_data)
+{
+    GncMainWindowPrivate *priv;
+    GncMainWindow        *window;
+    gboolean              new_value;
+
+    ENTER(" ");
+    g_return_if_fail(GNC_IS_MAIN_WINDOW(user_data));
+    window = user_data;
+    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
+    new_value = gconf_value_get_bool(entry->value);
+    priv->show_color_tabs = new_value;
+    gnc_main_window_foreach_page (gnc_main_window_update_tab_color_one_page, window);
+    LEAVE(" ");
+}
+
+
 /** Update the width of the label in the tab of a notebook page.  This
  *  function adjusts both the width and the ellipsize mode so that the tab
  *  label looks correct.  The special check for a zero value handles the
@@ -1983,13 +2055,12 @@
                                const gchar *color_in)
 {
     GncMainWindow *window;
+    GncMainWindowPrivate *priv;
     GtkWidget *event_box;
     GdkColor tab_color;
     gchar *color_string;
 
-
     ENTER(" ");
-
     if ((color_in == NULL) || (*color_in == '\0'))
     {
         LEAVE("no string");
@@ -2009,10 +2080,12 @@
     window = GNC_MAIN_WINDOW(page->window);
     gnc_plugin_page_set_page_color(page, color_string);
 
+    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
+
     /* Update the notebook tab */
     main_window_find_tab_event(window, page, &event_box);
 
-    if (gdk_color_parse(color_string, &tab_color))
+    if (gdk_color_parse(color_string, &tab_color) && priv->show_color_tabs)
     {
         gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, &tab_color);
         gtk_widget_modify_bg(event_box, GTK_STATE_ACTIVE, &tab_color);
@@ -2217,6 +2290,7 @@
     gnc_gconf_general_register_cb (KEY_TAB_WIDTH,
                                    gnc_main_window_update_tab_width,
                                    NULL);
+
     gnc_hook_add_dangler(HOOK_BOOK_SAVED,
                          (GFunc)gnc_main_window_update_all_titles, NULL);
     gnc_hook_add_dangler(HOOK_BOOK_OPENED,
@@ -2246,6 +2320,13 @@
     priv->event_handler_id =
         qof_event_register_handler(gnc_main_window_event_handler, window);
 
+    /* Get the show_color_tabs value from gconf */
+    priv->show_color_tabs = gnc_gconf_get_bool(GCONF_GENERAL, KEY_TAB_COLOR, NULL);
+
+    gnc_gconf_general_register_cb (KEY_TAB_COLOR,
+                                   gnc_main_window_update_tab_color,
+                                   window);
+
     gnc_main_window_setup_window (window);
     gnc_gobject_tracking_remember(G_OBJECT(window),
                                   G_OBJECT_CLASS(klass));
@@ -2553,7 +2634,6 @@
     GdkColor tab_color;
 
     ENTER("window %p, page %p", window, page);
-
     if (window)
         g_return_if_fail (GNC_IS_MAIN_WINDOW (window));
     g_return_if_fail (GNC_IS_PLUGIN_PAGE (page));
@@ -2588,6 +2668,7 @@
     }
 
     page->window = GTK_WIDGET(window);
+    priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
     page->notebook_page = gnc_plugin_page_create_widget (page);
     g_object_set_data (G_OBJECT (page->notebook_page),
                        PLUGIN_PAGE_LABEL, page);
@@ -2619,16 +2700,12 @@
         gtk_box_pack_start (GTK_BOX (tab_hbox), label, TRUE, TRUE, 0);
 
     event_box = gtk_event_box_new();
-    /* Note: this doesn't work properly on Windows with gtk+2.18.x (last
-     * with 2.18.7). Setting the eventbox visible with that version results
-     * in the tab's text being invisible. See bug #610675 for more on this.
-     */
     gtk_event_box_set_visible_window(GTK_EVENT_BOX(event_box), TRUE);
     gtk_widget_show(event_box);
     gtk_container_add(GTK_CONTAINER(event_box), tab_hbox);
     color_string = gnc_plugin_page_get_page_color(page);
     if (color_string == NULL) color_string = "";
-    if (gdk_color_parse(color_string, &tab_color))
+    if (gdk_color_parse(color_string, &tab_color) && priv->show_color_tabs)
     {
         gtk_widget_modify_bg(event_box, GTK_STATE_NORMAL, &tab_color);
         gtk_widget_modify_bg(event_box, GTK_STATE_ACTIVE, &tab_color);

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c	2012-09-05 10:45:04 UTC (rev 22358)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account.c	2012-09-05 13:34:12 UTC (rev 22359)
@@ -416,6 +416,7 @@
     case GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM:
 
     case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT:
+    case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_ACCOUNT:
     case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE:
     case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE_PERIOD:
     case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED:
@@ -793,6 +794,11 @@
         g_free (string);
         break;
 
+    case GNC_TREE_MODEL_ACCOUNT_COL_COLOR_ACCOUNT:
+        g_value_init (value, G_TYPE_STRING);
+        g_value_set_string (value, xaccAccountGetColor (account));
+        break;
+
     case GNC_TREE_MODEL_ACCOUNT_COL_NOTES:
         g_value_init (value, G_TYPE_STRING);
         g_value_set_string (value, xaccAccountGetNotes (account));

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-account.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-account.h	2012-09-05 10:45:04 UTC (rev 22358)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-account.h	2012-09-05 13:34:12 UTC (rev 22359)
@@ -85,6 +85,7 @@
 
     /* internal hidden columns */
     GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
+    GNC_TREE_MODEL_ACCOUNT_COL_COLOR_ACCOUNT,
     GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
     GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE_PERIOD,
     GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c	2012-09-05 10:45:04 UTC (rev 22358)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-account.c	2012-09-05 13:34:12 UTC (rev 22359)
@@ -1,26 +1,26 @@
-/********************************************************************\
- * gnc-tree-view-account.c -- GtkTreeView implementation to display *
- *                            accounts in a GtkTreeView.            *
+/**********************************************************************\
+ * gnc-tree-view-account.c -- GtkTreeView implementation to display   *
+ *                            accounts in a GtkTreeView.              *
  * Copyright (C) 2003,2005,2006 David Hampton <hampton at employees.org> *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
+ *                                                                    *
+ * This program is free software; you can redistribute it and/or      *
+ * modify it under the terms of the GNU General Public License as     *
+ * published by the Free Software Foundation; either version 2 of     *
+ * the License, or (at your option) any later version.                *
+ *                                                                    *
+ * This program is distributed in the hope that it will be useful,    *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *
+ * GNU General Public License for more details.                       *
+ *                                                                    *
+ * You should have received a copy of the GNU General Public License  *
+ * along with this program; if not, contact:                          *
+ *                                                                    *
+ * Free Software Foundation           Voice:  +1-617-542-5942         *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652         *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                     *
+ *                                                                    *
+\**********************************************************************/
 
 #include "config.h"
 
@@ -40,6 +40,7 @@
 #include "gnc-engine.h"
 #include "gnc-glib-utils.h"
 #include "gnc-gobject-utils.h"
+#include "gnc-gconf-utils.h"
 #include "gnc-hooks.h"
 #include "gnc-session.h"
 #include "gnc-icons.h"
@@ -77,6 +78,15 @@
                                 GtkTreeIter       *iter,
                                 gpointer           view);
 
+static void acc_color_data_func (GtkTreeViewColumn *col,
+                                GtkCellRenderer   *renderer,
+                                GtkTreeModel      *model,
+                                GtkTreeIter       *iter,
+                                gpointer           view);
+
+static void gnc_tree_view_account_color_update (GConfEntry *entry, gpointer user_data);
+
+
 typedef struct GncTreeViewAccountPrivate
 {
     AccountViewInfo avi;
@@ -95,6 +105,9 @@
     GtkTreeViewColumn *future_min_report_column;
     GtkTreeViewColumn *total_report_column;
     GtkTreeViewColumn *notes_column;
+
+    gboolean show_account_color;
+
 } GncTreeViewAccountPrivate;
 
 #define GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(o)  \
@@ -175,6 +188,11 @@
     GncTreeViewAccountPrivate *priv;
 
     priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(view);
+
+    gnc_gconf_general_register_cb("show_account_color",
+                                  gnc_tree_view_account_color_update,
+                                  view);
+
     gnc_init_account_view_info(&priv->avi);
 }
 
@@ -191,6 +209,10 @@
     account_view = GNC_TREE_VIEW_ACCOUNT (object);
 
     priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(account_view);
+
+    gnc_gconf_general_remove_cb("show_account_color",
+                                gnc_tree_view_account_color_update,
+                                account_view);
     if (priv->filter_destroy)
     {
         priv->filter_destroy(priv->filter_data);
@@ -535,6 +557,107 @@
 }
 
 /************************************************************/
+/*                acc_color data function                   */
+/************************************************************/
+/*
+ * The account-color column in the account tree view is obtained
+ * from the GNC_TREE_MODEL_ACCOUNT_COL_COLOR_ACCOUNT which is
+ * checked for a valid color string to set the background color
+ * of the cell.
+ */
+static void
+update_cell_renderers (GList *renderers, gchar *account_color)
+{
+    GtkCellRenderer *cell;
+    GList *node;
+
+    /* Update the cell background in the list of renderers */
+    for (node = renderers; node; node = node->next)
+    {
+        cell = node->data;
+        g_object_set (cell, "cell-background", account_color, NULL);
+    }
+}
+
+static void
+acc_color_data_func (GtkTreeViewColumn *col,
+                    GtkCellRenderer   *renderer,
+                    GtkTreeModel      *model,
+                    GtkTreeIter       *iter,
+                    gpointer           view)
+{
+    GncTreeViewAccountPrivate *priv;
+    gchar                     *acc_color = NULL;
+    gchar                     *item;
+    GdkColor                   color;
+    gchar                     *column_name;
+    GList                     *renderers;
+
+    gboolean                   valid_color = TRUE;
+
+    gtk_tree_model_get(model,
+                       iter,
+                       GNC_TREE_MODEL_ACCOUNT_COL_COLOR_ACCOUNT,
+                       &item,
+                       -1);
+
+    /* Check for NULL */
+    if ((item == NULL) || (*item == '\0'))
+        acc_color = g_strdup("Not Set");
+    else
+        acc_color = g_strstrip(g_strdup(item));
+
+    /* Parse the color string for valid color */
+    if (!gdk_color_parse(acc_color, &color))
+        valid_color = FALSE;
+
+    priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(view);
+
+    column_name = g_object_get_data(G_OBJECT(col), PREF_NAME);
+
+    renderers = gtk_cell_layout_get_cells (GTK_CELL_LAYOUT (col));
+
+    if(valid_color == TRUE)
+    {
+        /* Test for Account Color column and gconf preference. */
+        if (g_strcmp0(column_name, "account-color") == 0)
+            update_cell_renderers (renderers, acc_color);
+        else
+        {
+            if (priv->show_account_color == TRUE)
+                update_cell_renderers (renderers, acc_color);
+            else
+                update_cell_renderers (renderers, NULL);
+        }
+    }
+    else
+        update_cell_renderers (renderers, NULL);
+
+    g_list_free (renderers);
+    g_free (acc_color);
+    g_free (item);
+}
+
+/** Tell the GncTreeViewAccount code to show or not show the
+ *  Account name column with background in the account color.
+ *
+ *  @internal
+ */
+static void
+gnc_tree_view_account_color_update (GConfEntry *entry, gpointer user_data)
+{
+    GncTreeViewAccountPrivate *priv;
+    GncTreeViewAccount *view;
+    GConfValue *value;
+
+    g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(user_data));
+    view = user_data;
+    priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(view);
+    value = gconf_entry_get_value(entry);
+    priv->show_account_color = gconf_value_get_bool(value);
+}
+
+/************************************************************/
 /*                    New View Creation                     */
 /************************************************************/
 
@@ -552,7 +675,7 @@
     GtkTreePath *virtual_root_path = NULL;
     const gchar *sample_type, *sample_commodity;
     GncTreeViewAccountPrivate *priv;
-    GtkTreeViewColumn *tax_info_column;
+    GtkTreeViewColumn *tax_info_column, *acc_color_column;
     GtkCellRenderer *renderer;
 
     ENTER(" ");
@@ -562,6 +685,9 @@
 
     priv = GNC_TREE_VIEW_ACCOUNT_GET_PRIVATE(GNC_TREE_VIEW_ACCOUNT (view));
 
+    /* Get the show_account_color value from gconf */
+    priv->show_account_color = gnc_gconf_get_bool(GCONF_GENERAL, "show_account_color", NULL);
+
     /* Create/get a pointer to the existing model for this set of books. */
     model = gnc_tree_model_account_new (root);
 
@@ -593,10 +719,20 @@
                                     GNC_TREE_MODEL_ACCOUNT_COL_NAME,
                                     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                     sort_by_string);
+
+    renderer = gnc_tree_view_column_get_renderer(priv->name_column);
+
+    gtk_tree_view_column_set_cell_data_func(priv->name_column,
+                                            renderer,
+                                            acc_color_data_func,
+                                            GTK_TREE_VIEW(view),
+                                            NULL);
+
     gnc_tree_view_add_text_column(view, _("Type"), "type", NULL, sample_type,
                                   GNC_TREE_MODEL_ACCOUNT_COL_TYPE,
                                   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                   sort_by_string);
+
     gnc_tree_view_add_text_column(view, _("Commodity"), "commodity", NULL,
                                   sample_commodity,
                                   GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY,
@@ -614,11 +750,13 @@
                                     GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION,
                                     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                     sort_by_string);
+
     gnc_tree_view_add_numeric_column(view, _("Last Num"), "lastnum", "12345",
                                      GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM,
                                      GNC_TREE_VIEW_COLUMN_COLOR_NONE,
                                      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                      sort_by_string);
+
     gnc_tree_view_add_numeric_column(view, _("Present"), "present",
                                      SAMPLE_ACCOUNT_VALUE,
                                      GNC_TREE_MODEL_ACCOUNT_COL_PRESENT,
@@ -632,6 +770,7 @@
                                        GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
                                        GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                        sort_by_present_value);
+
     gnc_tree_view_add_numeric_column(view, _("Balance"), "balance",
                                      SAMPLE_ACCOUNT_VALUE,
                                      GNC_TREE_MODEL_ACCOUNT_COL_BALANCE,
@@ -652,6 +791,7 @@
                                      GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE_PERIOD,
                                      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                      sort_by_balance_period_value);
+
     gnc_tree_view_add_numeric_column(view, _("Cleared"), "cleared",
                                      SAMPLE_ACCOUNT_VALUE,
                                      GNC_TREE_MODEL_ACCOUNT_COL_CLEARED,
@@ -665,6 +805,7 @@
                                        GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
                                        GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                        sort_by_cleared_value);
+
     gnc_tree_view_add_numeric_column(view, _("Reconciled"), "reconciled",
                                      SAMPLE_ACCOUNT_VALUE,
                                      GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED,
@@ -678,11 +819,13 @@
                                        GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
                                        GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                        sort_by_reconciled_value);
+
     gnc_tree_view_add_text_column(view, _("Last Reconcile Date"), "last-recon-date", NULL,
                                   "Last Reconcile Date",
                                   GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_DATE,
                                   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                   sort_by_string);
+
     gnc_tree_view_add_numeric_column(view, _("Future Minimum"), "future_min",
                                      SAMPLE_ACCOUNT_VALUE,
                                      GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN,
@@ -696,6 +839,7 @@
                                         GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
                                         GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                         sort_by_future_min_value);
+
     gnc_tree_view_add_numeric_column(view, _("Total"), "total",
                                      SAMPLE_ACCOUNT_VALUE,
                                      GNC_TREE_MODEL_ACCOUNT_COL_TOTAL,
@@ -709,12 +853,33 @@
                                        GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
                                        GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                        sort_by_total_value);
+
     gnc_tree_view_add_numeric_column(view, _("Total (Period)"), "total-period",
                                      SAMPLE_ACCOUNT_VALUE,
                                      GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_PERIOD,
                                      GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL_PERIOD,
                                      GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                      sort_by_total_period_value);
+
+    /* Translators: The C is the column title and stands for Color, this should be one character */
+    acc_color_column
+    = gnc_tree_view_add_text_column(view, _("C"), "account-color", NULL,
+                                    "xx",
+                                    GNC_TREE_VIEW_COLUMN_DATA_NONE,
+                                    GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+                                    NULL);
+
+    renderer = gnc_tree_view_column_get_renderer(acc_color_column);
+
+    /* Add the full title to the object for menu creation */
+    g_object_set_data_full(G_OBJECT(acc_color_column), REAL_TITLE,
+                           g_strdup(_("Account Color")), g_free);
+
+    gtk_tree_view_column_set_cell_data_func(acc_color_column,
+                                            renderer,
+                                            acc_color_data_func,
+                                            GTK_TREE_VIEW(view),
+                                            NULL);
     priv->notes_column
     = gnc_tree_view_add_text_column(view, _("Notes"), "notes", NULL,
                                     "Sample account notes.",
@@ -727,12 +892,14 @@
                                     GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
                                     GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
                                     sort_by_string);
+
     renderer = gnc_tree_view_column_get_renderer(tax_info_column);
     gtk_tree_view_column_set_cell_data_func(tax_info_column,
                                             renderer,
                                             tax_info_data_func,
                                             GTK_TREE_VIEW(view),
                                             NULL);
+
     gnc_tree_view_add_toggle_column(view, _("Placeholder"),
                                     /* Translators: This string has a context prefix; the translation
                                     	must only contain the part after the | character. */

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-account.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-account.h	2012-09-05 10:45:04 UTC (rev 22358)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-account.h	2012-09-05 13:34:12 UTC (rev 22359)
@@ -1,26 +1,26 @@
-/********************************************************************\
- * gnc-tree-view-account.h -- GtkTreeView implementation to display *
- *                            accounts in a GtkTreeView.            *
+/**********************************************************************\
+ * gnc-tree-view-account.h -- GtkTreeView implementation to display   *
+ *                            accounts in a GtkTreeView.              *
  * Copyright (C) 2003,2005,2006 David Hampton <hampton at employees.org> *
- *                                                                  *
- * This program is free software; you can redistribute it and/or    *
- * modify it under the terms of the GNU General Public License as   *
- * published by the Free Software Foundation; either version 2 of   *
- * the License, or (at your option) any later version.              *
- *                                                                  *
- * This program is distributed in the hope that it will be useful,  *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
- * GNU General Public License for more details.                     *
- *                                                                  *
- * You should have received a copy of the GNU General Public License*
- * along with this program; if not, contact:                        *
- *                                                                  *
- * Free Software Foundation           Voice:  +1-617-542-5942       *
- * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
- * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
- *                                                                  *
-\********************************************************************/
+ *                                                                    *
+ * This program is free software; you can redistribute it and/or      *
+ * modify it under the terms of the GNU General Public License as     *
+ * published by the Free Software Foundation; either version 2 of     *
+ * the License, or (at your option) any later version.                *
+ *                                                                    *
+ * This program is distributed in the hope that it will be useful,    *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of     *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the      *
+ * GNU General Public License for more details.                       *
+ *                                                                    *
+ * You should have received a copy of the GNU General Public License  *
+ * along with this program; if not, contact:                          *
+ *                                                                    *
+ * Free Software Foundation           Voice:  +1-617-542-5942         *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652         *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                     *
+ *                                                                    *
+\**********************************************************************/
 
 /** @addtogroup GUI
     @{ */
@@ -64,8 +64,8 @@
 
 typedef struct
 {
-    GncTreeView gnc_tree_view;
-    int stamp;
+    GncTreeView   gnc_tree_view;
+    int           stamp;
 } GncTreeViewAccount;
 
 typedef struct
@@ -75,15 +75,15 @@
 
 typedef	struct
 {
-    GtkWidget    *dialog;
-    GtkTreeModel *model;
+    GtkWidget           *dialog;
+    GtkTreeModel        *model;
     GncTreeViewAccount  *tree_view;
-    guint32      visible_types;
-    guint32      original_visible_types;
-    gboolean     show_hidden;
-    gboolean     original_show_hidden;
-    gboolean     show_zero_total;
-    gboolean     original_show_zero_total;
+    guint32              visible_types;
+    guint32              original_visible_types;
+    gboolean             show_hidden;
+    gboolean             original_show_hidden;
+    gboolean             show_zero_total;
+    gboolean             original_show_zero_total;
 } AccountFilterDialog;
 
 void account_filter_dialog_create(AccountFilterDialog *fd,

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view.c	2012-09-05 10:45:04 UTC (rev 22358)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view.c	2012-09-05 13:34:12 UTC (rev 22359)
@@ -45,22 +45,6 @@
 #include "gnc-gobject-utils.h"
 #include "gnc-cell-renderer-date.h"
 
-/* The column id refers to a specific column in the tree model.  It is
- * also attached to the side of the tree column to allow lookup of a
- * GtkTreeViewColumn when passed a column id from the underlying
- * model. By convention, negative column numbers are used when the
- * visible column has no association with the underlying model.*/
-#define MODEL_COLUMN "model_column"
-
-/* For checkbox columns, this contains the real title for the column. */
-#define REAL_TITLE  "real_title"
-
-/* The name of this column as it should appear in gconf.  This is
- * attached to the column when it is created, and used to map back and
- * forth to gconf keys.  The actual gconf keys are built from these
- * strings. */
-#define PREF_NAME  "pref-name"
-
 /* The actual gconf key for a particular column visibility.  This is
  * attached to the menu items that are in the column selection menu.
  * Makes it very easy to update gconf when a menu item is toggled. */

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view.h	2012-09-05 10:45:04 UTC (rev 22358)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view.h	2012-09-05 13:34:12 UTC (rev 22359)
@@ -68,6 +68,22 @@
    g_object_set_data(col, ATTRIBUTE_NAME, value);
 */
 
+/* The column id refers to a specific column in the tree model.  It is
+ * also attached to the side of the tree column to allow lookup of a
+ * GtkTreeViewColumn when passed a column id from the underlying
+ * model. By convention, negative column numbers are used when the
+ * visible column has no association with the underlying model.*/
+#define MODEL_COLUMN "model_column"
+
+/* For checkbox columns, this contains the real title for the column. */
+#define REAL_TITLE  "real_title"
+
+/* The name of this column as it should appear in gconf.  This is
+ * attached to the column when it is created, and used to map back and
+ * forth to gconf keys.  The actual gconf keys are built from these
+ * strings. */
+#define PREF_NAME  "pref-name"
+
 /* A column with this attribute set cannot be hidden from view. Valid
    values: GINT_TO_POINTER(0) and GINT_TO_POINTER(1) */
 #define ALWAYS_VISIBLE  "always-visible"

Modified: gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade
===================================================================
--- gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade	2012-09-05 10:45:04 UTC (rev 22358)
+++ gnucash/trunk/src/gnome-utils/gtkbuilder/dialog-preferences.glade	2012-09-05 13:34:12 UTC (rev 22359)
@@ -743,6 +743,81 @@
                   </packing>
                 </child>
                 <child>
+                  <object class="GtkLabel" id="label11">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes"><b>Account Color</b></property>
+                    <property name="use_markup">True</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">16</property>
+                    <property name="bottom_attach">17</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="gconf/general/show_account_color">
+                    <property name="label" translatable="yes">Show the Account Color as background</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="tooltip_markup">Show the Account Color as Account Name Background</property>
+                    <property name="tooltip_text" translatable="yes">Show the Account Color as Account Name Background</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">4</property>
+                    <property name="top_attach">17</property>
+                    <property name="bottom_attach">18</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                    <property name="x_padding">12</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label13">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="xalign">0</property>
+                  </object>
+                  <packing>
+                    <property name="top_attach">15</property>
+                    <property name="bottom_attach">16</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkCheckButton" id="gconf/general/show_account_color_tabs">
+                    <property name="label" translatable="yes">Show the Account Color on tabs</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="receives_default">False</property>
+                    <property name="has_tooltip">True</property>
+                    <property name="tooltip_markup">Show the Account Color as tab background</property>
+                    <property name="tooltip_text" translatable="yes">Show the Account Color as tab background</property>
+                    <property name="use_action_appearance">False</property>
+                    <property name="use_underline">True</property>
+                    <property name="xalign">0</property>
+                    <property name="draw_indicator">True</property>
+                  </object>
+                  <packing>
+                    <property name="right_attach">4</property>
+                    <property name="top_attach">18</property>
+                    <property name="bottom_attach">19</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options"></property>
+                    <property name="x_padding">12</property>
+                  </packing>
+                 </child>
+                <child>
                   <placeholder/>
                 </child>
                 <child>



More information about the gnucash-changes mailing list