aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table-model.c
diff options
context:
space:
mode:
authorArturo Espinosa <unammx@src.gnome.org>1999-11-02 04:35:26 +0800
committerArturo Espinosa <unammx@src.gnome.org>1999-11-02 04:35:26 +0800
commitc5e2fd8592f00928776550e078f9eeba31caa163 (patch)
tree5be84c3f277c1ce679b644c04ad8334c7f345a2a /widgets/e-table-model.c
parentc8d14b53ef41de80458405ffadb0721458b7add9 (diff)
downloadgsoc2013-evolution-c5e2fd8592f00928776550e078f9eeba31caa163.tar
gsoc2013-evolution-c5e2fd8592f00928776550e078f9eeba31caa163.tar.gz
gsoc2013-evolution-c5e2fd8592f00928776550e078f9eeba31caa163.tar.bz2
gsoc2013-evolution-c5e2fd8592f00928776550e078f9eeba31caa163.tar.lz
gsoc2013-evolution-c5e2fd8592f00928776550e078f9eeba31caa163.tar.xz
gsoc2013-evolution-c5e2fd8592f00928776550e078f9eeba31caa163.tar.zst
gsoc2013-evolution-c5e2fd8592f00928776550e078f9eeba31caa163.zip
Added my widgets stuff -miguel
svn path=/trunk/; revision=1364
Diffstat (limited to 'widgets/e-table-model.c')
-rw-r--r--widgets/e-table-model.c152
1 files changed, 152 insertions, 0 deletions
diff --git a/widgets/e-table-model.c b/widgets/e-table-model.c
new file mode 100644
index 0000000000..23782e52c9
--- /dev/null
+++ b/widgets/e-table-model.c
@@ -0,0 +1,152 @@
+/*
+ * e-table-model.c: a Table Model
+ *
+ * Author:
+ * Miguel de Icaza (miguel@gnu.org)
+ *
+ * (C) 1999 International GNOME Support.
+ */
+#include <config.h>
+#include "e-table-model.h"
+
+#define ETM_CLASS(e) ((ETableModelClass *)((GtkObject *)e)->klass)
+
+static GtkObjectClass *e_table_model_parent_class;
+
+int
+e_table_model_column_count (ETableModel *etable)
+{
+ return ETM_CLASS (etable)->column_count (etable);
+}
+
+const char *
+e_table_model_column_name (ETableModel *etable, int col)
+{
+ return ETM_CLASS (etable)->column_name (etable, col);
+}
+
+int
+e_table_model_row_count (ETableModel *etable)
+{
+ return ETM_CLASS (etable)->row_count (etable);
+}
+
+void *
+e_table_model_value_at (ETableModel *etable, int col, int row)
+{
+ return ETM_CLASS (etable)->value_at (etable, col, row);
+}
+
+void
+e_table_model_set_value_at (ETableModel *etable, int col, int row, void *data)
+{
+ return ETM_CLASS (etable)->set_value_at (etable, col, row, data);
+}
+
+gboolean
+e_table_model_is_cell_editable (ETableModel *etable, int col, int row)
+{
+ return ETM_CLASS (etable)->is_cell_editable (etable, col, row);
+}
+
+int
+e_table_model_row_height (ETableModel *etable, int row)
+{
+ return ETM_CLASS (etable)->row_height (etable, row);
+}
+
+typedef struct {
+ ETableModelListenerFn listener;
+ void *data;
+} listener_t;
+
+void
+e_table_model_add_listener (ETableModel *etable, ETableModelListenerFn listener, void *data)
+{
+ listener_t *lis;
+
+ lis = g_new (listener_t, 1);
+ lis->listener_t = listener;
+ lis->data = data;
+
+ etable->listeners = g_list_prepend (etable->listeners, lis);
+}
+
+void
+e_table_model_remove_listener (ETableModel *etable, ETableModelListenerFn listener, void *data)
+{
+ GSList *l;
+
+ for (l = etable->listeners; l; l = l->next){
+ listener_t *lis = l->data;
+
+ if (lis->listener == listener && lis->data == data){
+ etable->listeners = g_list_remove (etable->listeners, lis);
+ g_free (lis);
+ return;
+ }
+ }
+}
+
+static void
+e_table_model_destroy (GtkObject *object)
+{
+ GSList *l;
+
+ ETableModel *etable = (ETableModel *) object;
+
+ for (l = etable->listeners; l; l = l->next)
+ g_free (l->data);
+ g_list_free (etable->listeners);
+
+ if (e_table_model_parent_class->destroy)
+ (*e_table_model_parent_class->destroy)(object);
+}
+
+static void
+e_table_model_class_init (GtkObjectClass *class)
+{
+ e_table_model_parent_class = gtk_type_class (gtk_object_get_type ());
+
+ class->destroy = e_table_model_destroy;
+}
+
+GtkType
+e_table_model_get_type (void)
+{
+ static GtkType type = 0;
+
+ if (!type){
+ GtkTypeInfo info = {
+ "ETableModel",
+ sizeof (ETableModel),
+ sizeof (ETableModelClass),
+ (GtkClassInitFunc) e_table_model_class_init,
+ (GtkObjectInitFunc) NULL,
+ NULL, /* reserved 1 */
+ NULL, /* reserved 2 */
+ (GtkClassInitFunc) NULL
+ };
+
+ type = gtk_type_unique (gtk_object_get_type (), &info);
+ }
+
+ return type;
+}
+
+int
+e_table_model_height (ETableModel *etable)
+{
+ int rows;
+ int size;
+ g_return_val_if_fail (etable != NULL);
+
+ rows = e_table_model_row_count (etable);
+ size = 0;
+
+ for (i = 0; i < rows; i++)
+ size += e_table_model_row_height (etable, i);
+
+ return size;
+}
+