diff options
author | Christopher James Lahey <clahey@ximian.com> | 2001-03-30 09:27:38 +0800 |
---|---|---|
committer | Chris Lahey <clahey@src.gnome.org> | 2001-03-30 09:27:38 +0800 |
commit | 491523b07ca6d9b1264ff2f53760a580715f2db6 (patch) | |
tree | 32c42d340fb0b3b667f25982192d64b88675b6e2 /widgets/table | |
parent | 55c3dea8392096c85ab4bfcd7872b44bb1a3e16c (diff) | |
download | gsoc2013-evolution-491523b07ca6d9b1264ff2f53760a580715f2db6.tar gsoc2013-evolution-491523b07ca6d9b1264ff2f53760a580715f2db6.tar.gz gsoc2013-evolution-491523b07ca6d9b1264ff2f53760a580715f2db6.tar.bz2 gsoc2013-evolution-491523b07ca6d9b1264ff2f53760a580715f2db6.tar.lz gsoc2013-evolution-491523b07ca6d9b1264ff2f53760a580715f2db6.tar.xz gsoc2013-evolution-491523b07ca6d9b1264ff2f53760a580715f2db6.tar.zst gsoc2013-evolution-491523b07ca6d9b1264ff2f53760a580715f2db6.zip |
Updated to set the width of the header canvas to be equal to the width of
2001-03-29 Christopher James Lahey <clahey@ximian.com>
* 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
Diffstat (limited to 'widgets/table')
-rw-r--r-- | widgets/table/e-table.c | 39 | ||||
-rw-r--r-- | widgets/table/e-tree.c | 55 | ||||
-rw-r--r-- | widgets/table/e-tree.h | 4 |
3 files changed, 73 insertions, 25 deletions
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c index 4a2edcb6f1..a61ec0fea9 100644 --- a/widgets/table/e-table.c +++ b/widgets/table/e-table.c @@ -257,12 +257,28 @@ et_focus (GtkContainer *container, GtkDirectionType direction) } static void +set_header_canvas_width (ETable *e_table) +{ + double oldwidth, oldheight, width; + + gnome_canvas_get_scroll_region (GNOME_CANVAS (e_table->table_canvas), + NULL, NULL, &width, NULL); + gnome_canvas_get_scroll_region (GNOME_CANVAS (e_table->header_canvas), + NULL, NULL, &oldwidth, &oldheight); + + if (oldwidth != width || + oldheight != E_TABLE_HEADER_ITEM (e_table->header_item)->height - 1) + gnome_canvas_set_scroll_region ( + GNOME_CANVAS (e_table->header_canvas), + 0, 0, width, /* COLUMN_HEADER_HEIGHT - 1 */ + E_TABLE_HEADER_ITEM (e_table->header_item)->height - 1); + +} + +static void header_canvas_size_allocate (GtkWidget *widget, GtkAllocation *alloc, ETable *e_table) { - gnome_canvas_set_scroll_region ( - GNOME_CANVAS (e_table->header_canvas), - 0, 0, alloc->width - 1, /* COLUMN_HEADER_HEIGHT - 1 */ - E_TABLE_HEADER_ITEM (e_table->header_item)->height - 1); + set_header_canvas_width (e_table); /* When the header item is created ->height == 0, as the font is only created when everything is realized. @@ -321,6 +337,7 @@ table_canvas_reflow_idle (ETable *e_table) { gdouble height, width; gdouble item_height; + gdouble oldheight, oldwidth; GtkAllocation *alloc = &(GTK_WIDGET (e_table->table_canvas)->allocation); gtk_object_get (GTK_OBJECT (e_table->canvas_vbox), @@ -331,11 +348,17 @@ table_canvas_reflow_idle (ETable *e_table) 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_table->table_canvas), - 0, 0, width - 1, height - 1); + gnome_canvas_get_scroll_region (GNOME_CANVAS (e_table->table_canvas), + NULL, NULL, &oldwidth, &oldheight); + + if (oldwidth != width - 1 || + oldheight != height - 1) { + gnome_canvas_set_scroll_region (GNOME_CANVAS (e_table->table_canvas), + 0, 0, width - 1, height - 1); + set_header_canvas_width (e_table); + } gtk_object_set (GTK_OBJECT (e_table->white_item), - "y1", item_height + 1, + "y1", item_height, "x2", width, "y2", height, NULL); 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; } @@ -206,12 +206,28 @@ et_focus (GtkContainer *container, GtkDirectionType 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", diff --git a/widgets/table/e-tree.h b/widgets/table/e-tree.h index 6b8f71789c..3ff63e315a 100644 --- a/widgets/table/e-tree.h +++ b/widgets/table/e-tree.h @@ -9,7 +9,7 @@ #include <gal/e-table/e-table-group.h> #include <gal/e-table/e-table-sort-info.h> #include <gal/e-table/e-table-item.h> -#include <gal/e-table/e-table-selection-model.h> +#include <gal/e-table/e-tree-selection-model.h> #include <gal/e-table/e-table-extras.h> #include <gal/e-table/e-table-specification.h> #include <gal/widgets/e-printable.h> @@ -41,7 +41,7 @@ typedef struct { ETableSortInfo *sort_info; ESorter *sorter; - ETableSelectionModel *selection; + ESelectionModel *selection; ETableSpecification *spec; int reflow_idle_id; |