diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-08-17 04:16:43 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-08-17 04:16:43 +0800 |
commit | 23c322c8934fb690cf1cbf9e155310e406892b75 (patch) | |
tree | 16a308b3a58d267798f2d5c0efbc9c297024e6de /widgets | |
parent | 0d18ddc63ae6159a1bf3401de9d06d1bab4e4fe0 (diff) | |
download | gsoc2013-evolution-23c322c8934fb690cf1cbf9e155310e406892b75.tar gsoc2013-evolution-23c322c8934fb690cf1cbf9e155310e406892b75.tar.gz gsoc2013-evolution-23c322c8934fb690cf1cbf9e155310e406892b75.tar.bz2 gsoc2013-evolution-23c322c8934fb690cf1cbf9e155310e406892b75.tar.lz gsoc2013-evolution-23c322c8934fb690cf1cbf9e155310e406892b75.tar.xz gsoc2013-evolution-23c322c8934fb690cf1cbf9e155310e406892b75.tar.zst gsoc2013-evolution-23c322c8934fb690cf1cbf9e155310e406892b75.zip |
Adding the first versions of these files. Doesn't work yet.
2001-08-16 Christopher James Lahey <clahey@ximian.com>
* e-table-without.c, e-table-without.h: Adding the first versions
of these files. Doesn't work yet.
svn path=/trunk/; revision=12121
Diffstat (limited to 'widgets')
-rw-r--r-- | widgets/table/e-table-without.c | 136 | ||||
-rw-r--r-- | widgets/table/e-table-without.h | 45 |
2 files changed, 181 insertions, 0 deletions
diff --git a/widgets/table/e-table-without.c b/widgets/table/e-table-without.c new file mode 100644 index 0000000000..ba70ee5651 --- /dev/null +++ b/widgets/table/e-table-without.c @@ -0,0 +1,136 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +/* + * E-table-subset.c: Implements a table that contains a subset of another table. + * + * Author: + * Miguel de Icaza (miguel@gnu.org) + * + * (C) 1999 Ximian, Inc. + */ +#include <config.h> +#include <stdlib.h> +#include <string.h> +#include <gtk/gtksignal.h> +#include "gal/util/e-util.h" +#include "e-table-without.h" + +#define ETW_CLASS(e) ((ETableWithoutClass *)((GtkObject *)e)->klass) + +#define PARENT_TYPE E_TABLE_SUBSET_TYPE + +#define INCREMENT_AMOUNT 10 + +static ETableSubsetClass *parent_class; + +struct _ETableWithoutPrivate { + GHashTable *hash; +}; + +static void +etw_proxy_model_rows_inserted (ETableSubset *etss, ETableModel *etm, int row, int count) +{ + int i; + + for (i = 0; i < etss->n_map; i++) { + if (etss->map_table[i] > row) + etss->map_table[i] += count; + } + + for (i = row; i < row + count; i++) { + if (check ()) { + add_row (); + } + } +} + +static void +etw_proxy_model_rows_deleted (ETableSubset *etss, ETableModel *etm, int row, int count) +{ + for (i = 0; i < n_map; i++) { + if (etss->map_table[i] >= row && etss->map_table[i] < row + count) + remove_row (); + else if (etss->map_table[i] >= row + count) + etss->map_table[i] -= count; + } +} + +static void +etw_proxy_model_changed (ETableSubset *etss, ETableModel *etm) +{ + int i; + int j; + int row_count; + g_free (etss->map_table); + row_count = e_table_model_row_count (etm); + etss->map_table = g_new (int, row_count); + for (i = 0; i < row_count; i++) { + if (check ()) { + etss->map_table[j++] = i; + } + } + etss->n_map = j; + + if (parent_class->proxy_model_changed) + parent_class->proxy_model_changed (etss, etm); +} + +static void +etw_class_init (GtkObjectClass *object_class) +{ + ETableWithoutClass *klass = E_TABLE_WITHOUT_CLASS (object_class); + ETableSubsetClass *etss_class = E_TABLE_SUBSET_CLASS (object_class); + parent_class = gtk_type_class (PARENT_TYPE); + + 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; +} + +E_MAKE_TYPE(e_table_without, "ETableWithout", ETableWithout, etw_class_init, NULL, PARENT_TYPE); + +ETableModel * +e_table_without_construct (ETableWithout *etw, + ETableModel *source) +{ + if (e_table_subset_construct (E_TABLE_SUBSET(etw), source, 1) == NULL) + return NULL; + E_TABLE_SUBSET(etw)->n_map = 0; + + return E_TABLE_MODEL (etw); +} + +ETableModel * +e_table_without_new (ETableModel *source) +{ + ETableWithout *etw = gtk_type_new (E_TABLE_WITHOUT_TYPE); + + if (e_table_without_construct (etw, source) == NULL){ + gtk_object_unref (GTK_OBJECT (etw)); + return NULL; + } + + return (ETableModel *) etw; +} + +void e_table_without_add (ETableWithout *etw, + void *key) +{ + 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 (etss->source, i, key)) { + remove_row (); + } + } +} + +void e_table_without_remove (ETableWithout *etw, + void *key) +{ + ETableSubset *etss = E_TABLE_SUBSET (etw); + for (i = 0; i < count; i++) { + if (check_with_key (etss)) { + add_row (); + } + } +} diff --git a/widgets/table/e-table-without.h b/widgets/table/e-table-without.h new file mode 100644 index 0000000000..59a86b0126 --- /dev/null +++ b/widgets/table/e-table-without.h @@ -0,0 +1,45 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ +#ifndef _E_TABLE_WITHOUT_H_ +#define _E_TABLE_WITHOUT_H_ + +#include <gtk/gtkobject.h> +#include <gal/e-table/e-table-subset.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#define E_TABLE_WITHOUT_TYPE (e_table_without_get_type ()) +#define E_TABLE_WITHOUT(o) (GTK_CHECK_CAST ((o), E_TABLE_WITHOUT_TYPE, ETableWithout)) +#define E_TABLE_WITHOUT_CLASS(k) (GTK_CHECK_CLASS_CAST((k), E_TABLE_WITHOUT_TYPE, ETableWithoutClass)) +#define E_IS_TABLE_WITHOUT(o) (GTK_CHECK_TYPE ((o), E_TABLE_WITHOUT_TYPE)) +#define E_IS_TABLE_WITHOUT_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TABLE_WITHOUT_TYPE)) + +typedef struct _ETableWithoutPrivate ETableWithoutPrivate; + +typedef struct { + ETableSubset base; + + ETableWithoutPrivate *priv; +} ETableWithout; + +typedef struct { + ETableSubsetClass parent_class; + +} ETableWithoutClass; + +GtkType e_table_without_get_type (void); +ETableModel *e_table_without_new (ETableModel *etm); +ETableModel *e_table_without_construct (ETableWithout *etw, + ETableModel *source); +void e_table_without_add (ETableWithout *etw, + void *key); +void e_table_without_remove (ETableWithout *etw, + void *key); +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /* _E_TABLE_WITHOUT_H_ */ + |