static void
etssv_add_all (ETableSubsetVariable *etssv)
{
	ETableModel *etm = E_TABLE_MODEL (etssv);
	ETableSubset *etss = E_TABLE_SUBSET (etssv);
	ETableModel *source_model;
	gint rows;
	gint i;

	e_table_model_pre_change (etm);

	source_model = e_table_subset_get_source_model (etss);
	rows = e_table_model_row_count (source_model);

	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 (gint));
	}
	for (i = 0; i < rows; i++)
		etss->map_table[etss->n_map++] = i;

	e_table_model_changed (etm);
}
static void
etsv_add_all   (ETableSubsetVariable *etssv)
{
	ETableModel *etm = E_TABLE_MODEL(etssv);
	ETableSubset *etss = E_TABLE_SUBSET(etssv);
	ETableSortedVariable *etsv = E_TABLE_SORTED_VARIABLE (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;

	if (etsv->sort_idle_id == 0) {
		etsv->sort_idle_id = g_idle_add_full(50, (GSourceFunc) etsv_sort_idle, etsv, NULL);
	}

	e_table_model_changed (etm);
}
static void
etsv_sort(ETableSortedVariable *etsv)
{
	ETableSubset *etss = E_TABLE_SUBSET(etsv);
	static int reentering = 0;
	if (reentering)
		return;
	reentering = 1;

	e_table_model_pre_change(E_TABLE_MODEL(etsv));

	e_table_sorting_utils_sort(etss->source, etsv->sort_info, etsv->full_header, etss->map_table, etss->n_map);

	e_table_model_changed (E_TABLE_MODEL(etsv));
	reentering = 0;
}
static void
etssv_add_array (ETableSubsetVariable *etssv,
                 const gint *array,
                 gint count)
{
	ETableModel *etm = E_TABLE_MODEL (etssv);
	ETableSubset *etss = E_TABLE_SUBSET (etssv);
	gint 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 (gint));
	}
	for (i = 0; i < count; i++)
		etss->map_table[etss->n_map++] = array[i];

	e_table_model_changed (etm);
}