Commit 1510304c authored by Christopher James Lahey's avatar Christopher James Lahey Committed by Chris Lahey

Deal with proxy_node_changed being called on a different root node than

2001-03-19  Christopher James Lahey  <clahey@ximian.com>

	* e-tree-sorted.c (ets_proxy_node_changed): Deal with
	proxy_node_changed being called on a different root node than the
	one we have in our tree.

	* e-tree-table-adapter.c: Did some general clean up here.

	* Merged branch:

2001-03-19  Christopher James Lahey  <clahey@ximian.com>

	* e-tree-sorted.c (find_child_path): Added this function to allow
	us to find paths that have been removed from the source.
	(ets_proxy_node_removed): Fixed the memmove here a bit.  Call
	find_child_path.

	* e-tree-table-adapter.c (find_node): Check that the passed in
	path isn't NULL.

2001-03-19  Christopher James Lahey  <clahey@ximian.com>

	* e-table-item.c (eti_reflow): Get width from header object
	instead of calculating it ourselves.

	* e-table-selection-model.c: Turn off selection saving since it's
	so slow.

	* e-table.c (e_table_set_state_object): Set the width of the newly
	created header object.

	* e-tree.c (e_tree_set_state_object): Set the width of the newly
	created header object.
	(tree_canvas_size_allocate): Don't bother setting the dimensions
	of the white background twice.

2001-03-18  Christopher James Lahey  <clahey@ximian.com>

	* e-table-selection-model.c, e-table-selection-model.h: Made
	ETableSelectionModel save the cursor properly across changed
	signals if has_save_id is true.

2001-03-18  Christopher James Lahey  <clahey@ximian.com>

	* e-table-selection-model.c, e-table-selection-model.h: Made
	ETableSelectionModel save selection properly across changed
	signals if has_save_id is true.

	* e-tree-memory.c: A couple of typos.

2001-03-18  Christopher James Lahey  <clahey@ximian.com>

	* e-tree-memory.c, e-tree-sorted.c: Send pre_changes properly.

2001-03-18  Christopher James Lahey  <clahey@ximian.com>

	* e-tree-table-adapter.c: Send pre_changes when performing
	set_expanded or root_node_set_visible.

2001-03-18  Christopher James Lahey  <clahey@ximian.com>

	* e-tree-sorted.c (ets_is_expandable): When the API requests
	whether the object is expandable and it isn't, make sure to send a
	signal when it becomes expandable.

	* e-tree-table-adapter.c: Made it so that in a number of cases
	where it doesn't need to create an empty hash table node if the
	current tree node has no children, it doesn't.

2001-03-18  Christopher James Lahey  <clahey@ximian.com>

	* e-tree-memory-callbacks.c, e-tree-memory-callbacks.h
	(etmc_has_save_id, etmc_get_save_id): Added has_save_id and
	get_save_id to the list of methods supported by
	e_tree_memory_callbacks.

	* e-tree-table-adapter.c, e-tree-table-adapter.h: Added saving of
	expanded nodes.

2001-03-18  Christopher James Lahey  <clahey@ximian.com>

	* e-table-model.c, e-table-model.h (e_table_model_get_save_id):
	Changed row_save_id to get_save_id to be consistent with ETree.

	* e-tree-model.c, e-tree-model.h: Added "pre_change" signal.
	Added has_save_id and get_save_id methods.

	* e-tree-sorted.c: Proxy pre_change signal.  Implemented
	has_save_id and get_save_id.  If the base model doesn't provide
	has_save_id then we g_strdup_printf the pointer of the base model
	ETreePath as the save_id.

	* e-tree-table-adapter.c: Proxy pre_change signal.  If base model
	has_save_id, then use the results of get_save_id as the key for
	the hash table of node attributes.  Otherwise use the pointer as
	before.

2001-03-17  Christopher James Lahey  <clahey@ximian.com>

	* e-tree-sorted.c (ets_sort_idle): Fixed it so that all nodes get
	sorted properly instead of just the top node.

2001-03-17  Christopher James Lahey  <clahey@ximian.com>

	* e-table-sorting-utils.c (e_table_sorting_utils_tree_sort): Made
	tree sorting faster by using a cache.

	* e-tree-sorted.c: Added commented out debugging g_prints.

2001-03-17  Christopher James Lahey  <clahey@ximian.com>

	* e-tree-sorted.c: Switched to using GMemChunks.

2001-03-17  Christopher James Lahey  <clahey@ximian.com>

	* e-tree-sorted.c (resort_node): Made it so that children of a
	node that's being sorted don't send changed signals.

2001-03-17  Christopher James Lahey  <clahey@ximian.com>

	* e-table-sorting-utils.c, e-table-sorting-utils.h: Switched to
	using e_sort and e_search instead of qsort and a linear search.
	Added the tree functions e_table_sorting_utils_tree_sort,
	e_table_sorting_utils_tree_check_position, and
	e_table_sorting_utils_tree_insert.

	* e-tree-sorted.c: Made this actually do sorting.

	* e-tree-table-adapter.c (etta_proxy_node_changed): The old_size
	needs to be the number of visible children + 1 to include the top
	node.

	* e-tree.c (e_tree_set_state_object): Set the sort_info on the
	ETreeSorted when you get a new sort_info.

