[Gnucash-changes] Base these views on the new common gnc-tree-view class.

David Hampton hampton at cvs.gnucash.org
Sat May 21 00:55:19 EDT 2005


Log Message:
-----------
Base these views on the new common gnc-tree-view class.

Tags:
----
gnucash-gnome2-dev

Modified Files:
--------------
    gnucash/src/gnome-utils:
        gnc-tree-view-account.c
        gnc-tree-view-account.h
        gnc-tree-view-commodity.c
        gnc-tree-view-commodity.h
        gnc-tree-view-price.c
        gnc-tree-view-price.h

Revision Data
-------------
Index: gnc-tree-view-commodity.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-tree-view-commodity.c,v
retrieving revision 1.1.2.7
retrieving revision 1.1.2.8
diff -Lsrc/gnome-utils/gnc-tree-view-commodity.c -Lsrc/gnome-utils/gnc-tree-view-commodity.c -u -r1.1.2.7 -r1.1.2.8
--- src/gnome-utils/gnc-tree-view-commodity.c
+++ src/gnome-utils/gnc-tree-view-commodity.c
@@ -27,8 +27,8 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
+#include "gnc-tree-view.h"
 #include "gnc-tree-model-commodity.h"
-#include "gnc-tree-view-common.h"
 #include "gnc-tree-view-commodity.h"
 
 #include "gnc-commodity.h"
@@ -59,9 +59,6 @@
   gboolean show_currencies;
 };
 
-/* Defined at the end of the file */
-static gnc_view_column view_column_defaults[];
-
 
 /************************************************************/
 /*               g_object required functions                */
@@ -87,7 +84,7 @@
 			(GInstanceInitFunc) gnc_tree_view_commodity_init
 		};
 		
-		gnc_tree_view_commodity_type = g_type_register_static (GTK_TYPE_TREE_VIEW,
+		gnc_tree_view_commodity_type = g_type_register_static (GNC_TYPE_TREE_VIEW,
 								     "GncTreeViewCommodity",
 								     &our_info, 0);
 	}
@@ -466,17 +463,22 @@
  * model.
  */
 GtkTreeView *
-gnc_tree_view_commodity_new (QofBook *book)
+gnc_tree_view_commodity_new (QofBook *book,
+			     const gchar *first_property_name,
+			     ...)
 {
-  GncTreeViewCommodity *view;
-  GtkTreeView *tree_view;
+  GncTreeView *view;
   GtkTreeModel *model, *f_model, *s_model;
   gnc_commodity_table *ct;
+  va_list var_args;
 
   ENTER(" ");
   /* Create our view */
-  view = g_object_new (GNC_TYPE_TREE_VIEW_COMMODITY, "name", "commodity_tree", NULL);
-  tree_view = GTK_TREE_VIEW (view);
+  va_start (var_args, first_property_name);
+  view = (GncTreeView *)g_object_new_valist (GNC_TYPE_TREE_VIEW_COMMODITY,
+					     first_property_name, var_args);
+  va_end (var_args);
+  g_object_set(view, "name", "commodity_tree", NULL);
 
   /* Create/get a pointer to the existing model for this set of books. */
   ct = gnc_book_get_commodity_table (book);
@@ -487,7 +489,7 @@
   gtk_object_sink(GTK_OBJECT(model));
   s_model = gtk_tree_model_sort_new_with_model (f_model);
   g_object_unref(G_OBJECT(f_model));
-  gtk_tree_view_set_model (tree_view, s_model);
+  gnc_tree_view_set_model (view, s_model);
   g_object_unref(G_OBJECT(s_model));
 
   DEBUG("model ref count is %d",   G_OBJECT(model)->ref_count);
@@ -495,14 +497,65 @@
   DEBUG("s_model ref count is %d", G_OBJECT(s_model)->ref_count);
 
   /* Set default visibilities */
-  gtk_tree_view_set_headers_visible (tree_view, FALSE);
-
-  gnc_tree_view_common_create_columns (tree_view, "Commodities", NULL,
-				       view_column_defaults);
+  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
 
-  gtk_widget_show(GTK_WIDGET(tree_view));
-  LEAVE(" %p", tree_view);
-  return tree_view;
+  gnc_tree_view_add_text_column (view, N_("Namespace"), "namespace", NULL,
+				 "NASDAQ",
+				 GNC_TREE_MODEL_COMMODITY_COL_NAMESPACE,
+				 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				 sort_by_namespace);
+  gnc_tree_view_add_text_column (view, N_("Symbol"), "symbol", NULL,
+				 "ACMEACME",
+				 GNC_TREE_MODEL_COMMODITY_COL_MNEMONIC,
+				 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
+				 sort_by_mnemonic);
+  gnc_tree_view_add_text_column (view, N_("Name"), "name", NULL,
+				 "Acme Corporation, Inc.",
+				 GNC_TREE_MODEL_COMMODITY_COL_FULLNAME,
+				 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
+				 sort_by_fullname);
+  gnc_tree_view_add_text_column (view, N_("Print Name"), "printname", NULL,
+				 "ACMEACME (Acme Corporation, Inc.)",
+				 GNC_TREE_MODEL_COMMODITY_COL_PRINTNAME,
+				 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
+				 sort_by_printname);
+  gnc_tree_view_add_text_column (view, N_("Unique Name"), "uniquename", NULL,
+				 "NASDAQ::ACMEACME",
+				 GNC_TREE_MODEL_COMMODITY_COL_UNIQUE_NAME,
+				 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
+				 sort_by_unique_name);
+  gnc_tree_view_add_text_column (view, N_("CUSIP code"), "cusip_code", NULL,
+				 "QWERTYUIOP",
+				 GNC_TREE_MODEL_COMMODITY_COL_EXCHANGE_CODE,
+				 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
+				 sort_by_cusip_code);
+  gnc_tree_view_add_numeric_column (view, N_("Fraction"), "fraction", "10000",
+				    GNC_TREE_MODEL_COMMODITY_COL_FRACTION,
+				    GNC_TREE_VIEW_COLUMN_COLOR_NONE,
+				    GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
+				    sort_by_fraction);
+  gnc_tree_view_add_toggle_column (view, N_("Get Quotes"), "Q", "quote_flag",
+				   GNC_TREE_MODEL_COMMODITY_COL_QUOTE_FLAG,
+				   GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
+				   sort_by_quote_flag,
+				   NULL);
+  gnc_tree_view_add_text_column (view, N_("Source"), "quote_source", NULL,
+				 "yahoo",
+				 GNC_TREE_MODEL_COMMODITY_COL_QUOTE_SOURCE,
+				 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
+				 sort_by_quote_source);
+  gnc_tree_view_add_text_column (view, N_("Timezone"), "quote_timezone", NULL,
+				 "America/New_York",
+				 GNC_TREE_MODEL_COMMODITY_COL_QUOTE_TZ,
+				 GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
+				 sort_by_quote_tz);
+
+  gnc_tree_view_configure_columns(view, "symbol", "name", "cusip_code",
+				  "fraction", NULL);
+
+  gtk_widget_show(GTK_WIDGET(view));
+  LEAVE(" %p", view);
+  return GTK_TREE_VIEW(view);
 }
 
 /************************************************************/
