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

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@17535 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Andreas Köhler 2008-09-17 04:17:43 +00:00
parent 44a07ec81c
commit dd1fe84980
2 changed files with 31 additions and 21 deletions

View File

@ -366,13 +366,6 @@ gnc_tree_view_commodity_new (QofBook *book,
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 @@ gnc_tree_view_commodity_new (QofBook *book,
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_view_commodity_new (QofBook *book,
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);

View File

@ -406,13 +406,6 @@ gnc_tree_view_price_new (QofBook *book,
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 @@ gnc_tree_view_price_new (QofBook *book,
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_price_new (QofBook *book,
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);