diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-07-01 22:45:01 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-07-02 22:34:11 +0800 |
commit | 4391d00cdfabb436e31ce1a3bdbe9d623132d79d (patch) | |
tree | 61eff4b0e883fb294c4f216558f2f8215c810cb7 /e-util | |
parent | 1f6560f3f2a1df2ae5bffae56a52206dd193a694 (diff) | |
download | gsoc2013-evolution-4391d00cdfabb436e31ce1a3bdbe9d623132d79d.tar.gz gsoc2013-evolution-4391d00cdfabb436e31ce1a3bdbe9d623132d79d.tar.zst gsoc2013-evolution-4391d00cdfabb436e31ce1a3bdbe9d623132d79d.zip |
Remove ETableWithout.
No longer used.
Diffstat (limited to 'e-util')
-rw-r--r-- | e-util/Makefile.am | 2 | ||||
-rw-r--r-- | e-util/e-table-without.c | 423 | ||||
-rw-r--r-- | e-util/e-table-without.h | 104 | ||||
-rw-r--r-- | e-util/e-util.h | 1 |
4 files changed, 0 insertions, 530 deletions
diff --git a/e-util/Makefile.am b/e-util/Makefile.am index ea3113a352..ab4efa5f57 100644 --- a/e-util/Makefile.am +++ b/e-util/Makefile.am @@ -283,7 +283,6 @@ evolution_util_include_HEADERS = \ e-table-subset-variable.h \ e-table-subset.h \ e-table-utils.h \ - e-table-without.h \ e-table.h \ e-text-event-processor-emacs-like.h \ e-text-event-processor-types.h \ @@ -526,7 +525,6 @@ libevolution_util_la_SOURCES = \ e-table-subset-variable.c \ e-table-subset.c \ e-table-utils.c \ - e-table-without.c \ e-table.c \ e-text-event-processor-emacs-like.c \ e-text-event-processor.c \ diff --git a/e-util/e-table-without.c b/e-util/e-table-without.c deleted file mode 100644 index 8e72747759..0000000000 --- a/e-util/e-table-without.c +++ /dev/null @@ -1,423 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#include <stdlib.h> -#include <string.h> - -#include "e-table-without.h" - -#define E_TABLE_WITHOUT_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), E_TYPE_TABLE_WITHOUT, ETableWithoutPrivate)) - -G_DEFINE_TYPE (ETableWithout, e_table_without, E_TYPE_TABLE_SUBSET) - -#define INCREMENT_AMOUNT 10 - -struct _ETableWithoutPrivate { - GHashTable *hash; - - GHashFunc hash_func; - GCompareFunc compare_func; - - ETableWithoutGetKeyFunc get_key_func; - ETableWithoutDuplicateKeyFunc duplicate_key_func; - ETableWithoutFreeKeyFunc free_gotten_key_func; - ETableWithoutFreeKeyFunc free_duplicated_key_func; - - gpointer closure; -}; - -static gboolean -check (ETableWithout *etw, - gint model_row) -{ - gboolean ret_val; - gpointer key; - ETableSubset *etss = E_TABLE_SUBSET (etw); - ETableModel *source_model; - - source_model = e_table_subset_get_source_model (etss); - - if (etw->priv->get_key_func) - key = etw->priv->get_key_func ( - source_model, model_row, etw->priv->closure); - else - key = GINT_TO_POINTER (model_row); - ret_val = (g_hash_table_lookup (etw->priv->hash, key) != NULL); - if (etw->priv->free_gotten_key_func) - etw->priv->free_gotten_key_func (key, etw->priv->closure); - return ret_val; -} - -static gboolean -check_with_key (ETableWithout *etw, - gpointer key, - gint model_row) -{ - gboolean ret_val; - gpointer key2; - ETableSubset *etss = E_TABLE_SUBSET (etw); - ETableModel *source_model; - - source_model = e_table_subset_get_source_model (etss); - - if (etw->priv->get_key_func) - key2 = etw->priv->get_key_func ( - source_model, 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 (key2, etw->priv->closure); - return ret_val; -} - -static gint -etw_view_to_model_row (ETableWithout *etw, - gint view_row) -{ - ETableSubset *etss = E_TABLE_SUBSET (etw); - return etss->map_table[view_row]; -} - -static void -add_row (ETableWithout *etw, - gint model_row) -{ - ETableSubset *etss = E_TABLE_SUBSET (etw); - - e_table_model_pre_change (E_TABLE_MODEL (etw)); - - etss->map_table = g_renew (int, etss->map_table, etss->n_map + 1); - - etss->map_table[etss->n_map++] = model_row; - - e_table_model_row_inserted (E_TABLE_MODEL (etw), etss->n_map - 1); -} - -static void -remove_row (ETableWithout *etw, - gint view_row) -{ - ETableSubset *etss = E_TABLE_SUBSET (etw); - - e_table_model_pre_change (E_TABLE_MODEL (etw)); - memmove ( - etss->map_table + view_row, - etss->map_table + view_row + 1, - (etss->n_map - view_row - 1) * sizeof (gint)); - etss->n_map--; - e_table_model_row_deleted (E_TABLE_MODEL (etw), view_row); -} - -static void -delete_hash_element (gpointer key, - gpointer value, - gpointer closure) -{ - ETableWithout *etw = closure; - if (etw->priv->free_duplicated_key_func) - etw->priv->free_duplicated_key_func (key, etw->priv->closure); -} - -static void -etw_dispose (GObject *object) -{ - ETableWithoutPrivate *priv; - - priv = E_TABLE_WITHOUT_GET_PRIVATE (object); - - if (priv->hash != NULL) { - g_hash_table_foreach (priv->hash, delete_hash_element, object); - g_hash_table_destroy (priv->hash); - priv->hash = NULL; - } - - /* Chain up to parent's dispose() method. */ - G_OBJECT_CLASS (e_table_without_parent_class)->dispose (object); -} - -static void -etw_proxy_model_rows_inserted (ETableSubset *etss, - ETableModel *etm, - gint model_row, - gint count) -{ - gint i; - ETableWithout *etw = E_TABLE_WITHOUT (etss); - gboolean shift = FALSE; - - /* i is View row */ - if (model_row != etss->n_map) { - for (i = 0; i < etss->n_map; i++) { - if (etss->map_table[i] > model_row) - etss->map_table[i] += count; - } - shift = TRUE; - } - - /* i is Model row */ - for (i = model_row; i < model_row + count; i++) { - if (!check (etw, i)) { - add_row (etw, i); - } - } - if (shift) - e_table_model_changed (E_TABLE_MODEL (etw)); - else - e_table_model_no_change (E_TABLE_MODEL (etw)); -} - -static void -etw_proxy_model_rows_deleted (ETableSubset *etss, - ETableModel *etm, - gint model_row, - gint count) -{ - gint i; /* View row */ - ETableWithout *etw = E_TABLE_WITHOUT (etss); - gboolean shift = FALSE; - - for (i = 0; i < etss->n_map; i++) { - if (etss->map_table[i] >= model_row && - etss->map_table[i] < model_row + count) { - remove_row (etw, i); - i--; - } else if (etss->map_table[i] >= model_row + count) { - etss->map_table[i] -= count; - shift = TRUE; - } - } - if (shift) - e_table_model_changed (E_TABLE_MODEL (etw)); - else - e_table_model_no_change (E_TABLE_MODEL (etw)); -} - -static void -etw_proxy_model_changed (ETableSubset *etss, - ETableModel *etm) -{ - gint i; /* Model row */ - gint j; /* View row */ - gint row_count; - ETableWithout *etw = E_TABLE_WITHOUT (etss); - - g_free (etss->map_table); - row_count = e_table_model_row_count (etm); - etss->map_table = g_new (int, row_count); - - for (i = 0, j = 0; i < row_count; i++) { - if (!check (etw, i)) { - etss->map_table[j++] = i; - } - } - etss->n_map = j; - - if (E_TABLE_SUBSET_CLASS (e_table_without_parent_class)->proxy_model_changed) - E_TABLE_SUBSET_CLASS (e_table_without_parent_class)->proxy_model_changed (etss, etm); -} - -static void -e_table_without_class_init (ETableWithoutClass *class) -{ - GObjectClass *object_class; - ETableSubsetClass *etss_class; - - g_type_class_add_private (class, sizeof (ETableWithoutPrivate)); - - object_class = G_OBJECT_CLASS (class); - object_class->dispose = etw_dispose; - - etss_class = E_TABLE_SUBSET_CLASS (class); - etss_class->proxy_model_rows_inserted = etw_proxy_model_rows_inserted; - etss_class->proxy_model_rows_deleted = etw_proxy_model_rows_deleted; - etss_class->proxy_model_changed = etw_proxy_model_changed; -} - -static void -e_table_without_init (ETableWithout *etw) -{ - etw->priv = E_TABLE_WITHOUT_GET_PRIVATE (etw); -} - -ETableModel * -e_table_without_construct (ETableWithout *etw, - ETableModel *source, - GHashFunc hash_func, - GCompareFunc compare_func, - ETableWithoutGetKeyFunc get_key_func, - ETableWithoutDuplicateKeyFunc duplicate_key_func, - ETableWithoutFreeKeyFunc free_gotten_key_func, - ETableWithoutFreeKeyFunc free_duplicated_key_func, - gpointer closure) -{ - if (e_table_subset_construct (E_TABLE_SUBSET (etw), source, 1) == NULL) - return NULL; - E_TABLE_SUBSET (etw)->n_map = 0; - - etw->priv->hash_func = hash_func; - etw->priv->compare_func = compare_func; - etw->priv->get_key_func = get_key_func; - etw->priv->duplicate_key_func = duplicate_key_func; - etw->priv->free_gotten_key_func = free_gotten_key_func; - etw->priv->free_duplicated_key_func = free_duplicated_key_func; - etw->priv->closure = closure; - - etw->priv->hash = g_hash_table_new ( - etw->priv->hash_func, etw->priv->compare_func); - - return E_TABLE_MODEL (etw); -} - -ETableModel * -e_table_without_new (ETableModel *source, - GHashFunc hash_func, - GCompareFunc compare_func, - ETableWithoutGetKeyFunc get_key_func, - ETableWithoutDuplicateKeyFunc duplicate_key_func, - ETableWithoutFreeKeyFunc free_gotten_key_func, - ETableWithoutFreeKeyFunc free_duplicated_key_func, - gpointer closure) -{ - ETableWithout *etw = g_object_new (E_TYPE_TABLE_WITHOUT, NULL); - - if (e_table_without_construct (etw, - source, - hash_func, - compare_func, - get_key_func, - duplicate_key_func, - free_gotten_key_func, - free_duplicated_key_func, - closure) - == NULL) { - g_object_unref (etw); - return NULL; - } - - return (ETableModel *) etw; -} - -void -e_table_without_hide (ETableWithout *etw, - gpointer key) -{ - gint i; /* View row */ - ETableSubset *etss = E_TABLE_SUBSET (etw); - - 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++) { - if (check_with_key (etw, key, etw_view_to_model_row (etw, i))) { - remove_row (etw, i); - i--; - } - } -} - -/* An adopted key will later be freed using the free_duplicated_key function. */ -void -e_table_without_hide_adopt (ETableWithout *etw, - gpointer key) -{ - gint i; /* View row */ - ETableSubset *etss = E_TABLE_SUBSET (etw); - - g_hash_table_insert (etw->priv->hash, key, key); - for (i = 0; i < etss->n_map; i++) { - if (check_with_key (etw, key, etw_view_to_model_row (etw, i))) { - remove_row (etw, i); - i--; - } - } -} - -void -e_table_without_show (ETableWithout *etw, - gpointer key) -{ - gint i; /* Model row */ - ETableSubset *etss = E_TABLE_SUBSET (etw); - ETableModel *source_model; - gint count; - gpointer old_key; - - source_model = e_table_subset_get_source_model (etss); - count = e_table_model_row_count (source_model); - - for (i = 0; i < count; i++) { - if (check_with_key (etw, key, i)) { - add_row (etw, i); - } - } - if (g_hash_table_lookup_extended (etw->priv->hash, key, &old_key, NULL)) { -#if 0 - if (etw->priv->free_duplicated_key_func) - etw->priv->free_duplicated_key_func (key, etw->priv->closure); -#endif - g_hash_table_remove (etw->priv->hash, key); - } -} - -void -e_table_without_show_all (ETableWithout *etw) -{ - gint i; /* Model row */ - gint row_count; - ETableSubset *etss = E_TABLE_SUBSET (etw); - ETableModel *source_model; - - e_table_model_pre_change (E_TABLE_MODEL (etw)); - - if (etw->priv->hash) { - g_hash_table_foreach (etw->priv->hash, delete_hash_element, etw); - g_hash_table_destroy (etw->priv->hash); - etw->priv->hash = NULL; - } - etw->priv->hash = g_hash_table_new ( - etw->priv->hash_func, etw->priv->compare_func); - - source_model = e_table_subset_get_source_model (etss); - row_count = e_table_model_row_count (source_model); - - g_free (etss->map_table); - etss->map_table = g_new (int, row_count); - - for (i = 0; i < row_count; i++) { - etss->map_table[i] = i; - } - etss->n_map = row_count; - - e_table_model_changed (E_TABLE_MODEL (etw)); -} diff --git a/e-util/e-table-without.h b/e-util/e-table-without.h deleted file mode 100644 index 0853c54cb5..0000000000 --- a/e-util/e-table-without.h +++ /dev/null @@ -1,104 +0,0 @@ -/* - * - * This program is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2 of the License, or (at your option) version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with the program; if not, see <http://www.gnu.org/licenses/> - * - * - * Authors: - * Chris Lahey <clahey@ximian.com> - * - * Copyright (C) 1999-2008 Novell, Inc. (www.novell.com) - * - */ - -#if !defined (__E_UTIL_H_INSIDE__) && !defined (LIBEUTIL_COMPILATION) -#error "Only <e-util/e-util.h> should be included directly." -#endif - -#ifndef _E_TABLE_WITHOUT_H_ -#define _E_TABLE_WITHOUT_H_ - -#include <e-util/e-table-subset.h> - -/* Standard GObject macros */ -#define E_TYPE_TABLE_WITHOUT \ - (e_table_without_get_type ()) -#define E_TABLE_WITHOUT(obj) \ - (G_TYPE_CHECK_INSTANCE_CAST \ - ((obj), E_TYPE_TABLE_WITHOUT, ETableWithout)) -#define E_TABLE_WITHOUT_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_CAST \ - ((cls), E_TYPE_TABLE_WITHOUT, ETableWithoutClass)) -#define E_IS_TABLE_WITHOUT(obj) \ - (G_TYPE_CHECK_INSTANCE_TYPE \ - ((obj), E_TYPE_TABLE_WITHOUT)) -#define E_IS_TABLE_WITHOUT_CLASS(cls) \ - (G_TYPE_CHECK_CLASS_TYPE \ - ((cls), E_TYPE_TABLE_WITHOUT)) -#define E_TABLE_WITHOUT_GET_CLASS(obj) \ - (G_TYPE_INSTANCE_GET_CLASS \ - ((obj), E_TYPE_TABLE_WITHOUT, ETableWithoutClass)) - -G_BEGIN_DECLS - -typedef struct _ETableWithout ETableWithout; -typedef struct _ETableWithoutClass ETableWithoutClass; -typedef struct _ETableWithoutPrivate ETableWithoutPrivate; - -typedef gpointer (*ETableWithoutGetKeyFunc) (ETableModel *source, - gint row, - gpointer closure); -typedef gpointer (*ETableWithoutDuplicateKeyFunc)(gconstpointer key, - gpointer closure); -typedef void (*ETableWithoutFreeKeyFunc) (gpointer key, - gpointer closure); - -struct _ETableWithout { - ETableSubset parent; - ETableWithoutPrivate *priv; -}; - -struct _ETableWithoutClass { - ETableSubsetClass parent_class; -}; - -GType e_table_without_get_type (void) G_GNUC_CONST; -ETableModel * e_table_without_new (ETableModel *source, - GHashFunc hash_func, - GCompareFunc compare_func, - ETableWithoutGetKeyFunc get_key_func, - ETableWithoutDuplicateKeyFunc duplicate_key_func, - ETableWithoutFreeKeyFunc free_gotten_key_func, - ETableWithoutFreeKeyFunc free_duplicated_key_func, - gpointer closure); -ETableModel * e_table_without_construct (ETableWithout *etw, - ETableModel *source, - GHashFunc hash_func, - GCompareFunc compare_func, - ETableWithoutGetKeyFunc get_key_func, - ETableWithoutDuplicateKeyFunc duplicate_key_func, - ETableWithoutFreeKeyFunc free_gotten_key_func, - ETableWithoutFreeKeyFunc free_duplicated_key_func, - gpointer closure); -void e_table_without_hide (ETableWithout *etw, - gpointer key); -void e_table_without_hide_adopt (ETableWithout *etw, - gpointer key); -void e_table_without_show (ETableWithout *etw, - gpointer key); -void e_table_without_show_all (ETableWithout *etw); - -G_END_DECLS - -#endif /* _E_TABLE_WITHOUT_H_ */ - diff --git a/e-util/e-util.h b/e-util/e-util.h index 0b54db8241..d2bd74229c 100644 --- a/e-util/e-util.h +++ b/e-util/e-util.h @@ -198,7 +198,6 @@ #include <e-util/e-table-subset-variable.h> #include <e-util/e-table-subset.h> #include <e-util/e-table-utils.h> -#include <e-util/e-table-without.h> #include <e-util/e-table.h> #include <e-util/e-text-event-processor-emacs-like.h> #include <e-util/e-text-event-processor-types.h> |