aboutsummaryrefslogtreecommitdiffstats
path: root/widgets
diff options
context:
space:
mode:
authorChris Toshok <toshok@helixcode.com>2000-10-03 02:02:53 +0800
committerChris Toshok <toshok@src.gnome.org>2000-10-03 02:02:53 +0800
commit1c2eec1fd409b7ec7a6742684c678bcd258aec53 (patch)
treef26b1011ae9ddb9133ba7b07b58e6806f86f05a8 /widgets
parent30b11ae4f9cfd2f33044d64894292593d2aa5e45 (diff)
downloadgsoc2013-evolution-1c2eec1fd409b7ec7a6742684c678bcd258aec53.tar.gz
gsoc2013-evolution-1c2eec1fd409b7ec7a6742684c678bcd258aec53.tar.zst
gsoc2013-evolution-1c2eec1fd409b7ec7a6742684c678bcd258aec53.zip
reinstate file.
2000-10-02 Chris Toshok <toshok@helixcode.com> * tree-expanded.xpm: reinstate file. * tree-unexpanded.xpm: same. * e-tree-example-1.c (main): remove calls to e_cursor_*, and don't create pixbufs. let's the tree give us the defaults. * e-tree-model.c (e_tree_model_node_changed): call e_table_model_row_changed on the node's row (if it's visible). (e_tree_model_node_inserted): call e_table_model_row_inserted on the new node's row, if it's visible. (e_tree_model_node_removed): call e_table_model_row_removed on the old node's row, if it was visible. * e-cell-tree.c (e_cell_tree_construct): allow open_pixbuf and closed_pixbuf to be NULL, and default them to the xpm data in rtee-{un}expanded.xpm. (ect_destroy): call gdk_pixbuf_unref on our open/closed pixbufs. * tree-expanded.xpm, tree-unexpanded.xpm: make the + and - a little lighter than straight black. svn path=/trunk/; revision=5660
Diffstat (limited to 'widgets')
-rw-r--r--widgets/table/e-cell-tree.c17
-rw-r--r--widgets/table/e-tree-example-1.c48
-rw-r--r--widgets/table/e-tree-model.c16
-rw-r--r--widgets/table/tree-expanded.xpm23
-rw-r--r--widgets/table/tree-unexpanded.xpm23
5 files changed, 103 insertions, 24 deletions
diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c
index dfeb2c515a..0d159ded19 100644
--- a/widgets/table/e-cell-tree.c
+++ b/widgets/table/e-cell-tree.c
@@ -31,6 +31,9 @@
#include <ctype.h>
#include <math.h>
+#include "tree-expanded.xpm"
+#include "tree-unexpanded.xpm"
+
#define PARENT_TYPE e_cell_get_type ()
typedef struct {
@@ -572,6 +575,9 @@ ect_destroy (GtkObject *object)
/* destroy our subcell */
gtk_object_destroy (GTK_OBJECT (ect->subcell));
+ gdk_pixbuf_unref (ect->open_pixbuf);
+ gdk_pixbuf_unref (ect->closed_pixbuf);
+
GTK_OBJECT_CLASS (parent_class)->destroy (object);
}
@@ -609,8 +615,15 @@ e_cell_tree_construct (ECellTree *ect,
ECell *subcell)
{
ect->subcell = subcell;
- ect->open_pixbuf = open_pixbuf;
- ect->closed_pixbuf = closed_pixbuf;
+ if (open_pixbuf)
+ ect->open_pixbuf = open_pixbuf;
+ else
+ ect->open_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)tree_expanded_xpm);
+ if (closed_pixbuf)
+ ect->closed_pixbuf = closed_pixbuf;
+ else
+ ect->closed_pixbuf = gdk_pixbuf_new_from_xpm_data ((const char **)tree_unexpanded_xpm);
+
ect->draw_lines = draw_lines;
}
diff --git a/widgets/table/e-tree-example-1.c b/widgets/table/e-tree-example-1.c
index 75e32c0a25..f62b1e0765 100644
--- a/widgets/table/e-tree-example-1.c
+++ b/widgets/table/e-tree-example-1.c
@@ -6,7 +6,6 @@
#include <libgnomeprint/gnome-print.h>
#include <libgnomeprint/gnome-print-preview.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
-#include "gal/e-util/e-cursors.h"
#include "e-table-header.h"
#include "e-table-header-item.h"
#include "e-table-item.h"
@@ -16,12 +15,6 @@
#include "e-table.h"
#include "e-tree-simple.h"
-#include "art/tree-expanded.xpm"
-#include "art/tree-unexpanded.xpm"
-
-GdkPixbuf *tree_expanded_pixbuf;
-GdkPixbuf *tree_unexpanded_pixbuf;
-
#define COLS 4
#define IMPORTANCE_COLUMN 4
@@ -268,6 +261,14 @@ print_tree (GtkButton *button, gpointer data)
gnome_print_context_close (gpc);
}
+static void
+save_state (GtkButton *button, gpointer data)
+{
+ ETreeModel *e_tree_model = E_TREE_MODEL (data);
+
+ e_tree_model_save_expanded_state (e_tree_model, "expanded_state");
+}
+
/* We create a window containing our new tree. */
static void
create_tree (void)
@@ -294,6 +295,8 @@ create_tree (void)
my_is_editable,
NULL);
+ e_tree_model_load_expanded_state (e_tree_model, "expanded_state");
+
/* create a root node with 5 children */
root_node = e_tree_model_node_insert (e_tree_model, NULL,
0,
@@ -302,13 +305,18 @@ create_tree (void)
e_tree_model_root_node_set_visible (e_tree_model, FALSE);
for (i = 0; i < 5; i++){
- ETreePath *n = e_tree_model_node_insert (e_tree_model,
- root_node, 0,
- g_strdup("First level of children"));
+ char *id = g_strdup_printf ("First level child %d", i);
+ ETreePath *n = e_tree_model_node_insert_id (e_tree_model,
+ root_node, 0,
+ g_strdup("First level of children"),
+ id);
+ g_free (id);
for (j = 0; j < 5; j ++) {
- e_tree_model_node_insert (e_tree_model,
- n, 0,
- g_strdup("Second level of children"));
+ char *id = g_strdup_printf ("Second level child %d", j);
+ e_tree_model_node_insert_id (e_tree_model,
+ n, 0,
+ g_strdup("Second level of children"), id);
+ g_free (id);
}
}
@@ -339,7 +347,7 @@ create_tree (void)
* text is displayed to the right of the tree pipes.
*/
cell_tree = e_cell_tree_new (E_TABLE_MODEL(e_tree_model),
- tree_expanded_pixbuf, tree_unexpanded_pixbuf,
+ NULL, NULL, /* use the default pixbufs for open/closed */
TRUE, cell_left_just);
/*
@@ -411,6 +419,10 @@ create_tree (void)
gtk_signal_connect (GTK_OBJECT (button), "clicked", print_tree, e_tree_model);
gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+ button = gtk_button_new_with_label ("Save State");
+ gtk_signal_connect (GTK_OBJECT (button), "clicked", save_state, e_tree_model);
+ gtk_box_pack_end (GTK_BOX (vbox), button, FALSE, FALSE, 0);
+
gtk_container_add (GTK_CONTAINER (window), vbox);
/* Size the initial window. */
@@ -428,22 +440,14 @@ int
main (int argc, char *argv [])
{
gnome_init ("TableExample", "TableExample", argc, argv);
- e_cursors_init ();
gtk_widget_push_visual (gdk_rgb_get_visual ());
gtk_widget_push_colormap (gdk_rgb_get_cmap ());
- /*
- * Create our pixbuf for expanding/unexpanding
- */
- tree_expanded_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)tree_expanded_xpm);
- tree_unexpanded_pixbuf = gdk_pixbuf_new_from_xpm_data((const char**)tree_unexpanded_xpm);
-
create_tree ();
gtk_main ();
- e_cursors_shutdown ();
return 0;
}
diff --git a/widgets/table/e-tree-model.c b/widgets/table/e-tree-model.c
index baf8d40416..c3f727e825 100644
--- a/widgets/table/e-tree-model.c
+++ b/widgets/table/e-tree-model.c
@@ -438,9 +438,14 @@ E_MAKE_TYPE(e_tree_model, "ETreeModel", ETreeModel, e_tree_model_class_init, NUL
void
e_tree_model_node_changed (ETreeModel *tree_model, ETreePath *node)
{
+ int row;
g_return_if_fail (tree_model != NULL);
g_return_if_fail (E_IS_TREE_MODEL (tree_model));
+ row = e_tree_model_row_of_node (tree_model, node);
+ if (row != -1)
+ e_table_model_row_changed (E_TABLE_MODEL (tree_model), row);
+
gtk_signal_emit (GTK_OBJECT (tree_model),
e_tree_model_signals [NODE_CHANGED]);
}
@@ -450,8 +455,13 @@ e_tree_model_node_inserted (ETreeModel *tree_model,
ETreePath *parent_node,
ETreePath *inserted_node)
{
+ int row;
g_return_if_fail (tree_model != NULL);
g_return_if_fail (E_IS_TREE_MODEL (tree_model));
+
+ row = e_tree_model_row_of_node (tree_model, inserted_node);
+ if (row != -1)
+ e_table_model_row_inserted (E_TABLE_MODEL (tree_model), row);
gtk_signal_emit (GTK_OBJECT (tree_model),
e_tree_model_signals [NODE_INSERTED],
@@ -461,8 +471,14 @@ e_tree_model_node_inserted (ETreeModel *tree_model,
void
e_tree_model_node_removed (ETreeModel *tree_model, ETreePath *parent_node, ETreePath *removed_node)
{
+ int row;
+
g_return_if_fail (tree_model != NULL);
g_return_if_fail (E_IS_TREE_MODEL (tree_model));
+
+ row = e_tree_model_row_of_node (tree_model, removed_node);
+ if (row != -1)
+ e_table_model_row_inserted (E_TABLE_MODEL (tree_model), row);
gtk_signal_emit (GTK_OBJECT (tree_model),
e_tree_model_signals [NODE_REMOVED],
diff --git a/widgets/table/tree-expanded.xpm b/widgets/table/tree-expanded.xpm
new file mode 100644
index 0000000000..4a89340cf4
--- /dev/null
+++ b/widgets/table/tree-expanded.xpm
@@ -0,0 +1,23 @@
+/* XPM */
+static char * tree_expanded_xpm[] = {
+"16 16 4 1",
+" c None",
+". c #FFFFFF",
+"* c #666666",
+"+ c #000000",
+" ",
+" ",
+" ",
+" ",
+" +++++++++ ",
+" +.......+ ",
+" +.......+ ",
+" +.......+ ",
+" +.*****.+ ",
+" +.......+ ",
+" +.......+ ",
+" +.......+ ",
+" +++++++++ ",
+" ",
+" ",
+" "};
diff --git a/widgets/table/tree-unexpanded.xpm b/widgets/table/tree-unexpanded.xpm
new file mode 100644
index 0000000000..3266a67020
--- /dev/null
+++ b/widgets/table/tree-unexpanded.xpm
@@ -0,0 +1,23 @@
+/* XPM */
+static char * tree_unexpanded_xpm[] = {
+"16 16 4 1",
+" c None",
+". c #FFFFFF",
+"* c #666666",
+"+ c #000000",
+" ",
+" ",
+" ",
+" ",
+" +++++++++ ",
+" +.......+ ",
+" +...*...+ ",
+" +...*...+ ",
+" +.*****.+ ",
+" +...*...+ ",
+" +...*...+ ",
+" +.......+ ",
+" +++++++++ ",
+" ",
+" ",
+" "};