/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * e-table-subset-variable.c * Copyright 2000, 2001, Ximian, Inc. * * Authors: * Chris Lahey * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public * License, version 2, as published by the Free Software Foundation. * * This library 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 * Library General Public License for more details. * * You should have received a copy of the GNU Library General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA * 02111-1307, USA. */ #include #include #include #include #include "gal/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); e_table_model_pre_change(etm); if (etss->n_map + 1 > etssv->n_vals_allocated){ etssv->n_vals_allocated += INCREMENT_AMOUNT; etss->map_table = g_realloc (etss->map_table, etssv->n_vals_allocated * sizeof(int)); } etss->map_table[etss->n_map++] = row; e_table_model_row_inserted (etm, etss->n_map - 1); } static void etssv_add_array (ETableSubsetVariable *etssv, const gint *array, gint count) { ETableModel *etm = E_TABLE_MODEL(etssv); ETableSubset *etss = E_TABLE_SUBSET(etssv); int i; e_table_model_pre_change(etm); if (etss->n_map + count > etssv->n_vals_allocated){ etssv->n_vals_allocated += MAX(INCREMENT_AMOUNT, count); etss->map_table = g_realloc (etss->map_table, etssv->n_vals_allocated * sizeof(int)); } for (i = 0; i < count; i++) etss->map_table[etss->n_map++] = array[i]; e_table_model_changed (etm); } static void etssv_add_all (ETableSubsetVariable *etssv) { ETableModel *etm = E_TABLE_MODEL(etssv); ETableSubset *etss = E_TABLE_SUBSET(etssv); int rows; int i; e_table_model_pre_change(etm); rows = e_table_model_row_count(etss->source); 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; 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; for (i = 0; i < etss->n_map; i++){ if (etss->map_table[i] == row) { e_table_model_pre_change (etm); memmove (etss->map_table + i, etss->map_table + i + 1, (etss->n_map - i - 1) * sizeof(int)); etss->n_map --; e_table_model_row_deleted (etm, i); return TRUE; } } return FALSE; } 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_array = etssv_add_array; 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_unref (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_array (ETableSubsetVariable *etssv, const gint *array, gint count) { g_return_if_fail (etssv != NULL); g_return_if_fail (E_IS_TABLE_SUBSET_VARIABLE(etssv)); if (ETSSV_CLASS(etssv)->add_array) ETSSV_CLASS (etssv)->add_array (etssv, array, count); } 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_decrement (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)); } } nome/log/devel/R-cran-foreach?h=gnome-3.24'>R-cran-foreach
Commit message (Expand)AuthorAgeFilesLines
* Remove ${PORTSDIR}/ from dependencies, categories d, e, f, and g.mat2016-04-011-1/+1
* - Update to 1.4.3tota2015-11-193-5/+4
* Update the default version of GCC in the Ports Collection from GCC 4.7.4gerald2014-09-111-0/+1
* - Update to 1.4.2tota2014-04-122-4/+3
* Update the default version of GCC used in the Ports Collection fromgerald2014-03-111-1/+1
* - rename AL2 to APACHE20 in Mk/bsd.licenses.db.mkohauer2013-12-311-1/+1
* Convert Mk/bsd.cran.mk to the Uses framework.dbn2013-12-281-2/+1
* Add stage support to Mk/bsd.cran.mk and all USE_R_MOD ports (aka R-cran-*).dbn2013-11-281-1/+0
* Update math/R to 3.0.2 patched r64207 and math/R-cran-SuppDists to 1.1-9.1;bf2013-11-131-1/+1
* Update to libmpc version 1.0.1 which brings the following fixes:gerald2013-10-261-0/+1
* Add NO_STAGE all over the place in preparation for the staging support (cat: ...bapt2013-09-211-0/+1
* - Update to 1.4.1tota2013-06-213-5/+4
* Update math/R to 3.0.1-patched, and adjust dependent ports;bf2013-05-281-1/+1
* update math/R to 2.15.3, and adjust dependent portsbf2013-03-071-1/+1
* update the R base ports to 2.15.2 and adjust dependent portsbf2013-01-051-6/+2
* update math/R to 2.15.1, switch to the new options format, andbf2012-06-271-1/+1
* - update math/R-cran-psych to 1.2.1 [1]bf2012-05-051-0/+1
* - Update to 1.4.0tota2012-04-182-3/+3
* - Update to 1.3.5tota2012-03-162-3/+3
* - Update to 1.3.4tota2012-03-152-4/+3
* update math/R to 2.14.2, and adjust dependent portsbf2012-03-041-1/+1
* update math/R to 2.14.1, and adjust dependent portsbf2012-01-191-1/+1
* - The proper acronym for Apache Software License 2 is really AL2tabthorpe2012-01-091-1/+1
* update math/R to 2.14.0, math/R-cran-sp to 0.9-91, and adjustbf2011-11-271-1/+1
* - Move PKGNAMEPREFIX defined in each R-cran- related ports Makefiletota2011-11-161-1/+0
* update math/R to 2.13.2, and adjust dependent portsbf2011-10-111-0/+1