[Gnucash-changes] r13573 - gnucash/trunk - Finish removing
deprecated QOF functions.
David Hampton
hampton at cvs.gnucash.org
Thu Mar 9 16:57:43 EST 2006
Author: hampton
Date: 2006-03-09 16:57:42 -0500 (Thu, 09 Mar 2006)
New Revision: 13573
Trac: http://svn.gnucash.org/trac/changeset/13573
Modified:
gnucash/trunk/ChangeLog
gnucash/trunk/configure.in
gnucash/trunk/lib/libqof/qof/deprecated.c
gnucash/trunk/lib/libqof/qof/deprecated.h
gnucash/trunk/lib/libqof/qof/qofevent-p.h
gnucash/trunk/lib/libqof/qof/qofevent.c
gnucash/trunk/src/app-utils/gnc-component-manager.c
gnucash/trunk/src/engine/gnc-commodity.h
gnucash/trunk/src/engine/gnc-engine.h
gnucash/trunk/src/gnome-utils/account-quickfill.c
gnucash/trunk/src/gnome-utils/gnc-account-sel.c
gnucash/trunk/src/gnome-utils/gnc-main-window.c
gnucash/trunk/src/gnome-utils/gnc-plugin-page.c
gnucash/trunk/src/gnome-utils/gnc-plugin-page.h
gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c
gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c
Log:
Finish removing deprecated QOF functions.
Modified: gnucash/trunk/ChangeLog
===================================================================
--- gnucash/trunk/ChangeLog 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/ChangeLog 2006-03-09 21:57:42 UTC (rev 13573)
@@ -1,5 +1,19 @@
2006-03-09 David Hampton <hampton at employees.org>
+ * src/gnome-utils/gnc-tree-model-commodity.c:
+ * src/gnome-utils/gnc-main-window.c:
+ * src/gnome-utils/gnc-tree-model-price.c:
+ * src/gnome-utils/gnc-plugin-page.[ch]:
+ * src/gnome-utils/gnc-account-sel.c:
+ * src/gnome-utils/account-quickfill.c:
+ * src/engine/gnc-commodity.h:
+ * src/engine/gnc-engine.h:
+ * src/app-utils/gnc-component-manager.c:
+ * lib/libqof/qof/deprecated.[ch]:
+ * lib/libqof/qof/qofevent.c:
+ * lib/libqof/qof/qofevent-p.h:
+ * configure.in: Finish removing deprecated QOF functions.
+
* src/gnome/dialog-price-editor.c:
* src/gnome/top-level.c:
* src/gnc-ui.h: Restore clickable links for price quotes.
Modified: gnucash/trunk/configure.in
===================================================================
--- gnucash/trunk/configure.in 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/configure.in 2006-03-09 21:57:42 UTC (rev 13573)
@@ -488,6 +488,8 @@
AC_SUBST(QOF_LIB_DIR)
AC_SUBST(QOF_XML_DIR)
+AC_DEFINE(QOF_DISABLE_DEPRECATED,1, [Don't use deprecated qof functions])
+
### --------------------------------------------------------------------------
### Variables
### Set up all the initial variable values...
Modified: gnucash/trunk/lib/libqof/qof/deprecated.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/deprecated.c 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/lib/libqof/qof/deprecated.c 2006-03-09 21:57:42 UTC (rev 13573)
@@ -22,6 +22,7 @@
\********************************************************************/
#include "config.h"
+#ifndef QOF_DISABLE_DEPRECATED
#include "qof.h"
/* Don't be fooled: gnc_trace_num_spaces has external linkage and
@@ -102,5 +103,4 @@
{
qof_book_merge_rule_foreach(mergeData, cb, mergeResult);
}
-
-/* ==================================================================== */
+#endif /* QOF_DISABLE_DEPRECATED */
Modified: gnucash/trunk/lib/libqof/qof/deprecated.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/deprecated.h 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/lib/libqof/qof/deprecated.h 2006-03-09 21:57:42 UTC (rev 13573)
@@ -21,6 +21,8 @@
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02110-1301, USA.
*/
+#ifndef QOF_DISABLE_DEPRECATED
+
#ifndef _DEPRECATED_H
#define _DEPRECATED_H
#include "qof.h"
@@ -147,3 +149,4 @@
qof_book_mergeCommit(QofBookMergeData *mergeData );
#endif /* _DEPRECATED_H */
+#endif /* QOF_DISABLE_DEPRECATED */
Modified: gnucash/trunk/lib/libqof/qof/qofevent-p.h
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofevent-p.h 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/lib/libqof/qof/qofevent-p.h 2006-03-09 21:57:42 UTC (rev 13573)
@@ -30,7 +30,9 @@
/* for backwards compatibility - to be moved back to qofevent.c in libqof2 */
typedef struct
{
+#ifndef QOF_DISABLE_DEPRECATED
GNCEngineEventHandler old_handler; /** \deprecated */
+#endif
QofEventHandler handler;
gpointer user_data;
Modified: gnucash/trunk/lib/libqof/qof/qofevent.c
===================================================================
--- gnucash/trunk/lib/libqof/qof/qofevent.c 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/lib/libqof/qof/qofevent.c 2006-03-09 21:57:42 UTC (rev 13573)
@@ -68,6 +68,7 @@
}
/* support deprecated code with a private function*/
+#ifndef QOF_DISABLE_DEPRECATED
gint
qof_event_register_old_handler (GNCEngineEventHandler handler, gpointer user_data)
{
@@ -98,6 +99,7 @@
return handler_id;
}
+#endif /* QOF_DISABLE_DEPRECATED */
gint
qof_event_register_handler (QofEventHandler handler, gpointer user_data)
@@ -150,13 +152,17 @@
if(hi->handler)
LEAVE ("(handler_id=%d) handler=%p data=%p", handler_id,
hi->handler, hi->user_data);
+#ifndef QOF_DISABLE_DEPRECATED
if(hi->old_handler)
LEAVE ("(handler_id=%d) handler=%p data=%p", handler_id,
hi->old_handler, hi->user_data);
+#endif
/* safety -- clear the handler in case we're running events now */
hi->handler = NULL;
- hi->old_handler = NULL;
+#ifndef QOF_DISABLE_DEPRECATED
+ hi->old_handler = NULL;
+#endif
if (handler_run_level == 0) {
handlers = g_list_remove_link (handlers, node);
@@ -224,6 +230,7 @@
HandlerInfo *hi = node->data;
next_node = node->next;
+#ifndef QOF_DISABLE_DEPRECATED
if ((hi->old_handler) && (use_old_handlers))
{
PINFO(" deprecated: id=%d hi=%p han=%p", hi->handler_id, hi,
@@ -231,6 +238,7 @@
hi->old_handler ((GUID *)&entity->guid, entity->e_type,
event_id, hi->user_data);
}
+#endif
if (hi->handler)
{
PINFO("id=%d hi=%p han=%p data=%p", hi->handler_id, hi,
@@ -249,7 +257,11 @@
{
HandlerInfo *hi = node->data;
next_node = node->next;
- if ((hi->handler == NULL)&&(hi->old_handler == NULL))
+ if ((hi->handler == NULL)
+#ifndef QOF_DISABLE_DEPRECATED
+ &&(hi->old_handler == NULL)
+#endif
+ )
{
/* remove this node from the list, then free this node */
handlers = g_list_remove_link (handlers, node);
Modified: gnucash/trunk/src/app-utils/gnc-component-manager.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-component-manager.c 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/src/app-utils/gnc-component-manager.c 2006-03-09 21:57:42 UTC (rev 13573)
@@ -257,19 +257,19 @@
}
static void
-gnc_cm_event_handler (GUID *entity, QofIdType type,
+gnc_cm_event_handler (QofEntity *entity,
QofEventId event_type,
- gpointer user_data)
+ gpointer user_data,
+ gpointer event_data)
{
+ const GUID *guid = qof_entity_get_guid(entity);
#if CM_DEBUG
- fprintf (stderr, "event_handler: event %d, type %s, guid %s\n", event_type,
- (type ? type : "(null)"), guid_to_string(entity));
+ fprintf (stderr, "event_handler: event %d, entity %p, guid %s\n", event_type,
+ entity, guid);
#endif
- add_event (&changes, entity, event_type, TRUE);
+ add_event (&changes, guid, event_type, TRUE);
- g_return_if_fail (type);
-
- if (safe_strcmp (type, GNC_ID_SPLIT) == 0)
+ if (QOF_CHECK_TYPE(entity, GNC_ID_SPLIT))
{
/* split events are never generated by the engine, but might
* be generated by a backend (viz. the postgres backend.)
@@ -277,7 +277,7 @@
add_event_type (&changes, GNC_ID_TRANS, QOF_EVENT_MODIFY, TRUE);
}
else
- add_event_type (&changes, type, event_type, TRUE);
+ add_event_type (&changes, entity->e_type, event_type, TRUE);
got_events = TRUE;
@@ -302,7 +302,7 @@
changes_backup.event_masks = g_hash_table_new (g_str_hash, g_str_equal);
changes_backup.entity_events = guid_hash_table_new ();
- handler_id = qof_event_register_old_handler (gnc_cm_event_handler, NULL);
+ handler_id = qof_event_register_handler (gnc_cm_event_handler, NULL);
}
void
Modified: gnucash/trunk/src/engine/gnc-commodity.h
===================================================================
--- gnucash/trunk/src/engine/gnc-commodity.h 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/src/engine/gnc-commodity.h 2006-03-09 21:57:42 UTC (rev 13573)
@@ -49,6 +49,11 @@
#include <glib.h>
#include "gnc-engine.h"
+#define GNC_IS_COMMODITY(obj) (QOF_CHECK_TYPE((obj), GNC_ID_COMMODITY))
+#define GNC_COMMODITY(obj) (QOF_CHECK_CAST((obj), GNC_ID_COMMODITY, gnc_commodity))
+#define GNC_IS_COMMODITY_NAMESPACE(obj) (QOF_CHECK_TYPE((obj), GNC_ID_COMMODITY_NAMESPACE))
+#define GNC_COMMODITY_NAMESPACE(obj) (QOF_CHECK_CAST((obj), GNC_ID_COMMODITY_NAMESPACE, gnc_commodity_namespace))
+
#define GNC_COMMODITY_TABLE "gnc_commodity_table"
/** The commodity namespace definitions are used to tag a commodity by
Modified: gnucash/trunk/src/engine/gnc-engine.h
===================================================================
--- gnucash/trunk/src/engine/gnc-engine.h 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/src/engine/gnc-engine.h 2006-03-09 21:57:42 UTC (rev 13573)
@@ -198,6 +198,8 @@
typedef struct gnc_price_s GNCPrice;
typedef struct gnc_quote_source_s gnc_quote_source;
+#define GNC_IS_PRICE(obj) (QOF_CHECK_TYPE((obj), GNC_ID_PRICE))
+#define GNC_PRICE(obj) (QOF_CHECK_CAST((obj), GNC_ID_PRICE, GNCPrice))
/** GList of Account */
typedef GList AccountList;
Modified: gnucash/trunk/src/gnome-utils/account-quickfill.c
===================================================================
--- gnucash/trunk/src/gnome-utils/account-quickfill.c 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/src/gnome-utils/account-quickfill.c 2006-03-09 21:57:42 UTC (rev 13573)
@@ -70,24 +70,21 @@
* for account modification events, and add new accounts.
*/
static void
-listen_for_account_events (GUID *guid, QofIdType type,
- QofEventId event_type,
- gpointer user_data)
+listen_for_account_events (QofEntity *entity, QofEventId event_type,
+ gpointer user_data, gpointer event_data)
{
QFB *qfb = user_data;
QuickFill *qf = qfb->qf;
QuickFill *match;
char * name;
const char *match_str;
- QofCollection *col;
Account *account;
GtkTreeIter iter;
if (! (event_type & QOF_EVENT_MODIFY)) return;
- if (QSTRCMP (type, GNC_ID_ACCOUNT)) return;
+ if (!GNC_IS_ACCOUNT (entity)) return;
- col = qof_book_get_collection (qfb->book, GNC_ID_ACCOUNT);
- account = GNC_ACCOUNT (qof_collection_lookup_entity (col, guid));
+ account = GNC_ACCOUNT (entity);
/* Not every new account is eligable for the menu */
if (qfb->dont_add_cb)
@@ -177,7 +174,7 @@
xaccGroupForEachAccount (group, load_shared_qf_cb, qfb, TRUE);
qfb->listener =
- qof_event_register_old_handler (listen_for_account_events, qfb);
+ qof_event_register_handler (listen_for_account_events, qfb);
qof_book_set_data_fin (book, key, qfb, shared_quickfill_destroy);
Modified: gnucash/trunk/src/gnome-utils/gnc-account-sel.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-account-sel.c 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/src/gnome-utils/gnc-account-sel.c 2006-03-09 21:57:42 UTC (rev 13573)
@@ -54,9 +54,6 @@
static void gas_populate_list (GNCAccountSel *gas);
static void gas_strcmp_adapter (gpointer a, gpointer b);
-static void gnc_account_sel_event_cb (GUID *entity, QofIdType id_type,
- QofEventId event_type,
- gpointer user_data);
static void gas_new_account_click (GtkButton *b, gpointer ud);
@@ -97,14 +94,15 @@
static
void
-gnc_account_sel_event_cb( GUID *entity, QofIdType type,
+gnc_account_sel_event_cb( QofEntity *entity,
QofEventId event_type,
- gpointer user_data )
+ gpointer user_data,
+ gpointer event_data )
{
if ( ! ( event_type == QOF_EVENT_CREATE
|| event_type == QOF_EVENT_MODIFY
|| event_type == QOF_EVENT_DESTROY )
- || strcmp( type, GNC_ID_ACCOUNT ) != 0 ) {
+ || !GNC_IS_ACCOUNT(entity) ) {
return;
}
gas_populate_list( (GNCAccountSel*)user_data );
@@ -157,7 +155,7 @@
gas_populate_list( gas );
gas->eventHandlerId =
- qof_event_register_old_handler( gnc_account_sel_event_cb, gas );
+ qof_event_register_handler( gnc_account_sel_event_cb, gas );
gas->initDone = TRUE;
}
Modified: gnucash/trunk/src/gnome-utils/gnc-main-window.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-main-window.c 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/src/gnome-utils/gnc-main-window.c 2006-03-09 21:57:42 UTC (rev 13573)
@@ -996,9 +996,8 @@
* @param user_data A pointer to the window data structure.
*/
static void
-gnc_main_window_event_handler (GUID *entity, QofIdType type,
- QofEventId event_type,
- gpointer user_data)
+gnc_main_window_event_handler (QofEntity *entity, QofEventId event_type,
+ gpointer user_data, gpointer event_data)
{
GncMainWindow *window;
GncMainWindowPrivate *priv;
@@ -1009,13 +1008,13 @@
g_return_if_fail(GNC_IS_MAIN_WINDOW(user_data));
/* soft failures */
- if (safe_strcmp(type, GNC_ID_BOOK) != 0)
+ if (!QOF_CHECK_TYPE(entity, QOF_ID_BOOK))
return;
if (event_type != QOF_EVENT_DESTROY)
return;
- ENTER("entity %p of type %s, event %d, window %p",
- entity, type, event_type, user_data);
+ ENTER("entity %p, event %d, window %p, event data %p",
+ entity, event_type, user_data, event_data);
window = GNC_MAIN_WINDOW(user_data);
priv = GNC_MAIN_WINDOW_GET_PRIVATE(window);
@@ -1025,7 +1024,7 @@
for (item = priv->installed_pages; item; item = next) {
next = g_list_next(item);
page = GNC_PLUGIN_PAGE(item->data);
- if (gnc_plugin_page_has_book (page, entity))
+ if (gnc_plugin_page_has_book (page, (QofBook *)entity))
gnc_main_window_close_page (page);
}
LEAVE(" ");
@@ -1622,8 +1621,7 @@
g_hash_table_new_full (g_str_hash, g_str_equal, g_free, g_free);
priv->event_handler_id =
- qof_event_register_old_handler(gnc_main_window_event_handler,
- window);
+ qof_event_register_handler(gnc_main_window_event_handler, window);
gnc_main_window_setup_window (window);
gnc_gobject_tracking_remember(G_OBJECT(window),
Modified: gnucash/trunk/src/gnome-utils/gnc-plugin-page.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-plugin-page.c 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/src/gnome-utils/gnc-plugin-page.c 2006-03-09 21:57:42 UTC (rev 13573)
@@ -533,7 +533,6 @@
{
GncPluginPagePrivate *priv;
GncPluginPage *page;
- GList *item;
page = GNC_PLUGIN_PAGE (object);
@@ -546,9 +545,6 @@
g_free(priv->statusbar_text);
if (priv->books) {
- for (item = priv->books; item; item = g_list_next(item)) {
- guid_free (item->data);
- }
g_list_free(priv->books);
priv->books = NULL;
}
@@ -700,17 +696,17 @@
* function takes a guid instead of a QofBook because that's what the
* engine event mechanism provides. */
gboolean
-gnc_plugin_page_has_book (GncPluginPage *page, GUID *entity)
+gnc_plugin_page_has_book (GncPluginPage *page, QofBook *book)
{
GncPluginPagePrivate *priv;
GList *item;
g_return_val_if_fail (GNC_IS_PLUGIN_PAGE (page), FALSE);
- g_return_val_if_fail (entity != NULL, FALSE);
+ g_return_val_if_fail (book != NULL, FALSE);
priv = GNC_PLUGIN_PAGE_GET_PRIVATE(page);
for (item = priv->books; item; item = g_list_next(item)) {
- if (guid_equal((GUID*)item->data, entity)) {
+ if (item->data == book) {
return TRUE;
}
}
Modified: gnucash/trunk/src/gnome-utils/gnc-plugin-page.h
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-plugin-page.h 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/src/gnome-utils/gnc-plugin-page.h 2006-03-09 21:57:42 UTC (rev 13573)
@@ -302,7 +302,7 @@
* @return TRUE if the page refers to the specified book. FALSE
* otherwise.
*/
-gboolean gnc_plugin_page_has_book (GncPluginPage *page, GUID *book);
+gboolean gnc_plugin_page_has_book (GncPluginPage *page, QofBook *book);
/** Query a page to see if it has a reference to any book.
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-commodity.c 2006-03-09 21:57:42 UTC (rev 13573)
@@ -82,9 +82,10 @@
static gboolean gnc_tree_model_commodity_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child);
-static void gnc_tree_model_commodity_event_handler (GUID *entity, QofIdType type,
+static void gnc_tree_model_commodity_event_handler (QofEntity *entity,
QofEventId event_type,
- gpointer user_data);
+ gpointer user_data,
+ gpointer event_data);
/** The instance private data for a commodity database tree model. */
typedef struct GncTreeModelCommodityPrivate
@@ -224,7 +225,7 @@
priv->commodity_table = ct;
priv->event_handler_id =
- qof_event_register_old_handler (gnc_tree_model_commodity_event_handler, model);
+ qof_event_register_handler (gnc_tree_model_commodity_event_handler, model);
return GTK_TREE_MODEL (model);
}
@@ -1021,7 +1022,6 @@
/************************************************************/
typedef struct _remove_data {
- GUID guid;
GncTreeModelCommodity *model;
GtkTreePath *path;
} remove_data;
@@ -1185,20 +1185,20 @@
* have this model mirror the engine's commodity table instead of
* referencing it directly.
*
- * @param entity The guid of the affected item.
+ * @param entity The affected item.
*
- * @param type The type of the affected item. This function only
- * cares about items of type "account" or "namespace".
- *
* @param event type The type of the event. This function only cares
* about items of type ADD, REMOVE, and DESTROY.
*
* @param user_data A pointer to the account tree model.
+ *
+ * @param event_data A pointer to additional data about this event.
*/
static void
-gnc_tree_model_commodity_event_handler (GUID *entity, QofIdType type,
+gnc_tree_model_commodity_event_handler (QofEntity *entity,
QofEventId event_type,
- gpointer user_data)
+ gpointer user_data,
+ gpointer event_data)
{
GncTreeModelCommodity *model;
GtkTreePath *path;
@@ -1206,18 +1206,18 @@
remove_data *data;
const gchar *name;
- ENTER("entity %p of type %s, event %d, model %p",
- entity, type, event_type, user_data);
+ ENTER("entity %p, event %d, model %p, event data %p",
+ entity, event_type, user_data, event_data);
model = (GncTreeModelCommodity *)user_data;
/* hard failures */
g_return_if_fail(GNC_IS_TREE_MODEL_COMMODITY(model));
/* get type specific data */
- if (safe_strcmp(type, GNC_ID_COMMODITY) == 0) {
+ if (GNC_IS_COMMODITY(entity)) {
gnc_commodity *commodity;
- commodity = gnc_commodity_find_commodity_by_guid(entity, gnc_get_current_book ());
+ commodity = GNC_COMMODITY(entity);
name = gnc_commodity_get_mnemonic(commodity);
if (event_type != QOF_EVENT_DESTROY) {
if (!gnc_tree_model_commodity_get_iter_from_commodity (model, commodity, &iter)) {
@@ -1225,10 +1225,10 @@
return;
}
}
- } else if (safe_strcmp(type, GNC_ID_COMMODITY_NAMESPACE) == 0) {
+ } else if (GNC_IS_COMMODITY_NAMESPACE(entity)) {
gnc_commodity_namespace *namespace;
- namespace = gnc_commodity_find_namespace_by_guid(entity, gnc_get_current_book ());
+ namespace = GNC_COMMODITY_NAMESPACE(entity);
name = gnc_commodity_namespace_get_name(namespace);
if (event_type != QOF_EVENT_DESTROY) {
if (!gnc_tree_model_commodity_get_iter_from_namespace (model, namespace, &iter)) {
@@ -1257,7 +1257,6 @@
}
data = malloc(sizeof(*data));
- data->guid = *entity;
data->model = model;
data->path = path;
pending_removals = g_slist_append (pending_removals, data);
Modified: gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c
===================================================================
--- gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c 2006-03-09 21:23:42 UTC (rev 13572)
+++ gnucash/trunk/src/gnome-utils/gnc-tree-model-price.c 2006-03-09 21:57:42 UTC (rev 13573)
@@ -101,9 +101,10 @@
static gboolean gnc_tree_model_price_iter_parent (GtkTreeModel *tree_model,
GtkTreeIter *iter,
GtkTreeIter *child);
-static void gnc_tree_model_price_event_handler (GUID *entity, QofIdType type,
+static void gnc_tree_model_price_event_handler (QofEntity *entity,
QofEventId event_type,
- gpointer user_data);
+ gpointer user_data,
+ gpointer event_data);
/** The instance private data for a price database tree model. */
typedef struct GncTreeModelPricePrivate
@@ -252,7 +253,7 @@
priv->price_db = price_db;
priv->event_handler_id =
- qof_event_register_old_handler (gnc_tree_model_price_event_handler, model);
+ qof_event_register_handler (gnc_tree_model_price_event_handler, model);
return GTK_TREE_MODEL (model);
}
@@ -1299,7 +1300,6 @@
/************************************************************/
typedef struct _remove_data {
- GUID guid;
GncTreeModelPrice *model;
GtkTreePath *path;
} remove_data;
@@ -1433,20 +1433,20 @@
* have this model mirror the engine's price table instead of
* referencing it directly.
*
- * @param entity The guid of the affected item.
+ * @param entity The affected item.
*
- * @param type The type of the affected item. This function only
- * cares about items of type "account" or "namespace".
- *
* @param event type The type of the event. This function only cares
* about items of type ADD, REMOVE, and DESTROY.
*
* @param user_data A pointer to the account tree model.
+ *
+ * @param event_data A pointer to additional data about this event.
*/
static void
-gnc_tree_model_price_event_handler (GUID *entity, QofIdType type,
+gnc_tree_model_price_event_handler (QofEntity *entity,
QofEventId event_type,
- gpointer user_data)
+ gpointer user_data,
+ gpointer event_data)
{
GncTreeModelPrice *model;
GtkTreePath *path;
@@ -1454,18 +1454,18 @@
remove_data *data;
const gchar *name;
- ENTER("entity %p of type %s, event %d, model %p",
- entity, type, event_type, user_data);
+ ENTER("entity %p, event %d, model %p, event data %p",
+ entity, event_type, user_data, event_data);
model = (GncTreeModelPrice *)user_data;
/* hard failures */
g_return_if_fail(GNC_IS_TREE_MODEL_PRICE(model));
/* get type specific data */
- if (safe_strcmp(type, GNC_ID_COMMODITY) == 0) {
+ if (GNC_IS_COMMODITY(entity)) {
gnc_commodity *commodity;
- commodity = gnc_commodity_find_commodity_by_guid(entity, gnc_get_current_book ());
+ commodity = GNC_COMMODITY(entity);
name = gnc_commodity_get_mnemonic(commodity);
if (event_type != QOF_EVENT_DESTROY) {
if (!gnc_tree_model_price_get_iter_from_commodity (model, commodity, &iter)) {
@@ -1473,10 +1473,10 @@
return;
}
}
- } else if (safe_strcmp(type, GNC_ID_COMMODITY_NAMESPACE) == 0) {
+ } else if (GNC_IS_COMMODITY_NAMESPACE(entity)) {
gnc_commodity_namespace *namespace;
- namespace = gnc_commodity_find_namespace_by_guid(entity, gnc_get_current_book ());
+ namespace = GNC_COMMODITY_NAMESPACE(entity);
name = gnc_commodity_namespace_get_name(namespace);
if (event_type != QOF_EVENT_DESTROY) {
if (!gnc_tree_model_price_get_iter_from_namespace (model, namespace, &iter)) {
@@ -1484,10 +1484,10 @@
return;
}
}
- } else if (safe_strcmp(type, GNC_ID_PRICE) == 0) {
+ } else if (GNC_IS_PRICE(entity)) {
GNCPrice *price;
- price = gnc_price_lookup(entity, gnc_get_current_book ());
+ price = GNC_PRICE(entity);
name = "price";
if (event_type != QOF_EVENT_DESTROY) {
if (!gnc_tree_model_price_get_iter_from_price (model, price, &iter)) {
@@ -1516,7 +1516,6 @@
}
data = malloc(sizeof(*data));
- data->guid = *entity;
data->model = model;
data->path = path;
pending_removals = g_slist_append (pending_removals, data);
More information about the gnucash-changes
mailing list