@@ -1077,121 +1130,3 @@
     return account;
 }
 #endif
-
-
-/************************************************************/
-/*         Commodity Tree View Get/Save Settings            */
-/************************************************************/
-
-void
-gnc_tree_view_commodity_save_settings (GncTreeViewCommodity *view, const gchar *section)
-{
-  gnc_tree_view_common_save_settings (GTK_TREE_VIEW(view), section,
-				      view_column_defaults);
-}
-
-void
-gnc_tree_view_commodity_restore_settings (GncTreeViewCommodity *view, const gchar *section)
-{
-  gnc_tree_view_common_restore_settings (GTK_TREE_VIEW(view), section,
-					 view_column_defaults);
-}
-
-
-/************************************************************/
-/*                    Column Definitions                    */
-/************************************************************/
-
-static gnc_view_column view_column_defaults[] = {
-  {GNC_TREE_MODEL_COMMODITY_COL_NAMESPACE,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_namespace,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "namespace",
-   N_("Namespace")},
-  {GNC_TREE_MODEL_COMMODITY_COL_MNEMONIC,
-   GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_mnemonic,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "symbol",
-   N_("Symbol")},
-  {GNC_TREE_MODEL_COMMODITY_COL_FULLNAME,
-   GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_fullname,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "name",
-   N_("Name")},
-  {GNC_TREE_MODEL_COMMODITY_COL_PRINTNAME,
-   GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_printname,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "printname",
-   N_("Print Name")},
-  {GNC_TREE_MODEL_COMMODITY_COL_UNIQUE_NAME,
-   GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_unique_name,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "uniquename",
-   N_("Unique Name")},
-  {GNC_TREE_MODEL_COMMODITY_COL_EXCHANGE_CODE,
-   GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_cusip_code,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "cusip_code",
-   N_("CUSIP Code")},
-  {GNC_TREE_MODEL_COMMODITY_COL_FRACTION,
-   GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   1.0, GNC_TREE_MODEL_COMMODITY_COL_ALIGN_RIGHT,
-   sort_by_fraction,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "fraction",
-   N_("Fraction")},
-  {GNC_TREE_MODEL_COMMODITY_COL_QUOTE_FLAG,
-   GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_quote_flag,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   TRUE, NULL,
-   "quote_flag",
-   N_("Quotes")},
-  {GNC_TREE_MODEL_COMMODITY_COL_QUOTE_SOURCE,
-   GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_quote_source,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "quote_source",
-   N_("Source")},
-  {GNC_TREE_MODEL_COMMODITY_COL_QUOTE_TZ,
-   GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_quote_tz,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "quote_timezone",
-   N_("Timezone")},
-  { 0 }
-};
Index: gnc-tree-view-price.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-tree-view-price.c,v
retrieving revision 1.1.2.5
retrieving revision 1.1.2.6
diff -Lsrc/gnome-utils/gnc-tree-view-price.c -Lsrc/gnome-utils/gnc-tree-view-price.c -u -r1.1.2.5 -r1.1.2.6
--- src/gnome-utils/gnc-tree-view-price.c
+++ src/gnome-utils/gnc-tree-view-price.c
@@ -27,8 +27,8 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
+#include "gnc-tree-view.h"
 #include "gnc-tree-model-price.h"
-#include "gnc-tree-view-common.h"
 #include "gnc-tree-view-price.h"
 
 #include "gnc-pricedb.h"
@@ -38,6 +38,7 @@
 #include "gnc-gnome-utils.h"
 #include "gnc-icons.h"
 #include "gnc-ui-util.h"
+#include "global-options.h"
 //#include "messages.h"
 #include <libgnome/libgnome.h>
 
@@ -59,9 +60,6 @@
   gboolean show_currencies;
 };
 
-/* Defined at the end of the file */
-static gnc_view_column view_column_defaults[];
-
 
 /************************************************************/
 /*               g_object required functions                */
@@ -87,7 +85,7 @@
 			(GInstanceInitFunc) gnc_tree_view_price_init
 		};
 		