2001-03-16  Christopher James Lahey  <clahey@ximian.com>

	* Makefile.am: Added e-tree-sorted.c and e-tree-sorted.h.

	* e-table-item.c (eti_realize_cell_views): Only realize the cells
	if they're not realized already and if the canvas is realized.

	* e-table-sorted.c (ets_proxy_model_cell_changed): Matched the
	change to the signature of e_table_sorting_utils_affects_sort.

	* e-table-sorting-utils.c, e-table-sorting-utils.h
	(e_table_sorting_utils_affects_sort): Changed the signature of
	this function to not take the ETableModel source since it doesn't
	use it and we need to use this function for ETreeSorted which
	doesn't have an ETableModel.

	* e-tree-memory.c (etmm_get_expanded_default): Actually implement
	the get_expanded_default for this tree.

	* e-tree-model.h: Cleaned up the indentation here.

	* e-tree-sorted.c, e-tree-sorted.h: New class meant to be used for
	sorting trees.  It doesn't actually sort yet.  It simply acts as
	an ETreeProxy which is the hardest part of making ETreeSorted.

	* e-tree.c, e-tree.h: Made this use an ETreeSorted.

2001-03-14  Christopher James Lahey  <clahey@ximian.com>

	* e-table-item.c, e-table-item.h, e-table-selection-model.c,
	e-table-selection-model.h, e-table-sorted.c, e-table-sorted.h,
	e-table-subset.c, e-table-subset.h, e-table.c, e-table.h: Switch
	to handling e_table_model_rows_inserted instead of
	e_table_model_row_inserted and e_table_model_rows_deleted instead
	of e_table_model_row_deleted.

	* e-table-model.c, e-table-model.h: Replaced the signals
	"model_row_inserted" and "model_row_deleted" with
	"model_rows_inserted" and "model_rows_deleted" so that when
	multiple rows are inserted or deleted at the same time they can be
	handled properly.

	* e-tree-table-adapter.c: Call "model_rows_inserted" and
	"model_rows_deleted" instead of "model_changed" when inserting or
	deleting multiple rows.

2001-03-14  Christopher James Lahey  <clahey@ximian.com>

	* e-table-item.c (e_table_item_row_diff): Made this not count the
	pixel between rows if it isn't there.

2001-03-14  Christopher James Lahey  <clahey@ximian.com>

	* e-table-item.c (eti_header_structure_changed): Properly attach &
	realize cell views here.

2001-03-13  Christopher James Lahey  <clahey@ximian.com>

	* e-tree-table-adapter.c (etta_proxy_node_removed): Check that
	parent_node and parent aren't NULL before making function calls on
	them.

2001-03-13  Christopher James Lahey  <clahey@ximian.com>

	* e-table-item.c (confirm_height_cache): Fixed a height cache
	miscalculation.

	* e-tree-table-adapter.c (find_first_child_node): Made the
	semantics of this mean that find_first_child_node(adapter, -1)
	means return the first node in the tree.

2001-03-13  Christopher James Lahey  <clahey@ximian.com>

	* e-table-extras.c: Added a "string-integer" comparison function
	to the default %ETableExtras so you can do comparisons based on
	integer value even if you using strings for the data (this lets
	you do editable numbers, for instance.)

	* e-table-item.c: Rearranged it a bit so that if you have
	draw_grid off it doesn't add space for the horizontal lines, nor
	leave them the background color.

	* e-table-model.c, e-table-model.h: Added the row_save_id and
	has_save_id methods to %ETableModel.

	* e-tree.c, e-tree.h: Replaced e_tree_compute_location with
	e_tree_get_cell_at.

