diff options
author | nobody <nobody@localhost> | 2000-05-15 12:36:44 +0800 |
---|---|---|
committer | nobody <nobody@localhost> | 2000-05-15 12:36:44 +0800 |
commit | ed0a36823be616e1bc7ba9a67e437140c1f12459 (patch) | |
tree | 8e6809dc4947632fed7279523d66fcd047cada6f /widgets/e-table/e-table-subset-variable.c | |
parent | f8ff932ae3149c285acea3977a50596749d38584 (diff) | |
download | gsoc2013-evolution-today.tar gsoc2013-evolution-today.tar.gz gsoc2013-evolution-today.tar.bz2 gsoc2013-evolution-today.tar.lz gsoc2013-evolution-today.tar.xz gsoc2013-evolution-today.tar.zst gsoc2013-evolution-today.zip |
This commit was manufactured by cvs2svn to create tag 'today'.today
svn path=/tags/today/; revision=3041
Diffstat (limited to 'widgets/e-table/e-table-subset-variable.c')
-rw-r--r-- | widgets/e-table/e-table-subset-variable.c | 187 |
1 files changed, 0 insertions, 187 deletions
diff --git a/widgets/e-table/e-table-subset-variable.c b/widgets/e-table/e-table-subset-variable.c deleted file mode 100644 index a8948c5e68..0000000000 --- a/widgets/e-table/e-table-subset-variable.c +++ /dev/null @@ -1,187 +0,0 @@ -/* -*- 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 Helix Code, Inc. - */ -#include <config.h> -#include <stdlib.h> -#include <gtk/gtksignal.h> -#include <string.h> -#include "e-util/e-util.h" -#include "e-table-subset-variable.h" - -#define ETSSV_CLASS(e) ((ETableSubsetVariableClass *)((GtkObject *)e)->klass) - -#define PARENT_TYPE E_TABLE_SUBSET_TYPE - -#define INCREMENT_AMOUNT 10 - -static ETableSubsetClass *etssv_parent_class; - -static void -etssv_add (ETableSubsetVariable *etssv, - gint row) -{ - ETableModel *etm = E_TABLE_MODEL(etssv); - ETableSubset *etss = E_TABLE_SUBSET(etssv); - int i; - - if (etss->n_map + 1 > etssv->n_vals_allocated){ - etss->map_table = g_realloc (etss->map_table, (etssv->n_vals_allocated + INCREMENT_AMOUNT) * sizeof(int)); - etssv->n_vals_allocated += INCREMENT_AMOUNT; - } - if (row < e_table_model_row_count(etss->source) - 1) - for ( i = 0; i < etss->n_map; i++ ) - if (etss->map_table[i] >= row) - etss->map_table[i] ++; - etss->map_table[etss->n_map++] = row; - if (!etm->frozen) - e_table_model_row_inserted (etm, etss->n_map - 1); -} - -static void -etssv_add_all (ETableSubsetVariable *etssv) -{ - ETableModel *etm = E_TABLE_MODEL(etssv); - ETableSubset *etss = E_TABLE_SUBSET(etssv); - int rows = e_table_model_row_count(etss->source); - int i; - - if (etss->n_map + rows > etssv->n_vals_allocated){ - etssv->n_vals_allocated += MAX(INCREMENT_AMOUNT, rows); - etss->map_table = g_realloc (etss->map_table, etssv->n_vals_allocated * sizeof(int)); - } - for (i = 0; i < rows; i++) - etss->map_table[etss->n_map++] = i; - if (!etm->frozen) - e_table_model_changed (etm); -} - -static gboolean -etssv_remove (ETableSubsetVariable *etssv, - gint row) -{ - ETableModel *etm = E_TABLE_MODEL(etssv); - ETableSubset *etss = E_TABLE_SUBSET(etssv); - int i; - int ret_val = FALSE; - - for (i = 0; i < etss->n_map; i++){ - if (etss->map_table[i] == row) { - memmove (etss->map_table + i, etss->map_table + i + 1, (etss->n_map - i - 1) * sizeof(int)); - etss->n_map --; - if (!etm->frozen) - e_table_model_changed (etm); - ret_val = TRUE; - break; - } - } - - for (i = 0; i < etss->n_map; i++){ - if (etss->map_table[i] > row) { - etss->map_table[i] --; - } - } - - return ret_val; -} - -static void -etssv_class_init (GtkObjectClass *object_class) -{ - ETableSubsetVariableClass *klass = E_TABLE_SUBSET_VARIABLE_CLASS(object_class); - etssv_parent_class = gtk_type_class (PARENT_TYPE); - - klass->add = etssv_add; - klass->add_all = etssv_add_all; - klass->remove = etssv_remove; -} - -E_MAKE_TYPE(e_table_subset_variable, "ETableSubsetVariable", ETableSubsetVariable, etssv_class_init, NULL, PARENT_TYPE); - -ETableModel * -e_table_subset_variable_construct (ETableSubsetVariable *etssv, - ETableModel *source) -{ - if (e_table_subset_construct (E_TABLE_SUBSET(etssv), source, 1) == NULL) - return NULL; - E_TABLE_SUBSET(etssv)->n_map = 0; - - return E_TABLE_MODEL (etssv); -} - -ETableModel * -e_table_subset_variable_new (ETableModel *source) -{ - ETableSubsetVariable *etssv = gtk_type_new (E_TABLE_SUBSET_VARIABLE_TYPE); - - if (e_table_subset_variable_construct (etssv, source) == NULL){ - gtk_object_destroy (GTK_OBJECT (etssv)); - return NULL; - } - - return (ETableModel *) etssv; -} - -void -e_table_subset_variable_add (ETableSubsetVariable *etssv, - gint row) -{ - g_return_if_fail (etssv != NULL); - g_return_if_fail (E_IS_TABLE_SUBSET_VARIABLE(etssv)); - - if (ETSSV_CLASS(etssv)->add) - ETSSV_CLASS (etssv)->add (etssv, row); -} - -void -e_table_subset_variable_add_all (ETableSubsetVariable *etssv) -{ - g_return_if_fail (etssv != NULL); - g_return_if_fail (E_IS_TABLE_SUBSET_VARIABLE(etssv)); - - if (ETSSV_CLASS(etssv)->add_all) - ETSSV_CLASS (etssv)->add_all (etssv); -} - -gboolean -e_table_subset_variable_remove (ETableSubsetVariable *etssv, - gint row) -{ - g_return_val_if_fail (etssv != NULL, FALSE); - g_return_val_if_fail (E_IS_TABLE_SUBSET_VARIABLE(etssv), FALSE); - - if (ETSSV_CLASS(etssv)->remove) - return ETSSV_CLASS (etssv)->remove (etssv, row); - else - return FALSE; -} - -void -e_table_subset_variable_increment (ETableSubsetVariable *etssv, - gint position, - gint amount) -{ - int i; - ETableSubset *etss = E_TABLE_SUBSET(etssv); - for (i = 0; i < etss->n_map; i++){ - if (etss->map_table[i] > position) - etss->map_table[i] += amount; - } -} - -void -e_table_subset_variable_set_allocation (ETableSubsetVariable *etssv, - gint total) -{ - ETableSubset *etss = E_TABLE_SUBSET(etssv); - if (total <= 0) - total = 1; - if (total > etss->n_map){ - etss->map_table = g_realloc (etss->map_table, total * sizeof(int)); - } -} |