aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table-subset.c
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/e-table-subset.c')
-rw-r--r--widgets/e-table-subset.c114
1 files changed, 92 insertions, 22 deletions
diff --git a/widgets/e-table-subset.c b/widgets/e-table-subset.c
index 0b9621ac84..afa1b862b4 100644
--- a/widgets/e-table-subset.c
+++ b/widgets/e-table-subset.c
@@ -19,52 +19,122 @@ etss_destroy (GtkObject *object)
{
ETableSubset *etss = E_TABLE_SUBSET (object);
- gtk_object_unref (GTK_OBJECT (etss->source));
- free (ets->subset_table);
+ if (etss->source)
+ gtk_object_unref (GTK_OBJECT (etss->source));
- GTK_OBJECT_CLASS (ets_parent_class)->destroy (object);
+ if (etss->map_table)
+ free (etss->map_table);
+
+ GTK_OBJECT_CLASS (etss_parent_class)->destroy (object);
+}
+
+static int
+etss_column_count (ETableModel *etm)
+{
+ ETableSubset *etss = (ETableSubset *)etm;
+
+ return e_table_model_column_count (etss->source);
+}
+
+static const char *
+etss_column_name (ETableModel *etm, int col)
+{
+ ETableSubset *etss = (ETableSubset *)etm;
+
+ return e_table_model_column_name (etss->source, col);
+}
+
+static int
+etss_row_count (ETableModel *etm)
+{
+ ETableSubset *etss = (ETableSubset *)etm;
+
+ return e_table_model_row_count (etss->source);
+}
+
+static void *
+etss_value_at (ETableModel *etm, int col, int row)
+{
+ ETableSubset *etss = (ETableSubset *)etm;
+
+ return e_table_model_value_at (etss->source, col, etss->map_table [row]);
+}
+
+static void
+etss_set_value_at (ETableModel *etm, int col, int row, void *val)
+{
+ ETableSubset *etss = (ETableSubset *)etm;
+
+ return e_table_model_set_value_at (etss->source, col, etss->map_table [row], val);
+}
+
+static gboolean
+etss_is_cell_editable (ETableModel *etm, int col, int row)
+{
+ ETableSubset *etss = (ETableSubset *)etm;
+
+ return e_table_model_is_cell_editable (etss->source, col, etss->map_table [row]);
+}
+
+static int
+etss_row_height (ETableModel *etm, int row)
+{
+ ETableSubset *etss = (ETableSubset *)etm;
+
+ return e_table_model_row_height (etss->source, etss->map_table [row]);
}
static void
etss_class_init (GtkObjectClass *klass)
{
+ ETableModelClass *table_class = (ETableModelClass *) klass;
+
etss_parent_class = gtk_type_class (PARENT_TYPE);
klass->destroy = etss_destroy;
+
+ table_class->column_count = etss_column_count;
+ table_class->column_name = etss_column_name;
+ table_class->row_count = etss_row_count;
+ table_class->value_at = etss_value_at;
+ table_class->set_value_at = etss_set_value_at;
+ table_class->is_cell_editable = etss_is_cell_editable;
+ table_class->row_height = etss_row_height;
+
}
E_MAKE_TYPE(e_table_subset, "ETableSubset", ETableSubset, etss_class_init, NULL, PARENT_TYPE);
ETableModel *
-e_table_subset_new (ETableModel *source, ETableHeader *header, short sort_field)
+e_table_subset_construct (ETableSubset *etss, ETableModel *source, int nvals)
{
- ETableSorted *ets = gtk_type_new (E_TABLE_SORTED_TYPE);
- const int nvals = e_table_model_row_count (source);
unsigned int *buffer;
int i;
- buffer = malloc (sizeof (unsigned int *) * nvals);
+ buffer = (unsigned int *) malloc (sizeof (unsigned int *) * nvals);
if (buffer = NULL)
return NULL;
- ets->map_table = buffer;
- ets->n_map = nvals;
- ets->source = source;
- ets->header = header;
- ets->sort_col = e_table_header_get_column (header, sort_field);
- ets->sort_idx = sort_field;
+ etss->map_table = buffer;
+ etss->n_map = nvals;
+ etss->source = source;
gtk_object_ref (GTK_OBJECT (source));
- gtk_object_ref (GTK_OBJECT (header));
/* Init */
for (i = 0; i < nvals; i++)
- ets->map_table [i] = i;
+ etss->map_table [i] = i;
- /* Sort */
- g_assert (sort_ets == NULL);
- sort_ets = ets;
- qsort (ets->map_table, nvals, sizeof (unsigned int), my_sort);
- sort_ets = NULL;
-
- return (ETableModel *) ets;
+}
+
+ETableModel *
+e_table_subset_new (ETableModel *source, const int nvals)
+{
+ ETableSubset *etss = gtk_type_new (E_TABLE_SUBSET_TYPE);
+
+ if (e_table_subset_construct (etss, source, nvals) == NULL){
+ gtk_object_destroy (GTK_OBJECT (etss));
+ return NULL;
+ }
+
+ return (ETableModel *) etss;
}