2001-03-08  Christopher James Lahey  <clahey@ximian.com>

	* Makefile.am: Added e-table/e-table-utils.c,
	e-table/e-tree-memory-callbacks.c, e-table/e-tree-memory.c,
	e-table/e-tree-scrolled.c, e-table/e-tree-table-adapter.c, and
	e-table/e-tree.c.  Removed e-table/e-tree-simple.c.  Added
	e-table/e-table-utils.h, e-table/e-tree-memory-callbacks.h,
	e-table/e-tree-memory.h, e-table/e-tree-scrolled.h,
	e-table/e-tree-table-adapter.h, and e-table/e-tree.h.  Removed
	e-table/e-tree-simple.h.

	* e-cell-tree.c: Updated this for the new tree.

	* e-table-item.c: Added some redraw requests where appropriate.

	* e-table-item.h: Fixed an incorrect class method declaration.

	* e-table-model.c, e-table-model.h: Removed
	e_table_model_has_sort_group and e_table_model_row_sort_group.

	* e-table-scrolled.h: Removed unused headers.

	* e-table-simple.c, e-table-simple.h: Rearranged this a bit.

	* e-table-sorter.c, e-table-sorting-utils.c,
	e-table-sorting-utils.h: Removed sort group stuff.  Added the
	function e_table_sorting_utils_check_position.

	* e-table-utils.c, e-table-utils.h: Utility functions for ETable
	and ETree.

	* e-table.c: Moved some of the functionality from here to
	e-table-utils.c so that it can be reused by ETree.

	* e-tree-memory-callbacks.c, e-tree-memory-callbacks.h: Class to
	implement an ETreeMemory as callbacks instead of overriding the
	class.

	* e-tree-memory.c, e-tree-memory.h: ETreeModel that stores a tree
	of physical nodes.

	* e-tree-model.c, e-tree-model.h: Removed most of the
	functionality from here to the classes ETreeMemory and
	ETreeTableAdapter.  This is now just a simple virtualized tree
	class.

	* e-tree-scrolled.c, e-tree-scrolled.h: New class.  An ETree in an
	EScrollFrame.

	* e-tree-simple.c: Small change.  This is no longer used.

	* e-tree-table-adapter.c, e-tree-table-adapter.h: ETableModel that
	represents an ETreeModel as a table.

	* e-tree.c, e-tree.h: New super class kind of like ETable but for
	trees.

End of branch

