AUDIT: r17535 - gnucash/trunk/src/gnome-utils - In price and commodity tree views, restore gconf settings after initialization.

Andreas Köhler andi5 at cvs.gnucash.org
Wed Sep 17 00:17:43 EDT 2008


Author: andi5
Date: 2008-09-17 00:17:43 -0400 (Wed, 17 Sep 2008)
New Revision: 17535
Trac: http://svn.gnucash.org/trac/changeset/17535

Modified:
   gnucash/trunk/src/gnome-utils/gnc-tree-view-commodity.c
   gnucash/trunk/src/gnome-utils/gnc-tree-view-price.c
Log:
In price and commodity tree views, restore gconf settings after initialization.

Previously, gconf settings like sort column and order for price and commodity
dialogs were read in while creating the main tree view objects themselves,
i.e. before a model has been set.  In this early stage of initialization, these
properties cannot always be set and are ignored subsequently.

Instead, apply the properties after the view has been built and set default
sorting column only if no column has been found in gconf.

BP

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-commodity.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-commodity.c	2008-09-16 23:00:01 UTC (rev 17534)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-commodity.c	2008-09-17 04:17:43 UTC (rev 17535)
@@ -366,13 +366,6 @@
   va_list var_args;
 
   ENTER(" ");
-  /* Create our 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);
   model = gnc_tree_model_commodity_new (book, ct);
@@ -382,6 +375,10 @@
   g_object_unref(G_OBJECT(model));
   s_model = gtk_tree_model_sort_new_with_model (f_model);
   g_object_unref(G_OBJECT(f_model));
+
+  /* Create our view */
+  view = g_object_new (GNC_TYPE_TREE_VIEW_COMMODITY,
+                       "name", "commodity_tree", NULL);
   gnc_tree_view_set_model (view, s_model);
   g_object_unref(G_OBJECT(s_model));
 
@@ -454,15 +451,23 @@
       GNC_TREE_MODEL_COMMODITY_COL_QUOTE_TZ,
       GNC_TREE_MODEL_COMMODITY_COL_VISIBILITY,
       sort_by_commodity_string);
-  
   g_object_set_data(G_OBJECT(col), DEFAULT_VISIBLE, GINT_TO_POINTER(1));
+
   gnc_tree_view_configure_columns(view);
 
+  /* Set properties */
+  va_start (var_args, first_property_name);
+  g_object_set_valist (G_OBJECT(view), first_property_name, var_args);
+  va_end (var_args);
+
   /* Sort on the name column by default. This allows for a consistent
    * sort if commodities are briefly removed and re-added. */
-  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
-                                       GNC_TREE_MODEL_COMMODITY_COL_FULLNAME,
-                                       GTK_SORT_ASCENDING);
+  if (!gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(s_model),
+                                            NULL, NULL)) {
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
+                                         GNC_TREE_MODEL_COMMODITY_COL_FULLNAME,
+                                         GTK_SORT_ASCENDING);
+  }
 
   gtk_widget_show(GTK_WIDGET(view));
   LEAVE(" %p", view);

Modified: gnucash/trunk/src/gnome-utils/gnc-tree-view-price.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-view-price.c	2008-09-16 23:00:01 UTC (rev 17534)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-view-price.c	2008-09-17 04:17:43 UTC (rev 17535)
@@ -406,13 +406,6 @@
   gchar *sample_text2;
 
   ENTER(" ");
-  /* Create our 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);
   model = gnc_tree_model_price_new (book, price_db);
@@ -422,6 +415,10 @@
   g_object_unref(G_OBJECT(model));
   s_model = gtk_tree_model_sort_new_with_model (f_model);
   g_object_unref(G_OBJECT(f_model));
+
+  /* Create our view */
+  view = g_object_new (GNC_TYPE_TREE_VIEW_PRICE,
+                       "name", "price_tree", NULL);
   gnc_tree_view_set_model (view, s_model);
   g_object_unref(G_OBJECT(s_model));
 
@@ -471,11 +468,19 @@
 
   gnc_tree_view_configure_columns(view);
 
+  /* Set properties */
+  va_start (var_args, first_property_name);
+  g_object_set_valist (G_OBJECT(view), first_property_name, var_args);
+  va_end (var_args);
+
   /* Sort on the commodity column by default. This allows for a consistent
    * sort if commodities are removed and re-added from the model. */
-  gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
-                                       GNC_TREE_MODEL_PRICE_COL_COMMODITY,
-                                       GTK_SORT_ASCENDING);
+  if (!gtk_tree_sortable_get_sort_column_id(GTK_TREE_SORTABLE(s_model),
+                                            NULL, NULL)) {
+    gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(s_model),
+                                         GNC_TREE_MODEL_PRICE_COL_COMMODITY,
+                                         GTK_SORT_ASCENDING);
+  }
 
   gtk_widget_show(GTK_WIDGET(view));
   LEAVE(" %p", view);



More information about the gnucash-changes mailing list