r17558 - gnucash/branches/2.2/src/gnome-utils - [r17349, 17468, 17535] In price and commodity tree views, restore gconf settings after initialization, add default sort column.
Andreas Köhler
andi5 at cvs.gnucash.org
Thu Sep 18 22:18:10 EDT 2008
Author: andi5
Date: 2008-09-18 22:18:09 -0400 (Thu, 18 Sep 2008)
New Revision: 17558
Trac: http://svn.gnucash.org/trac/changeset/17558
Modified:
gnucash/branches/2.2/src/gnome-utils/gnc-tree-view-commodity.c
gnucash/branches/2.2/src/gnome-utils/gnc-tree-view-price.c
Log:
[r17349,17468,17535] In price and commodity tree views, restore gconf settings after initialization, add default sort column.
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.
Set a default sorting column if no column has been found in gconf.
Committed by cedayiv and andi5.
Modified: gnucash/branches/2.2/src/gnome-utils/gnc-tree-view-commodity.c
===================================================================
--- gnucash/branches/2.2/src/gnome-utils/gnc-tree-view-commodity.c 2008-09-19 02:14:45 UTC (rev 17557)
+++ gnucash/branches/2.2/src/gnome-utils/gnc-tree-view-commodity.c 2008-09-19 02:18:09 UTC (rev 17558)
@@ -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,10 +451,24 @@
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. */
+ 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);
return GTK_TREE_VIEW(view);
Modified: gnucash/branches/2.2/src/gnome-utils/gnc-tree-view-price.c
===================================================================
--- gnucash/branches/2.2/src/gnome-utils/gnc-tree-view-price.c 2008-09-19 02:14:45 UTC (rev 17557)
+++ gnucash/branches/2.2/src/gnome-utils/gnc-tree-view-price.c 2008-09-19 02:18:09 UTC (rev 17558)
@@ -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,6 +468,20 @@
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. */
+ 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);
return GTK_TREE_VIEW(view);
More information about the gnucash-changes
mailing list