r15122 - gnucash/branches/sx-cleanup/src/app-utils - Hookup SX QOF_MODIFY_EVENT -> gnc-sx-instance-model:updated; the sx list view now reflects changes. :)
Joshua Sled
jsled at cvs.gnucash.org
Tue Nov 14 20:45:37 EST 2006
Author: jsled
Date: 2006-11-14 20:45:36 -0500 (Tue, 14 Nov 2006)
New Revision: 15122
Trac: http://svn.gnucash.org/trac/changeset/15122
Modified:
gnucash/branches/sx-cleanup/src/app-utils/gnc-sx-instance-model.c
Log:
Hookup SX QOF_MODIFY_EVENT -> gnc-sx-instance-model:updated; the sx list view now reflects changes. :)
Modified: gnucash/branches/sx-cleanup/src/app-utils/gnc-sx-instance-model.c
===================================================================
--- gnucash/branches/sx-cleanup/src/app-utils/gnc-sx-instance-model.c 2006-11-15 01:44:18 UTC (rev 15121)
+++ gnucash/branches/sx-cleanup/src/app-utils/gnc-sx-instance-model.c 2006-11-15 01:45:36 UTC (rev 15122)
@@ -465,6 +465,14 @@
inst->qof_event_handler_id = qof_event_register_handler(_gnc_sx_instance_event_handler, inst);
}
+static gint
+_gnc_sx_instance_find_by_sx(GncSxInstances *in_list_instances, GncSxInstances *to_find)
+{
+ if (in_list_instances->sx == to_find->sx)
+ return 0;
+ return -1;
+}
+
static void
_gnc_sx_instance_event_handler(QofEntity *ent, QofEventId event_type, gpointer user_data, gpointer evt_data)
{
@@ -484,7 +492,16 @@
sx = GNC_SX(ent);
if (event_type & QOF_EVENT_MODIFY)
{
- /* @re-generate instance, update*/
+ GncSxInstances *new_instances;
+ GList *link;
+
+ new_instances = _gnc_sx_gen_instances((gpointer)sx, &instances->range_end);
+
+ link = g_list_find_custom(instances->sx_instance_list, new_instances, (GCompareFunc)_gnc_sx_instance_find_by_sx);
+ g_assert(link != NULL);
+ // @fixme g_object_unref(link->data);
+ link->data = new_instances;
+ g_signal_emit_by_name(instances, "updated"); // , new_instances[->sx].
}
/* else { unsupported event type; ignore } */
}
@@ -512,8 +529,9 @@
{
g_signal_emit_by_name(instances, "removing", GUINT_TO_POINTER(GPOINTER_TO_UINT(((GncSxInstances*)sx_instance_to_remove)->sx)));
instances->sx_instance_list = g_list_remove(instances->sx_instance_list, sx_instance_to_remove);
- g_signal_emit_by_name(instances, "updated"); // @@fixme remove
+ g_signal_emit_by_name(instances, "updated"); // @@fixme remove when callers support "removing"
}
+ // @@fixme: uh, actually remove...?
else { printf("err\n"); }
}
else if (event_type & GNC_EVENT_ITEM_ADDED)
@@ -523,7 +541,7 @@
= g_list_append(instances->sx_instance_list,
(*_gnc_sx_gen_instances)((gpointer)sx, (gpointer)&instances->range_end));
g_signal_emit_by_name(instances, "added", GUINT_TO_POINTER(GPOINTER_TO_UINT(sx)));
- g_signal_emit_by_name(instances, "updated"); // @fixme remove
+ g_signal_emit_by_name(instances, "updated"); // @fixme remove when callers look for "added".
}
/* else { printf("unsupported event type [%d]\n", event_type); } */
}
More information about the gnucash-changes
mailing list