aboutsummaryrefslogtreecommitdiffstats
path: root/widgets/e-table
diff options
context:
space:
mode:
Diffstat (limited to 'widgets/e-table')
-rw-r--r--widgets/e-table/ChangeLog15
-rw-r--r--widgets/e-table/e-table-header-item.c42
-rw-r--r--widgets/e-table/e-table-header-item.h1
-rw-r--r--widgets/e-table/e-table-item.c68
-rw-r--r--widgets/e-table/e-table-item.h2
-rw-r--r--widgets/e-table/e-table.c15
6 files changed, 98 insertions, 45 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog
index 26f77cae2f..9b81185f1d 100644
--- a/widgets/e-table/ChangeLog
+++ b/widgets/e-table/ChangeLog
@@ -1,3 +1,18 @@
+2000-03-08 Christopher James Lahey <clahey@helixcode.com>
+
+ * e-table.c: Changed the destroy function to disconnect from
+ signals before unrefing the objects the sinnals are on. Changed
+ the destroy function to match the objects and signal ids properly
+ in its disconnect section.
+
+ * e-table-item.c, e-table-item.h: Changed this to do follow the
+ canvas rules better.
+
+ * e-table-header-item.c, e-table-header-item.h: Made
+ ETableHeaderItem connect to the "sort_info_changed" on its
+ ETableSortInfo instead of just manually redrawing itself. Fixed
+ the update function a bit to follow the canvas rules a bit better.
+
2000-03-06 Christopher James Lahey <clahey@helixcode.com>
* e-table-item.c: Made rows get unselected when switching from one
diff --git a/widgets/e-table/e-table-header-item.c b/widgets/e-table/e-table-header-item.c
index b8fe005753..e6001d24de 100644
--- a/widgets/e-table/e-table-header-item.c
+++ b/widgets/e-table/e-table-header-item.c
@@ -75,8 +75,12 @@ ethi_destroy (GtkObject *object){
ETableHeaderItem *ethi = E_TABLE_HEADER_ITEM (object);
ethi_drop_table_header (ethi);
- if ( ethi->sort_info )
+
+ if ( ethi->sort_info ) {
+ if ( ethi->sort_info_changed_id )
+ gtk_signal_disconnect(GTK_OBJECT(ethi->sort_info), ethi->sort_info_changed_id);
gtk_object_unref(GTK_OBJECT(ethi->sort_info));
+ }
if (GTK_OBJECT_CLASS (ethi_parent_class)->destroy)
(*GTK_OBJECT_CLASS (ethi_parent_class)->destroy) (object);
@@ -90,12 +94,20 @@ ethi_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags
if (GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update)
(*GNOME_CANVAS_ITEM_CLASS (ethi_parent_class)->update)(item, affine, clip_path, flags);
- item->x1 = ethi->x1;
- item->y1 = ethi->y1;
- item->x2 = ethi->x1 + ethi->width;
- item->y2 = ethi->y1 + ethi->height;
-
- gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
+ if ( item->x1 != ethi->x1 ||
+ item->y1 != ethi->y1 ||
+ item->x2 != ethi->x1 + ethi->width ||
+ item->y2 != ethi->y1 + ethi->height )
+ {
+ gnome_canvas_request_redraw(item->canvas, item->x1, item->y1, item->x2, item->y2);
+ item->x1 = ethi->x1;
+ item->y1 = ethi->y1;
+ item->x2 = ethi->x1 + ethi->width;
+ item->y2 = ethi->y1 + ethi->height;
+
+ gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
+ }
+ gnome_canvas_request_redraw(item->canvas, item->x1, item->y1, item->x2, item->y2);
}
static void
@@ -162,6 +174,12 @@ ethi_add_table_header (ETableHeaderItem *ethi, ETableHeader *header)
}
static void
+ethi_sort_info_changed (ETableSortInfo *sort_info, ETableHeaderItem *ethi)
+{
+ gnome_canvas_item_request_update (GNOME_CANVAS_ITEM(ethi));
+}
+
+static void
ethi_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
{
GnomeCanvasItem *item;
@@ -189,8 +207,15 @@ ethi_set_arg (GtkObject *o, GtkArg *arg, guint arg_id)
break;
case ARG_SORT_INFO:
+ if ( ethi->sort_info ) {
+ if ( ethi->sort_info_changed_id )
+ gtk_signal_disconnect(GTK_OBJECT(ethi->sort_info), ethi->sort_info_changed_id);
+ gtk_object_unref(GTK_OBJECT(ethi->sort_info));
+ }
ethi->sort_info = GTK_VALUE_POINTER (*arg);
gtk_object_ref(GTK_OBJECT(ethi->sort_info));
+ ethi->sort_info_changed_id = gtk_signal_connect(GTK_OBJECT(ethi->sort_info), "sort_info_changed",
+ GTK_SIGNAL_FUNC(ethi_sort_info_changed), ethi);
break;
}
@@ -934,7 +959,6 @@ ethi_event (GnomeCanvasItem *item, GdkEvent *e)
}
}
e_table_sort_info_changed(ethi->sort_info);
- ethi_request_redraw (ethi);
}
if (needs_ungrab)
gnome_canvas_item_ungrab (item, e->button.time);
@@ -1007,6 +1031,8 @@ ethi_init (GnomeCanvasItem *item)
ethi->sort_info = NULL;
+ ethi->sort_info_changed_id = 0;
+
ethi->group_indent_width = 0;
}
diff --git a/widgets/e-table/e-table-header-item.h b/widgets/e-table/e-table-header-item.h
index 32d87025d6..add488d2f7 100644
--- a/widgets/e-table/e-table-header-item.h
+++ b/widgets/e-table/e-table-header-item.h
@@ -48,6 +48,7 @@ typedef struct {
int click_x, click_y;
int drag_col, drag_mark;
guint drag_motion_id, drag_end_id, drag_leave_id, drag_drop_id;
+ guint sort_info_changed_id;
GnomeCanvasItem *drag_mark_item, *remove_item;
GdkBitmap *stipple;
diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c
index 1b2a4d884d..095a14ea90 100644
--- a/widgets/e-table/e-table-item.c
+++ b/widgets/e-table/e-table-item.c
@@ -134,22 +134,6 @@ eti_detach_cell_views (ETableItem *eti)
static void
eti_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y2)
{
- double i2c [6];
- ArtPoint c1, c2, i1, i2;
- ETableItem *eti = E_TABLE_ITEM (item);
-
- gnome_canvas_item_i2c_affine (item, i2c);
- i1.x = eti->x1;
- i1.y = eti->y1;
- i2.x = eti->x1 + eti->width;
- i2.y = eti->y1 + eti->height;
- art_affine_point (&c1, &i1, i2c);
- art_affine_point (&c2, &i2, i2c);
-
- item->x1 = c1.x;
- item->y1 = c1.y;
- item->x2 = c2.x;
- item->y2 = c2.y;
}
@@ -159,11 +143,39 @@ eti_bounds (GnomeCanvasItem *item, double *x1, double *y1, double *x2, double *y
static void
eti_update (GnomeCanvasItem *item, double *affine, ArtSVP *clip_path, int flags)
{
+ double i2c [6];
+ ArtPoint c1, c2, i1, i2;
+ ETableItem *eti = E_TABLE_ITEM (item);
+
if (GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)
(*GNOME_CANVAS_ITEM_CLASS (eti_parent_class)->update)(item, affine, clip_path, flags);
+
+ gnome_canvas_item_i2c_affine (item, i2c);
+
+ i1.x = eti->x1;
+ i1.y = eti->y1;
+ i2.x = eti->x1 + eti->width;
+ i2.y = eti->y1 + eti->height;
+ art_affine_point (&c1, &i1, i2c);
+ art_affine_point (&c2, &i2, i2c);
eti_bounds (item, &item->x1, &item->y1, &item->x2, &item->y2);
- gnome_canvas_group_child_bounds (GNOME_CANVAS_GROUP (item->parent), item);
+ if ( item->x1 != c1.x ||
+ item->y1 != c1.y ||
+ item->x2 != c2.x ||
+ item->y2 != c2.y )
+ {
+ gnome_canvas_request_redraw(item->canvas, item->x1, item->y1, item->x2, item->y2);
+ item->x1 = c1.x;
+ item->y1 = c1.y;
+ item->x2 = c2.x;
+ item->y2 = c2.y;
+ eti->needs_redraw = 1;
+ }
+ if ( eti->needs_redraw ) {
+ gnome_canvas_request_redraw(item->canvas, item->x1, item->y1, item->x2, item->y2);
+ eti->needs_redraw = 0;
+ }
}
/*
@@ -338,6 +350,8 @@ eti_table_model_changed (ETableModel *table_model, ETableItem *eti)
eti_item_region_redraw (eti, 0, 0, eti->width, eti->height);
}
+/* Unused. */
+#if 0
/*
* eti_request_redraw:
*
@@ -348,6 +362,7 @@ eti_request_redraw (ETableItem *eti)
{
eti_item_region_redraw (eti, eti->x1, eti->y1, eti->x1 + eti->width + 1, eti->y1 + eti->height + 1);
}
+#endif
/*
* Computes the distance between @start_row and @end_row in pixels
@@ -452,19 +467,13 @@ eti_add_table_model (ETableItem *eti, ETableModel *table_model)
static void
eti_header_dim_changed (ETableHeader *eth, int col, ETableItem *eti)
{
- eti_request_redraw (eti);
-
- eti->width = e_table_header_total_width (eti->header);
- eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
-
- eti_request_redraw (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_request_redraw (eti);
-
eti->cols = e_table_header_count (eti->header);
eti->width = e_table_header_total_width (eti->header);
@@ -484,10 +493,8 @@ eti_header_structure_changed (ETableHeader *eth, ETableItem *eti)
eti_attach_cell_views (eti);
}
}
-
- eti_update (GNOME_CANVAS_ITEM (eti), NULL, NULL, 0);
-
- eti_request_redraw (eti);
+ eti->needs_redraw = 1;
+ gnome_canvas_item_request_update(GNOME_CANVAS_ITEM(eti));
}
static void
@@ -601,6 +608,8 @@ eti_init (GnomeCanvasItem *item)
eti->renderers_can_change_size = 1;
eti->selection_mode = GTK_SELECTION_SINGLE;
+
+ eti->needs_redraw = 0;
}
#define gray50_width 2
@@ -1125,7 +1134,6 @@ eti_class_init (GtkObjectClass *object_class)
item_class->draw = eti_draw;
item_class->point = eti_point;
item_class->event = eti_event;
- item_class->bounds = eti_bounds;
eti_class->row_selection = eti_row_selection;
diff --git a/widgets/e-table/e-table-item.h b/widgets/e-table/e-table-item.h
index 635dc76922..d8f458a212 100644
--- a/widgets/e-table/e-table-item.h
+++ b/widgets/e-table/e-table-item.h
@@ -62,6 +62,8 @@ typedef struct {
*/
int editing_col, editing_row;
void *edit_ctx;
+
+ guint needs_redraw : 1;
} ETableItem;
typedef struct {
diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c
index d75937d5ed..36f7d5a776 100644
--- a/widgets/e-table/e-table.c
+++ b/widgets/e-table/e-table.c
@@ -49,12 +49,6 @@ et_destroy (GtkObject *object)
{
ETable *et = E_TABLE (object);
- gtk_object_unref (GTK_OBJECT (et->model));
- gtk_object_unref (GTK_OBJECT (et->full_header));
- gtk_object_unref (GTK_OBJECT (et->header));
- gtk_object_unref (GTK_OBJECT (et->sort_info));
- gtk_widget_destroy (GTK_WIDGET (et->header_canvas));
- gtk_widget_destroy (GTK_WIDGET (et->table_canvas));
gtk_signal_disconnect (GTK_OBJECT (et->model),
et->table_model_change_id);
@@ -63,9 +57,16 @@ et_destroy (GtkObject *object)
gtk_signal_disconnect (GTK_OBJECT (et->model),
et->table_cell_change_id);
if (et->sort_info_change_id)
- gtk_signal_disconnect (GTK_OBJECT (et->model),
+ gtk_signal_disconnect (GTK_OBJECT (et->sort_info),
et->sort_info_change_id);
+ gtk_object_unref (GTK_OBJECT (et->model));
+ gtk_object_unref (GTK_OBJECT (et->full_header));
+ gtk_object_unref (GTK_OBJECT (et->header));
+ gtk_object_unref (GTK_OBJECT (et->sort_info));
+ gtk_widget_destroy (GTK_WIDGET (et->header_canvas));
+ gtk_widget_destroy (GTK_WIDGET (et->table_canvas));
+
if (et->rebuild_idle_id) {
g_source_remove(et->rebuild_idle_id);
et->rebuild_idle_id = 0;