From ec83e3a338ba817509b178840d5435ca638965f1 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Tue, 8 Mar 2016 15:19:52 -0800 Subject: [PATCH 1/4] Bug 722996 - Cannot add stock price on Price Editor gtk_combo_box_set_active() doesn't work if the model is changed after the combo box is constructed. --- src/gnome-utils/dialog-commodity.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/gnome-utils/dialog-commodity.c b/src/gnome-utils/dialog-commodity.c index 2ebe179b2d..ca3c564921 100644 --- a/src/gnome-utils/dialog-commodity.c +++ b/src/gnome-utils/dialog-commodity.c @@ -644,9 +644,8 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe, { GtkComboBox *combo_box; GtkTreeModel *model; - GtkTreeIter iter; + GtkTreeIter iter, match; GList *namespaces, *node; - gint current = 0, match = 0; g_return_if_fail(GTK_IS_COMBO_BOX (cbwe)); @@ -654,7 +653,8 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe, combo_box = GTK_COMBO_BOX(cbwe); model = gtk_combo_box_get_model(combo_box); gtk_list_store_clear(GTK_LIST_STORE(model)); - gtk_combo_box_set_active(combo_box, -1); + gtk_tree_model_get_iter_first(model, &match); + gtk_combo_box_set_active_iter(combo_box, &match); /* fetch a list of the namespaces */ switch (mode) @@ -698,11 +698,10 @@ gnc_ui_update_namespace_picker (GtkWidget *cbwe, } if (init_string && (g_utf8_collate(node->data, init_string) == 0)) - match = current; - current++; + match = iter; } - gtk_combo_box_set_active(combo_box, match); + gtk_combo_box_set_active_iter(combo_box, &match); g_list_free(namespaces); } From 5b40df510d9cc97b64e5db7d36526f9e2428bd92 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 10 Mar 2016 09:49:43 -0800 Subject: [PATCH 2/4] Bug 763279 - GnuCash has empty reports On recent builds of gentoo, apparently because the supplied webkit dislikes that we output xhtml in a file called foo.html. Make the header say that we're using HTML4. --- src/report/report-system/html-document.scm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/report/report-system/html-document.scm b/src/report/report-system/html-document.scm index 9b63d09e2c..89239bc2f8 100644 --- a/src/report/report-system/html-document.scm +++ b/src/report/report-system/html-document.scm @@ -158,9 +158,8 @@ ;;./share/gnucash/scm/gnucash/report/taxinvoice.eguile.scm: ;;./share/gnucash/scm/gnucash/report/balsheet-eg.eguile.scm: - ;; Validate against XHTML 1.0 Transitional - (push "") - (push "\n") + ;; Validate against HTML4 Transitional: + (push "") (push "\n") (push "\n") (if css? From 2b958161250bcd0191e7815e65065b9507231ea8 Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 10 Mar 2016 10:27:55 -0800 Subject: [PATCH 3/4] Bug 763111 - commodities prices editor creates hidden db entries There were two problems: First, if there were multiple prices in the database for a particular day only one would be displayed. Second, if one manually created a second price on a day in the price editor the first wouldn't be removed. --- src/engine/gnc-pricedb.c | 32 +++++++++++++++++--------------- 1 file changed, 17 insertions(+), 15 deletions(-) diff --git a/src/engine/gnc-pricedb.c b/src/engine/gnc-pricedb.c index 123c5202e2..790cf32d70 100644 --- a/src/engine/gnc-pricedb.c +++ b/src/engine/gnc-pricedb.c @@ -1001,18 +1001,6 @@ gnc_pricedb_equal (GNCPriceDB *db1, GNCPriceDB *db2) return equal_data.equal; } -static gboolean -insert_or_replace_price(GNCPriceDB *db, GNCPrice *p) -{ - GNCPrice *old_price = gnc_pricedb_lookup_day (db, p->commodity, - p->currency, p->tmspec); - if (old_price == NULL) - return TRUE; - if (p->source < old_price->source) - return TRUE; - return FALSE; - -} /* ==================================================================== */ /* The add_price() function is a utility that only manages the * dual hash table instertion */ @@ -1026,6 +1014,7 @@ add_price(GNCPriceDB *db, GNCPrice *p) gnc_commodity *commodity; gnc_commodity *currency; GHashTable *currency_hash; + GNCPrice *old_price; if (!db || !p) return FALSE; ENTER ("db=%p, pr=%p dirty=%d destroying=%d", @@ -1072,19 +1061,32 @@ add_price(GNCPriceDB *db, GNCPrice *p) LEAVE ("gnc_price_list_insert failed"); return FALSE; } + if (!price_list) { LEAVE (" no price list"); return FALSE; } - if (!insert_or_replace_price(db, p)) +/* Check for an existing price on the same day. If there is no existing price, + * add this one. If this price is of equal or better precedence than the old + * one, copy this one over the old one. + */ + old_price = gnc_pricedb_lookup_day (db, p->commodity, p->currency, + p->tmspec); + if (!db->bulk_update && old_price != NULL) { - LEAVE("A better price already exists"); - return FALSE; + if (p->source > old_price->source) + { + gnc_price_unref(p); + LEAVE ("Better price already in DB."); + return FALSE; + } + gnc_pricedb_remove_price(db, old_price); } g_hash_table_insert(currency_hash, currency, price_list); p->db = db; + qof_event_gen (&p->inst, QOF_EVENT_ADD, NULL); LEAVE ("db=%p, pr=%p dirty=%d dextroying=%d commodity=%s/%s currency_hash=%p", From 4a60e490663a00e54a41f1e4bae18199a24c91cd Mon Sep 17 00:00:00 2001 From: John Ralls Date: Thu, 10 Mar 2016 10:59:53 -0800 Subject: [PATCH 4/4] Fix typo in HTML header. --- src/report/report-system/html-document.scm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/report/report-system/html-document.scm b/src/report/report-system/html-document.scm index 89239bc2f8..4bfcb89215 100644 --- a/src/report/report-system/html-document.scm +++ b/src/report/report-system/html-document.scm @@ -159,7 +159,7 @@ ;;./share/gnucash/scm/gnucash/report/balsheet-eg.eguile.scm: ;; Validate against HTML4 Transitional: - (push "") + (push "") (push "\n") (push "\n") (if css?