aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/table/e-tree-example-1.c
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/table/e-tree-example-1.c
parent30b11ae4f9cfd2f33044d64894292593d2aa5e45 (diff)
downloadgsoc2013-evolution-1c2eec1fd409b7ec7a6742684c678bcd258aec53.tar
gsoc2013-evolution-1c2eec1fd409b7ec7a6742684c678bcd258aec53.tar.gz
gsoc2013-evolution-1c2eec1fd409b7ec7a6742684c678bcd258aec53.tar.bz2
gsoc2013-evolution-1c2eec1fd409b7ec7a6742684c678bcd258aec53.tar.lz
gsoc2013-evolution-1c2eec1fd409b7ec7a6742684c678bcd258aec53.tar.xz
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/table/e-tree-example-1.c')
-rw-r--r--widgets/table/e-tree-example-1.c48
1 files changed, 26 insertions, 22 deletions
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;
}