aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2000-06-23 15:47:37 +0800
committerChris Toshok <toshok@src.gnome.org>2000-06-23 15:47:37 +0800
commit422046cc58a534f6916205f282cc6b50a98eeb95 (patch)
tree3c5ab189a7edaa7adb10dac1031249ae1ec4f6f7 /widgets/table
parent29a313c41efa7844952000a88d772af11fbb6f37 (diff)
downloadgsoc2013-evolution-422046cc58a534f6916205f282cc6b50a98eeb95.tar
gsoc2013-evolution-422046cc58a534f6916205f282cc6b50a98eeb95.tar.gz
gsoc2013-evolution-422046cc58a534f6916205f282cc6b50a98eeb95.tar.bz2
gsoc2013-evolution-422046cc58a534f6916205f282cc6b50a98eeb95.tar.lz
gsoc2013-evolution-422046cc58a534f6916205f282cc6b50a98eeb95.tar.xz
gsoc2013-evolution-422046cc58a534f6916205f282cc6b50a98eeb95.tar.zst
gsoc2013-evolution-422046cc58a534f6916205f282cc6b50a98eeb95.zip
add icon_at virtual function - it was stupid to make the insert call take
2000-06-23 Chris Toshok <toshok@helixcode.com> * e-tree-model.h, e-tree-model.c: add icon_at virtual function - it was stupid to make the insert call take 2 pixbufs. the model should give this information. * e-cell-tree.c: get rid of the opened/closed pixbuf stuff. call e_tree_model_icon_of_node. * e-tree-example-1.c: add my_icon_at. * e-tree-simple.c (simple_icon_at): new function (e_tree_simple_new): add icon_at parameter. * e-tree-simple.h: add SimpleIconAtFn. svn path=/trunk/; revision=3707
Diffstat (limited to 'widgets/table')
-rw-r--r--widgets/table/e-cell-tree.c5
-rw-r--r--widgets/table/e-tree-example-1.c19
-rw-r--r--widgets/table/e-tree-model.c48
-rw-r--r--widgets/table/e-tree-model.h8
-rw-r--r--widgets/table/e-tree-simple.c13
-rw-r--r--widgets/table/e-tree-simple.h11
6 files changed, 52 insertions, 52 deletions
diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c
index 61c86fad2d..2d1a006fdb 100644
--- a/widgets/table/e-cell-tree.c
+++ b/widgets/table/e-cell-tree.c
@@ -178,10 +178,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
expanded = e_tree_model_node_is_expanded (tree_model, node);
subcell_offset = offset;
- if (expanded)
- node_image = e_tree_model_node_get_opened_pixbuf (tree_model, node);
- else
- node_image = e_tree_model_node_get_closed_pixbuf (tree_model, node);
+ node_image = e_tree_model_icon_of_node (tree_model, node);
if (node_image) {
node_image_width = gdk_pixbuf_get_width (node_image);
diff --git a/widgets/table/e-tree-example-1.c b/widgets/table/e-tree-example-1.c
index c506faebd5..c98e53c7af 100644
--- a/widgets/table/e-tree-example-1.c
+++ b/widgets/table/e-tree-example-1.c
@@ -83,6 +83,15 @@ my_value_at (ETreeModel *etm, ETreePath *path, int col, void *model_data)
}
}
+static GdkPixbuf *
+my_icon_at (ETreeModel *etm, ETreePath *path, void *model_data)
+{
+ if (e_tree_model_node_is_expanded (etm, path))
+ return tree_expanded_pixbuf;
+ else
+ return tree_unexpanded_pixbuf;
+}
+
/* This function sets the value at a particular point in our ETreeModel. */
static void
my_set_value_at (ETreeModel *etm, ETreePath *path, int col, const void *val, void *model_data)
@@ -130,7 +139,6 @@ add_sibling (GtkButton *button, gpointer data)
e_tree_model_node_insert_before (e_tree_model, parent_node,
selected_node,
- NULL, NULL,
g_strdup("User added sibling"));
}
@@ -150,7 +158,7 @@ add_child (GtkButton *button, gpointer data)
g_assert (selected_node);
e_tree_model_node_insert (e_tree_model, selected_node,
- 0, NULL, NULL,
+ 0,
g_strdup("User added child"));
}
@@ -238,25 +246,24 @@ create_tree (void)
/* here we create our model. This uses the functions we defined
earlier. */
- e_tree_model = e_tree_simple_new (my_value_at,
+ e_tree_model = e_tree_simple_new (my_icon_at,
+ my_value_at,
my_set_value_at,
my_is_editable,
NULL);
/* create a root node with 5 children */
root_node = e_tree_model_node_insert (e_tree_model, NULL,
- 0, NULL, NULL,
+ 0,
g_strdup("Root Node"));
for (i = 0; i < 5; i++){
ETreePath *n = e_tree_model_node_insert (e_tree_model,
root_node, 0,
- tree_expanded_pixbuf, tree_unexpanded_pixbuf,
g_strdup("First level of children"));
for (j = 0; j < 5; j ++) {
e_tree_model_node_insert (e_tree_model,
n, 0,
- NULL, NULL,
g_strdup("Second level of children"));
}
}
diff --git a/widgets/table/e-tree-model.c b/widgets/table/e-tree-model.c
index 47b82d3689..992caf40f2 100644
--- a/widgets/table/e-tree-model.c
+++ b/widgets/table/e-tree-model.c
@@ -23,8 +23,6 @@ static ETableModel *e_tree_model_parent_class;
typedef struct {
gboolean expanded;
guint visible_descendents;
- GdkPixbuf *opened_pixbuf;
- GdkPixbuf *closed_pixbuf;
gpointer node_data;
} ENode;
@@ -216,6 +214,14 @@ etree_value_at (ETreeModel *etm, ETreePath* node, int col)
return NULL;
}
+static GdkPixbuf*
+etree_icon_at (ETreeModel *etm, ETreePath* node)
+{
+ /* shouldn't be called */
+ g_assert (0);
+ return NULL;
+}
+
static void
etree_set_value_at (ETreeModel *etm, ETreePath* node, int col, const void *val)
{
@@ -337,6 +343,7 @@ e_tree_model_class_init (GtkObjectClass *klass)
tree_class->get_parent = etree_get_parent;
tree_class->value_at = etree_value_at;
+ tree_class->icon_at = etree_icon_at;
tree_class->set_value_at = etree_set_value_at;
tree_class->is_editable = etree_is_editable;
@@ -417,6 +424,12 @@ e_tree_model_node_at_row (ETreeModel *etree, int row)
return ETM_CLASS(etree)->node_at_row (etree, row);
}
+GdkPixbuf *
+e_tree_model_icon_of_node (ETreeModel *etree, ETreePath *path)
+{
+ return ETM_CLASS(etree)->icon_at (etree, path);
+}
+
int
e_tree_model_row_of_node (ETreeModel *etree, ETreePath *node)
{
@@ -554,36 +567,10 @@ e_tree_model_node_set_data (ETreeModel *etm, ETreePath *node, gpointer node_data
enode->node_data = node_data;
}
-GdkPixbuf *
-e_tree_model_node_get_opened_pixbuf (ETreeModel *etm, ETreePath *node)
-{
- ENode *enode;
-
- g_return_val_if_fail (node && node->data, NULL);
-
- enode = (ENode*)node->data;
-
- return enode->opened_pixbuf;
-}
-
-GdkPixbuf *
-e_tree_model_node_get_closed_pixbuf (ETreeModel *etm, ETreePath *node)
-{
- ENode *enode;
-
- g_return_val_if_fail (node && node->data, NULL);
-
- enode = (ENode*)node->data;
-
- return enode->closed_pixbuf;
-}
-
ETreePath*
e_tree_model_node_insert (ETreeModel *tree_model,
ETreePath *parent_path,
int position,
- GdkPixbuf *opened_pixbuf,
- GdkPixbuf *closed_pixbuf,
gpointer node_data)
{
ENode *node;
@@ -594,8 +581,6 @@ e_tree_model_node_insert (ETreeModel *tree_model,
node = g_new0 (ENode, 1);
node->expanded = FALSE;
- node->closed_pixbuf = closed_pixbuf;
- node->opened_pixbuf = opened_pixbuf;
node->node_data = node_data;
if (parent_path != NULL) {
@@ -641,13 +626,10 @@ ETreePath *
e_tree_model_node_insert_before (ETreeModel *etree,
ETreePath *parent,
ETreePath *sibling,
- GdkPixbuf *opened_pixbuf,
- GdkPixbuf *closed_pixbuf,
gpointer node_data)
{
return e_tree_model_node_insert (etree, parent,
g_node_child_position (parent, sibling),
- opened_pixbuf, closed_pixbuf,
node_data);
}
diff --git a/widgets/table/e-tree-model.h b/widgets/table/e-tree-model.h
index 0a7ecdb7ed..7b8d86826f 100644
--- a/widgets/table/e-tree-model.h
+++ b/widgets/table/e-tree-model.h
@@ -39,6 +39,7 @@ typedef struct {
void (*set_expanded_recurse) (ETreeModel *etm, ETreePath *node, gboolean expanded);
void (*set_expanded_level) (ETreeModel *etm, ETreePath *node, gboolean expanded, int level);
+ GdkPixbuf *(*icon_at) (ETreeModel *etm, ETreePath* node);
ETreePath* (*node_at_row) (ETreeModel *etm, int row);
/*
@@ -69,8 +70,8 @@ ETreePath *e_tree_model_node_get_next (ETreeModel *etree, ETreePath *path);
ETreePath *e_tree_model_node_get_prev (ETreeModel *etree, ETreePath *path);
/* node operations */
-ETreePath *e_tree_model_node_insert (ETreeModel *etree, ETreePath *parent, int position, GdkPixbuf *opened_pixbuf, GdkPixbuf *closed_pixbuf, gpointer node_data);
-ETreePath *e_tree_model_node_insert_before (ETreeModel *etree, ETreePath *parent, ETreePath *sibling, GdkPixbuf *opened_pixbuf, GdkPixbuf *closed_pixbuf, gpointer node_data);
+ETreePath *e_tree_model_node_insert (ETreeModel *etree, ETreePath *parent, int position, gpointer node_data);
+ETreePath *e_tree_model_node_insert_before (ETreeModel *etree, ETreePath *parent, ETreePath *sibling, gpointer node_data);
gpointer e_tree_model_node_remove (ETreeModel *etree, ETreePath *path);
/* node accessors */
@@ -85,11 +86,10 @@ guint e_tree_model_node_depth (ETreeModel *etree, ETreePath
guint e_tree_model_node_num_visible_descendents (ETreeModel *etm, ETreePath *node);
gpointer e_tree_model_node_get_data (ETreeModel *etm, ETreePath *node);
void e_tree_model_node_set_data (ETreeModel *etm, ETreePath *node, gpointer node_data);
-GdkPixbuf *e_tree_model_node_get_opened_pixbuf (ETreeModel *etm, ETreePath *node);
-GdkPixbuf *e_tree_model_node_get_closed_pixbuf (ETreeModel *etm, ETreePath *node);
/* display oriented routines */
ETreePath *e_tree_model_node_at_row (ETreeModel *etree, int row);
+GdkPixbuf *e_tree_model_icon_of_node (ETreeModel *etree, ETreePath *path);
int e_tree_model_row_of_node (ETreeModel *etree, ETreePath *path);
void e_tree_model_root_node_set_visible (ETreeModel *etree, gboolean visible);
gboolean e_tree_model_root_node_is_visible (ETreeModel *etree);
diff --git a/widgets/table/e-tree-simple.c b/widgets/table/e-tree-simple.c
index 9bf747a43f..e5883e6ae0 100644
--- a/widgets/table/e-tree-simple.c
+++ b/widgets/table/e-tree-simple.c
@@ -23,6 +23,14 @@ simple_value_at (ETreeModel *etm, ETreePath *node, int col)
return simple->value_at (etm, node, col, simple->model_data);
}
+static GdkPixbuf *
+simple_icon_at (ETreeModel *etm, ETreePath *node)
+{
+ ETreeSimple *simple = E_TREE_SIMPLE(etm);
+
+ return simple->icon_at (etm, node, simple->model_data);
+}
+
static void
simple_set_value_at (ETreeModel *etm, ETreePath *node, int col, const void *val)
{
@@ -44,6 +52,7 @@ 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;
@@ -52,7 +61,8 @@ e_tree_simple_class_init (GtkObjectClass *object_class)
E_MAKE_TYPE(e_tree_simple, "ETreeSimple", ETreeSimple, e_tree_simple_class_init, NULL, PARENT_TYPE)
ETreeModel *
-e_tree_simple_new (ETreeSimpleValueAtFn value_at,
+e_tree_simple_new (ETreeSimpleIconAtFn icon_at,
+ ETreeSimpleValueAtFn value_at,
ETreeSimpleSetValueAtFn set_value_at,
ETreeSimpleIsEditableFn is_editable,
gpointer model_data)
@@ -63,6 +73,7 @@ e_tree_simple_new (ETreeSimpleValueAtFn value_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;
diff --git a/widgets/table/e-tree-simple.h b/widgets/table/e-tree-simple.h
index 6820b14673..edda53e82d 100644
--- a/widgets/table/e-tree-simple.h
+++ b/widgets/table/e-tree-simple.h
@@ -12,13 +12,15 @@
#define E_IS_TREE_SIMPLE_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), E_TREE_SIMPLE_TYPE))
-typedef void* (*ETreeSimpleValueAtFn) (ETreeModel *etree, ETreePath *path, int col, void *model_data);
-typedef void (*ETreeSimpleSetValueAtFn) (ETreeModel *etree, ETreePath *path, int col, const void *val, void *model_data);
-typedef gboolean (*ETreeSimpleIsEditableFn) (ETreeModel *etree, ETreePath *path, int col, void *model_data);
+typedef GdkPixbuf* (*ETreeSimpleIconAtFn) (ETreeModel *etree, ETreePath *path, void *model_data);
+typedef void* (*ETreeSimpleValueAtFn) (ETreeModel *etree, ETreePath *path, int col, void *model_data);
+typedef void (*ETreeSimpleSetValueAtFn) (ETreeModel *etree, ETreePath *path, int col, const void *val, void *model_data);
+typedef gboolean (*ETreeSimpleIsEditableFn) (ETreeModel *etree, ETreePath *path, int col, void *model_data);
typedef struct {
ETreeModel parent;
+ ETreeSimpleIconAtFn icon_at;
ETreeSimpleValueAtFn value_at;
ETreeSimpleSetValueAtFn set_value_at;
ETreeSimpleIsEditableFn is_editable;
@@ -32,7 +34,8 @@ typedef struct {
GtkType e_tree_simple_get_type (void);
-ETreeModel *e_tree_simple_new (ETreeSimpleValueAtFn value_at,
+ETreeModel *e_tree_simple_new (ETreeSimpleIconAtFn icon_at,
+ ETreeSimpleValueAtFn value_at,
ETreeSimpleSetValueAtFn set_value_at,
ETreeSimpleIsEditableFn is_editable,
gpointer model_data);