diff options
Diffstat (limited to 'widgets/e-table')
-rw-r--r-- | widgets/e-table/ChangeLog | 23 | ||||
-rw-r--r-- | widgets/e-table/Makefile.am | 16 | ||||
-rw-r--r-- | widgets/e-table/e-cell-text.c | 31 | ||||
-rw-r--r-- | widgets/e-table/e-cell.c | 26 | ||||
-rw-r--r-- | widgets/e-table/e-cell.h | 42 | ||||
-rw-r--r-- | widgets/e-table/e-table-field-chooser.glade | 2 | ||||
-rw-r--r-- | widgets/e-table/e-table-group-container.c | 2 | ||||
-rw-r--r-- | widgets/e-table/e-table-group-leaf.c | 8 | ||||
-rw-r--r-- | widgets/e-table/e-table-group.c | 13 | ||||
-rw-r--r-- | widgets/e-table/e-table-group.h | 44 | ||||
-rw-r--r-- | widgets/e-table/e-table-item.c | 255 | ||||
-rw-r--r-- | widgets/e-table/e-table-item.h | 6 | ||||
-rw-r--r-- | widgets/e-table/e-table.c | 6 | ||||
-rw-r--r-- | widgets/e-table/e-table.h | 45 |
14 files changed, 454 insertions, 65 deletions
diff --git a/widgets/e-table/ChangeLog b/widgets/e-table/ChangeLog index 5f6000a4eb..5a6ded8c04 100644 --- a/widgets/e-table/ChangeLog +++ b/widgets/e-table/ChangeLog @@ -1,3 +1,26 @@ +2000-06-10 Christopher James Lahey <clahey@helixcode.com> + + * Makefile.am: Added $(GNOME_PRINT_LIBS) to all of the LDADDs. + + * e-cell-text.c: Added printing of text cells. + + * e-cell.c, e-cell.h: Added print and print_height methods. + + * e-table-field-chooser.glade: Added a minimum size. + + * e-table-group-container.c: Fixed a rectangle sizing bug. + + * e-table-group-leaf.c: Implemented get_printable. + + * e-table-group.c, e-table-group.h: Added a get_printable method + to return an EPrintable. + + * e-table-item.c, e-table-item.h: Added a get_printable function + to return an EPrintable. + + * e-table.c, e-table.h: Added a get_printable function to return + an EPrintable. + 2000-06-08 Chris Toshok <toshok@helixcode.com> * e-tree-gnode.c, e-tree-gnode.h: New files. A tree model using a diff --git a/widgets/e-table/Makefile.am b/widgets/e-table/Makefile.am index 8048435753..5f7af50a9a 100644 --- a/widgets/e-table/Makefile.am +++ b/widgets/e-table/Makefile.am @@ -12,6 +12,7 @@ glade_headers = \ INCLUDES = \ $(EXTRA_GNOME_CFLAGS) \ + $(GNOME_PRINT_CFLAGS) \ $(GNOME_INCLUDEDIR) \ -DETABLE_GLADEDIR=\"$(gladedir)\" \ -I$(top_srcdir)/widgets/e-text \ @@ -94,7 +95,8 @@ table_test_LDADD = \ libetable.a \ $(EXTRA_GNOME_LIBS) \ $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/e-util/libeutil.la + $(top_builddir)/e-util/libeutil.la \ + $(GNOME_PRINT_LIBS) table_test_LDFLAGS = `gnome-config --libs gdk_pixbuf` @@ -105,7 +107,8 @@ table_size_test_LDADD = \ libetable.a \ $(EXTRA_GNOME_LIBS) \ $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/e-util/libeutil.la + $(top_builddir)/e-util/libeutil.la \ + $(GNOME_PRINT_LIBS) table_size_test_LDFLAGS = `gnome-config --libs gdk_pixbuf` @@ -116,7 +119,8 @@ table_example_1_LDADD = \ libetable.a \ $(EXTRA_GNOME_LIBS) \ $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/e-util/libeutil.la + $(top_builddir)/e-util/libeutil.la \ + $(GNOME_PRINT_LIBS) table_example_1_LDFLAGS = `gnome-config --libs gdk_pixbuf` @@ -127,7 +131,8 @@ table_example_2_LDADD = \ libetable.a \ $(EXTRA_GNOME_LIBS) \ $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/e-util/libeutil.la + $(top_builddir)/e-util/libeutil.la \ + $(GNOME_PRINT_LIBS) table_example_2_LDFLAGS = `gnome-config --libs gdk_pixbuf` @@ -140,7 +145,8 @@ tree_example_1_LDADD = \ libetable.a \ $(EXTRA_GNOME_LIBS) \ $(top_builddir)/widgets/e-text/libetext.a \ - $(top_builddir)/e-util/libeutil.la + $(top_builddir)/e-util/libeutil.la \ + $(GNOME_PRINT_LIBS) icons = \ arrow-down.xpm \ diff --git a/widgets/e-table/e-cell-text.c b/widgets/e-table/e-cell-text.c index a3a7acf35b..9495ce86a9 100644 --- a/widgets/e-table/e-cell-text.c +++ b/widgets/e-table/e-cell-text.c @@ -1154,6 +1154,35 @@ ect_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, voi } } +static void +ect_print (ECellView *ecell_view, GnomePrintContext *context, + int model_col, int view_col, int row, + double width, double height) +{ + GnomeFont *font = gnome_font_new("Helvetica", 12); + char *string; + ECellText *ect = E_CELL_TEXT(ecell_view->ecell); + if (ect->filter) { + string = (*ect->filter)(e_table_model_value_at (ecell_view->e_table_model, model_col, row)); + } else { + string = e_table_model_value_at (ecell_view->e_table_model, model_col, row); + } + gnome_print_moveto(context, 0, (height - gnome_font_get_ascender(font) + gnome_font_get_descender(font)) / 2); + gnome_print_setfont(context, font); + gnome_print_show(context, string); + if (ect->filter) { + g_free(string); + } +} + +static gdouble +ect_print_height (ECellView *ecell_view, GnomePrintContext *context, + int model_col, int view_col, int row, + double width) +{ + return 12; +} + /* * GtkObject::destroy method */ @@ -1233,6 +1262,8 @@ e_cell_text_class_init (GtkObjectClass *object_class) ecc->height = ect_height; ecc->enter_edit = ect_enter_edit; ecc->leave_edit = ect_leave_edit; + ecc->print = ect_print; + ecc->print_height = ect_print_height; object_class->get_arg = ect_get_arg; object_class->set_arg = ect_set_arg; diff --git a/widgets/e-table/e-cell.c b/widgets/e-table/e-cell.c index b472b6f6ff..75be2ce916 100644 --- a/widgets/e-table/e-cell.c +++ b/widgets/e-table/e-cell.c @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * e-cell.c: base class for cell renderers in e-table * @@ -104,6 +105,8 @@ e_cell_class_init (GtkObjectClass *object_class) ecc->height = ec_height; ecc->enter_edit = ec_enter_edit; ecc->leave_edit = ec_leave_edit; + ecc->print = NULL; + ecc->print_height = NULL; } static void @@ -145,7 +148,7 @@ e_cell_unrealize (ECellView *ecell_view) { E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->unrealize (ecell_view); } - + void e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable, int model_col, int view_col, int row, gboolean selected, int x1, int y1, int x2, int y2) @@ -154,6 +157,27 @@ e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable, ecell_view, drawable, model_col, view_col, row, selected, x1, y1, x2, y2); } +void +e_cell_print (ECellView *ecell_view, GnomePrintContext *context, + int model_col, int view_col, int row, + double width, double height) +{ + E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->print + (ecell_view, context, model_col, view_col, row, width, height); +} + +gdouble +e_cell_print_height (ECellView *ecell_view, GnomePrintContext *context, + int model_col, int view_col, int row, + double width) +{ + if (E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->print_height) + return E_CELL_CLASS (GTK_OBJECT (ecell_view->ecell)->klass)->print_height + (ecell_view, context, model_col, view_col, row, width); + else + return 0.0; +} + int e_cell_height (ECellView *ecell_view, int model_col, int view_col, int row) { diff --git a/widgets/e-table/e-cell.h b/widgets/e-table/e-cell.h index 8804d2066f..40b257f264 100644 --- a/widgets/e-table/e-cell.h +++ b/widgets/e-table/e-cell.h @@ -1,3 +1,4 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ #ifndef _E_CELL_H_ #define _E_CELL_H_ @@ -32,23 +33,28 @@ struct _ECellView { typedef struct { GtkObjectClass parent_class; - ECellView *(*new_view) (ECell *ecell, ETableModel *table_model, void *e_table_item_view); - void (*kill_view) (ECellView *ecell_view); - - void (*realize) (ECellView *ecell_view); - void (*unrealize) (ECellView *ecell_view); - - void (*draw) (ECellView *ecell_view, GdkDrawable *drawable, - int model_col, int view_col, int row, - gboolean selected, int x1, int y1, int x2, int y2); - gint (*event) (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row); - void (*focus) (ECellView *ecell_view, int model_col, int view_col, - int row, int x1, int y1, int x2, int y2); - void (*unfocus) (ECellView *ecell_view); - int (*height) (ECellView *ecell_view, int model_col, int view_col, int row); - - void *(*enter_edit)(ECellView *ecell_view, int model_col, int view_col, int row); - void (*leave_edit)(ECellView *ecell_view, int model_col, int view_col, int row, void *context); + ECellView *(*new_view) (ECell *ecell, ETableModel *table_model, void *e_table_item_view); + void (*kill_view) (ECellView *ecell_view); + + void (*realize) (ECellView *ecell_view); + void (*unrealize) (ECellView *ecell_view); + + void (*draw) (ECellView *ecell_view, GdkDrawable *drawable, + int model_col, int view_col, int row, + gboolean selected, int x1, int y1, int x2, int y2); + gint (*event) (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, int row); + void (*focus) (ECellView *ecell_view, int model_col, int view_col, + int row, int x1, int y1, int x2, int y2); + void (*unfocus) (ECellView *ecell_view); + int (*height) (ECellView *ecell_view, int model_col, int view_col, int row); + + void *(*enter_edit) (ECellView *ecell_view, int model_col, int view_col, int row); + void (*leave_edit) (ECellView *ecell_view, int model_col, int view_col, int row, void *context); + void (*print) (ECellView *ecell_view, GnomePrintContext *context, + int model_col, int view_col, int row, + gdouble width, gdouble height); + gdouble (*print_height) (ECellView *ecell_view, GnomePrintContext *context, + int model_col, int view_col, int row, gdouble width); } ECellClass; GtkType e_cell_get_type (void); @@ -66,6 +72,8 @@ void e_cell_draw (ECellView *ecell_view, GdkDrawable *dr, void e_cell_print (ECellView *ecell_view, GnomePrintContext *context, int model_col, int view_col, int row, double width, double height); +gdouble e_cell_print_height (ECellView *ecell_view, GnomePrintContext *context, + int model_col, int view_col, int row, gdouble width); void e_cell_focus (ECellView *ecell_view, int model_col, int view_col, int row, int x1, int y1, int x2, int y2); void e_cell_unfocus (ECellView *ecell_view); diff --git a/widgets/e-table/e-table-field-chooser.glade b/widgets/e-table/e-table-field-chooser.glade index 40997e7a68..e09b3a9f3a 100644 --- a/widgets/e-table/e-table-field-chooser.glade +++ b/widgets/e-table/e-table-field-chooser.glade @@ -85,6 +85,8 @@ <widget> <class>GtkScrolledWindow</class> <name>scrolledwindow1</name> + <width>200</width> + <height>200</height> <hscrollbar_policy>GTK_POLICY_AUTOMATIC</hscrollbar_policy> <vscrollbar_policy>GTK_POLICY_AUTOMATIC</vscrollbar_policy> <hupdate_policy>GTK_UPDATE_CONTINUOUS</hupdate_policy> diff --git a/widgets/e-table/e-table-group-container.c b/widgets/e-table/e-table-group-container.c index a2e9575bcb..25c7fb2132 100644 --- a/widgets/e-table/e-table-group-container.c +++ b/widgets/e-table/e-table-group-container.c @@ -754,7 +754,7 @@ etgc_reflow (GnomeCanvasItem *item, gint flags) gnome_canvas_item_set (GNOME_CANVAS_ITEM(child_node->rect), "x1", (double) 0, - "x2", (double) running_width, + "x2", (double) running_width + GROUP_INDENT, "y1", (double) running_height - extra_height, "y2", (double) running_height + item_height, NULL); diff --git a/widgets/e-table/e-table-group-leaf.c b/widgets/e-table/e-table-group-leaf.c index 25819bb188..0845f93695 100644 --- a/widgets/e-table/e-table-group-leaf.c +++ b/widgets/e-table/e-table-group-leaf.c @@ -245,6 +245,13 @@ etgl_get_focus_column (ETableGroup *etg) return e_table_item_get_focused_column (etgl->item); } +static EPrintable * +etgl_get_printable (ETableGroup *etg) +{ + ETableGroupLeaf *etgl = E_TABLE_GROUP_LEAF (etg); + return e_table_item_get_printable (etgl->item); +} + static void etgl_set_arg (GtkObject *object, GtkArg *arg, guint arg_id) { @@ -356,6 +363,7 @@ etgl_class_init (GtkObjectClass *object_class) e_group_class->unfocus = etgl_unfocus; e_group_class->get_selected_view_row = etgl_get_selected_view_row; e_group_class->get_focus_column = etgl_get_focus_column; + e_group_class->get_printable = etgl_get_printable; gtk_object_add_arg_type ("ETableGroupLeaf::drawgrid", GTK_TYPE_BOOL, GTK_ARG_WRITABLE, ARG_TABLE_DRAW_GRID); diff --git a/widgets/e-table/e-table-group.c b/widgets/e-table/e-table-group.c index 987636ed6b..571280e46f 100644 --- a/widgets/e-table/e-table-group.c +++ b/widgets/e-table/e-table-group.c @@ -240,6 +240,18 @@ e_table_group_get_ecol (ETableGroup *etg) return NULL; } +EPrintable * +e_table_group_get_printable (ETableGroup *etg) +{ + g_return_val_if_fail (etg != NULL, NULL); + g_return_val_if_fail (E_IS_TABLE_GROUP (etg), NULL); + + if (ETG_CLASS (etg)->get_printable) + return ETG_CLASS (etg)->get_printable (etg); + else + return NULL; +} + void e_table_group_row_selection (ETableGroup *e_table_group, gint row, gboolean selected) { @@ -369,6 +381,7 @@ etg_class_init (GtkObjectClass *object_class) klass->unfocus = NULL; klass->get_focus = etg_get_focus; klass->get_ecol = NULL; + klass->get_printable = NULL; etg_parent_class = gtk_type_class (PARENT_TYPE); diff --git a/widgets/e-table/e-table-group.h b/widgets/e-table/e-table-group.h index 8f9e047959..6505759ce7 100644 --- a/widgets/e-table/e-table-group.h +++ b/widgets/e-table/e-table-group.h @@ -7,6 +7,7 @@ #include "e-table-header.h" #include "e-table-sort-info.h" #include "e-util/e-util.h" +#include "e-util/e-printable.h" #define E_TABLE_GROUP_TYPE (e_table_group_get_type ()) #define E_TABLE_GROUP(o) (GTK_CHECK_CAST ((o), E_TABLE_GROUP_TYPE, ETableGroup)) @@ -63,30 +64,33 @@ typedef struct { gboolean (*get_focus) (ETableGroup *etg); gint (*get_focus_column) (ETableGroup *etg); ETableCol *(*get_ecol) (ETableGroup *etg); + EPrintable *(*get_printable) (ETableGroup *etg); } ETableGroupClass; -void e_table_group_add (ETableGroup *etg, - gint row); -void e_table_group_add_all (ETableGroup *etg); -gboolean e_table_group_remove (ETableGroup *etg, - gint row); -gint e_table_group_get_count (ETableGroup *etg); -void e_table_group_increment (ETableGroup *etg, - gint position, - gint amount); -gint e_table_group_row_count (ETableGroup *etg); -void e_table_group_set_focus (ETableGroup *etg, - EFocus direction, - gint view_col); -void e_table_group_select_row (ETableGroup *etg, - gint row); +/* Virtual functions */ +void e_table_group_add (ETableGroup *etg, + gint row); +void e_table_group_add_all (ETableGroup *etg); +gboolean e_table_group_remove (ETableGroup *etg, + gint row); +gint e_table_group_get_count (ETableGroup *etg); +void e_table_group_increment (ETableGroup *etg, + gint position, + gint amount); +gint e_table_group_row_count (ETableGroup *etg); +void e_table_group_set_focus (ETableGroup *etg, + EFocus direction, + gint view_col); +void e_table_group_select_row (ETableGroup *etg, + gint row); int e_table_group_get_selected_view_row (ETableGroup *etg); -void e_table_group_unfocus (ETableGroup *etg); -gboolean e_table_group_get_focus (ETableGroup *etg); -gint e_table_group_get_focus_column (ETableGroup *etg); -ETableHeader *e_table_group_get_header (ETableGroup *etg); -ETableCol *e_table_group_get_ecol (ETableGroup *etg); +void e_table_group_unfocus (ETableGroup *etg); +gboolean e_table_group_get_focus (ETableGroup *etg); +gint e_table_group_get_focus_column (ETableGroup *etg); +ETableHeader *e_table_group_get_header (ETableGroup *etg); +ETableCol *e_table_group_get_ecol (ETableGroup *etg); +EPrintable *e_table_group_get_printable (ETableGroup *etg); ETableGroup *e_table_group_new (GnomeCanvasGroup *parent, ETableHeader *full_header, diff --git a/widgets/e-table/e-table-item.c b/widgets/e-table/e-table-item.c index e494e5ed2b..3a4d98bf91 100644 --- a/widgets/e-table/e-table-item.c +++ b/widgets/e-table/e-table-item.c @@ -1714,3 +1714,258 @@ e_table_item_leave_edit (ETableItem *eti) eti->edit_ctx = NULL; } +typedef struct { + ETableItem *item; + int rows_printed; +} ETableItemPrintContext; + +static gdouble * +e_table_item_calculate_print_widths (ETableHeader *eth, gdouble width) +{ + int i; + double extra; + double expansion; + int last_resizable = -1; + gdouble scale = 300.0L / 70.0L; + gdouble *widths = g_new(gdouble, e_table_header_count(eth)); + /* - 1 to account for the last pixel border. */ + extra = width - 1; + expansion = 0; + for (i = 0; i < eth->col_count; i++) { + extra -= eth->columns[i]->min_width * scale; + if (eth->columns[i]->resizeable && eth->columns[i]->expansion > 0) + last_resizable = i; + expansion += eth->columns[i]->resizeable ? eth->columns[i]->expansion : 0; + widths[i] = eth->columns[i]->min_width * scale; + } + for (i = 0; i <= last_resizable; i++) { + widths[i] += extra * (eth->columns[i]->resizeable ? eth->columns[i]->expansion : 0)/expansion; + } + + return widths; +} + +static gdouble +eti_printed_row_height (ETableItem *item, gdouble *widths, GnomePrintContext *context, gint row) +{ + int col; + int cols = item->cols; + gdouble height = 0; + for (col = 0; col < cols; col++) { + ETableCol *ecol = e_table_header_get_column (item->header, col); + ECellView *ecell_view = item->cell_views [col]; + gdouble this_height = e_cell_print_height (ecell_view, context, ecol->col_idx, col, row, + widths[col] - 1); + if (this_height > height) + height = this_height; + } + return height; +} + +#define CHECK(x) if((x) == -1) return -1; + +static gint +gp_draw_rect (GnomePrintContext *context, gdouble x, gdouble y, gdouble width, gdouble height) +{ + CHECK(gnome_print_moveto(context, x, y)); + CHECK(gnome_print_lineto(context, x + width, y)); + CHECK(gnome_print_lineto(context, x + width, y - height)); + CHECK(gnome_print_lineto(context, x, y - height)); + CHECK(gnome_print_lineto(context, x, y)); + return gnome_print_fill(context); +} + +static void +e_table_item_print_page (EPrintable *ep, + GnomePrintContext *context, + gdouble width, + gdouble height, + gboolean quantize, + ETableItemPrintContext *itemcontext) +{ + ETableItem *item = itemcontext->item; + const int rows = item->rows; + const int cols = item->cols; + int rows_printed = itemcontext->rows_printed; + gdouble *widths; + int row, col; + gdouble yd = height; + + widths = e_table_item_calculate_print_widths (itemcontext->item->header, width); + + /* + * Draw cells + */ + if (item->draw_grid){ + gp_draw_rect(context, 0, yd, width, 1); + } + yd--; + + for (row = rows_printed; row < rows; row++){ + gdouble xd = 0, row_height; + + row_height = eti_printed_row_height(item, widths, context, row); + if (quantize) { + if (yd - row_height - 1 < 0 && row != rows_printed) { + break; + } + } else { + if (yd < 0) { + break; + } + } + + for (col = 0; col < cols; col++){ + ETableCol *ecol = e_table_header_get_column (item->header, col); + ECellView *ecell_view = item->cell_views [col]; + + if (gnome_print_gsave(context) == -1) + /* FIXME */; + if (gnome_print_translate(context, xd, yd - row_height) == -1) + /* FIXME */; + + if (gnome_print_moveto(context, 0, 0) == -1) + /* FIXME */; + if (gnome_print_lineto(context, widths[col] - 1, 0) == -1) + /* FIXME */; + if (gnome_print_lineto(context, widths[col] - 1, row_height) == -1) + /* FIXME */; + if (gnome_print_lineto(context, 0, row_height) == -1) + /* FIXME */; + if (gnome_print_lineto(context, 0, 0) == -1) + /* FIXME */; + if (gnome_print_clip(context) == -1) + /* FIXME */; + + e_cell_print (ecell_view, context, ecol->col_idx, col, row, + widths[col] - 1, row_height); + + if (gnome_print_grestore(context) == -1) + /* FIXME */; + + xd += widths[col]; + } + yd -= row_height; + + if (item->draw_grid){ + gp_draw_rect(context, 0, yd, width, 1); + } + yd--; + } + + itemcontext->rows_printed = row; + + if (item->draw_grid){ + gdouble xd = 0; + + for (col = 0; col < cols; col++){ + gp_draw_rect(context, xd, height, 1, height - yd); + + xd += widths[col]; + } + gp_draw_rect(context, xd, height, 1, height - yd); + } + + g_free (widths); +} + +static gboolean +e_table_item_data_left (EPrintable *ep, + ETableItemPrintContext *itemcontext) +{ + ETableItem *item = itemcontext->item; + int rows_printed = itemcontext->rows_printed; + + gtk_signal_emit_stop_by_name(GTK_OBJECT(ep), "data_left"); + return rows_printed < item->rows; +} + +static void +e_table_item_reset (EPrintable *ep, + ETableItemPrintContext *itemcontext) +{ + itemcontext->rows_printed = 0; +} + +static gdouble +e_table_item_height (EPrintable *ep, + GnomePrintContext *context, + gdouble width, + gdouble max_height, + ETableItemPrintContext *itemcontext) +{ + ETableItem *item = itemcontext->item; + const int rows = item->rows; + int rows_printed = itemcontext->rows_printed; + gdouble *widths; + int row; + gdouble yd = 0; + + widths = e_table_item_calculate_print_widths (itemcontext->item->header, width); + + /* + * Draw cells + */ + yd++; + + for (row = rows_printed; row < rows; row++){ + gdouble row_height; + + row_height = eti_printed_row_height(item, widths, context, row); + if (max_height != -1 && yd + row_height + 1 > max_height && row != rows_printed) { + break; + } + + yd += row_height; + + yd++; + } + + g_free (widths); + + gtk_signal_emit_stop_by_name(GTK_OBJECT(ep), "height"); + return yd; +} + +static void +e_table_item_printable_destroy (GtkObject *object, + ETableItemPrintContext *itemcontext) +{ + gtk_object_unref(GTK_OBJECT(itemcontext->item)); + g_free(itemcontext); +} + +EPrintable * +e_table_item_get_printable (ETableItem *item) +{ + EPrintable *printable = e_printable_new(); + ETableItemPrintContext *itemcontext; + + itemcontext = g_new(ETableItemPrintContext, 1); + itemcontext->item = item; + gtk_object_ref(GTK_OBJECT(item)); + itemcontext->rows_printed = 0; + + gtk_signal_connect (GTK_OBJECT(printable), + "print_page", + GTK_SIGNAL_FUNC(e_table_item_print_page), + itemcontext); + gtk_signal_connect (GTK_OBJECT(printable), + "data_left", + GTK_SIGNAL_FUNC(e_table_item_data_left), + itemcontext); + gtk_signal_connect (GTK_OBJECT(printable), + "reset", + GTK_SIGNAL_FUNC(e_table_item_reset), + itemcontext); + gtk_signal_connect (GTK_OBJECT(printable), + "height", + GTK_SIGNAL_FUNC(e_table_item_height), + itemcontext); + gtk_signal_connect (GTK_OBJECT(printable), + "destroy", + GTK_SIGNAL_FUNC(e_table_item_printable_destroy), + itemcontext); + + return printable; +} diff --git a/widgets/e-table/e-table-item.h b/widgets/e-table/e-table-item.h index 961103b665..aa9d703910 100644 --- a/widgets/e-table/e-table-item.h +++ b/widgets/e-table/e-table-item.h @@ -5,6 +5,7 @@ #include <libgnomeui/gnome-canvas.h> #include "e-table-model.h" #include "e-table-header.h" +#include <e-util/e-printable.h> #define E_TABLE_ITEM_TYPE (e_table_item_get_type ()) #define E_TABLE_ITEM(o) (GTK_CHECK_CAST ((o), E_TABLE_ITEM_TYPE, ETableItem)) @@ -134,4 +135,9 @@ void e_table_item_redraw_range (ETableItem *eti, int start_col, int start_row, int end_col, int end_row); +EPrintable *e_table_item_get_printable (ETableItem *eti); +void e_table_item_print_height (ETableItem *eti, + GnomePrintContext *context, + gdouble width); + #endif /* _E_TABLE_ITEM_H_ */ diff --git a/widgets/e-table/e-table.c b/widgets/e-table/e-table.c index 1be22b7bde..6d0f6409d9 100644 --- a/widgets/e-table/e-table.c +++ b/widgets/e-table/e-table.c @@ -682,6 +682,12 @@ e_table_get_selected_view_row (ETable *e_table) return e_table_group_get_selected_view_row(e_table->group); } +EPrintable * +e_table_get_printable (ETable *e_table) +{ + return e_table_group_get_printable(e_table->group); +} + static void et_get_arg (GtkObject *o, GtkArg *arg, guint arg_id) { diff --git a/widgets/e-table/e-table.h b/widgets/e-table/e-table.h index ff15628dc5..4679af538b 100644 --- a/widgets/e-table/e-table.h +++ b/widgets/e-table/e-table.h @@ -10,6 +10,7 @@ #include "e-table-group.h" #include "e-table-sort-info.h" #include "e-table-item.h" +#include "e-util/e-printable.h" BEGIN_GNOME_DECLS @@ -66,29 +67,31 @@ typedef struct { gint (*key_press) (ETable *et, int row, int col, GdkEvent *event); } ETableClass; -GtkType e_table_get_type (void); - -ETable *e_table_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm, - const char *spec); -GtkWidget *e_table_new (ETableHeader *full_header, ETableModel *etm, - const char *spec); - -ETable *e_table_construct_from_spec_file (ETable *e_table, - ETableHeader *full_header, - ETableModel *etm, - const char *filename); -GtkWidget *e_table_new_from_spec_file (ETableHeader *full_header, - ETableModel *etm, - const char *filename); - -gchar *e_table_get_specification (ETable *e_table); -void e_table_save_specification (ETable *e_table, gchar *filename); - -void e_table_select_row (ETable *e_table, - int row); +GtkType e_table_get_type (void); + +ETable *e_table_construct (ETable *e_table, ETableHeader *full_header, ETableModel *etm, + const char *spec); +GtkWidget *e_table_new (ETableHeader *full_header, ETableModel *etm, + const char *spec); + +ETable *e_table_construct_from_spec_file (ETable *e_table, + ETableHeader *full_header, + ETableModel *etm, + const char *filename); +GtkWidget *e_table_new_from_spec_file (ETableHeader *full_header, + ETableModel *etm, + const char *filename); + +gchar *e_table_get_specification (ETable *e_table); +void e_table_save_specification (ETable *e_table, gchar *filename); + +void e_table_select_row (ETable *e_table, + int row); /* -1 means no selection. */ -int e_table_get_selected_view_row (ETable *e_table); +int e_table_get_selected_view_row (ETable *e_table); +EPrintable *e_table_get_printable (ETable *e_table); END_GNOME_DECLS #endif /* _E_TABLE_H_ */ + |