-		gnc_tree_view_price_type = g_type_register_static (GTK_TYPE_TREE_VIEW,
+		gnc_tree_view_price_type = g_type_register_static (GNC_TYPE_TREE_VIEW,
 								     "GncTreeViewPrice",
 								     &our_info, 0);
 	}
@@ -405,17 +403,24 @@
  * model.
  */
 GtkTreeView *
-gnc_tree_view_price_new (QofBook *book)
+gnc_tree_view_price_new (QofBook *book,
+			 const gchar *first_property_name,
+			 ...)
 {
-  GncTreeViewPrice *view;
-  GtkTreeView *tree_view;
+  GncTreeView *view;
   GtkTreeModel *model, *f_model, *s_model;
   GNCPriceDB *price_db;
+  va_list var_args;
+  const gchar *sample_text;
+  gchar *sample_text2;
 
   ENTER(" ");
   /* Create our view */
-  view = g_object_new (GNC_TYPE_TREE_VIEW_PRICE, "name", "price_tree", NULL);
-  tree_view = GTK_TREE_VIEW (view);
+  va_start (var_args, first_property_name);
+  view = (GncTreeView *)g_object_new_valist (GNC_TYPE_TREE_VIEW_PRICE,
+					     first_property_name, var_args);
+  va_end (var_args);
+  g_object_set(view, "name", "price_tree", NULL);
 
   /* Create/get a pointer to the existing model for this set of books. */
   price_db = gnc_pricedb_get_db(book);
@@ -426,22 +431,52 @@
   gtk_object_sink(GTK_OBJECT(model));
   s_model = gtk_tree_model_sort_new_with_model (f_model);
   g_object_unref(G_OBJECT(f_model));
-  gtk_tree_view_set_model (tree_view, s_model);
+  gnc_tree_view_set_model (view, s_model);
   g_object_unref(G_OBJECT(s_model));
 
   DEBUG("model ref count is %d",   G_OBJECT(model)->ref_count);
   DEBUG("f_model ref count is %d", G_OBJECT(f_model)->ref_count);
   DEBUG("s_model ref count is %d", G_OBJECT(s_model)->ref_count);
 
-  /* Set default visibilities */
-  gtk_tree_view_set_headers_visible (tree_view, FALSE);
-
-  gnc_tree_view_common_create_columns (tree_view, "Prices", NULL,
-				       view_column_defaults);
-
-  gtk_widget_show(GTK_WIDGET(tree_view));
-  LEAVE(" %p", tree_view);
-  return tree_view;
+  sample_text = gnc_commodity_get_printname(gnc_default_currency());
+  sample_text2 = g_strdup_printf("%s%s", sample_text, sample_text);
+  gnc_tree_view_add_text_column (view, N_("Commodity"), "commodity", NULL,
+				 sample_text2,
+				 GNC_TREE_MODEL_PRICE_COL_COMMODITY,
+				 GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				 sort_by_name);
+  g_free(sample_text2);
+  gnc_tree_view_add_text_column (view, N_("Currency"), "currency", NULL,
+				 sample_text,
+				 GNC_TREE_MODEL_PRICE_COL_CURRENCY,
+				 GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
+				 sort_by_name);
+  gnc_tree_view_add_text_column (view, N_("Date"), "date", NULL,
+				 "2005-05-20",
+				 GNC_TREE_MODEL_PRICE_COL_DATE,
+				 GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
+				 sort_by_date);
+  gnc_tree_view_add_text_column (view, N_("Source"), "source", NULL,
+				 "Finance::Quote",
+				 GNC_TREE_MODEL_PRICE_COL_SOURCE,
+				 GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
+				 sort_by_source);
+  gnc_tree_view_add_text_column (view, N_("Type"), "type", NULL, "last",
+				 GNC_TREE_MODEL_PRICE_COL_TYPE,
+				 GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
+				 sort_by_type);
+  gnc_tree_view_add_numeric_column (view, N_("Price"), "price", "100.00000",
+				    GNC_TREE_MODEL_PRICE_COL_VALUE,
+				    GNC_TREE_VIEW_COLUMN_COLOR_NONE,
+				    GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
+				    sort_by_value);
+
+  gnc_tree_view_configure_columns(view, "commodity", "currency",
+				  "date", "source", "type", "price", NULL);
+
+  gtk_widget_show(GTK_WIDGET(view));
+  LEAVE(" %p", view);
+  return GTK_TREE_VIEW(view);
 }
 
 /************************************************************/
@@ -1026,85 +1061,3 @@
     return account;
 }
 #endif
