diff options
author | Matthew Barnes <mbarnes@src.gnome.org> | 2007-04-20 14:57:55 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@src.gnome.org> | 2007-04-20 14:57:55 +0800 |
commit | 4a044a636e418f4c95a85819aa92316e21f58b35 (patch) | |
tree | fed737c87045e269aa840b770172fb798682fd10 /widgets/table | |
parent | ba064da784cd29692e0db6d4560c7e7a8c68aeeb (diff) | |
download | gsoc2013-evolution-4a044a636e418f4c95a85819aa92316e21f58b35.tar gsoc2013-evolution-4a044a636e418f4c95a85819aa92316e21f58b35.tar.gz gsoc2013-evolution-4a044a636e418f4c95a85819aa92316e21f58b35.tar.bz2 gsoc2013-evolution-4a044a636e418f4c95a85819aa92316e21f58b35.tar.lz gsoc2013-evolution-4a044a636e418f4c95a85819aa92316e21f58b35.tar.xz gsoc2013-evolution-4a044a636e418f4c95a85819aa92316e21f58b35.tar.zst gsoc2013-evolution-4a044a636e418f4c95a85819aa92316e21f58b35.zip |
Clean up printing in Evolution (bug #426816)
svn path=/trunk/; revision=33440
Diffstat (limited to 'widgets/table')
-rw-r--r-- | widgets/table/ChangeLog | 9 | ||||
-rw-r--r-- | widgets/table/e-cell-pixbuf.c | 11 | ||||
-rw-r--r-- | widgets/table/e-cell-text.c | 1 | ||||
-rw-r--r-- | widgets/table/e-cell-tree.c | 89 | ||||
-rw-r--r-- | widgets/table/e-cell.h | 2 | ||||
-rw-r--r-- | widgets/table/e-table-group-container.c | 60 |
6 files changed, 88 insertions, 84 deletions
diff --git a/widgets/table/ChangeLog b/widgets/table/ChangeLog index 43d102a326..670368435d 100644 --- a/widgets/table/ChangeLog +++ b/widgets/table/ChangeLog @@ -1,3 +1,12 @@ +2007-04-20 Matthew Barnes <mbarnes@redhat.com> + + * e-cell.h: + * e-cell-pixbuf.c: + * e-cell-text.c: + * e-printable.h: + * e-table-group-container.c: + Refactor the printing infrastructure. (#426816) + 2007-04-19 Matthew Barnes <mbarnes@redhat.com> ** Fixes part of bug #429422 diff --git a/widgets/table/e-cell-pixbuf.c b/widgets/table/e-cell-pixbuf.c index 22d92bf98a..8b341c48a9 100644 --- a/widgets/table/e-cell-pixbuf.c +++ b/widgets/table/e-cell-pixbuf.c @@ -50,17 +50,6 @@ enum { PROP_UNSELECTED_COLUMN }; -static int -gnome_print_pixbuf (GtkPrintContext *pc, GdkPixbuf *pixbuf) -{ - cairo_t *cr = gtk_print_context_get_cairo_context (pc); - - gdk_cairo_set_source_pixbuf (cr, pixbuf, - (double)gdk_pixbuf_get_width (pixbuf), - (double)gdk_pixbuf_get_height (pixbuf)); - return TRUE; -} - /* * ECellPixbuf functions */ diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c index 47088029a6..c6698182e7 100644 --- a/widgets/table/e-cell-text.c +++ b/widgets/table/e-cell-text.c @@ -45,7 +45,6 @@ #include <gtk/gtk.h> #include <libgnomecanvas/gnome-canvas.h> #include <libgnomecanvas/gnome-canvas-rect-ellipse.h> -#include <libgnomeprint/gnome-print-pango.h> #include "a11y/e-table/gal-a11y-e-cell-registry.h" #include "a11y/e-table/gal-a11y-e-cell-text.h" diff --git a/widgets/table/e-cell-tree.c b/widgets/table/e-cell-tree.c index 8853a7a132..6bb61e03d8 100644 --- a/widgets/table/e-cell-tree.c +++ b/widgets/table/e-cell-tree.c @@ -695,11 +695,14 @@ ect_leave_edit (ECellView *ecell_view, int model_col, int view_col, int row, voi } static void -ect_print (ECellView *ecell_view, GnomePrintContext *context, +ect_print (ECellView *ecell_view, GtkPrintContext *context, int model_col, int view_col, int row, double width, double height) { ECellTreeView *tree_view = (ECellTreeView *) ecell_view; + cairo_t *cr = gtk_print_context_get_cairo_context (context); + + cairo_save (cr); 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); @@ -716,24 +719,20 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context, if (!e_tree_model_node_is_root (tree_model, node) || e_tree_model_node_get_children (tree_model, node, NULL) > 0) { - gnome_print_moveto (context, - offset - INDENT_AMOUNT / 2, - height / 2); - - gnome_print_lineto (context, - offset, - height / 2); + cairo_move_to (cr, + offset - INDENT_AMOUNT / 2, + height / 2); + cairo_line_to (cr, offset, height / 2); } if (visible_depth_of_node (ecell_view->e_table_model, row) != 0) { - gnome_print_moveto (context, - offset - INDENT_AMOUNT / 2, - height); - gnome_print_lineto (context, - offset - INDENT_AMOUNT / 2, - (e_tree_table_adapter_node_get_next (tree_table_adapter, node) - ? 0 - : height / 2)); + cairo_move_to (cr, + offset - INDENT_AMOUNT / 2, height); + cairo_line_to (cr, + offset - INDENT_AMOUNT / 2, + e_tree_table_adapter_node_get_next + (tree_table_adapter, node) ? 0 : + height / 2); } /* now traverse back up to the root of the tree, checking at @@ -744,12 +743,11 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context, offset -= INDENT_AMOUNT; while (node && depth != 0) { if (e_tree_table_adapter_node_get_next(tree_table_adapter, node)) { - gnome_print_moveto (context, - offset - INDENT_AMOUNT / 2, - height); - gnome_print_lineto (context, - offset - INDENT_AMOUNT / 2, - 0); + cairo_move_to (cr, + offset - INDENT_AMOUNT / 2, + height); + cairo_line_to (cr, + offset - INDENT_AMOUNT / 2, 0); } node = e_tree_model_node_get_parent (tree_model, node); depth --; @@ -759,41 +757,40 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context, /* now draw our icon if we're expandable */ if (expandable) { - double image_matrix [6] = {16, 0, 0, 16, 0, 0}; - GdkPixbuf *image = (expanded - ? E_CELL_TREE(tree_view->cell_view.ecell)->open_pixbuf - : E_CELL_TREE(tree_view->cell_view.ecell)->closed_pixbuf); - int image_width, image_height, image_rowstride; - guchar *image_pixels; - - image_width = gdk_pixbuf_get_width(image); - image_height = gdk_pixbuf_get_height(image); - image_pixels = gdk_pixbuf_get_pixels(image); - image_rowstride = gdk_pixbuf_get_rowstride(image); - - image_matrix [4] = subcell_offset - INDENT_AMOUNT / 2 - image_width / 2; - image_matrix [5] = height / 2 - image_height / 2; - - gnome_print_gsave (context); - gnome_print_concat (context, image_matrix); - - gnome_print_rgbaimage (context, image_pixels, image_width, image_height, image_rowstride); - gnome_print_grestore (context); + ECellTree *tree; + GdkPixbuf *pixbuf; + gint image_width; + gint image_height; + + tree = E_CELL_TREE (tree_view->cell_view.ecell); + + if (expanded) + pixbuf = tree->open_pixbuf; + else + pixbuf = tree->closed_pixbuf; + + image_width = gdk_pixbuf_get_width (pixbuf); + image_height = gdk_pixbuf_get_height (pixbuf); + + gdk_cairo_set_source_pixbuf ( + cr, pixbuf, subcell_offset - + INDENT_AMOUNT / 2 - image_width - 2, + height / 2 - image_height / 2); } - gnome_print_stroke (context); + cairo_stroke (cr); - if (gnome_print_translate(context, subcell_offset, 0) == -1) - /* FIXME */; + cairo_translate (cr, subcell_offset, 0); width -= subcell_offset; } + cairo_restore (cr); e_cell_print (tree_view->subcell_view, context, model_col, view_col, row, width, height); } static gdouble -ect_print_height (ECellView *ecell_view, GnomePrintContext *context, +ect_print_height (ECellView *ecell_view, GtkPrintContext *context, int model_col, int view_col, int row, double width) { diff --git a/widgets/table/e-cell.h b/widgets/table/e-cell.h index 378d32d75e..72ae6a6c79 100644 --- a/widgets/table/e-cell.h +++ b/widgets/table/e-cell.h @@ -27,8 +27,6 @@ #include <gdk/gdktypes.h> #include <gtk/gtk.h> -#include <libgnomeprint/gnome-print.h> -#include <libgnomeprint/gnome-font.h> #include <table/e-table-model.h> #include <table/e-table-tooltip.h> diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c index 3a21171d1c..0cccdd6e38 100644 --- a/widgets/table/e-table-group-container.c +++ b/widgets/table/e-table-group-container.c @@ -1152,7 +1152,8 @@ e_table_group_container_print_page (EPrintable *ep, GList *child; EPrintable *child_printable; gchar *string; - GnomeFont *font = gnome_font_find_closest ("Helvetica", TEXT_HEIGHT); + PangoLayout *layout; + PangoFontDescription *desc; child_printable = groupcontext->child_printable; child = groupcontext->child; @@ -1177,22 +1178,30 @@ e_table_group_container_print_page (EPrintable *ep, } } + layout = gtk_print_context_create_pango_layout (context); + + desc = pango_font_description_new (); + pango_font_description_set_family_static (desc, "Helvetica"); + pango_font_description_set_size (desc, TEXT_HEIGHT); + pango_layout_set_font_description (layout, desc); + pango_font_description_free (desc); + while (1) { - child_height = e_printable_height(child_printable, context, width,yd + 2 * TEXT_AREA_HEIGHT, quantize); - cr = gtk_print_context_get_cairo_context (context); - cairo_save (cr); - cairo_rectangle (cr, 0, 0, width,TEXT_AREA_HEIGHT); - cairo_rectangle (cr, 0, 0, 2 * TEXT_AREA_HEIGHT, child_height + TEXT_AREA_HEIGHT); - cairo_set_source_rgb (cr, .7, .7, .7) ; - cairo_fill(cr) ; - cairo_restore (cr); - - cairo_save (cr); - cairo_rectangle (cr, 0, 0, width, TEXT_AREA_HEIGHT); - cairo_clip (cr); - cairo_restore (cr); + child_height = e_printable_height(child_printable, context, width,yd + 2 * TEXT_AREA_HEIGHT, quantize); + cr = gtk_print_context_get_cairo_context (context); + cairo_save (cr); + cairo_rectangle (cr, 0, 0, width,TEXT_AREA_HEIGHT); + cairo_rectangle (cr, 0, 0, 2 * TEXT_AREA_HEIGHT, child_height + TEXT_AREA_HEIGHT); + cairo_set_source_rgb (cr, .7, .7, .7) ; + cairo_fill(cr) ; + cairo_restore (cr); + + cairo_save (cr); + cairo_rectangle (cr, 0, 0, width, TEXT_AREA_HEIGHT); + cairo_clip (cr); + cairo_restore (cr); - cairo_move_to(cr, 0, (gnome_font_get_ascender(font) - gnome_font_get_descender(font)) / 2); + cairo_move_to(cr, 0, 0); if (groupcontext->etgc->ecol->text) string = g_strdup_printf ("%s : %s (%d item%s)", groupcontext->etgc->ecol->text, @@ -1204,16 +1213,17 @@ e_table_group_container_print_page (EPrintable *ep, child_node->string, (gint) child_node->count, child_node->count == 1 ? "" : "s"); - cairo_show_text (cr, string); - g_free(string); - - cairo_translate(cr, 2 * TEXT_AREA_HEIGHT, TEXT_AREA_HEIGHT) ; - cairo_move_to(cr, 0, 0); - cairo_rectangle (cr, 0, 0, width - 2 * TEXT_AREA_HEIGHT,child_height); - cairo_clip(cr); + pango_layout_set_text (layout, string, -1); + pango_cairo_show_layout (cr, layout); + g_free(string); + + cairo_translate(cr, 2 * TEXT_AREA_HEIGHT, TEXT_AREA_HEIGHT) ; + cairo_move_to(cr, 0, 0); + cairo_rectangle (cr, 0, 0, width - 2 * TEXT_AREA_HEIGHT,child_height); + cairo_clip(cr); - e_printable_print_page (child_printable, context, width-2 * TEXT_AREA_HEIGHT, 0, quantize); - yd += child_height + TEXT_AREA_HEIGHT; + e_printable_print_page (child_printable, context, width-2 * TEXT_AREA_HEIGHT, 0, quantize); + yd += child_height + TEXT_AREA_HEIGHT; if (e_printable_data_left(child_printable)) break; @@ -1236,6 +1246,8 @@ e_table_group_container_print_page (EPrintable *ep, g_object_unref (groupcontext->child_printable); groupcontext->child_printable = child_printable; groupcontext->child = child; + + g_object_unref (layout); } static gboolean |