From 4dd3f5e734c4582596bfdabc29ffcac8261fb74d Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Mon, 20 Aug 2001 17:13:36 +0000 Subject: Made this object handle NULLs for all the handler functions. 2001-08-20 Christopher James Lahey * e-table-without.c: Made this object handle NULLs for all the handler functions. svn path=/trunk/; revision=12316 --- widgets/table/e-table-without.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) (limited to 'widgets') diff --git a/widgets/table/e-table-without.c b/widgets/table/e-table-without.c index 366b6c9f35..a597ac7381 100644 --- a/widgets/table/e-table-without.c +++ b/widgets/table/e-table-without.c @@ -43,9 +43,13 @@ check (ETableWithout *etw, int model_row) void *key; ETableSubset *etss = E_TABLE_SUBSET (etw); - key = etw->priv->get_key_func (etss->source, model_row, etw->priv->closure); + if (etw->priv->get_key_func) + key = etw->priv->get_key_func (etss->source, model_row, etw->priv->closure); + else + key = GINT_TO_POINTER (model_row); ret_val = (g_hash_table_lookup (etw->priv->hash, key) != NULL); - etw->priv->free_gotten_key_func (key, etw->priv->closure); + if (etw->priv->free_gotten_key_func) + etw->priv->free_gotten_key_func (key, etw->priv->closure); return ret_val; } @@ -56,9 +60,16 @@ check_with_key (ETableWithout *etw, void *key, int model_row) void *key2; ETableSubset *etss = E_TABLE_SUBSET (etw); - key2 = etw->priv->get_key_func (etss->source, model_row, etw->priv->closure); - ret_val = (etw->priv->compare_func (key, key2)); - etw->priv->free_gotten_key_func (key, etw->priv->closure); + if (etw->priv->get_key_func) + key2 = etw->priv->get_key_func (etss->source, model_row, etw->priv->closure); + else + key2 = GINT_TO_POINTER (model_row); + if (etw->priv->compare_func) + ret_val = (etw->priv->compare_func (key, key2)); + else + ret_val = (key == key2); + if (etw->priv->free_gotten_key_func) + etw->priv->free_gotten_key_func (key, etw->priv->closure); return ret_val; } @@ -97,7 +108,8 @@ delete_hash_element (gpointer key, gpointer closure) { ETableWithout *etw = closure; - etw->priv->free_duplicated_key_func (key, etw->priv->closure); + if (etw->priv->free_duplicated_key_func) + etw->priv->free_duplicated_key_func (key, etw->priv->closure); } static void @@ -269,7 +281,8 @@ void e_table_without_add (ETableWithout *etw, int i; /* View row */ ETableSubset *etss = E_TABLE_SUBSET (etw); - key = etw->priv->duplicate_key_func (key, etw->priv->closure); + if (etw->priv->duplicate_key_func) + key = etw->priv->duplicate_key_func (key, etw->priv->closure); g_hash_table_insert (etw->priv->hash, key, key); for (i = 0; i < etss->n_map; i++) { @@ -312,7 +325,8 @@ void e_table_without_remove (ETableWithout *etw, } } if (g_hash_table_lookup_extended (etw->priv->hash, key, &old_key, NULL)) { - etw->priv->free_duplicated_key_func (key, etw->priv->closure); + if (etw->priv->free_duplicated_key_func) + etw->priv->free_duplicated_key_func (key, etw->priv->closure); g_hash_table_remove (etw->priv->hash, key); } } -- cgit v1.2.3