From 491523b07ca6d9b1264ff2f53760a580715f2db6 Mon Sep 17 00:00:00 2001 From: Christopher James Lahey Date: Fri, 30 Mar 2001 01:27:38 +0000 Subject: Updated to set the width of the header canvas to be equal to the width of 2001-03-29 Christopher James Lahey * e-table.c, e-tree.c, e-tree.h: Updated to set the width of the header canvas to be equal to the width of the table canvas to avoid infinite loops. Added left arrow and right arrow as tree collapse and expand bindings. svn path=/trunk/; revision=9035 --- widgets/table/e-tree.c | 55 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 40 insertions(+), 15 deletions(-) (limited to 'widgets/table/e-tree.c') diff --git a/widgets/table/e-tree.c b/widgets/table/e-tree.c index d73c63d144..5263271557 100644 --- a/widgets/table/e-tree.c +++ b/widgets/table/e-tree.c @@ -174,7 +174,7 @@ e_tree_init (GtkObject *object) e_tree->drag_source_button_press_event_id = 0; e_tree->drag_source_motion_notify_event_id = 0; - e_tree->selection = e_table_selection_model_new(); + e_tree->selection = E_SELECTION_MODEL(e_table_selection_model_new()); e_tree->spec = NULL; } @@ -205,13 +205,29 @@ et_focus (GtkContainer *container, GtkDirectionType direction) return gtk_container_focus (GTK_CONTAINER (e_tree->table_canvas), direction); } +static void +set_header_canvas_width (ETree *e_tree) +{ + double oldwidth, oldheight, width; + + gnome_canvas_get_scroll_region (GNOME_CANVAS (e_tree->table_canvas), + NULL, NULL, &width, NULL); + gnome_canvas_get_scroll_region (GNOME_CANVAS (e_tree->header_canvas), + NULL, NULL, &oldwidth, &oldheight); + + if (oldwidth != width || + oldheight != E_TABLE_HEADER_ITEM (e_tree->header_item)->height - 1) + gnome_canvas_set_scroll_region ( + GNOME_CANVAS (e_tree->header_canvas), + 0, 0, width, /* COLUMN_HEADER_HEIGHT - 1 */ + E_TABLE_HEADER_ITEM (e_tree->header_item)->height - 1); + +} + static void header_canvas_size_allocate (GtkWidget *widget, GtkAllocation *alloc, ETree *e_tree) { - gnome_canvas_set_scroll_region ( - GNOME_CANVAS (e_tree->header_canvas), - 0, 0, alloc->width - 1, /* COLUMN_HEADER_HEIGHT - 1 */ - E_TABLE_HEADER_ITEM (e_tree->header_item)->height - 1); + set_header_canvas_width (e_tree); /* When the header item is created ->height == 0, as the font is only created when everything is realized. @@ -259,6 +275,7 @@ tree_canvas_reflow_idle (ETree *e_tree) { gdouble height, width; gdouble item_height; + gdouble oldheight, oldwidth; GtkAllocation *alloc = &(GTK_WIDGET (e_tree->table_canvas)->allocation); gtk_object_get (GTK_OBJECT (e_tree->item), @@ -269,11 +286,17 @@ tree_canvas_reflow_idle (ETree *e_tree) height = MAX ((int)height, alloc->height); width = MAX((int)width, alloc->width); /* I have no idea why this needs to be -1, but it works. */ - gnome_canvas_set_scroll_region ( - GNOME_CANVAS (e_tree->table_canvas), - 0, 0, width - 1, height - 1); + gnome_canvas_get_scroll_region (GNOME_CANVAS (e_tree->table_canvas), + NULL, NULL, &oldwidth, &oldheight); + + if (oldwidth != width - 1 || + oldheight != height - 1) { + gnome_canvas_set_scroll_region (GNOME_CANVAS (e_tree->table_canvas), + 0, 0, width - 1, height - 1); + set_header_canvas_width (e_tree); + } gtk_object_set (GTK_OBJECT (e_tree->white_item), - "y1", item_height + 1, + "y1", item_height, "x2", width, "y2", height, NULL); @@ -415,10 +438,12 @@ item_key_press (ETableItem *eti, int row, int col, GdkEvent *event, ETree *et) return_val = 1; break; case '=': + case GDK_Right: path = e_tree_table_adapter_node_at_row(et->etta, row); e_tree_table_adapter_node_set_expanded (et->etta, path, TRUE); break; case '-': + case GDK_Left: path = e_tree_table_adapter_node_at_row(et->etta, row); e_tree_table_adapter_node_set_expanded (et->etta, path, FALSE); break; @@ -747,12 +772,6 @@ et_real_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, e_tree->etta = E_TREE_TABLE_ADAPTER(e_tree_table_adapter_new(E_TREE_MODEL(e_tree->sorted))); - gtk_object_set(GTK_OBJECT(e_tree->selection), - "model", E_TABLE_MODEL(e_tree->etta), - "selection_mode", specification->selection_mode, - "cursor_mode", specification->cursor_mode, - NULL); - gtk_widget_push_visual (gdk_rgb_get_visual ()); gtk_widget_push_colormap (gdk_rgb_get_cmap ()); @@ -761,6 +780,12 @@ et_real_construct (ETree *e_tree, ETreeModel *etm, ETableExtras *ete, gtk_object_set (GTK_OBJECT (e_tree->selection), "model", e_tree->etta, "sorter", e_tree->sorter, +#if 0 + "ets", e_tree->sorted, + "model", e_tree->model, +#endif + "selection_mode", specification->selection_mode, + "cursor_mode", specification->cursor_mode, NULL); gtk_signal_connect(GTK_OBJECT(e_tree->selection), "selection_changed", -- cgit