svn path=/trunk/; revision=8837
parent 0629bbb7
......@@ -13,6 +13,9 @@
*/
#include <config.h>
#include "e-cell-tree.h"
#include <gtk/gtkenums.h>
#include <gtk/gtkentry.h>
#include <gtk/gtkwindow.h>
......@@ -21,9 +24,9 @@
#include <gdk/gdkkeysyms.h>
#include <libgnomeui/gnome-canvas.h>
#include <stdio.h>
#include "e-table-sorted-variable.h"
#include "e-tree-table-adapter.h"
#include "e-tree-model.h"
#include "e-cell-tree.h"
#include "gal/util/e-util.h"
#include "e-table-item.h"
......@@ -49,29 +52,38 @@ static ECellClass *parent_class;
#define INDENT_AMOUNT 16
static int
visible_depth_of_node (ETreeModel *tree_model, ETreePath *path)
static ETreePath
e_cell_tree_get_node (ETableModel *table_model, int row)
{
return (e_tree_model_node_depth (tree_model, path)
- (e_tree_model_root_node_is_visible (tree_model) ? 0 : 1));
return e_table_model_value_at (table_model, -1, row);
}
static gint
offset_of_node (ETreeModel *tree_model, ETreePath *path)
static ETreeModel*
e_cell_tree_get_tree_model (ETableModel *table_model, int row)
{
return (visible_depth_of_node(tree_model, path) + 1) * INDENT_AMOUNT;
return e_table_model_value_at (table_model, -2, row);
}
static ETreePath*
e_cell_tree_get_node (ETableModel *table_model, int row)
static ETreeTableAdapter *
e_cell_tree_get_tree_table_adapter (ETableModel *table_model, int row)
{
return (ETreePath*)e_table_model_value_at (table_model, -1, row);
return e_table_model_value_at (table_model, -3, row);
}
static ETreeModel*
e_cell_tree_get_tree_model (ETableModel *table_model, int row)
static int
visible_depth_of_node (ETableModel *model, int row)
{
return (ETreeModel*)e_table_model_value_at (table_model, -2, row);
ETreeModel *tree_model = e_cell_tree_get_tree_model(model, row);
ETreeTableAdapter *adapter = e_cell_tree_get_tree_table_adapter(model, row);
ETreePath path = e_cell_tree_get_node(model, row);
return (e_tree_model_node_depth (tree_model, path)
- (e_tree_table_adapter_root_node_is_visible (adapter) ? 0 : 1));
}
static gint
offset_of_node (ETableModel *table_model, int row)
{
return (visible_depth_of_node(table_model, row) + 1) * INDENT_AMOUNT;
}
/*
......@@ -159,7 +171,8 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
{
ECellTreeView *tree_view = (ECellTreeView *)ecell_view;
ETreeModel *tree_model = e_cell_tree_get_tree_model(ecell_view->e_table_model, row);
ETreePath *node;
ETreeTableAdapter *tree_table_adapter = e_cell_tree_get_tree_table_adapter(ecell_view->e_table_model, row);
ETreePath node;
GdkRectangle rect, *clip_rect;
GtkWidget *canvas = GTK_WIDGET (tree_view->canvas);
GdkGC *fg_gc = canvas->style->fg_gc[GTK_STATE_ACTIVE];
......@@ -175,21 +188,21 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
if (/* XXX */ TRUE) {
GdkPixbuf *node_image;
int node_image_width = 0, node_image_height = 0;
ETreePath *parent_node;
ETreePath parent_node;
node = e_cell_tree_get_node (ecell_view->e_table_model, row);
expandable = e_tree_model_node_is_expandable (tree_model, node);
expanded = e_tree_model_node_is_expanded (tree_model, node);
expanded = e_tree_table_adapter_node_is_expanded (tree_table_adapter, node);
if (visible_depth_of_node (tree_model, node) > 0 || expandable) {
offset = offset_of_node (tree_model, node);
if (visible_depth_of_node (ecell_view->e_table_model, row) > 0 || expandable) {
offset = offset_of_node (ecell_view->e_table_model, row);
} else {
offset = 0;
}
subcell_offset = offset;
node_image = e_tree_model_icon_of_node (tree_model, node);
node_image = e_tree_model_icon_at (tree_model, node);
if (node_image) {
node_image_width = gdk_pixbuf_get_width (node_image);
......@@ -219,7 +232,9 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
/* draw our lines */
if (E_CELL_TREE(tree_view->cell_view.ecell)->draw_lines) {
if (visible_depth_of_node (tree_model, node) > 0
int depth;
if (visible_depth_of_node (ecell_view->e_table_model, row) > 0
|| e_tree_model_node_get_children (tree_model, node, NULL) > 0)
gdk_draw_line (drawable, tree_view->gc,
rect.x + offset - INDENT_AMOUNT / 2 + 1,
......@@ -227,7 +242,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
rect.x + offset,
rect.y + rect.height / 2);
if (visible_depth_of_node (tree_model, node) != 0) {
if (visible_depth_of_node (ecell_view->e_table_model, row) != 0) {
gdk_draw_line (drawable, tree_view->gc,
rect.x + offset - INDENT_AMOUNT / 2,
rect.y,
......@@ -242,7 +257,8 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
correct vertical pipe for it's configuration. */
parent_node = e_tree_model_node_get_parent (tree_model, node);
offset -= INDENT_AMOUNT;
while (parent_node && visible_depth_of_node (tree_model, parent_node) != 0) {
depth = visible_depth_of_node (ecell_view->e_table_model, row) - 1;
while (parent_node && depth != 0) {
if (e_tree_model_node_get_next(tree_model, parent_node)) {
gdk_draw_line (drawable, tree_view->gc,
rect.x + offset - INDENT_AMOUNT / 2,
......@@ -251,6 +267,7 @@ ect_draw (ECellView *ecell_view, GdkDrawable *drawable,
rect.y + rect.height);
}
parent_node = e_tree_model_node_get_parent (tree_model, parent_node);
depth --;
offset -= INDENT_AMOUNT;
}
}
......@@ -309,8 +326,9 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col,
{
ECellTreeView *tree_view = (ECellTreeView *) ecell_view;
ETreeModel *tree_model = e_cell_tree_get_tree_model (ecell_view->e_table_model, row);
ETreePath *node = e_cell_tree_get_node (ecell_view->e_table_model, row);
int offset = offset_of_node (tree_model, node);
ETreeTableAdapter *tree_table_adapter = e_cell_tree_get_tree_table_adapter(ecell_view->e_table_model, row);
ETreePath node = e_cell_tree_get_node (ecell_view->e_table_model, row);
int offset = offset_of_node (ecell_view->e_table_model, row);
switch (event->type) {
case GDK_BUTTON_PRESS: {
......@@ -320,9 +338,9 @@ ect_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col,
/* only activate the tree control if the click/release happens in the icon's area. */
if (event->button.x > (offset - INDENT_AMOUNT) && event->button.x < offset) {
if (e_tree_model_node_is_expandable (tree_model, node)) {
e_tree_model_node_set_expanded (tree_model,
node,
!e_tree_model_node_is_expanded(tree_model, node));
e_tree_table_adapter_node_set_expanded (tree_table_adapter,
node,
!e_tree_table_adapter_node_is_expanded(tree_table_adapter, node));
return TRUE;
}
}
......@@ -399,7 +417,8 @@ ect_max_width (ECellView *ecell_view, int model_col, int view_col)
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;
ETreeTableAdapter *tree_table_adapter = e_cell_tree_get_tree_table_adapter(ecell_view->e_table_model, row);
ETreePath node;
GdkPixbuf *node_image;
int node_image_width = 0, node_image_height = 0;
......@@ -408,12 +427,12 @@ ect_max_width (ECellView *ecell_view, int model_col, int view_col)
node = e_cell_tree_get_node (ecell_view->e_table_model, row);
offset = offset_of_node (tree_model, node);
offset = offset_of_node (ecell_view->e_table_model, row);
expandable = e_tree_model_node_is_expandable (tree_model, node);
expanded = e_tree_model_node_is_expanded (tree_model, node);
expanded = e_tree_table_adapter_node_is_expanded (tree_table_adapter, node);
subcell_offset = offset;
node_image = e_tree_model_icon_of_node (tree_model, node);
node_image = e_tree_model_icon_at (tree_model, node);
if (node_image) {
node_image_width = gdk_pixbuf_get_width (node_image);
......@@ -447,11 +466,11 @@ ect_show_tooltip (ECellView *ecell_view, int model_col, int view_col, int row,
{
ECellTreeView *tree_view = (ECellTreeView *) ecell_view;
ETreeModel *tree_model = e_cell_tree_get_tree_model (ecell_view->e_table_model, row);
ETreePath *node = e_cell_tree_get_node (ecell_view->e_table_model, row);
int offset = offset_of_node (tree_model, node);
ETreePath node = e_cell_tree_get_node (ecell_view->e_table_model, row);
int offset = offset_of_node (ecell_view->e_table_model, row);
GdkPixbuf *node_image;
node_image = e_tree_model_icon_of_node (tree_model, node);
node_image = e_tree_model_icon_at (tree_model, node);
if (node_image)
offset += gdk_pixbuf_get_width (node_image);
......@@ -492,14 +511,16 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context,
if (/* XXX only if we're the active sort */ TRUE) {
ETreeModel *tree_model = e_cell_tree_get_tree_model (ecell_view->e_table_model, row);
ETreePath *node = e_cell_tree_get_node (ecell_view->e_table_model, row);
int offset = offset_of_node (tree_model, node);
ETreeTableAdapter *tree_table_adapter = e_cell_tree_get_tree_table_adapter(ecell_view->e_table_model, row);
ETreePath node = e_cell_tree_get_node (ecell_view->e_table_model, row);
int offset = offset_of_node (ecell_view->e_table_model, row);
int subcell_offset = offset;
gboolean expandable = e_tree_model_node_is_expandable (tree_model, node);
gboolean expanded = e_tree_model_node_is_expanded (tree_model, node);
gboolean expanded = e_tree_table_adapter_node_is_expanded (tree_table_adapter, node);
/* draw our lines */
if (E_CELL_TREE(tree_view->cell_view.ecell)->draw_lines) {
int depth;
if (!e_tree_model_node_is_root (tree_model, node)
|| e_tree_model_node_get_children (tree_model, node, NULL) > 0) {
......@@ -512,7 +533,7 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context,
height / 2);
}
if (visible_depth_of_node (tree_model, node) != 0) {
if (visible_depth_of_node (ecell_view->e_table_model, row) != 0) {
gnome_print_moveto (context,
offset - INDENT_AMOUNT / 2,
height);
......@@ -527,8 +548,9 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context,
each level if the node has siblings, and drawing the
correct vertical pipe for it's configuration. */
node = e_tree_model_node_get_parent (tree_model, node);
depth = visible_depth_of_node (ecell_view->e_table_model, row) - 1;
offset -= INDENT_AMOUNT;
while (node && visible_depth_of_node (tree_model, node) != 0) {
while (node && depth != 0) {
if (e_tree_model_node_get_next(tree_model, node)) {
gnome_print_moveto (context,
offset - INDENT_AMOUNT / 2,
......@@ -538,6 +560,7 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context,
0);
}
node = e_tree_model_node_get_parent (tree_model, node);
depth --;
offset -= INDENT_AMOUNT;
}
}
......
......@@ -363,16 +363,18 @@ do_sort_and_group_config_dialog (ETableConfig *config, gboolean is_sort)
config_group_info_update (config);
}
GtkWidget *
#if 0
static GtkWidget *
e_table_proxy_etable_new (void)
{
return gtk_label_new ("Waiting for the ETable/ETree\nmerger to be commited");
}
#endif
static void
config_button_fields (GtkWidget *widget, ETableConfig *config)
{
gnome_dialog_run (config->dialog_show_fields);
gnome_dialog_run (GNOME_DIALOG(config->dialog_show_fields));
gnome_dialog_close (GNOME_DIALOG (config->dialog_show_fields));
}
......
......@@ -72,6 +72,15 @@ ete_class_init (GtkObjectClass *klass)
klass->destroy = ete_destroy;
}
static gint
e_strint_compare(gconstpointer data1, gconstpointer data2)
{
int int1 = atoi(data1);
int int2 = atoi(data2);
return g_int_compare(GINT_TO_POINTER(int1), GINT_TO_POINTER(int2));
}
static void
ete_init (ETableExtras *extras)
{
......@@ -81,6 +90,7 @@ ete_init (ETableExtras *extras)
e_table_extras_add_compare(extras, "string", g_str_compare);
e_table_extras_add_compare(extras, "integer", g_int_compare);
e_table_extras_add_compare(extras, "string-integer", e_strint_compare);
e_table_extras_add_cell(extras, "checkbox", e_cell_checkbox_new());
e_table_extras_add_cell(extras, "date", e_cell_date_new (NULL, GTK_JUSTIFY_LEFT));
......
......@@ -63,7 +63,6 @@ enum {
static int eti_get_height (ETableItem *eti);
static int eti_get_minimum_width (ETableItem *eti);
static int eti_row_height (ETableItem *eti, int row);
static void e_table_item_focus (ETableItem *eti, int col, int row, GdkModifierType state);
static void eti_cursor_change (ETableSelectionModel *selection, int row, int col, ETableItem *eti);
......@@ -149,6 +148,12 @@ static void
eti_realize_cell_views (ETableItem *eti)
{
int i;
if (eti->cell_views_realized)
return;
if (!(GTK_OBJECT_FLAGS(eti) & GNOME_CANVAS_ITEM_REALIZED))
return;
for (i = 0; i < eti->n_cells; i++)
e_cell_realize (eti->cell_views [i]);
......@@ -254,8 +259,7 @@ eti_reflow (GnomeCanvasItem *item, gint flags)
eti->needs_compute_height = 0;
}
if (eti->needs_compute_width) {
int new_width = eti_get_minimum_width (eti);
new_width = MAX(new_width, eti->minimum_width);
int new_width = e_table_header_total_width(eti->header);
if (new_width != eti->width) {
eti->width = new_width;
e_canvas_item_request_parent_reflow (GNOME_CANVAS_ITEM (eti));
......@@ -319,9 +323,9 @@ eti_remove_table_model (ETableItem *eti)
gtk_signal_disconnect (GTK_OBJECT (eti->table_model),
eti->table_model_cell_change_id);
gtk_signal_disconnect (GTK_OBJECT (eti->table_model),
eti->table_model_row_inserted_id);
eti->table_model_rows_inserted_id);
gtk_signal_disconnect (GTK_OBJECT (eti->table_model),
eti->table_model_row_deleted_id);
eti->table_model_rows_deleted_id);
gtk_object_unref (GTK_OBJECT (eti->table_model));
if (eti->source_model)
gtk_object_unref (GTK_OBJECT (eti->source_model));
......@@ -330,8 +334,8 @@ eti_remove_table_model (ETableItem *eti)
eti->table_model_change_id = 0;
eti->table_model_row_change_id = 0;
eti->table_model_cell_change_id = 0;
eti->table_model_row_inserted_id = 0;
eti->table_model_row_deleted_id = 0;
eti->table_model_rows_inserted_id = 0;
eti->table_model_rows_deleted_id = 0;
eti->table_model = NULL;
eti->source_model = NULL;
eti->uses_source_model = 0;
......@@ -418,14 +422,25 @@ eti_row_height_real (ETableItem *eti, int row)
return max_h;
}
static void
confirm_height_cache (ETableItem *eti)
{
int i;
if (eti->height_cache)
return;
eti->height_cache = g_new(int, eti->rows);
for (i = 0; i < eti->rows; i++) {
eti->height_cache[i] = -1;
}
}
static gboolean
height_cache_idle(ETableItem *eti)
{
int changed = 0;
int i;
if (!eti->height_cache) {
eti->height_cache = g_new(int, eti->rows);
}
confirm_height_cache(eti);
for (i = eti->height_cache_idle_count; i < eti->rows; i++) {
if (eti->height_cache[i] == -1) {
eti_row_height(eti, i);
......@@ -457,12 +472,8 @@ free_height_cache (ETableItem *eti)
static void
calculate_height_cache (ETableItem *eti)
{
int i;
free_height_cache(eti);
eti->height_cache = g_new(int, eti->rows);
for (i = 0; i < eti->rows; i++) {
eti->height_cache[i] = -1;
}
confirm_height_cache(eti);
}
......@@ -509,6 +520,7 @@ eti_get_height (ETableItem *eti)
const int rows = eti->rows;
int row;
int height;
int height_extra = eti->draw_grid ? 1 : 0;
if (rows == 0)
return 0;
......@@ -520,42 +532,29 @@ eti_get_height (ETableItem *eti)
height = 0;
for (row = 0; row < rows; row++) {
if (eti->height_cache[row] == -1) {
height += (row_height + 1) * (rows - row);
height += (row_height + height_extra) * (rows - row);
break;
}
else
height += eti->height_cache[row] + 1;
height += eti->height_cache[row] + height_extra;
}
} else
height = (eti_row_height (eti, 0) + 1) * rows;
height = (eti_row_height (eti, 0) + height_extra) * rows;
/*
* 1 pixel at the top
*/
return height + 1;
return height + height_extra;
}
}
height = 1;
height = height_extra;
for (row = 0; row < rows; row++)
height += eti_row_height (eti, row) + 1;
height += eti_row_height (eti, row) + height_extra;
return height;
}
static int
eti_get_minimum_width (ETableItem *eti)
{
int width = 0;
int col;
for (col = 0; col < eti->cols; col++){
ETableCol *ecol = e_table_header_get_column (eti->header, col);
width += ecol->min_width;
}
return width;
}
static void
eti_item_region_redraw (ETableItem *eti, int x0, int y0, int x1, int y1)
{
......@@ -617,11 +616,12 @@ int
e_table_item_row_diff (ETableItem *eti, int start_row, int end_row)
{
int row, total;
int height_extra = eti->draw_grid ? 1 : 0;
total = 0;
for (row = start_row; row < end_row; row++)
total += eti_row_height (eti, row) + 1;
total += eti_row_height (eti, row) + height_extra;
return total;
}
......@@ -708,14 +708,16 @@ eti_table_model_cell_changed (ETableModel *table_model, int col, int row, ETable
}
static void
eti_table_model_row_inserted (ETableModel *table_model, int row, ETableItem *eti)
eti_table_model_rows_inserted (ETableModel *table_model, int row, int count, ETableItem *eti)
{
eti->rows = e_table_model_row_count (eti->table_model);
if (eti->height_cache) {
int i;
eti->height_cache = g_renew(int, eti->height_cache, eti->rows);
memmove(eti->height_cache + row + 1, eti->height_cache + row, (eti->rows - 1 - row) * sizeof(int));
eti->height_cache[row] = -1;
memmove(eti->height_cache + row + count, eti->height_cache + row, (eti->rows - count - row) * sizeof(int));
for (i = row; i < row + count; i++)
eti->height_cache[i] = -1;
}
eti->needs_compute_height = 1;
......@@ -725,12 +727,12 @@ eti_table_model_row_inserted (ETableModel *table_model, int row, ETableItem *eti
}
static void
eti_table_model_row_deleted (ETableModel *table_model, int row, ETableItem *eti)
eti_table_model_rows_deleted (ETableModel *table_model, int row, int count, ETableItem *eti)
{
eti->rows = e_table_model_row_count (eti->table_model);
if (eti->height_cache)
memmove(eti->height_cache + row, eti->height_cache + row + 1, (eti->rows - row) * sizeof(int));
memmove(eti->height_cache + row, eti->height_cache + row + count, (eti->rows - row) * sizeof(int));
eti->needs_compute_height = 1;
e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti));
......@@ -800,13 +802,13 @@ eti_add_table_model (ETableItem *eti, ETableModel *table_model)
GTK_OBJECT (table_model), "model_cell_changed",
GTK_SIGNAL_FUNC (eti_table_model_cell_changed), eti);
eti->table_model_row_inserted_id = gtk_signal_connect (
GTK_OBJECT (table_model), "model_row_inserted",
GTK_SIGNAL_FUNC (eti_table_model_row_inserted), eti);
eti->table_model_rows_inserted_id = gtk_signal_connect (
GTK_OBJECT (table_model), "model_rows_inserted",
GTK_SIGNAL_FUNC (eti_table_model_rows_inserted), eti);
eti->table_model_row_deleted_id = gtk_signal_connect (
GTK_OBJECT (table_model), "model_row_deleted",
GTK_SIGNAL_FUNC (eti_table_model_row_deleted), eti);
eti->table_model_rows_deleted_id = gtk_signal_connect (
GTK_OBJECT (table_model), "model_rows_deleted",
GTK_SIGNAL_FUNC (eti_table_model_rows_deleted), eti);
if (eti->header) {
eti_detach_cell_views (eti);
......@@ -851,13 +853,14 @@ eti_header_dim_changed (ETableHeader *eth, int col, ETableItem *eti)
{
eti->needs_compute_width = 1;
e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti));
eti->needs_redraw = 1;
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (eti));
}
static void
eti_header_structure_changed (ETableHeader *eth, ETableItem *eti)
{
eti->cols = e_table_header_count (eti->header);
eti->width = e_table_header_total_width (eti->header);
/*
* There should be at least one column
......@@ -872,12 +875,14 @@ eti_header_structure_changed (ETableHeader *eth, ETableItem *eti)
eti_realize_cell_views (eti);
} else {
if (eti->table_model) {
eti_detach_cell_views (eti);
eti_attach_cell_views (eti);
eti_realize_cell_views (eti);
}
}
eti->needs_compute_width = 1;
e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti));
eti->needs_redraw = 1;
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (eti));
}
static int
......@@ -992,11 +997,12 @@ eti_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
case ARG_MINIMUM_WIDTH:
case ARG_WIDTH:
if (eti->minimum_width == eti->width && GTK_VALUE_DOUBLE (*arg) > eti->width)
e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti));
if ((eti->minimum_width == eti->width && GTK_VALUE_DOUBLE (*arg) > eti->width) ||
GTK_VALUE_DOUBLE (*arg) < eti->width) {
eti->needs_compute_width = 1;
e_canvas_item_request_reflow (GNOME_CANVAS_ITEM(eti));
}
eti->minimum_width = GTK_VALUE_DOUBLE (*arg);
if (eti->minimum_width < eti->width)
e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti));
break;
case ARG_CURSOR_ROW:
gtk_object_get(GTK_OBJECT(eti->selection),
......@@ -1156,6 +1162,7 @@ eti_realize (GnomeCanvasItem *item)
eti_realize_cell_views (eti);
eti->needs_compute_height = 1;
eti->needs_compute_width = 1;
e_canvas_item_request_reflow (GNOME_CANVAS_ITEM (eti));
eti->needs_redraw = 1;
gnome_canvas_item_request_update (GNOME_CANVAS_ITEM (eti));
......@@ -1202,6 +1209,7 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
ArtPoint eti_base, eti_base_item, lower_right;
GtkWidget *canvas = GTK_WIDGET(item->canvas);
GdkColor *background;
int height_extra = eti->draw_grid ? 1 : 0;
/*
* Clear the background
......@@ -1257,10 +1265,10 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
*/
first_row = -1;
y_offset = 0;
y1 = y2 = floor (eti_base.y) + 1;
y1 = y2 = floor (eti_base.y) + height_extra;
for (row = 0; row < rows; row++, y1 = y2){
y2 += ETI_ROW_HEIGHT (eti, row) + 1;
y2 += ETI_ROW_HEIGHT (eti, row) + height_extra;
if (y1 > y + height)
break;
......@@ -1290,7 +1298,8 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
drawable, eti->grid_gc,
eti_base.x - x, yd, eti_base.x + eti->width - x, yd);
}
yd++;
yd += height_extra;
for (row = first_row; row < last_row; row++){
int xd, height;
......@@ -1393,11 +1402,13 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width,
}
yd += height;
if (eti->draw_grid)
if (eti->draw_grid) {
gdk_draw_line (
drawable, eti->grid_gc,
eti_base.x - x, yd, eti_base.x + eti->width - x, yd);
yd++;
yd++;
}
}
if (eti->draw_grid){
......@@ -1444,6 +1455,8 @@ find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, doub
const int rows = eti->rows;
gdouble x1, y1, x2, y2;
int col, row;
int height_extra = eti->draw_grid ? 1 : 0;
/* FIXME: this routine is inneficient, fix later */
......@@ -1479,7 +1492,7 @@ find_cell (ETableItem *eti, double x, double y, int *col_res, int *row_res, doub
if (y < y1)
return FALSE;
y2 += ETI_ROW_HEIGHT (eti, row) + 1;
y2 += ETI_ROW_HEIGHT (eti, row) + height_extra;
if (y <= y2)
break;
......@@ -1573,7 +1586,7 @@ _do_tooltip (ETableItem *eti)
eti->tooltip->x = x;
for (i = 0; i < eti->tooltip->row; i++)
y += (ETI_ROW_HEIGHT (eti, i) + 1);
y += (ETI_ROW_HEIGHT (eti, i) + height_extra);
eti->tooltip->y = y;
eti->tooltip->row_height = ETI_ROW_HEIGHT (eti, i);
......
......@@ -41,8 +41,8 @@ typedef struct {
int table_model_change_id;
int table_model_row_change_id;
int table_model_cell_change_id;
int table_model_row_inserted_id;
int table_model_row_deleted_id;
int table_model_rows_inserted_id;
int table_model_rows_deleted_id;
int selection_change_id;
int cursor_change_id;
......@@ -105,7 +105,7 @@ typedef struct {
void (*cursor_change) (ETableItem *eti, int row);
void (*cursor_activated) (ETableItem *eti, int row);
void (*double_click) (ETableItem *eti, int row);
void (*double_click) (ETableItem *eti, int row, int col, GdkEvent *event);
gint (*right_click) (ETableItem *eti, int row, int col, GdkEvent *event);
gint (*click) (ETableItem *eti, int row, int col, GdkEvent *event);
gint (*key_press) (ETableItem *eti, int row, int col, GdkEvent *event);
......
......@@ -28,8 +28,8 @@ enum {
MODEL_PRE_CHANGE,
MODEL_ROW_CHANGED,
MODEL_CELL_CHANGED,
MODEL_ROW_INSERTED,
MODEL_ROW_DELETED,
MODEL_ROWS_INSERTED,
MODEL_ROWS_DELETED,
ROW_SELECTION,
LAST_SIGNAL
};
......@@ -67,6 +67,23 @@ e_table_model_row_count (ETableModel *e_table_model)
return ETM_CLASS (e_table_model)->row_count (e_table_model);
}
/**
* e_table_model_append_row:
* @e_table_model: the table model to append the a row to.
* @source:
* @row:
*
*/
void
e_table_model_append_row (ETableModel *e_table_model, ETableModel *source, int row)
{
g_return_if_fail (e_table_model != NULL);
g_return_if_fail (E_IS_TABLE_MODEL (e_table_model));
if (ETM_CLASS (e_table_model)->append_row)
ETM_CLASS (e_table_model)->append_row (e_table_model, source, row);
}
/**
* e_table_value_at:
* @e_table_model: the e-table-model to operate on
......@@ -131,46 +148,6 @@ e_table_model_is_cell_editable (ETableModel *e_table_model, int col, int row)
return ETM_CLASS (e_table_model)->is_cell_editable (e_table_model, col, row);
}
/**
* e_table_model_append_row: