aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorChristopher James Lahey <clahey@helixcode.com>2000-09-09 00:51:21 +0800
committerChris Lahey <clahey@src.gnome.org>2000-09-09 00:51:21 +0800
commit7816388a7ab06deb31f269c0f716eea5a62c9666 (patch)
tree4a243e55764d7666b279f10c78fbdb0f28783081 /widgets
parenta0ab37d85aeb661516a1afa1e1cf699e194f4a8d (diff)
downloadgsoc2013-evolution-7816388a7ab06deb31f269c0f716eea5a62c9666.tar
gsoc2013-evolution-7816388a7ab06deb31f269c0f716eea5a62c9666.tar.gz
gsoc2013-evolution-7816388a7ab06deb31f269c0f716eea5a62c9666.tar.bz2
gsoc2013-evolution-7816388a7ab06deb31f269c0f716eea5a62c9666.tar.lz
gsoc2013-evolution-7816388a7ab06deb31f269c0f716eea5a62c9666.tar.xz
gsoc2013-evolution-7816388a7ab06deb31f269c0f716eea5a62c9666.tar.zst
gsoc2013-evolution-7816388a7ab06deb31f269c0f716eea5a62c9666.zip
Added base ETableModel functions.
2000-09-08 Christopher James Lahey <clahey@helixcode.com> * e-tree-example-1.c: Added base ETableModel functions. * e-tree-example-2.c: Added base ETableModel functions. Made it never return NULL as a string, instead return "". * e-tree-simple.c, e-tree-simple.h: Require base ETableModel functions. svn path=/trunk/; revision=5266
Diffstat (limited to 'widgets')
-rw-r--r--widgets/e-table/ChangeLog10
-rw-r--r--widgets/e-table/e-tree-example-1.c50
-rw-r--r--widgets/e-table/e-tree-example-2.c84
-rw-r--r--widgets/e-table/e-tree-simple.c121
-rw-r--r--widgets/e-table/e-tree-simple.h26
-rw-r--r--widgets/table/e-tree-example-1.c50
-rw-r--r--widgets/table/e-tree-example-2.c84
-rw-r--r--widgets/table/e-tree-simple.c121
-rw-r--r--widgets/table/e-tree-simple.h26
9 files changed, 498 insertions, 74 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index fd66cfa74e..fa71dd0bfc 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,3 +1,13 @@
+2000-09-08 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-tree-example-1.c: Added base ETableModel functions.
+
+ * e-tree-example-2.c: Added base ETableModel functions. Made it
+ never return NULL as a string, instead return "".
+
+ * e-tree-simple.c, e-tree-simple.h: Require base ETableModel
+ functions.
+
2000-09-01 Christopher James Lahey <clahey@helixcode.com>
* e-table-item.c, e-table.c: Fixed a leak and a double unref.
diff --git a/widgets/e-table/e-tree-example-1.c b/widgets/e-table/e-tree-example-1.c
index 71b3f7ca5d..abc40a0449 100644
--- a/widgets/e-table/e-tree-example-1.c
+++ b/widgets/e-table/e-tree-example-1.c
@@ -70,6 +70,48 @@ GtkWidget *e_table;
* These are the callbacks that define the behavior of our custom model.
*/
+/* This function returns the number of columns in our ETableModel. */
+static int
+my_col_count (ETableModel *etc, void *data)
+{
+ return COLS;
+}
+
+/* This function duplicates the value passed to it. */
+static void *
+my_duplicate_value (ETableModel *etc, int col, const void *value, void *data)
+{
+ return g_strdup (value);
+}
+
+/* This function frees the value passed to it. */
+static void
+my_free_value (ETableModel *etc, int col, void *value, void *data)
+{
+ g_free (value);
+}
+
+/* This function creates an empty value. */
+static void *
+my_initialize_value (ETableModel *etc, int col, void *data)
+{
+ return g_strdup ("");
+}
+
+/* This function reports if a value is empty. */
+static gboolean
+my_value_is_empty (ETableModel *etc, int col, const void *value, void *data)
+{
+ return !(value && *(char *)value);
+}
+
+/* This function reports if a value is empty. */
+static char *
+my_value_to_string (ETableModel *etc, int col, const void *value, void *data)
+{
+ return g_strdup(value);
+}
+
/* This function returns the value at a particular point in our ETreeModel. */
static void *
my_value_at (ETreeModel *etm, ETreePath *path, int col, void *model_data)
@@ -241,7 +283,13 @@ create_tree (void)
/* here we create our model. This uses the functions we defined
earlier. */
- e_tree_model = e_tree_simple_new (my_icon_at,
+ e_tree_model = e_tree_simple_new (my_col_count,
+ my_duplicate_value,
+ my_free_value,
+ my_initialize_value,
+ my_value_is_empty,
+ my_value_to_string,
+ my_icon_at,
my_value_at,
my_set_value_at,
my_is_editable,
diff --git a/widgets/e-table/e-tree-example-2.c b/widgets/e-table/e-tree-example-2.c
index d7db861953..6324333c19 100644
--- a/widgets/e-table/e-tree-example-2.c
+++ b/widgets/e-table/e-tree-example-2.c
@@ -149,20 +149,20 @@ tree_value_at (ETreeModel *etm, ETreePath *path, int col, void *model_data)
static char buf[15];
if (vfs_info->info) {
if (vfs_info->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
- return NULL;
+ return "";
else {
g_snprintf (buf, sizeof(buf), "%ld", (glong) vfs_info->info->size);
return buf;
}
}
else
- return NULL;
+ return "";
}
case 2: /* file type */
if (vfs_info->info)
return type_to_string (vfs_info->info->type);
else
- return NULL;
+ return "";
case 3: /* mime type */
if (vfs_info->info) {
const char *mime_type = gnome_vfs_file_info_get_mime_type (vfs_info->info);
@@ -171,12 +171,54 @@ tree_value_at (ETreeModel *etm, ETreePath *path, int col, void *model_data)
return (void*)mime_type;
}
else {
- return NULL;
+ return "";
}
- default: return NULL;
+ default: return "";
}
}
+/* This function returns the number of columns in our ETableModel. */
+static int
+tree_col_count (ETableModel *etc, void *data)
+{
+ return RIGHT_COLS;
+}
+
+/* This function duplicates the value passed to it. */
+static void *
+tree_duplicate_value (ETableModel *etc, int col, const void *value, void *data)
+{
+ return g_strdup (value);
+}
+
+/* This function frees the value passed to it. */
+static void
+tree_free_value (ETableModel *etc, int col, void *value, void *data)
+{
+ g_free (value);
+}
+
+/* This function creates an empty value. */
+static void *
+tree_initialize_value (ETableModel *etc, int col, void *data)
+{
+ return g_strdup ("");
+}
+
+/* This function reports if a value is empty. */
+static gboolean
+tree_value_is_empty (ETableModel *etc, int col, const void *value, void *data)
+{
+ return !(value && *(char *)value);
+}
+
+/* This function reports if a value is empty. */
+static char *
+tree_value_to_string (ETableModel *etc, int col, const void *value, void *data)
+{
+ return g_strdup(value);
+}
+
static GdkPixbuf *
tree_icon_at (ETreeModel *etm, ETreePath *path, void *model_data)
{
@@ -416,11 +458,17 @@ create_right_tree(GtkWidget *paned)
/* here we create our model. This uses the functions we defined
earlier. */
- right_model = e_tree_simple_new (tree_icon_at,
- tree_value_at,
- tree_set_value_at,
- tree_is_editable,
- NULL);
+ right_model = e_tree_simple_new (tree_col_count,
+ tree_duplicate_value,
+ tree_free_value,
+ tree_initialize_value,
+ tree_value_is_empty,
+ tree_value_to_string,
+ tree_icon_at,
+ tree_value_at,
+ tree_set_value_at,
+ tree_is_editable,
+ NULL);
/* create the unexpanded root node and it's placeholder child. */
right_root = e_tree_model_node_insert (right_model, NULL,
@@ -517,11 +565,17 @@ create_left_tree (GtkWidget *paned, char *root_uri)
/* here we create our model. This uses the functions we defined
earlier. */
- left_model = e_tree_simple_new (tree_icon_at,
- tree_value_at,
- tree_set_value_at,
- tree_is_editable,
- NULL);
+ left_model = e_tree_simple_new (tree_col_count,
+ tree_duplicate_value,
+ tree_free_value,
+ tree_initialize_value,
+ tree_value_is_empty,
+ tree_value_to_string,
+ tree_icon_at,
+ tree_value_at,
+ tree_set_value_at,
+ tree_is_editable,
+ NULL);
/* catch collapsed/expanded signals */
gtk_signal_connect (GTK_OBJECT (left_model), "node_expanded",
diff --git a/widgets/e-table/e-tree-simple.c b/widgets/e-table/e-tree-simple.c
index e5883e6ae0..2df7586526 100644
--- a/widgets/e-table/e-tree-simple.c
+++ b/widgets/e-table/e-tree-simple.c
@@ -15,6 +15,71 @@
#define PARENT_TYPE E_TREE_MODEL_TYPE
+static int
+simple_column_count (ETableModel *etm)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->col_count)
+ return simple->col_count (etm, simple->data);
+ else
+ return 0;
+}
+
+/* The default for simple_duplicate_value is to return the raw value. */
+static void *
+simple_duplicate_value (ETableModel *etm, int col, const void *value)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->duplicate_value)
+ return simple->duplicate_value (etm, col, value, simple->data);
+ else
+ return (void *)value;
+}
+
+static void
+simple_free_value (ETableModel *etm, int col, void *value)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->free_value)
+ simple->free_value (etm, col, value, simple->data);
+}
+
+static void *
+simple_initialize_value (ETableModel *etm, int col)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->initialize_value)
+ return simple->initialize_value (etm, col, simple->data);
+ else
+ return NULL;
+}
+
+static gboolean
+simple_value_is_empty (ETableModel *etm, int col, const void *value)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->value_is_empty)
+ return simple->value_is_empty (etm, col, value, simple->data);
+ else
+ return FALSE;
+}
+
+static char *
+simple_value_to_string (ETableModel *etm, int col, const void *value)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->value_to_string)
+ return simple->value_to_string (etm, col, value, simple->data);
+ else
+ return g_strdup ("");
+}
+
static void *
simple_value_at (ETreeModel *etm, ETreePath *node, int col)
{
@@ -50,22 +115,38 @@ simple_is_editable (ETreeModel *etm, ETreePath *node, int col)
static void
e_tree_simple_class_init (GtkObjectClass *object_class)
{
- ETreeModelClass *model_class = (ETreeModelClass *) object_class;
-
- model_class->icon_at = simple_icon_at;
- model_class->value_at = simple_value_at;
- model_class->set_value_at = simple_set_value_at;
- model_class->is_editable = simple_is_editable;
+ ETreeModelClass *model_class = (ETreeModelClass *) object_class;
+ ETableModelClass *table_model_class = (ETableModelClass *) object_class;
+
+ table_model_class->column_count = simple_column_count;
+ table_model_class->duplicate_value = simple_duplicate_value;
+ table_model_class->free_value = simple_free_value;
+ table_model_class->initialize_value = simple_initialize_value;
+ table_model_class->value_is_empty = simple_value_is_empty;
+ table_model_class->value_to_string = simple_value_to_string;
+
+ model_class ->icon_at = simple_icon_at;
+ model_class ->value_at = simple_value_at;
+ model_class ->set_value_at = simple_set_value_at;
+ model_class ->is_editable = simple_is_editable;
}
E_MAKE_TYPE(e_tree_simple, "ETreeSimple", ETreeSimple, e_tree_simple_class_init, NULL, PARENT_TYPE)
ETreeModel *
-e_tree_simple_new (ETreeSimpleIconAtFn icon_at,
- ETreeSimpleValueAtFn value_at,
- ETreeSimpleSetValueAtFn set_value_at,
- ETreeSimpleIsEditableFn is_editable,
- gpointer model_data)
+e_tree_simple_new (ETableSimpleColumnCountFn col_count,
+ ETableSimpleDuplicateValueFn duplicate_value,
+ ETableSimpleFreeValueFn free_value,
+ ETableSimpleInitializeValueFn initialize_value,
+ ETableSimpleValueIsEmptyFn value_is_empty,
+ ETableSimpleValueToStringFn value_to_string,
+
+ ETreeSimpleIconAtFn icon_at,
+ ETreeSimpleValueAtFn value_at,
+ ETreeSimpleSetValueAtFn set_value_at,
+ ETreeSimpleIsEditableFn is_editable,
+
+ gpointer model_data)
{
ETreeSimple *etg;
@@ -73,11 +154,19 @@ e_tree_simple_new (ETreeSimpleIconAtFn icon_at,
e_tree_model_construct (E_TREE_MODEL (etg));
- etg->icon_at = icon_at;
- etg->value_at = value_at;
- etg->set_value_at = set_value_at;
- etg->is_editable = is_editable;
- etg->model_data = model_data;
+ etg->col_count = col_count;
+ etg->duplicate_value = duplicate_value;
+ etg->free_value = free_value;
+ etg->initialize_value = initialize_value;
+ etg->value_is_empty = value_is_empty;
+ etg->value_to_string = value_to_string;
+
+ etg->icon_at = icon_at;
+ etg->value_at = value_at;
+ etg->set_value_at = set_value_at;
+ etg->is_editable = is_editable;
+
+ etg->model_data = model_data;
return (ETreeModel*)etg;
}
diff --git a/widgets/e-table/e-tree-simple.h b/widgets/e-table/e-tree-simple.h
index edda53e82d..46d910c39f 100644
--- a/widgets/e-table/e-tree-simple.h
+++ b/widgets/e-table/e-tree-simple.h
@@ -4,6 +4,7 @@
#define _E_TREE_SIMPLE_H_
#include "e-tree-model.h"
+#include "e-table-simple.h"
#define E_TREE_SIMPLE_TYPE (e_tree_simple_get_type ())
#define E_TREE_SIMPLE(o) (GTK_CHECK_CAST ((o), E_TREE_SIMPLE_TYPE, ETreeSimple))
@@ -20,6 +21,15 @@ typedef gboolean (*ETreeSimpleIsEditableFn) (ETreeModel *etree, ETreePath *pat
typedef struct {
ETreeModel parent;
+ /* Table methods */
+ ETableSimpleColumnCountFn col_count;
+ ETableSimpleDuplicateValueFn duplicate_value;
+ ETableSimpleFreeValueFn free_value;
+ ETableSimpleInitializeValueFn initialize_value;
+ ETableSimpleValueIsEmptyFn value_is_empty;
+ ETableSimpleValueToStringFn value_to_string;
+
+ /* Tree methods */
ETreeSimpleIconAtFn icon_at;
ETreeSimpleValueAtFn value_at;
ETreeSimpleSetValueAtFn set_value_at;
@@ -34,10 +44,16 @@ typedef struct {
GtkType e_tree_simple_get_type (void);
-ETreeModel *e_tree_simple_new (ETreeSimpleIconAtFn icon_at,
- ETreeSimpleValueAtFn value_at,
- ETreeSimpleSetValueAtFn set_value_at,
- ETreeSimpleIsEditableFn is_editable,
- gpointer model_data);
+ETreeModel *e_tree_simple_new (ETableSimpleColumnCountFn col_count,
+ ETableSimpleDuplicateValueFn duplicate_value,
+ ETableSimpleFreeValueFn free_value,
+ ETableSimpleInitializeValueFn initialize_value,
+ ETableSimpleValueIsEmptyFn value_is_empty,
+ ETableSimpleValueToStringFn value_to_string,
+ ETreeSimpleIconAtFn icon_at,
+ ETreeSimpleValueAtFn value_at,
+ ETreeSimpleSetValueAtFn set_value_at,
+ ETreeSimpleIsEditableFn is_editable,
+ gpointer model_data);
#endif /* _E_TREE_SIMPLE_H_ */
diff --git a/widgets/table/e-tree-example-1.c b/widgets/table/e-tree-example-1.c
index 71b3f7ca5d..abc40a0449 100644
--- a/widgets/table/e-tree-example-1.c
+++ b/widgets/table/e-tree-example-1.c
@@ -70,6 +70,48 @@ GtkWidget *e_table;
* These are the callbacks that define the behavior of our custom model.
*/
+/* This function returns the number of columns in our ETableModel. */
+static int
+my_col_count (ETableModel *etc, void *data)
+{
+ return COLS;
+}
+
+/* This function duplicates the value passed to it. */
+static void *
+my_duplicate_value (ETableModel *etc, int col, const void *value, void *data)
+{
+ return g_strdup (value);
+}
+
+/* This function frees the value passed to it. */
+static void
+my_free_value (ETableModel *etc, int col, void *value, void *data)
+{
+ g_free (value);
+}
+
+/* This function creates an empty value. */
+static void *
+my_initialize_value (ETableModel *etc, int col, void *data)
+{
+ return g_strdup ("");
+}
+
+/* This function reports if a value is empty. */
+static gboolean
+my_value_is_empty (ETableModel *etc, int col, const void *value, void *data)
+{
+ return !(value && *(char *)value);
+}
+
+/* This function reports if a value is empty. */
+static char *
+my_value_to_string (ETableModel *etc, int col, const void *value, void *data)
+{
+ return g_strdup(value);
+}
+
/* This function returns the value at a particular point in our ETreeModel. */
static void *
my_value_at (ETreeModel *etm, ETreePath *path, int col, void *model_data)
@@ -241,7 +283,13 @@ create_tree (void)
/* here we create our model. This uses the functions we defined
earlier. */
- e_tree_model = e_tree_simple_new (my_icon_at,
+ e_tree_model = e_tree_simple_new (my_col_count,
+ my_duplicate_value,
+ my_free_value,
+ my_initialize_value,
+ my_value_is_empty,
+ my_value_to_string,
+ my_icon_at,
my_value_at,
my_set_value_at,
my_is_editable,
diff --git a/widgets/table/e-tree-example-2.c b/widgets/table/e-tree-example-2.c
index d7db861953..6324333c19 100644
--- a/widgets/table/e-tree-example-2.c
+++ b/widgets/table/e-tree-example-2.c
@@ -149,20 +149,20 @@ tree_value_at (ETreeModel *etm, ETreePath *path, int col, void *model_data)
static char buf[15];
if (vfs_info->info) {
if (vfs_info->info->type == GNOME_VFS_FILE_TYPE_DIRECTORY)
- return NULL;
+ return "";
else {
g_snprintf (buf, sizeof(buf), "%ld", (glong) vfs_info->info->size);
return buf;
}
}
else
- return NULL;
+ return "";
}
case 2: /* file type */
if (vfs_info->info)
return type_to_string (vfs_info->info->type);
else
- return NULL;
+ return "";
case 3: /* mime type */
if (vfs_info->info) {
const char *mime_type = gnome_vfs_file_info_get_mime_type (vfs_info->info);
@@ -171,12 +171,54 @@ tree_value_at (ETreeModel *etm, ETreePath *path, int col, void *model_data)
return (void*)mime_type;
}
else {
- return NULL;
+ return "";
}
- default: return NULL;
+ default: return "";
}
}
+/* This function returns the number of columns in our ETableModel. */
+static int
+tree_col_count (ETableModel *etc, void *data)
+{
+ return RIGHT_COLS;
+}
+
+/* This function duplicates the value passed to it. */
+static void *
+tree_duplicate_value (ETableModel *etc, int col, const void *value, void *data)
+{
+ return g_strdup (value);
+}
+
+/* This function frees the value passed to it. */
+static void
+tree_free_value (ETableModel *etc, int col, void *value, void *data)
+{
+ g_free (value);
+}
+
+/* This function creates an empty value. */
+static void *
+tree_initialize_value (ETableModel *etc, int col, void *data)
+{
+ return g_strdup ("");
+}
+
+/* This function reports if a value is empty. */
+static gboolean
+tree_value_is_empty (ETableModel *etc, int col, const void *value, void *data)
+{
+ return !(value && *(char *)value);
+}
+
+/* This function reports if a value is empty. */
+static char *
+tree_value_to_string (ETableModel *etc, int col, const void *value, void *data)
+{
+ return g_strdup(value);
+}
+
static GdkPixbuf *
tree_icon_at (ETreeModel *etm, ETreePath *path, void *model_data)
{
@@ -416,11 +458,17 @@ create_right_tree(GtkWidget *paned)
/* here we create our model. This uses the functions we defined
earlier. */
- right_model = e_tree_simple_new (tree_icon_at,
- tree_value_at,
- tree_set_value_at,
- tree_is_editable,
- NULL);
+ right_model = e_tree_simple_new (tree_col_count,
+ tree_duplicate_value,
+ tree_free_value,
+ tree_initialize_value,
+ tree_value_is_empty,
+ tree_value_to_string,
+ tree_icon_at,
+ tree_value_at,
+ tree_set_value_at,
+ tree_is_editable,
+ NULL);
/* create the unexpanded root node and it's placeholder child. */
right_root = e_tree_model_node_insert (right_model, NULL,
@@ -517,11 +565,17 @@ create_left_tree (GtkWidget *paned, char *root_uri)
/* here we create our model. This uses the functions we defined
earlier. */
- left_model = e_tree_simple_new (tree_icon_at,
- tree_value_at,
- tree_set_value_at,
- tree_is_editable,
- NULL);
+ left_model = e_tree_simple_new (tree_col_count,
+ tree_duplicate_value,
+ tree_free_value,
+ tree_initialize_value,
+ tree_value_is_empty,
+ tree_value_to_string,
+ tree_icon_at,
+ tree_value_at,
+ tree_set_value_at,
+ tree_is_editable,
+ NULL);
/* catch collapsed/expanded signals */
gtk_signal_connect (GTK_OBJECT (left_model), "node_expanded",
diff --git a/widgets/table/e-tree-simple.c b/widgets/table/e-tree-simple.c
index e5883e6ae0..2df7586526 100644
--- a/widgets/table/e-tree-simple.c
+++ b/widgets/table/e-tree-simple.c
@@ -15,6 +15,71 @@
#define PARENT_TYPE E_TREE_MODEL_TYPE
+static int
+simple_column_count (ETableModel *etm)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->col_count)
+ return simple->col_count (etm, simple->data);
+ else
+ return 0;
+}
+
+/* The default for simple_duplicate_value is to return the raw value. */
+static void *
+simple_duplicate_value (ETableModel *etm, int col, const void *value)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->duplicate_value)
+ return simple->duplicate_value (etm, col, value, simple->data);
+ else
+ return (void *)value;
+}
+
+static void
+simple_free_value (ETableModel *etm, int col, void *value)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->free_value)
+ simple->free_value (etm, col, value, simple->data);
+}
+
+static void *
+simple_initialize_value (ETableModel *etm, int col)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->initialize_value)
+ return simple->initialize_value (etm, col, simple->data);
+ else
+ return NULL;
+}
+
+static gboolean
+simple_value_is_empty (ETableModel *etm, int col, const void *value)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->value_is_empty)
+ return simple->value_is_empty (etm, col, value, simple->data);
+ else
+ return FALSE;
+}
+
+static char *
+simple_value_to_string (ETableModel *etm, int col, const void *value)
+{
+ ETableSimple *simple = E_TABLE_SIMPLE(etm);
+
+ if (simple->value_to_string)
+ return simple->value_to_string (etm, col, value, simple->data);
+ else
+ return g_strdup ("");
+}
+
static void *
simple_value_at (ETreeModel *etm, ETreePath *node, int col)
{
@@ -50,22 +115,38 @@ simple_is_editable (ETreeModel *etm, ETreePath *node, int col)
static void
e_tree_simple_class_init (GtkObjectClass *object_class)
{
- ETreeModelClass *model_class = (ETreeModelClass *) object_class;
-
- model_class->icon_at = simple_icon_at;
- model_class->value_at = simple_value_at;
- model_class->set_value_at = simple_set_value_at;
- model_class->is_editable = simple_is_editable;
+ ETreeModelClass *model_class = (ETreeModelClass *) object_class;
+ ETableModelClass *table_model_class = (ETableModelClass *) object_class;
+
+ table_model_class->column_count = simple_column_count;
+ table_model_class->duplicate_value = simple_duplicate_value;
+ table_model_class->free_value = simple_free_value;
+ table_model_class->initialize_value = simple_initialize_value;
+ table_model_class->value_is_empty = simple_value_is_empty;
+ table_model_class->value_to_string = simple_value_to_string;
+
+ model_class ->icon_at = simple_icon_at;
+ model_class ->value_at = simple_value_at;
+ model_class ->set_value_at = simple_set_value_at;
+ model_class ->is_editable = simple_is_editable;
}
E_MAKE_TYPE(e_tree_simple, "ETreeSimple", ETreeSimple, e_tree_simple_class_init, NULL, PARENT_TYPE)
ETreeModel *
-e_tree_simple_new (ETreeSimpleIconAtFn icon_at,
- ETreeSimpleValueAtFn value_at,
- ETreeSimpleSetValueAtFn set_value_at,
- ETreeSimpleIsEditableFn is_editable,
- gpointer model_data)
+e_tree_simple_new (ETableSimpleColumnCountFn col_count,
+ ETableSimpleDuplicateValueFn duplicate_value,
+ ETableSimpleFreeValueFn free_value,
+ ETableSimpleInitializeValueFn initialize_value,
+ ETableSimpleValueIsEmptyFn value_is_empty,
+ ETableSimpleValueToStringFn value_to_string,
+
+ ETreeSimpleIconAtFn icon_at,
+ ETreeSimpleValueAtFn value_at,
+ ETreeSimpleSetValueAtFn set_value_at,
+ ETreeSimpleIsEditableFn is_editable,
+
+ gpointer model_data)
{
ETreeSimple *etg;
@@ -73,11 +154,19 @@ e_tree_simple_new (ETreeSimpleIconAtFn icon_at,
e_tree_model_construct (E_TREE_MODEL (etg));
- etg->icon_at = icon_at;
- etg->value_at = value_at;
- etg->set_value_at = set_value_at;
- etg->is_editable = is_editable;
- etg->model_data = model_data;
+ etg->col_count = col_count;
+ etg->duplicate_value = duplicate_value;
+ etg->free_value = free_value;
+ etg->initialize_value = initialize_value;
+ etg->value_is_empty = value_is_empty;
+ etg->value_to_string = value_to_string;
+
+ etg->icon_at = icon_at;
+ etg->value_at = value_at;
+ etg->set_value_at = set_value_at;
+ etg->is_editable = is_editable;
+
+ etg->model_data = model_data;
return (ETreeModel*)etg;
}
diff --git a/widgets/table/e-tree-simple.h b/widgets/table/e-tree-simple.h
index edda53e82d..46d910c39f 100644
--- a/widgets/table/e-tree-simple.h
+++ b/widgets/table/e-tree-simple.h
@@ -4,6 +4,7 @@
#define _E_TREE_SIMPLE_H_
#include "e-tree-model.h"
+#include "e-table-simple.h"
#define E_TREE_SIMPLE_TYPE (e_tree_simple_get_type ())
#define E_TREE_SIMPLE(o) (GTK_CHECK_CAST ((o), E_TREE_SIMPLE_TYPE, ETreeSimple))
@@ -20,6 +21,15 @@ typedef gboolean (*ETreeSimpleIsEditableFn) (ETreeModel *etree, ETreePath *pat
typedef struct {
ETreeModel parent;
+ /* Table methods */
+ ETableSimpleColumnCountFn col_count;
+ ETableSimpleDuplicateValueFn duplicate_value;
+ ETableSimpleFreeValueFn free_value;
+ ETableSimpleInitializeValueFn initialize_value;
+ ETableSimpleValueIsEmptyFn value_is_empty;
+ ETableSimpleValueToStringFn value_to_string;
+
+ /* Tree methods */
ETreeSimpleIconAtFn icon_at;
ETreeSimpleValueAtFn value_at;
ETreeSimpleSetValueAtFn set_value_at;
@@ -34,10 +44,16 @@ typedef struct {
GtkType e_tree_simple_get_type (void);
-ETreeModel *e_tree_simple_new (ETreeSimpleIconAtFn icon_at,
- ETreeSimpleValueAtFn value_at,
- ETreeSimpleSetValueAtFn set_value_at,
- ETreeSimpleIsEditableFn is_editable,
- gpointer model_data);
+ETreeModel *e_tree_simple_new (ETableSimpleColumnCountFn col_count,
+ ETableSimpleDuplicateValueFn duplicate_value,
+ ETableSimpleFreeValueFn free_value,
+ ETableSimpleInitializeValueFn initialize_value,
+ ETableSimpleValueIsEmptyFn value_is_empty,
+ ETableSimpleValueToStringFn value_to_string,
+ ETreeSimpleIconAtFn icon_at,
+ ETreeSimpleValueAtFn value_at,
+ ETreeSimpleSetValueAtFn set_value_at,
+ ETreeSimpleIsEditableFn is_editable,
+ gpointer model_data);
#endif /* _E_TREE_SIMPLE_H_ */