From 22f72cc08e20c7871d93f05375fe2bafb0c1023a Mon Sep 17 00:00:00 2001 From: Iain Holmes Date: Fri, 15 Sep 2000 00:08:06 +0000 Subject: Fix some crashes Make double clicking on the header dividers automatically Fix some crashes Make double clicking on the header dividers automatically size the header to it's best fit. When dragging onto the header check the dragged item is a header object. Check the column is resizeable before setting the cursor to <-> Use the font and themes to draw the table and items. svn path=/trunk/; revision=5438 --- widgets/table/e-cell-tree.c | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'widgets/table/e-cell-tree.c') diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c index 3cc06a73ee..48ae9f4af1 100644 --- a/widgets/table/e-cell-tree.c +++ b/widgets/table/e-cell-tree.c @@ -352,6 +352,67 @@ ect_height (ECellView *ecell_view, int model_col, int view_col, int row) return e_cell_height (tree_view->subcell_view, model_col, view_col, row); } +/* + * ECell::max_width method + */ +static int +ect_max_width (ECellView *ecell_view, int model_col, int view_col) +{ + ECellTreeView *tree_view = (ECellTreeView *) ecell_view; + int row; + int number_of_rows; + int max_width = 0; + int width = 0; + + number_of_rows = e_table_model_row_count (ecell_view->e_table_model); + + for (row = 0; row < number_of_rows; row++) { + ETreeModel *tree_model = e_cell_tree_get_tree_model(ecell_view->e_table_model, row); + ETreePath *node; + GdkPixbuf *node_image; + int node_image_width = 0, node_image_height = 0; + ETreePath *parent_node; + + int offset, subcell_offset; + gboolean expanded, expandable; + + node = e_cell_tree_get_node (tree_model, row); + + offset = offset_of_node (tree_model, node); + expandable = e_tree_model_node_is_expandable (tree_model, node); + expanded = e_tree_model_node_is_expanded (tree_model, node); + subcell_offset = offset; + + node_image = e_tree_model_icon_of_node (tree_model, node); + + if (node_image) { + node_image_width = gdk_pixbuf_get_width (node_image); + node_image_height = gdk_pixbuf_get_height (node_image); + } + + width = subcell_offset + node_image_width; + + if (expandable) { + GdkPixbuf *image; + + image = (expanded + ? E_CELL_TREE(tree_view->cell_view.ecell)->open_pixbuf + : E_CELL_TREE(tree_view->cell_view.ecell)->closed_pixbuf); + + width += gdk_pixbuf_get_width(image); + } + + width += e_cell_max_width (tree_view->subcell_view, model_col, + view_col); + + max_width = MAX (max_width, width); + } + + return max_width; +} + + + /* * ECellView::enter_edit method */ @@ -510,6 +571,7 @@ e_cell_tree_class_init (GtkObjectClass *object_class) ecc->leave_edit = ect_leave_edit; ecc->print = ect_print; ecc->print_height = ect_print_height; + ecc->max_width = ect_max_width; parent_class = gtk_type_class (PARENT_TYPE); } -- cgit