-
-
-/************************************************************/
-/*         Price Tree View Save/Restore Settings            */
-/************************************************************/
-
-void
-gnc_tree_view_price_save_settings (GncTreeViewPrice *view, const gchar *section)
-{
-  gnc_tree_view_common_save_settings (GTK_TREE_VIEW(view), section,
-				      view_column_defaults);
-}
-
-void
-gnc_tree_view_price_restore_settings (GncTreeViewPrice *view, const gchar *section)
-{
-  gnc_tree_view_common_restore_settings (GTK_TREE_VIEW(view), section,
-					 view_column_defaults);
-}
-
-
-/************************************************************/
-/*                    Column Definitions                    */
-/************************************************************/
-
-static gnc_view_column view_column_defaults[] = {
-  {GNC_TREE_MODEL_PRICE_COL_COMMODITY,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_name,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "commodity",
-   N_("Commodity")},
-  {GNC_TREE_MODEL_PRICE_COL_CURRENCY,
-   GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_name,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "currency",
-   N_("Currency")},
-  {GNC_TREE_MODEL_PRICE_COL_DATE,
-   GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_date,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "date",
-   N_("Date")},
-  {GNC_TREE_MODEL_PRICE_COL_SOURCE,
-   GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_source,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "source",
-   N_("Source")},
-  {GNC_TREE_MODEL_PRICE_COL_TYPE,
-   GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_type,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "type",
-   N_("Type")},
-  {GNC_TREE_MODEL_PRICE_COL_VALUE,
-   GNC_TREE_MODEL_PRICE_COL_VISIBILITY,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   1.0, GNC_TREE_MODEL_PRICE_COL_ALIGN_RIGHT,
-   sort_by_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "price",
-   N_("Price")},
-  { 0 }
-};
Index: gnc-tree-view-account.c
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-tree-view-account.c,v
retrieving revision 1.1.2.18
retrieving revision 1.1.2.19
diff -Lsrc/gnome-utils/gnc-tree-view-account.c -Lsrc/gnome-utils/gnc-tree-view-account.c -u -r1.1.2.18 -r1.1.2.19
--- src/gnome-utils/gnc-tree-view-account.c
+++ src/gnome-utils/gnc-tree-view-account.c
@@ -27,9 +27,9 @@
 #include <gtk/gtk.h>
 #include <string.h>
 
+#include "gnc-tree-view.h"
 #include "gnc-tree-model-account.h"
 #include "gnc-tree-view-account.h"
-#include "gnc-tree-view-common.h"
 
 #include "Account.h"
 #include "Group.h"
@@ -38,9 +38,12 @@
 #include "gnc-engine-util.h"
 #include "gnc-icons.h"
 #include "gnc-ui-util.h"
+#include "global-options.h"
 #include "messages.h"
 
 
+#define SAMPLE_ACCOUNT_VALUE "$1,000,000.00"
+
 /** Static Globals *******************************************************/
 
 /* This static indicates the debugging module that this .o belongs to.  */
@@ -66,9 +69,6 @@
     GtkDestroyNotify                  filter_destroy;
 };
 
-/* Defined at the end of the file */
-static gnc_view_column view_column_defaults[];
-
 
 /************************************************************/
 /*               g_object required functions                */
@@ -94,7 +94,7 @@
 			(GInstanceInitFunc) gnc_tree_view_account_init
 		};
 		
-		gnc_tree_view_account_type = g_type_register_static (GTK_TYPE_TREE_VIEW,
+		gnc_tree_view_account_type = g_type_register_static (GNC_TYPE_TREE_VIEW,
 								     "GncTreeViewAccount",
 								     &our_info, 0);
 	}
@@ -155,13 +155,6 @@
 
   for (i = 0; i < NUM_ACCOUNT_TYPES; i++)
     avi->include_type[i] = TRUE;
-
-  for (i = 0; i < NUM_ACCOUNT_FIELDS; i++)
-    avi->show_field[i] = FALSE;
-
-  avi->show_field[ACCOUNT_NAME] = TRUE;
-  avi->show_field[ACCOUNT_DESCRIPTION] = TRUE;
-  avi->show_field[ACCOUNT_TOTAL] = TRUE;
 }
 
 static void
@@ -367,7 +360,7 @@
   account = gnc_tree_model_account_get_account (GNC_TREE_MODEL_ACCOUNT(model), &iter);
   flag_b = xaccAccountGetPlaceholder(account);
 
-  if (flag_a < flag_b)
+  if (flag_a > flag_b)
     return -1;
   else if (flag_a == flag_b)
     return 0;
@@ -388,15 +381,14 @@
 GtkTreeView *
 gnc_tree_view_account_new_with_group (AccountGroup *group, gboolean show_root)
 {
-  GncTreeViewAccount *account_view;
-  GtkTreeView *tree_view;
+  GncTreeView *view;
   GtkTreeModel *model, *f_model, *s_model;
   GtkTreePath *virtual_root_path = NULL;
+  const gchar *sample_type, *sample_commodity;
 
   ENTER(" ");
   /* Create our view */
-  account_view = g_object_new (GNC_TYPE_TREE_VIEW_ACCOUNT, "name", "account_tree", NULL);
-  tree_view = GTK_TREE_VIEW (account_view);
+  view = g_object_new (GNC_TYPE_TREE_VIEW_ACCOUNT, "name", "account_tree", NULL);
 
   /* Create/get a pointer to the existing model for this set of books. */
   model = gnc_tree_model_account_new (group);
@@ -411,24 +403,141 @@
 
   /* Set up the view private sort layer on the common model. */
   s_model = gtk_tree_model_sort_new_with_model(f_model);
-  gtk_tree_view_set_model (tree_view, s_model);
+  gnc_tree_view_set_model (view, s_model);
   g_object_unref(G_OBJECT(f_model));
 
   /* Set default visibilities */
-  gtk_tree_view_set_headers_visible (tree_view, FALSE);
-  gnc_tree_view_account_init_view_info(&account_view->priv->avi);
+  gtk_tree_view_set_headers_visible (GTK_TREE_VIEW(view), FALSE);
 
-  gnc_tree_view_common_create_columns (tree_view, "Accounts", 
-                                       GNC_STOCK_ACCOUNT,
-				       view_column_defaults);
+  sample_type = xaccAccountGetTypeStr(CREDIT);
+  sample_commodity = gnc_commodity_get_fullname(gnc_default_currency());
+
+  gnc_tree_view_add_text_column(view, N_("Account Name"), "name",
+				GNC_STOCK_ACCOUNT, "Expenses:Entertainment",
+				GNC_TREE_MODEL_ACCOUNT_COL_NAME,
+				GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				NULL);
+  gnc_tree_view_add_text_column(view, N_("Type"), "type", NULL, sample_type,
+				GNC_TREE_MODEL_ACCOUNT_COL_TYPE,
+				GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				NULL);
+  gnc_tree_view_add_text_column(view, N_("Commodity"), "commodity", NULL,
+				sample_commodity,
+				GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY,
+				GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				NULL);
+  gnc_tree_view_add_text_column(view, N_("Account Code"), "account-code", NULL,
+				"1-123-1234",
+				GNC_TREE_MODEL_ACCOUNT_COL_CODE,
+				GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				NULL);
+  gnc_tree_view_add_text_column(view, N_("Description"), "description", NULL,
+				"Sample account description.",
+				GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION,
+				GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				NULL);
+  gnc_tree_view_add_numeric_column(view, N_("Last Num"), "lastnum", "12345",
+				   GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM,
+				   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
+				   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				   NULL);
+  gnc_tree_view_add_numeric_column(view, N_("Present"), "present",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_PRESENT,
+				   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
+				   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				   sort_by_present_value);
+  gnc_tree_view_add_numeric_column(view, N_("Present (Report)"), "present_report",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT,
+				   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
+				   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				   sort_by_present_value);
+  gnc_tree_view_add_numeric_column(view, N_("Balance"), "balance",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_BALANCE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
+				   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				   sort_by_balance_value);
+  gnc_tree_view_add_numeric_column(view, N_("Balance (Report)"), "balance_report",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT,
+				   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
+				   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				   sort_by_balance_value);
+  gnc_tree_view_add_numeric_column(view, N_("Cleared"), "cleared",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_CLEARED,
+				   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
+				   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				   sort_by_cleared_value);
+  gnc_tree_view_add_numeric_column(view, N_("Cleared (Report)"), "cleared_report",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT,
+				   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
+				   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				   sort_by_cleared_value);
+  gnc_tree_view_add_numeric_column(view, N_("Reconciled"), "reconciled",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED,
+				   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
+				   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				   sort_by_reconciled_value);
+  gnc_tree_view_add_numeric_column(view, N_("Reconciled (Report)"), "reconciled_report",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT,
+				   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
+				   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				   sort_by_reconciled_value);
+  gnc_tree_view_add_numeric_column(view, N_("Future Minimum"), "future_min",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN,
+				   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, N_("Future Minimum (Report)"), "future_min_report",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT,
+				   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, N_("Total"), "total",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_TOTAL,
+				   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
+				   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				   sort_by_total_value);
+  gnc_tree_view_add_numeric_column(view, N_("Total (Report)"), "total_report",
+				   SAMPLE_ACCOUNT_VALUE,
+				   GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT,
+				   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
+				   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				   sort_by_total_value);
+  gnc_tree_view_add_text_column(view, N_("Notes"), "notes", NULL,
+				"Sample account notes.",
+				GNC_TREE_MODEL_ACCOUNT_COL_NOTES,
+				GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				NULL);
+  gnc_tree_view_add_text_column(view, N_("Tax Info"), "tax-info", NULL,
+				"Sample tax info.",
+				GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
+				GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				NULL);
+  gnc_tree_view_add_toggle_column(view, N_("Placeholder"), "P", "placeholder",
+				  GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER,
+				  GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
+				  sort_by_placeholder,
+				  gnc_tree_view_account_placeholder_toggled);
+
+  gnc_tree_view_configure_columns(view, "description", "total", NULL);
   gtk_tree_model_filter_set_visible_func (GTK_TREE_MODEL_FILTER (f_model),
 					  gnc_tree_view_account_filter_helper,
-					  account_view,
+					  view,
 					  NULL);
 
-  gtk_widget_show(GTK_WIDGET(tree_view));
-  LEAVE("%p", tree_view);
-  return tree_view;
+  gtk_widget_show(GTK_WIDGET(view));
+  LEAVE("%p", view);
+  return GTK_TREE_VIEW(view);
 }
 
 /*
@@ -562,79 +671,6 @@
 /************************************************************/
 
 /*
- * Convert a column name to a column index.  This index valid for the
- * TreeView's list of TreeViewColumns.  When the column is a "builtin"
- * TreeViewAccount column, then the index is also valid for the
- * gnc_tree_view_account_defaults[] array.
- *
- *  Returns -1 when column is not found.
- */
-static gint
-gnc_tree_view_account_pref_name_to_field (const char *pref_name)
-{
-  gint i;
-  g_return_val_if_fail (pref_name, -1);
-
-  for (i = 0; i <= GNC_TREE_MODEL_ACCOUNT_COL_LAST_VISIBLE; i++)
-    if (safe_strcmp(view_column_defaults[i].pref_name, pref_name) == 0)
-      return i;
-
-  return -1;
-}
-
-const char *
-gnc_tree_view_account_get_field_name (AccountFieldCode field)
-{
-  g_return_val_if_fail ((field >= 0) && (field <= GNC_TREE_MODEL_ACCOUNT_COL_LAST_VISIBLE), NULL);
-
-  return(gettext(view_column_defaults[field].field_name));
-}
-
-
-/*
- * Set the list of columns that will be visible in an account tree view.
- */
-void
-gnc_tree_view_account_configure_columns (GncTreeViewAccount *account_view,
-					 GSList *column_names)
-{
-  AccountViewInfo new_avi;
-  AccountFieldCode field;
-  GSList *node;
-
-  g_return_if_fail(GNC_IS_TREE_VIEW_ACCOUNT(account_view));
-
-  ENTER(" ");
-  memset (&new_avi, 0, sizeof(new_avi));
-
-  for (node = column_names; node; node = node->next)
-  {
-    field = gnc_tree_view_account_pref_name_to_field(node->data);
-    if (field <= GNC_TREE_MODEL_ACCOUNT_COL_LAST_VISIBLE)
-      new_avi.show_field[field] = TRUE;
-  }
-
-  new_avi.show_field[ACCOUNT_NAME] = TRUE;
-
-  gnc_tree_view_account_set_view_info (account_view, &new_avi);
-  LEAVE(" ");
-}
-
-/*
- * Initialize an account view info structure with default values.
- */
-void
-gnc_tree_view_account_init_view_info(AccountViewInfo *avi)
-{
-  int i;
-
-  for (i = 0; i <= GNC_TREE_MODEL_ACCOUNT_COL_LAST_VISIBLE; i++)
-    avi->show_field[i] = FALSE;
-
-  avi->show_field[ACCOUNT_NAME] = TRUE;
-}
-
-/*
  * Get a copy of the account view info structure in use by the
  * specified tree.
  */
