aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--widgets/e-table/ChangeLog10
-rw-r--r--widgets/e-table/e-table-group-container.c63
-rw-r--r--widgets/e-table/e-table-group-container.h5
-rw-r--r--widgets/e-table/e-table-group-leaf.c61
-rw-r--r--widgets/e-table/e-table-group-leaf.h6
-rw-r--r--widgets/e-table/e-table-header.c29
-rw-r--r--widgets/e-table/e-table.c65
-rw-r--r--widgets/e-table/e-table.h10
-rw-r--r--widgets/table/e-table-group-container.c63
-rw-r--r--widgets/table/e-table-group-container.h5
-rw-r--r--widgets/table/e-table-group-leaf.c61
-rw-r--r--widgets/table/e-table-group-leaf.h6
-rw-r--r--widgets/table/e-table-header.c29
-rw-r--r--widgets/table/e-table.c65
-rw-r--r--widgets/table/e-table.h10
15 files changed, 408 insertions, 80 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index 644d1d64f9..706a51cf35 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,3 +1,13 @@
+2000-05-26 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-table-group-container.c, e-table-group-container.h,
+ e-table-group-leaf.c, e-table-group-leaf.h, e-table.c, e-table.h:
+ Made "drawgrid", "drawfocus", "spreadsheet", and
+ "length_threshold" arguments set from the ETable effect all the
+ end ETableItems.
+
+ * e-table-header.c: Made column resize a bit less bumpy.
+
2000-05-25 Christopher James Lahey <clahey@helixcode.com>
* e-table-header.c: Account for extra pixel at right end of
diff --git a/widgets/e-table/e-table-group-container.c b/widgets/e-table/e-table-group-container.c
index e7771f86de..6c69d1765d 100644
--- a/widgets/e-table/e-table-group-container.c
+++ b/widgets/e-table/e-table-group-container.c
@@ -34,6 +34,10 @@ enum {
ARG_WIDTH,
ARG_MINIMUM_WIDTH,
ARG_FROZEN,
+ ARG_TABLE_DRAW_GRID,
+ ARG_TABLE_DRAW_FOCUS,
+ ARG_MODE_SPREADSHEET,
+ ARG_LENGTH_THRESHOLD,
};
typedef struct {
@@ -330,6 +334,12 @@ etgc_add (ETableGroup *etg, gint row)
NULL);
child = e_table_group_new (GNOME_CANVAS_GROUP (etgc), etg->full_header,
etg->header, etg->model, etgc->sort_info, etgc->n + 1);
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(child),
+ "drawgrid", etgc->draw_grid,
+ "drawfocus", etgc->draw_focus,
+ "spreadsheet", etgc->mode_spreadsheet,
+ "length_threshold", etgc->length_threshold,
+ NULL);
gtk_signal_connect (GTK_OBJECT (child), "row_selection",
GTK_SIGNAL_FUNC (child_row_selection), etgc);
child_node->child = child;
@@ -455,6 +465,45 @@ etgc_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
NULL);
}
break;
+ case ARG_LENGTH_THRESHOLD:
+ etgc->length_threshold = GTK_VALUE_INT (*arg);
+ for (list = etgc->children; list; list = g_list_next (list)) {
+ ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data;
+ gtk_object_set (GTK_OBJECT(child_node->child),
+ "length_threshold", GTK_VALUE_INT (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_TABLE_DRAW_GRID:
+ etgc->draw_grid = GTK_VALUE_BOOL (*arg);
+ for (list = etgc->children; list; list = g_list_next (list)) {
+ ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data;
+ gtk_object_set (GTK_OBJECT(child_node->child),
+ "draw_grid", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_TABLE_DRAW_FOCUS:
+ etgc->draw_focus = GTK_VALUE_BOOL (*arg);
+ for (list = etgc->children; list; list = g_list_next (list)) {
+ ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data;
+ gtk_object_set (GTK_OBJECT(child_node->child),
+ "draw_focus", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_MODE_SPREADSHEET:
+ etgc->mode_spreadsheet = GTK_VALUE_BOOL (*arg);
+ for (list = etgc->children; list; list = g_list_next (list)) {
+ ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data;
+ gtk_object_set (GTK_OBJECT(child_node->child),
+ "mode_spreadsheet", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
default:
break;
}
@@ -508,6 +557,15 @@ etgc_class_init (GtkObjectClass *object_class)
e_group_class->set_focus = etgc_set_focus;
e_group_class->get_focus_column = etgc_get_focus_column;
+ gtk_object_add_arg_type ("ETableGroupContainer::drawgrid", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID);
+ gtk_object_add_arg_type ("ETableGroupContainer::drawfocus", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS);
+ gtk_object_add_arg_type ("ETableGroupContainer::spreadsheet", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
+ gtk_object_add_arg_type ("ETableGroupContainer::length_threshold", GTK_TYPE_INT,
+ GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD);
+
gtk_object_add_arg_type ("ETableGroupContainer::frozen", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_FROZEN);
gtk_object_add_arg_type ("ETableGroupContainer::height", GTK_TYPE_DOUBLE,
@@ -606,6 +664,11 @@ etgc_init (GtkObject *object)
container->children = FALSE;
e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM(object), etgc_reflow);
+
+ container->draw_grid = 1;
+ container->draw_focus = 1;
+ container->mode_spreadsheet = 1;
+ container->length_threshold = -1;
}
E_MAKE_TYPE (e_table_group_container, "ETableGroupContainer", ETableGroupContainer, etgc_class_init, etgc_init, PARENT_TYPE);
diff --git a/widgets/e-table/e-table-group-container.h b/widgets/e-table/e-table-group-container.h
index 7577a3d70a..cfeeb7bbc9 100644
--- a/widgets/e-table/e-table-group-container.h
+++ b/widgets/e-table/e-table-group-container.h
@@ -38,6 +38,11 @@ typedef struct {
ETableSortInfo *sort_info;
int n;
+ int length_threshold;
+
+ guint draw_grid : 1;
+ guint draw_focus : 1;
+ guint mode_spreadsheet : 1;
/*
* State: the ETableGroup is open or closed
diff --git a/widgets/e-table/e-table-group-leaf.c b/widgets/e-table/e-table-group-leaf.c
index a6f6eac15a..4f7f462ee8 100644
--- a/widgets/e-table/e-table-group-leaf.c
+++ b/widgets/e-table/e-table-group-leaf.c
@@ -30,6 +30,10 @@ enum {
ARG_WIDTH,
ARG_MINIMUM_WIDTH,
ARG_FROZEN,
+ ARG_TABLE_DRAW_GRID,
+ ARG_TABLE_DRAW_FOCUS,
+ ARG_MODE_SPREADSHEET,
+ ARG_LENGTH_THRESHOLD,
};
static void etgl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
@@ -111,11 +115,11 @@ etgl_realize (GnomeCanvasItem *item)
e_table_item_get_type (),
"ETableHeader", E_TABLE_GROUP(etgl)->header,
"ETableModel", etgl->subset,
- "drawgrid", TRUE,
- "drawfocus", TRUE,
- "spreadsheet", TRUE,
+ "drawgrid", etgl->draw_grid,
+ "drawfocus", etgl->draw_focus,
+ "spreadsheet", etgl->mode_spreadsheet,
"minimum_width", etgl->minimum_width,
- "length_threshold", 200,
+ "length_threshold", etgl->length_threshold,
NULL));
gtk_signal_connect (GTK_OBJECT(etgl->item), "row_selection",
@@ -191,6 +195,41 @@ etgl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
NULL);
}
break;
+ case ARG_LENGTH_THRESHOLD:
+ etgl->length_threshold = GTK_VALUE_INT (*arg);
+ if (etgl->item) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etgl->item),
+ "length_threshold", GTK_VALUE_INT (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_TABLE_DRAW_GRID:
+ etgl->draw_grid = GTK_VALUE_BOOL (*arg);
+ if (etgl->item) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etgl->item),
+ "drawgrid", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_TABLE_DRAW_FOCUS:
+ etgl->draw_focus = GTK_VALUE_BOOL (*arg);
+ if (etgl->item) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etgl->item),
+ "drawfocus", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_MODE_SPREADSHEET:
+ etgl->mode_spreadsheet = GTK_VALUE_BOOL (*arg);
+ if (etgl->item) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etgl->item),
+ "spreadsheet", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
default:
break;
}
@@ -242,6 +281,15 @@ etgl_class_init (GtkObjectClass *object_class)
e_group_class->set_focus = etgl_set_focus;
e_group_class->get_focus_column = etgl_get_focus_column;
+ gtk_object_add_arg_type ("ETableGroupLeaf::drawgrid", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID);
+ gtk_object_add_arg_type ("ETableGroupLeaf::drawfocus", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS);
+ gtk_object_add_arg_type ("ETableGroupLeaf::spreadsheet", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
+ gtk_object_add_arg_type ("ETableGroupLeaf::length_threshold", GTK_TYPE_INT,
+ GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD);
+
gtk_object_add_arg_type ("ETableGroupLeaf::height", GTK_TYPE_DOUBLE,
GTK_ARG_READABLE, ARG_HEIGHT);
gtk_object_add_arg_type ("ETableGroupLeaf::width", GTK_TYPE_DOUBLE,
@@ -264,6 +312,11 @@ etgl_init (GtkObject *object)
etgl->subset = NULL;
etgl->item = NULL;
+ etgl->draw_grid = 1;
+ etgl->draw_focus = 1;
+ etgl->mode_spreadsheet = 1;
+ etgl->length_threshold = -1;
+
e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM(object), etgl_reflow);
}
diff --git a/widgets/e-table/e-table-group-leaf.h b/widgets/e-table/e-table-group-leaf.h
index bffeb798e0..3789e16402 100644
--- a/widgets/e-table/e-table-group-leaf.h
+++ b/widgets/e-table/e-table-group-leaf.h
@@ -26,6 +26,12 @@ typedef struct {
gdouble minimum_width;
ETableSubsetVariable *subset;
+
+ int length_threshold;
+
+ guint draw_grid : 1;
+ guint draw_focus : 1;
+ guint mode_spreadsheet : 1;
} ETableGroupLeaf;
typedef struct {
diff --git a/widgets/e-table/e-table-header.c b/widgets/e-table/e-table-header.c
index f1066f745c..383f7a9080 100644
--- a/widgets/e-table/e-table-header.c
+++ b/widgets/e-table/e-table-header.c
@@ -629,34 +629,31 @@ static void
eth_calc_widths (ETableHeader *eth)
{
int i;
- int extra, extra_left;
+ int extra;
double expansion;
- int last_resizeable = -1;
+ int last_position = 0;
+ double next_position = 0;
+ int last_resizable = -1;
/* - 1 to account for the last pixel border. */
extra = eth->width - 1;
expansion = 0;
for (i = 0; i < eth->col_count; i++) {
extra -= eth->columns[i]->min_width;
- if (eth->columns[i]->resizeable && eth->columns[i]->expansion != 0.0) {
- expansion += eth->columns[i]->expansion;
- last_resizeable = i;
- }
+ if (eth->columns[i]->resizeable && eth->columns[i]->expansion > 0)
+ last_resizable = i;
+ expansion += eth->columns[i]->resizeable ? eth->columns[i]->expansion : 0;
eth->columns[i]->width = eth->columns[i]->min_width;
}
if (eth->sort_info)
extra -= e_table_sort_info_grouping_get_count(eth->sort_info) * GROUP_INDENT;
- if (expansion == 0 || extra < 0)
+ if (expansion == 0 || extra <= 0)
return;
- extra_left = extra;
- for (i = 0; i < last_resizeable; i++) {
- if (eth->columns[i]->resizeable) {
- int this_extra = MIN(extra_left, extra * (eth->columns[i]->expansion / expansion));
- eth->columns[i]->width += this_extra;
- extra_left -= this_extra;
- }
+ for (i = 0; i < last_resizable; i++) {
+ next_position += extra * (eth->columns[i]->resizeable ? eth->columns[i]->expansion : 0)/expansion;
+ eth->columns[i]->width += next_position - last_position;
+ last_position = next_position;
}
- if (i >= 0 && i < eth->col_count && eth->columns[i]->resizeable)
- eth->columns[i]->width += extra_left;
+ eth->columns[i]->width += extra - last_position;
eth_update_offsets (eth);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c
index 225880705b..61f7f97918 100644
--- a/widgets/e-table/e-table.c
+++ b/widgets/e-table/e-table.c
@@ -46,7 +46,9 @@ enum {
enum {
ARG_0,
ARG_TABLE_DRAW_GRID,
- ARG_TABLE_DRAW_FOCUS
+ ARG_TABLE_DRAW_FOCUS,
+ ARG_MODE_SPREADSHEET,
+ ARG_LENGTH_THRESHOLD,
};
static gint et_signals [LAST_SIGNAL] = { 0, };
@@ -103,6 +105,7 @@ e_table_init (GtkObject *object)
e_table->draw_grid = 1;
e_table->draw_focus = 1;
e_table->spreadsheet = 1;
+ e_table->length_threshold = 200;
e_table->need_rebuild = 0;
e_table->rebuild_idle_id = 0;
@@ -198,6 +201,12 @@ changed_idle (gpointer data)
et->model,
et->sort_info,
0);
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(et->group),
+ "drawgrid", et->draw_grid,
+ "drawfocus", et->draw_focus,
+ "spreadsheet", et->spreadsheet,
+ "length_threshold", et->length_threshold,
+ NULL);
gtk_signal_connect (GTK_OBJECT (et->group), "row_selection",
GTK_SIGNAL_FUNC (group_row_selection), et);
e_table_fill_table (et, et->model);
@@ -271,6 +280,13 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h
full_header, header,
model, e_table->sort_info, 0);
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(e_table->group),
+ "drawgrid", e_table->draw_grid,
+ "drawfocus", e_table->draw_focus,
+ "spreadsheet", e_table->spreadsheet,
+ "length_threshold", e_table->length_threshold,
+ NULL);
+
gtk_signal_connect (GTK_OBJECT (e_table->group), "row_selection",
GTK_SIGNAL_FUNC(group_row_selection), e_table);
@@ -625,32 +641,45 @@ typedef struct {
} bool_closure;
static void
-leaf_bool_change (void *etgl, void *closure)
-{
- bool_closure *bc = closure;
-
- gtk_object_set (GTK_OBJECT (etgl), bc->arg, bc->setting, NULL);
-}
-
-static void
et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
ETable *etable = E_TABLE (o);
- bool_closure bc;
switch (arg_id){
+ case ARG_LENGTH_THRESHOLD:
+ etable->length_threshold = GTK_VALUE_INT (*arg);
+ if (etable->group) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etable->group),
+ "length_threshold", GTK_VALUE_INT (*arg),
+ NULL);
+ }
+ break;
+
case ARG_TABLE_DRAW_GRID:
etable->draw_grid = GTK_VALUE_BOOL (*arg);
- bc.arg = "drawgrid";
- bc.setting = etable->draw_grid;
- e_table_group_apply_to_leafs (etable->group, leaf_bool_change, &bc);
+ if (etable->group) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etable->group),
+ "drawgrid", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
break;
case ARG_TABLE_DRAW_FOCUS:
etable->draw_focus = GTK_VALUE_BOOL (*arg);
- bc.arg = "drawfocus";
- bc.setting = etable->draw_focus;
- e_table_group_apply_to_leafs (etable->group, leaf_bool_change, &bc);
+ if (etable->group) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etable->group),
+ "drawfocus", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_MODE_SPREADSHEET:
+ etable->spreadsheet = GTK_VALUE_BOOL (*arg);
+ if (etable->group) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etable->group),
+ "spreadsheet", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
break;
}
}
@@ -681,6 +710,10 @@ e_table_class_init (GtkObjectClass *object_class)
GTK_ARG_READWRITE, ARG_TABLE_DRAW_GRID);
gtk_object_add_arg_type ("ETable::drawfocus", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_TABLE_DRAW_FOCUS);
+ gtk_object_add_arg_type ("ETable::spreadsheet", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
+ gtk_object_add_arg_type ("ETable::length_threshold", GTK_TYPE_INT,
+ GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD);
}
diff --git a/widgets/e-table/e-table.h b/widgets/e-table/e-table.h
index ff03caf00d..053de782e5 100644
--- a/widgets/e-table/e-table.h
+++ b/widgets/e-table/e-table.h
@@ -41,15 +41,17 @@ typedef struct {
GnomeCanvasItem *header_item, *root;
- guint need_rebuild:1;
+ gint length_threshold;
+
gint rebuild_idle_id;
+ guint need_rebuild:1;
/*
* Configuration settings
*/
- guint draw_grid:1;
- guint draw_focus:1;
- guint spreadsheet:1;
+ guint draw_grid : 1;
+ guint draw_focus : 1;
+ guint spreadsheet : 1;
} ETable;
typedef struct {
diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c
index e7771f86de..6c69d1765d 100644
--- a/widgets/table/e-table-group-container.c
+++ b/widgets/table/e-table-group-container.c
@@ -34,6 +34,10 @@ enum {
ARG_WIDTH,
ARG_MINIMUM_WIDTH,
ARG_FROZEN,
+ ARG_TABLE_DRAW_GRID,
+ ARG_TABLE_DRAW_FOCUS,
+ ARG_MODE_SPREADSHEET,
+ ARG_LENGTH_THRESHOLD,
};
typedef struct {
@@ -330,6 +334,12 @@ etgc_add (ETableGroup *etg, gint row)
NULL);
child = e_table_group_new (GNOME_CANVAS_GROUP (etgc), etg->full_header,
etg->header, etg->model, etgc->sort_info, etgc->n + 1);
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(child),
+ "drawgrid", etgc->draw_grid,
+ "drawfocus", etgc->draw_focus,
+ "spreadsheet", etgc->mode_spreadsheet,
+ "length_threshold", etgc->length_threshold,
+ NULL);
gtk_signal_connect (GTK_OBJECT (child), "row_selection",
GTK_SIGNAL_FUNC (child_row_selection), etgc);
child_node->child = child;
@@ -455,6 +465,45 @@ etgc_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
NULL);
}
break;
+ case ARG_LENGTH_THRESHOLD:
+ etgc->length_threshold = GTK_VALUE_INT (*arg);
+ for (list = etgc->children; list; list = g_list_next (list)) {
+ ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data;
+ gtk_object_set (GTK_OBJECT(child_node->child),
+ "length_threshold", GTK_VALUE_INT (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_TABLE_DRAW_GRID:
+ etgc->draw_grid = GTK_VALUE_BOOL (*arg);
+ for (list = etgc->children; list; list = g_list_next (list)) {
+ ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data;
+ gtk_object_set (GTK_OBJECT(child_node->child),
+ "draw_grid", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_TABLE_DRAW_FOCUS:
+ etgc->draw_focus = GTK_VALUE_BOOL (*arg);
+ for (list = etgc->children; list; list = g_list_next (list)) {
+ ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data;
+ gtk_object_set (GTK_OBJECT(child_node->child),
+ "draw_focus", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_MODE_SPREADSHEET:
+ etgc->mode_spreadsheet = GTK_VALUE_BOOL (*arg);
+ for (list = etgc->children; list; list = g_list_next (list)) {
+ ETableGroupContainerChildNode *child_node = (ETableGroupContainerChildNode *)list->data;
+ gtk_object_set (GTK_OBJECT(child_node->child),
+ "mode_spreadsheet", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
default:
break;
}
@@ -508,6 +557,15 @@ etgc_class_init (GtkObjectClass *object_class)
e_group_class->set_focus = etgc_set_focus;
e_group_class->get_focus_column = etgc_get_focus_column;
+ gtk_object_add_arg_type ("ETableGroupContainer::drawgrid", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID);
+ gtk_object_add_arg_type ("ETableGroupContainer::drawfocus", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS);
+ gtk_object_add_arg_type ("ETableGroupContainer::spreadsheet", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
+ gtk_object_add_arg_type ("ETableGroupContainer::length_threshold", GTK_TYPE_INT,
+ GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD);
+
gtk_object_add_arg_type ("ETableGroupContainer::frozen", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_FROZEN);
gtk_object_add_arg_type ("ETableGroupContainer::height", GTK_TYPE_DOUBLE,
@@ -606,6 +664,11 @@ etgc_init (GtkObject *object)
container->children = FALSE;
e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM(object), etgc_reflow);
+
+ container->draw_grid = 1;
+ container->draw_focus = 1;
+ container->mode_spreadsheet = 1;
+ container->length_threshold = -1;
}
E_MAKE_TYPE (e_table_group_container, "ETableGroupContainer", ETableGroupContainer, etgc_class_init, etgc_init, PARENT_TYPE);
diff --git a/widgets/table/e-table-group-container.h b/widgets/table/e-table-group-container.h
index 7577a3d70a..cfeeb7bbc9 100644
--- a/widgets/table/e-table-group-container.h
+++ b/widgets/table/e-table-group-container.h
@@ -38,6 +38,11 @@ typedef struct {
ETableSortInfo *sort_info;
int n;
+ int length_threshold;
+
+ guint draw_grid : 1;
+ guint draw_focus : 1;
+ guint mode_spreadsheet : 1;
/*
* State: the ETableGroup is open or closed
diff --git a/widgets/table/e-table-group-leaf.c b/widgets/table/e-table-group-leaf.c
index a6f6eac15a..4f7f462ee8 100644
--- a/widgets/table/e-table-group-leaf.c
+++ b/widgets/table/e-table-group-leaf.c
@@ -30,6 +30,10 @@ enum {
ARG_WIDTH,
ARG_MINIMUM_WIDTH,
ARG_FROZEN,
+ ARG_TABLE_DRAW_GRID,
+ ARG_TABLE_DRAW_FOCUS,
+ ARG_MODE_SPREADSHEET,
+ ARG_LENGTH_THRESHOLD,
};
static void etgl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id);
@@ -111,11 +115,11 @@ etgl_realize (GnomeCanvasItem *item)
e_table_item_get_type (),
"ETableHeader", E_TABLE_GROUP(etgl)->header,
"ETableModel", etgl->subset,
- "drawgrid", TRUE,
- "drawfocus", TRUE,
- "spreadsheet", TRUE,
+ "drawgrid", etgl->draw_grid,
+ "drawfocus", etgl->draw_focus,
+ "spreadsheet", etgl->mode_spreadsheet,
"minimum_width", etgl->minimum_width,
- "length_threshold", 200,
+ "length_threshold", etgl->length_threshold,
NULL));
gtk_signal_connect (GTK_OBJECT(etgl->item), "row_selection",
@@ -191,6 +195,41 @@ etgl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id)
NULL);
}
break;
+ case ARG_LENGTH_THRESHOLD:
+ etgl->length_threshold = GTK_VALUE_INT (*arg);
+ if (etgl->item) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etgl->item),
+ "length_threshold", GTK_VALUE_INT (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_TABLE_DRAW_GRID:
+ etgl->draw_grid = GTK_VALUE_BOOL (*arg);
+ if (etgl->item) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etgl->item),
+ "drawgrid", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_TABLE_DRAW_FOCUS:
+ etgl->draw_focus = GTK_VALUE_BOOL (*arg);
+ if (etgl->item) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etgl->item),
+ "drawfocus", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_MODE_SPREADSHEET:
+ etgl->mode_spreadsheet = GTK_VALUE_BOOL (*arg);
+ if (etgl->item) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etgl->item),
+ "spreadsheet", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
default:
break;
}
@@ -242,6 +281,15 @@ etgl_class_init (GtkObjectClass *object_class)
e_group_class->set_focus = etgl_set_focus;
e_group_class->get_focus_column = etgl_get_focus_column;
+ gtk_object_add_arg_type ("ETableGroupLeaf::drawgrid", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID);
+ gtk_object_add_arg_type ("ETableGroupLeaf::drawfocus", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_TABLE_DRAW_FOCUS);
+ gtk_object_add_arg_type ("ETableGroupLeaf::spreadsheet", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
+ gtk_object_add_arg_type ("ETableGroupLeaf::length_threshold", GTK_TYPE_INT,
+ GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD);
+
gtk_object_add_arg_type ("ETableGroupLeaf::height", GTK_TYPE_DOUBLE,
GTK_ARG_READABLE, ARG_HEIGHT);
gtk_object_add_arg_type ("ETableGroupLeaf::width", GTK_TYPE_DOUBLE,
@@ -264,6 +312,11 @@ etgl_init (GtkObject *object)
etgl->subset = NULL;
etgl->item = NULL;
+ etgl->draw_grid = 1;
+ etgl->draw_focus = 1;
+ etgl->mode_spreadsheet = 1;
+ etgl->length_threshold = -1;
+
e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM(object), etgl_reflow);
}
diff --git a/widgets/table/e-table-group-leaf.h b/widgets/table/e-table-group-leaf.h
index bffeb798e0..3789e16402 100644
--- a/widgets/table/e-table-group-leaf.h
+++ b/widgets/table/e-table-group-leaf.h
@@ -26,6 +26,12 @@ typedef struct {
gdouble minimum_width;
ETableSubsetVariable *subset;
+
+ int length_threshold;
+
+ guint draw_grid : 1;
+ guint draw_focus : 1;
+ guint mode_spreadsheet : 1;
} ETableGroupLeaf;
typedef struct {
diff --git a/widgets/table/e-table-header.c b/widgets/table/e-table-header.c
index f1066f745c..383f7a9080 100644
--- a/widgets/table/e-table-header.c
+++ b/widgets/table/e-table-header.c
@@ -629,34 +629,31 @@ static void
eth_calc_widths (ETableHeader *eth)
{
int i;
- int extra, extra_left;
+ int extra;
double expansion;
- int last_resizeable = -1;
+ int last_position = 0;
+ double next_position = 0;
+ int last_resizable = -1;
/* - 1 to account for the last pixel border. */
extra = eth->width - 1;
expansion = 0;
for (i = 0; i < eth->col_count; i++) {
extra -= eth->columns[i]->min_width;
- if (eth->columns[i]->resizeable && eth->columns[i]->expansion != 0.0) {
- expansion += eth->columns[i]->expansion;
- last_resizeable = i;
- }
+ if (eth->columns[i]->resizeable && eth->columns[i]->expansion > 0)
+ last_resizable = i;
+ expansion += eth->columns[i]->resizeable ? eth->columns[i]->expansion : 0;
eth->columns[i]->width = eth->columns[i]->min_width;
}
if (eth->sort_info)
extra -= e_table_sort_info_grouping_get_count(eth->sort_info) * GROUP_INDENT;
- if (expansion == 0 || extra < 0)
+ if (expansion == 0 || extra <= 0)
return;
- extra_left = extra;
- for (i = 0; i < last_resizeable; i++) {
- if (eth->columns[i]->resizeable) {
- int this_extra = MIN(extra_left, extra * (eth->columns[i]->expansion / expansion));
- eth->columns[i]->width += this_extra;
- extra_left -= this_extra;
- }
+ for (i = 0; i < last_resizable; i++) {
+ next_position += extra * (eth->columns[i]->resizeable ? eth->columns[i]->expansion : 0)/expansion;
+ eth->columns[i]->width += next_position - last_position;
+ last_position = next_position;
}
- if (i >= 0 && i < eth->col_count && eth->columns[i]->resizeable)
- eth->columns[i]->width += extra_left;
+ eth->columns[i]->width += extra - last_position;
eth_update_offsets (eth);
gtk_signal_emit (GTK_OBJECT (eth), eth_signals [DIMENSION_CHANGE]);
diff --git a/widgets/table/e-table.c b/widgets/table/e-table.c
index 225880705b..61f7f97918 100644
--- a/widgets/table/e-table.c
+++ b/widgets/table/e-table.c
@@ -46,7 +46,9 @@ enum {
enum {
ARG_0,
ARG_TABLE_DRAW_GRID,
- ARG_TABLE_DRAW_FOCUS
+ ARG_TABLE_DRAW_FOCUS,
+ ARG_MODE_SPREADSHEET,
+ ARG_LENGTH_THRESHOLD,
};
static gint et_signals [LAST_SIGNAL] = { 0, };
@@ -103,6 +105,7 @@ e_table_init (GtkObject *object)
e_table->draw_grid = 1;
e_table->draw_focus = 1;
e_table->spreadsheet = 1;
+ e_table->length_threshold = 200;
e_table->need_rebuild = 0;
e_table->rebuild_idle_id = 0;
@@ -198,6 +201,12 @@ changed_idle (gpointer data)
et->model,
et->sort_info,
0);
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(et->group),
+ "drawgrid", et->draw_grid,
+ "drawfocus", et->draw_focus,
+ "spreadsheet", et->spreadsheet,
+ "length_threshold", et->length_threshold,
+ NULL);
gtk_signal_connect (GTK_OBJECT (et->group), "row_selection",
GTK_SIGNAL_FUNC (group_row_selection), et);
e_table_fill_table (et, et->model);
@@ -271,6 +280,13 @@ e_table_setup_table (ETable *e_table, ETableHeader *full_header, ETableHeader *h
full_header, header,
model, e_table->sort_info, 0);
+ gnome_canvas_item_set(GNOME_CANVAS_ITEM(e_table->group),
+ "drawgrid", e_table->draw_grid,
+ "drawfocus", e_table->draw_focus,
+ "spreadsheet", e_table->spreadsheet,
+ "length_threshold", e_table->length_threshold,
+ NULL);
+
gtk_signal_connect (GTK_OBJECT (e_table->group), "row_selection",
GTK_SIGNAL_FUNC(group_row_selection), e_table);
@@ -625,32 +641,45 @@ typedef struct {
} bool_closure;
static void
-leaf_bool_change (void *etgl, void *closure)
-{
- bool_closure *bc = closure;
-
- gtk_object_set (GTK_OBJECT (etgl), bc->arg, bc->setting, NULL);
-}
-
-static void
et_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
ETable *etable = E_TABLE (o);
- bool_closure bc;
switch (arg_id){
+ case ARG_LENGTH_THRESHOLD:
+ etable->length_threshold = GTK_VALUE_INT (*arg);
+ if (etable->group) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etable->group),
+ "length_threshold", GTK_VALUE_INT (*arg),
+ NULL);
+ }
+ break;
+
case ARG_TABLE_DRAW_GRID:
etable->draw_grid = GTK_VALUE_BOOL (*arg);
- bc.arg = "drawgrid";
- bc.setting = etable->draw_grid;
- e_table_group_apply_to_leafs (etable->group, leaf_bool_change, &bc);
+ if (etable->group) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etable->group),
+ "drawgrid", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
break;
case ARG_TABLE_DRAW_FOCUS:
etable->draw_focus = GTK_VALUE_BOOL (*arg);
- bc.arg = "drawfocus";
- bc.setting = etable->draw_focus;
- e_table_group_apply_to_leafs (etable->group, leaf_bool_change, &bc);
+ if (etable->group) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etable->group),
+ "drawfocus", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
+ break;
+
+ case ARG_MODE_SPREADSHEET:
+ etable->spreadsheet = GTK_VALUE_BOOL (*arg);
+ if (etable->group) {
+ gnome_canvas_item_set (GNOME_CANVAS_ITEM(etable->group),
+ "spreadsheet", GTK_VALUE_BOOL (*arg),
+ NULL);
+ }
break;
}
}
@@ -681,6 +710,10 @@ e_table_class_init (GtkObjectClass *object_class)
GTK_ARG_READWRITE, ARG_TABLE_DRAW_GRID);
gtk_object_add_arg_type ("ETable::drawfocus", GTK_TYPE_BOOL,
GTK_ARG_READWRITE, ARG_TABLE_DRAW_FOCUS);
+ gtk_object_add_arg_type ("ETable::spreadsheet", GTK_TYPE_BOOL,
+ GTK_ARG_WRITABLE, ARG_MODE_SPREADSHEET);
+ gtk_object_add_arg_type ("ETable::length_threshold", GTK_TYPE_INT,
+ GTK_ARG_WRITABLE, ARG_LENGTH_THRESHOLD);
}
diff --git a/widgets/table/e-table.h b/widgets/table/e-table.h
index ff03caf00d..053de782e5 100644
--- a/widgets/table/e-table.h
+++ b/widgets/table/e-table.h
@@ -41,15 +41,17 @@ typedef struct {
GnomeCanvasItem *header_item, *root;
- guint need_rebuild:1;
+ gint length_threshold;
+
gint rebuild_idle_id;
+ guint need_rebuild:1;
/*
* Configuration settings
*/
- guint draw_grid:1;
- guint draw_focus:1;
- guint spreadsheet:1;
+ guint draw_grid : 1;
+ guint draw_focus : 1;
+ guint spreadsheet : 1;
} ETable;
typedef struct {