@@ -670,7 +706,6 @@
 gnc_tree_view_account_set_view_info (GncTreeViewAccount *account_view,
 				     AccountViewInfo *avi)
 {
-  GtkTreeViewColumn *column;
   gint i;
   guint sel_bits = 0;
 
@@ -680,11 +715,6 @@
 
   account_view->priv->avi = *avi;
   
-  for (i = 0; i <= GNC_TREE_MODEL_ACCOUNT_COL_LAST_VISIBLE; i++) {
-    column = gtk_tree_view_get_column (GTK_TREE_VIEW(account_view), i);
-    gtk_tree_view_column_set_visible (column, avi->show_field[i]);
-  }
-
   for (i = 0; i < NUM_ACCOUNT_TYPES; i++) {
       sel_bits |= avi->include_type[i] ? (1 << i): 0;
   }
@@ -1213,12 +1243,12 @@
     renderer = gtk_cell_renderer_text_new ();
     g_object_set (G_OBJECT (renderer), "xalign", 1.0, NULL);
 
-    column = gtk_tree_view_column_new_with_attributes (column_title,
-						       renderer, NULL);
+    column = gnc_tree_view_add_text_column(GNC_TREE_VIEW(view), column_title,
+					   kvp_key, NULL, "Sample text",
+					   -1, -1, NULL);
     gtk_tree_view_column_set_cell_data_func (column, renderer, 
 					     account_cell_kvp_data_func,
 					     g_strdup(kvp_key), g_free);
-    gtk_tree_view_append_column (GTK_TREE_VIEW(view), column);
 }
 
 static void col_edited_helper(GtkCellRendererText *cell, gchar *path_string, 
@@ -1255,7 +1285,7 @@
     col_source_cb = (GncTreeViewAccountColumnSource) _col_source_cb;
     account = gnc_tree_view_account_get_account_from_iter(s_model, s_iter);
     text = col_source_cb(account, col, cell);
-    g_object_set (G_OBJECT (cell), "text", text, "xalign", 0.0, NULL);
+    g_object_set (G_OBJECT (cell), "text", text, "xalign", 1.0, NULL);
     g_free(text);
 }
 
@@ -1291,223 +1321,6 @@
     gtk_tree_view_column_set_cell_data_func (column, renderer, 
                                              col_source_helper,
                                              col_source_cb, NULL);
-    gtk_tree_view_append_column (GTK_TREE_VIEW(account_view), column);
+    gnc_tree_view_append_column (GNC_TREE_VIEW(account_view), column);
     return column;
 }
-
-
-/************************************************************/
-/*          Account Tree View Get/Save Settings             */
-/************************************************************/
-
-void
-gnc_tree_view_account_save_settings (GncTreeViewAccount *view, const gchar *section)
-{
-  gnc_tree_view_common_save_settings (GTK_TREE_VIEW(view), section,
-				      view_column_defaults);
-}
-
-void
-gnc_tree_view_account_restore_settings (GncTreeViewAccount *view, const gchar *section)
-{
-  gnc_tree_view_common_restore_settings (GTK_TREE_VIEW(view), section,
-					 view_column_defaults);
-}
-
-
-/************************************************************/
-/*                    Column Definitions                    */
-/************************************************************/
-
-static gnc_view_column view_column_defaults[] = {
-  {GNC_TREE_MODEL_ACCOUNT_COL_NAME,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   NULL,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "name",
-   N_("Account Name")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_TYPE,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   NULL,
-   GTK_TREE_VIEW_COLUMN_FIXED,
-   FALSE, NULL,
-   "type",
-   N_("Type")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_COMMODITY,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   NULL,
-   GTK_TREE_VIEW_COLUMN_FIXED,
-   FALSE, NULL,
-   "commodity",
-   N_("Commodity")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_CODE,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   NULL,
-   GTK_TREE_VIEW_COLUMN_FIXED,
-   FALSE, NULL,
-   "code",
-   N_("Account Code")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_DESCRIPTION,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   NULL,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "description",
-   N_("Description")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_LASTNUM,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   NULL,
-   FALSE,
-   FALSE, NULL,
-   "lastnum",
-   N_("Last Num")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_PRESENT,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_present_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "present",
-   N_("Present")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_PRESENT_REPORT,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_PRESENT,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_present_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "present_report",
-   N_("Present (Report)")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_BALANCE,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_balance_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "balance",
-   N_("Balance")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_BALANCE_REPORT,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_BALANCE,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_balance_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "balance_report",
-   N_("Balance (Report)")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_CLEARED,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_cleared_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "cleared",
-   N_("Cleared")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_CLEARED_REPORT,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_CLEARED,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_cleared_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "cleared_report",
-   N_("Cleared (Report)")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_reconciled_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "reconciled",
-   N_("Reconciled")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_RECONCILED_REPORT,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_RECONCILED,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_reconciled_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "reconciled_report",
-   N_("Reconciled (Report)")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_future_min_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "future_min",
-   N_("Future Minimum")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_FUTURE_MIN_REPORT,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_FUTURE_MIN,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_future_min_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "future_min_report",
-   N_("Future Minimum (Report)")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_TOTAL,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_total_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "total",
-   N_("Total")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_TOTAL_REPORT,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_MODEL_ACCOUNT_COL_COLOR_TOTAL,
-   1.0, GNC_TREE_MODEL_ACCOUNT_COL_ALIGN_RIGHT,
-   sort_by_total_value,
-   GTK_TREE_VIEW_COLUMN_AUTOSIZE,
-   FALSE, NULL,
-   "total_report",
-   N_("Total (Report)")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_NOTES,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   NULL,
-   FALSE,
-   FALSE, NULL,
-   "notes",
-   N_("Notes")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_TAX_INFO,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   NULL,
-   FALSE,
-   FALSE, NULL,
-   "tax-info",
-   N_("Tax Info")},
-  {GNC_TREE_MODEL_ACCOUNT_COL_PLACEHOLDER,
-   GNC_TREE_VIEW_COLUMN_VISIBLE_ALWAYS,
-   GNC_TREE_VIEW_COLUMN_COLOR_NONE,
-   0.0, GNC_TREE_VIEW_COLUMN_ALIGN_NONE,
-   sort_by_placeholder,
-   FALSE,
-   TRUE, gnc_tree_view_account_placeholder_toggled,
-   "placeholder",
-   N_("Placeholder")},
-  { 0 }
-};
Index: gnc-tree-view-commodity.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-tree-view-commodity.h,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -Lsrc/gnome-utils/gnc-tree-view-commodity.h -Lsrc/gnome-utils/gnc-tree-view-commodity.h -u -r1.1.2.4 -r1.1.2.5
--- src/gnome-utils/gnc-tree-view-commodity.h
+++ src/gnome-utils/gnc-tree-view-commodity.h
@@ -36,6 +36,7 @@
 
 #include <gtk/gtktreemodel.h>
 #include <gtk/gtktreeview.h>
+#include "gnc-tree-view.h"
 
 #include "gnc-commodity.h"
 #include "gnc-ui-util.h"
@@ -55,7 +56,7 @@
 
 
 typedef struct {
-	GtkTreeView parent;
+	GncTreeView parent;
 
 	GncTreeViewCommodityPrivate *priv;
 
@@ -63,7 +64,7 @@
 } GncTreeViewCommodity;
 
 typedef struct {
-	GtkTreeViewClass parent;
+	GncTreeViewClass parent;
 } GncTreeViewCommodityClass;
 
 
@@ -83,9 +84,15 @@
  *
  *  @param book The book containing the commodities to show.
  *
+ *  @param first_property_name Pairs of property name/value settings
+ *  for the newly created object.  Terminate the properties with a
+ *  single NULL argument.
+ *
  *  @return A pointer to a new commodity tree view.
  */
-GtkTreeView  *gnc_tree_view_commodity_new (QofBook *book);
+GtkTreeView  *gnc_tree_view_commodity_new (QofBook *book,
+					   const gchar *first_property_name,
+					   ...);
 /** @} */
 
 
@@ -307,32 +314,6 @@
 
 /** @} */
 
-
-
-/** @name Commodity Tree View Save/Restore Functions 
- @{ */
-
-/** This function saves the settings of a commodity tree.  This saves
- *  column order, sort order, etc.
- *
- *  @param view A pointer to an commodity tree view.
- *
- *  @param section The name of a gconf section where the tree
- *  information should be saved. */
-void gnc_tree_view_commodity_save_settings (GncTreeViewCommodity *view,
-					    const gchar *section);
-
-/** This function restores the settings of a commodity tree.  This saves
- *  column order, sort order, etc.
- *
- *  @param view A pointer to an commodity tree view.
- *
- *  @param section The name of a gconf section where the tree
- *  information should be restores from. */
-void gnc_tree_view_commodity_restore_settings (GncTreeViewCommodity *view,
-					       const gchar *section);
-/** @} */
-
 G_END_DECLS
 
 #endif /* __GNC_TREE_VIEW_COMMODITY_H */
Index: gnc-tree-view-account.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-tree-view-account.h,v
retrieving revision 1.1.2.13
retrieving revision 1.1.2.14
diff -Lsrc/gnome-utils/gnc-tree-view-account.h -Lsrc/gnome-utils/gnc-tree-view-account.h -u -r1.1.2.13 -r1.1.2.14
--- src/gnome-utils/gnc-tree-view-account.h
+++ src/gnome-utils/gnc-tree-view-account.h
@@ -36,6 +36,7 @@
 
 #include <gtk/gtktreemodel.h>
 #include <gtk/gtktreeview.h>
+#include "gnc-tree-view.h"
 
 #include "Group.h"
 #include "gnc-ui-util.h"
@@ -58,13 +59,11 @@
 struct AccountViewInfo_s
 {
   gboolean include_type[NUM_ACCOUNT_TYPES];
-
-  gboolean show_field[NUM_ACCOUNT_FIELDS];
 };
 
 
 typedef struct {
-	GtkTreeView parent;
+	GncTreeView parent;
 
 	GncTreeViewAccountPrivate *priv;
 
@@ -72,7 +71,7 @@
 } GncTreeViewAccount;
 
 typedef struct {
-	GtkTreeViewClass parent;
+	GncTreeViewClass parent;
 } GncTreeViewAccountClass;
 
 
@@ -103,25 +102,6 @@
 /** @name Account Tree View Configuration 
  @{ */
 
-const char *gnc_tree_view_account_get_field_name (AccountFieldCode field);
-
-/** Configure (by name) the set of visible columns in an account tree
- *  view.  By default, when a GncTreeViewAccount is created, all
- *  columns are shown, but if you call this function with a NULL list,
- *  only the account name column will be shown.  Unrecognized column
- *  names are silently ignored.  The avalible list of columns can be
- *  found in the file gnc-tree-view-account.c.  NOTE: This function
- *  does not handle columns added with
- *  gnc_tree_view_account_add_kvp_column() -- it only handles the
- *  "builtin" columns.
- *
- *  @param account_view A pointer to an account tree view.
- *
- *  @param column_names A list of column names to make visible.
- */
-void gnc_tree_view_account_configure_columns (GncTreeViewAccount *account_view,
-                                              GSList *column_names);
-
 typedef gchar * (*GncTreeViewAccountColumnSource) (Account *account, 
                                                    GtkTreeViewColumn *col,
                                                    GtkCellRenderer *cell);
@@ -187,14 +167,6 @@
 void gnc_tree_view_account_set_view_info (GncTreeViewAccount *account_view,
                                           AccountViewInfo *avi);
 
-/** Given a pointer to an old style filter block, initialize it to the
- *  default values for an account tree.  The defaults are to show all
- *  types of accounts, and show only the account name column.
- *
- *  @param avi A pointer to an old style filter block.
- */
-void gnc_tree_view_account_init_view_info (AccountViewInfo *avi);
-
 
 /** This function attaches a filter function to the given account
  *  tree.  This function will be called for each account that the view
@@ -422,31 +394,6 @@
 
 /** @} */
 
-/** @name Account Tree View Save/Restore Functions
-@{ */
-
-/** This function saves the settings of a account tree.  This saves
- *  column order, sort order, etc.
- *
- *  @param view A pointer to an account tree view.
- *
- *  @param section The name of a gconf section where the tree
- *  information should be saved. */
-void gnc_tree_view_account_save_settings (GncTreeViewAccount *view,
-					  const gchar *section);
-
-/** This function restores the settings of a account tree.  This saves
- *  column order, sort order, etc.
- *
- *  @param view A pointer to an account tree view.
- *
- *  @param section The name of a gconf section where the tree
- *  information should be restores from. */
-void gnc_tree_view_account_restore_settings (GncTreeViewAccount *view,
-					     const gchar *section);
-
-/** @} */
-
 G_END_DECLS
 
 #endif /* __GNC_TREE_VIEW_ACCOUNT_H */
Index: gnc-tree-view-price.h
===================================================================
RCS file: /home/cvs/cvsroot/gnucash/src/gnome-utils/Attic/gnc-tree-view-price.h,v
retrieving revision 1.1.2.4
retrieving revision 1.1.2.5
diff -Lsrc/gnome-utils/gnc-tree-view-price.h -Lsrc/gnome-utils/gnc-tree-view-price.h -u -r1.1.2.4 -r1.1.2.5
--- src/gnome-utils/gnc-tree-view-price.h
+++ src/gnome-utils/gnc-tree-view-price.h
@@ -36,6 +36,7 @@
 
 #include <gtk/gtktreemodel.h>
 #include <gtk/gtktreeview.h>
+#include "gnc-tree-view.h"
 
 #include "gnc-pricedb.h"
 #include "gnc-ui-util.h"
@@ -55,7 +56,7 @@
 
 
 typedef struct {
-	GtkTreeView parent;
+	GncTreeView parent;
 
 	GncTreeViewPricePrivate *priv;
 
@@ -63,7 +64,7 @@
 } GncTreeViewPrice;
 
 typedef struct {
-	GtkTreeViewClass parent;
+	GncTreeViewClass parent;
 } GncTreeViewPriceClass;
 
 
@@ -83,9 +84,15 @@
  *
  *  @param book The book containing the prices to show.
  *
+ *  @param first_property_name Pairs of property name/value settings
+ *  for the newly created object.  Terminate the properties with a
+ *  single NULL argument.
+ *
  *  @return A pointer to a new price tree view.
  */
-GtkTreeView  *gnc_tree_view_price_new (QofBook *book);
+GtkTreeView *gnc_tree_view_price_new (QofBook *book,
+				      const gchar *first_property_name,
+				      ...);
 /** @} */
 
 
@@ -305,33 +312,6 @@
  */
 void          gnc_tree_view_price_select_subprices (GncTreeViewPrice *view,
 						    GNCPrice *price);
-
-/** @} */
-
-
-
-/** @name Price Tree View Save/Restore Functions
- @{ */
-
-/** This function saves the settings of a price tree.  This saves
- *  column order, sort order, etc.
- *
- *  @param view A pointer to an price tree view.
- *
- *  @param section The name of a gconf section where the tree
- *  information should be saved. */
-void gnc_tree_view_price_save_settings (GncTreeViewPrice *view,
-					const gchar *section);
-
-/** This function restores the settings of a price tree.  This saves
- *  column order, sort order, etc.
- *
- *  @param view A pointer to an price tree view.
- *
- *  @param section The name of a gconf section where the tree
- *  information should be restores from. */
-void gnc_tree_view_price_restore_settings (GncTreeViewPrice *view,
-					   const gchar *section);
 /** @} */
 
 G_END_DECLS


More information about the gnucash-changes mailing list