diff options
27 files changed, 1874 insertions, 1401 deletions
diff --git a/addressbook/ChangeLog b/addressbook/ChangeLog index 77837de923..bf4ceb6a3a 100644 --- a/addressbook/ChangeLog +++ b/addressbook/ChangeLog @@ -1,3 +1,22 @@ +2007-01-22 Srinivasa Ragavan <sragavan@novell.com> + + ** GtkPrint api migration from Ebby Wiselyn. + + * gui/component/addressbook-view.c: (print_cb): + * gui/widgets/e-addressbook-view.c: (print), + (e_contact_print_button), (contact_print_button_draw_page), + (eab_view_print), (eab_view_print_preview): + * gui/widgets/e-addressbook-view.h: + * printing/e-contact-print.c: (e_contact_output), + (e_contact_text_height), (e_contact_rectangle), + (e_contact_print_letter_heading), (e_contact_start_new_page), + (e_contact_get_contact_size), (e_contact_print_contact), + (e_contact_start_new_column), (complete_sequence), + (book_view_loaded), (e_contact_do_print_contacts), + (e_contact_build_style), (e_contact_print_response), + (e_contact_print_dialog_new), (e_contact_print_contact_dialog_new), + (contact_draw_page): + 2007-01-08 Veerapuram Varadhan <vvaradhan@novell.com> Patch submitted by Nathan Owens <pianocomp81@yahoo.com> and diff --git a/addressbook/gui/component/addressbook-view.c b/addressbook/gui/component/addressbook-view.c index d6da6a09cc..21b7cbd2f7 100644 --- a/addressbook/gui/component/addressbook-view.c +++ b/addressbook/gui/component/addressbook-view.c @@ -193,7 +193,7 @@ print_cb (BonoboUIComponent *uih, void *user_data, const char *path) AddressbookView *view = (AddressbookView *) user_data; EABView *v = get_current_view (view); if (v) - eab_view_print(v); + eab_view_print(v, 1); } static void diff --git a/addressbook/gui/widgets/e-addressbook-view.c b/addressbook/gui/widgets/e-addressbook-view.c index 6b0788b9d5..e210dd71d5 100644 --- a/addressbook/gui/widgets/e-addressbook-view.c +++ b/addressbook/gui/widgets/e-addressbook-view.c @@ -81,6 +81,7 @@ #include <libxml/tree.h> #include <libxml/parser.h> +#include <gtk/gtkprintunixdialog.h> #define SHOW_ALL_SEARCH "(contains \"x-evolution-any-field\" \"\")" @@ -120,6 +121,7 @@ static void query_changed (ESearchBar *esb, EABView *view); static void search_activated (ESearchBar *esb, EABView *view); static void search_menu_activated (ESearchBar *esb, int id, EABView *view); static GList *get_master_list (void); +static void contact_print_button_draw_page (GtkPrintOperation *print, GtkPrintContext *context, gint page_nr,EPrintable *printable); #define PARENT_TYPE GTK_TYPE_VBOX static GtkVBoxClass *parent_class = NULL; @@ -872,9 +874,11 @@ print (EPopup *ep, EPopupItem *pitem, void *data) { /*ContactAndBook *contact_and_book = data;*/ EABPopupTargetSelect *t = (EABPopupTargetSelect *)ep->target; + GtkWidget *dialog; if (t->cards->len == 1) { - gtk_widget_show(e_contact_print_contact_dialog_new(t->cards->pdata[0])); + dialog = e_contact_print_contact_dialog_new(t->cards->pdata[0]); + e_contact_print_response (dialog, GTK_RESPONSE_OK, NULL); } else { GList *contacts = get_contact_list(t); @@ -1699,8 +1703,6 @@ get_master_list (void) return category_list; } - - typedef struct { GtkWidget *table; GObject *printable; @@ -1717,67 +1719,61 @@ e_contact_print_destroy(gpointer data, GObject *where_object_was) static void e_contact_print_button(GtkDialog *dialog, gint response, gpointer data) -{ - GnomePrintJob *master; - GnomePrintContext *pc; - EPrintable *printable = g_object_get_data(G_OBJECT(dialog), "printable"); +{ GtkWidget *preview; - switch( response ) { - case GNOME_PRINT_DIALOG_RESPONSE_PRINT: - master = gnome_print_job_new(gnome_print_dialog_get_config ( GNOME_PRINT_DIALOG(dialog) )); - pc = gnome_print_job_get_context( master ); - e_printable_reset(printable); - while (e_printable_data_left(printable)) { - gnome_print_beginpage (pc, "Contacts"); - if (gnome_print_gsave(pc) == -1) - /* FIXME */; - if (gnome_print_translate(pc, 72, 72) == -1) - /* FIXME */; - e_printable_print_page(printable, - pc, - 6.5 * 72, - 5 * 72, - TRUE); - if (gnome_print_grestore(pc) == -1) - /* FIXME */; - if (gnome_print_showpage(pc) == -1) - /* FIXME */; - } - gnome_print_job_close(master); - gnome_print_job_print(master); - g_object_unref (master); - gtk_widget_destroy((GtkWidget *)dialog); - break; - case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: - master = gnome_print_job_new (gnome_print_dialog_get_config ( GNOME_PRINT_DIALOG(dialog) )); - pc = gnome_print_job_get_context( master ); - e_printable_reset(printable); + GtkPrintOperation *print; + GtkPrintSettings *settings; + GtkPageSetup *page_setup; + GtkPaperSize *paper_size; + + EPrintable *printable = g_object_get_data(G_OBJECT(dialog), "printable"); + print = gtk_print_operation_new (); + page_setup = gtk_page_setup_new (); + + /*get & set,the settings of the dialog */ + settings = gtk_print_unix_dialog_get_settings (GTK_PRINT_UNIX_DIALOG (dialog)); + paper_size = gtk_paper_size_new ("iso_a4"); /* FIXME paper size hardcoded */ + gtk_page_setup_set_paper_size (page_setup, paper_size); + gtk_print_operation_set_print_settings (print, settings); + + gtk_print_operation_set_n_pages (print, 1); + gtk_print_operation_set_default_page_setup (print, page_setup); + /* run the dialog */ + g_signal_connect (print,"draw_page",G_CALLBACK(contact_print_button_draw_page), printable); + + if (response == GTK_RESPONSE_APPLY) + gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PREVIEW, NULL, NULL); + else + gtk_print_operation_run (print,GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL,NULL); + + gtk_widget_destroy(dialog); + g_object_unref (print); + g_object_unref (settings); + g_object_unref (page_setup); + g_object_unref (paper_size); +} + +static void +contact_print_button_draw_page (GtkPrintOperation *print, GtkPrintContext *context, gint page_nr,EPrintable *printable) + +{ + cairo_t *cr; + GtkPageSetup *page_setup; + gdouble top_margin; + + cr = gtk_print_context_get_cairo_context (context); + page_setup = gtk_print_operation_get_default_page_setup (print); + top_margin = gtk_page_setup_get_top_margin (page_setup, GTK_UNIT_POINTS); + e_printable_reset(printable); while (e_printable_data_left(printable)) { - gnome_print_beginpage (pc, "Contacts"); - if (gnome_print_gsave(pc) == -1) - /* FIXME */; - if (gnome_print_translate(pc, 72, 72) == -1) - /* FIXME */; - e_printable_print_page(printable, - pc, - 6.5 * 72, - 9 * 72, - TRUE); - if (gnome_print_grestore(pc) == -1) - /* FIXME */; - if (gnome_print_showpage(pc) == -1) - /* FIXME */; + cairo_save (cr); + e_printable_print_page (printable, + context, + 6.5 * 72, + top_margin + 10, + TRUE); + cairo_restore (cr); } - gnome_print_job_close(master); - preview = GTK_WIDGET(gnome_print_job_preview_new(master, "Print Preview")); - gtk_widget_show_all(preview); - g_object_unref (master); - break; - case GNOME_PRINT_DIALOG_RESPONSE_CANCEL: - default: - gtk_widget_destroy((GtkWidget *)dialog); - break; - } } void @@ -1842,7 +1838,7 @@ eab_view_discard_menus (EABView *view) } void -eab_view_print(EABView *view) +eab_view_print(EABView *view, int preview) { if (view->view_type == EAB_VIEW_MINICARD) { char *query; @@ -1855,9 +1851,14 @@ eab_view_print(EABView *view) NULL); GList *list = get_selected_contacts (view); print = e_contact_print_dialog_new (book, query, list); - g_free(query); - e_free_object_list(list); - gtk_widget_show(print); + + if (!preview) + e_contact_print_response (print, GTK_RESPONSE_OK, NULL); + else + e_contact_print_response (print, GTK_RESPONSE_APPLY, NULL); + + g_free (query); + e_free_object_list (list); } else if (view->view_type == EAB_VIEW_TABLE) { GtkWidget *dialog; @@ -1878,17 +1879,14 @@ eab_view_print(EABView *view) g_object_set_data (G_OBJECT (dialog), "table", view->widget); g_object_set_data (G_OBJECT (dialog), "printable", printable); - g_signal_connect(dialog, - "response", G_CALLBACK(e_contact_print_button), NULL); - weak_data = g_new (EContactPrintDialogWeakData, 1); - weak_data->table = view->widget; weak_data->printable = G_OBJECT (printable); - g_object_weak_ref (G_OBJECT (dialog), e_contact_print_destroy, weak_data); - - gtk_widget_show(dialog); + if (preview) + e_contact_print_button (dialog, GTK_RESPONSE_APPLY, NULL); + else + e_contact_print_button (dialog, GTK_RESPONSE_OK, NULL); } #ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW else if (view->view_type == EAB_VIEW_TREEVIEW) { @@ -1903,60 +1901,40 @@ eab_view_print_preview(EABView *view) if (view->view_type == EAB_VIEW_MINICARD) { char *query; EBook *book; + GtkWidget *print; g_object_get (view->model, "query", &query, "book", &book, NULL); - GList *list = get_selected_contacts (view); + GList *list = get_selected_contacts (view); e_contact_print_preview (book, query, list); e_free_object_list (list); - g_free (query); - } else if (view->view_type == EAB_VIEW_TABLE) { + }else if (view->view_type == EAB_VIEW_TABLE) { + GtkWidget *dialog; EPrintable *printable; ETable *etable; - GnomePrintJob *master; - GnomePrintContext *pc; - GnomePrintConfig *config; - GtkWidget *preview; + EContactPrintDialogWeakData *weak_data; + + /* FIXME: Allow range selection in table views, as in minicard view */ + dialog = e_print_get_dialog (_("Print cards"), GNOME_PRINT_DIALOG_COPIES); g_object_get(view->widget, "table", &etable, NULL); printable = e_table_get_printable(etable); - g_object_unref(etable); g_object_ref (printable); gtk_object_sink (GTK_OBJECT (printable)); + g_object_unref(etable); + g_object_ref (view->widget); - config = e_print_load_config (); - master = gnome_print_job_new (config); - pc = gnome_print_job_get_context( master ); - e_printable_reset(printable); - while (e_printable_data_left(printable)) { - gnome_print_beginpage (pc, "Contacts"); - if (gnome_print_gsave(pc) == -1) - /* FIXME */; - if (gnome_print_translate(pc, 72, 72) == -1) - /* FIXME */; - e_printable_print_page(printable, - pc, - 6.5 * 72, - 9 * 72, - TRUE); - if (gnome_print_grestore(pc) == -1) - /* FIXME */; - if (gnome_print_showpage(pc) == -1) - /* FIXME */; - } - gnome_print_job_close(master); - preview = GTK_WIDGET(gnome_print_job_preview_new(master, "Print Preview")); - gtk_widget_show_all(preview); - g_object_unref (master); - g_object_unref (printable); - } -#ifdef WITH_ADDRESSBOOK_VIEW_TREEVIEW - else if (view->view_type == EAB_VIEW_TREEVIEW) { - /* XXX */ + g_object_set_data (G_OBJECT (dialog), "table", view->widget); + g_object_set_data (G_OBJECT (dialog), "printable", printable); + + weak_data = g_new (EContactPrintDialogWeakData, 1); + weak_data->table = view->widget; + weak_data->printable = G_OBJECT (printable); + g_object_weak_ref (G_OBJECT (dialog), e_contact_print_destroy, weak_data); + e_contact_print_button (dialog, GTK_RESPONSE_OK, NULL); } -#endif } /* callback function to handle removal of contacts for diff --git a/addressbook/gui/widgets/e-addressbook-view.h b/addressbook/gui/widgets/e-addressbook-view.h index 3327bb6868..0f674c9edd 100644 --- a/addressbook/gui/widgets/e-addressbook-view.h +++ b/addressbook/gui/widgets/e-addressbook-view.h @@ -130,7 +130,7 @@ void eab_view_save_as (EABView *view, gboolean all); void eab_view_view (EABView *view); void eab_view_send (EABView *view); void eab_view_send_to (EABView *view); -void eab_view_print (EABView *view); +void eab_view_print (EABView *view, int preview); void eab_view_print_preview (EABView *view); void eab_view_delete_selection (EABView *view, gboolean is_delete); void eab_view_cut (EABView *view); diff --git a/addressbook/printing/e-contact-print.c b/addressbook/printing/e-contact-print.c index 950d30338b..16c219fe1e 100644 --- a/addressbook/printing/e-contact-print.c +++ b/addressbook/printing/e-contact-print.c @@ -44,6 +44,8 @@ #include <libebook/e-book.h> #include <libebook/e-contact.h> +#include <gtk/gtk.h> +#include <gtk/gtkprintunixdialog.h> #include <libedataserver/e-xml-utils.h> #include "e-util/e-print.h" @@ -51,16 +53,17 @@ #include "e-util/e-util-private.h" #include "e-contact-print.h" - + #define SCALE 5 #define HYPHEN_PIXELS 20 #define HYPHEN_PENALTY ( (SCALE) * (SCALE) * (HYPHEN_PIXELS) * (HYPHEN_PIXELS) ) typedef struct _EContactPrintContext EContactPrintContext; +typedef struct _ContactPrintItem ContactPrintItem; struct _EContactPrintContext { - GnomePrintContext *pc; + GtkPrintContext *pc; GnomePrintJob *master; PangoLayout *pl; gdouble x; @@ -81,6 +84,20 @@ struct _EContactPrintContext GList *contacts; }; +struct _ContactPrintItem +{ + EContactPrintContext *ctxt; + EContactPrintStyle *style; + EContact *contact; + GList *contact_list; + EBook *book; + GtkPrintSettings *settings; + gboolean uses_book, uses_list; +}; + +static void +contact_draw_page (GtkPrintOperation *print, GtkPrintContext *context, gint page_nr, ContactPrintItem *cpi); + static double get_font_height (PangoFontDescription *font) { @@ -139,14 +156,14 @@ find_closest_font_from_weight_slant (const guchar *family, GnomeFontWeight weigh static void e_contact_output(EContactPrintContext *ctxt, PangoFontDescription *font, double x, double y, double width, const gchar *text) { - gnome_print_gsave(ctxt->pc); - - /* Preserve the indentation behaviour of the old e_contact_divide_text function: */ double indent; + cairo_t *cr = gtk_print_context_get_cairo_context (ctxt->pc); + cairo_save(cr); + if ( width == -1 || get_font_width(ctxt, font, text) <= width ) { indent = 0.0; } else { - indent = get_font_width (ctxt, font, " "); + indent = get_font_width (ctxt, font, " "); } g_assert (ctxt->pl); @@ -155,9 +172,10 @@ e_contact_output(EContactPrintContext *ctxt, PangoFontDescription *font, double pango_layout_set_width (ctxt->pl, width*PANGO_SCALE); pango_layout_set_indent (ctxt->pl, indent*PANGO_SCALE); - gnome_print_moveto(ctxt->pc, x, y); - gnome_print_pango_layout (ctxt->pc, ctxt->pl); - gnome_print_grestore(ctxt->pc); + cairo_move_to(cr, x, y); + pango_cairo_show_layout (cr, ctxt->pl); + cairo_restore (cr); + } static gdouble @@ -168,12 +186,9 @@ e_contact_text_height(EContactPrintContext *ctxt, PangoFontDescription *font, do g_assert (ctxt->pl); pango_layout_set_font_description (ctxt->pl, font); pango_layout_set_text (ctxt->pl, text, -1); - pango_layout_set_width (ctxt->pl, width*PANGO_SCALE); + pango_layout_set_width (ctxt->pl, 1); /* fix me width hard coded */ pango_layout_set_indent (ctxt->pl, 0); - - pango_layout_get_size (ctxt->pl, - &w, - &h); + pango_layout_get_size (ctxt->pl, &w, &h); return (double)h/(double)PANGO_SCALE; } @@ -190,7 +205,7 @@ e_contact_output_and_advance(EContactPrintContext *ctxt, PangoFontDescription *f #endif static void -e_contact_rectangle(GnomePrintContext *pc, +e_contact_rectangle(GtkPrintContext *pc, gdouble x0, gdouble y0, gdouble x1, @@ -199,15 +214,13 @@ e_contact_rectangle(GnomePrintContext *pc, gdouble g, gdouble b) { - gnome_print_gsave(pc); - gnome_print_setrgbcolor(pc, r, g, b); - gnome_print_moveto(pc, x0, y0); - gnome_print_lineto(pc, x1, y0); - gnome_print_lineto(pc, x1, y1); - gnome_print_lineto(pc, x0, y1); - gnome_print_lineto(pc, x0, y0); - gnome_print_fill(pc); - gnome_print_grestore(pc); + cairo_t *cr; + cr = gtk_print_context_get_cairo_context (pc); + cairo_save(cr); + cairo_set_source_rgb(cr, r, g, b); + cairo_rectangle (cr,x0, y0, x1, y1); + cairo_fill (cr); + cairo_restore (cr); } static double @@ -221,38 +234,47 @@ e_contact_print_letter_heading (EContactPrintContext *ctxt, gchar *character) { gdouble height; gdouble width; + cairo_t *cr; width = get_font_width(ctxt, ctxt->letter_heading_font, "m") * 1.7; height = get_font_height (ctxt->letter_heading_font); - gnome_print_gsave( ctxt->pc ); - e_contact_rectangle( ctxt->pc, ctxt->x, ctxt->y, ctxt->x + width, ctxt->y - (height + 6), 0, 0, 0); - gnome_print_setrgbcolor(ctxt->pc, 1, 1, 1); - ctxt->y -= 4; - e_contact_output(ctxt, ctxt->letter_heading_font, ctxt->x + (width - get_font_width(ctxt, ctxt->letter_heading_font, character))/ 2, ctxt->y, -1, character); - ctxt->y -= height; - ctxt->y -= 2; - ctxt->y -= 3; - gnome_print_grestore( ctxt->pc ); + + cr = gtk_print_context_get_cairo_context (ctxt->pc); + cairo_save(cr); + + e_contact_rectangle( ctxt->pc, ctxt->x, ctxt->y, width, height + 6, 0, 0, 0); + cairo_set_source_rgb(cr, 1, 1, 1); + ctxt->y += 4; + e_contact_output(ctxt, ctxt->letter_heading_font, + ctxt->x + (width - get_font_width(ctxt, ctxt->letter_heading_font, character))/ 2 - 5, + ctxt->y - 5, + -1, + character); + ctxt->y += height; + ctxt->y += 2; + ctxt->y += 3; + + cairo_restore(cr); } static void e_contact_start_new_page(EContactPrintContext *ctxt) { - ctxt->x = ctxt->style->left_margin * 72; - ctxt->y = (ctxt->style->page_height - ctxt->style->top_margin) * 72; + cairo_t *cr; + cr = gtk_print_context_get_cairo_context (ctxt->pc); + ctxt->x = ctxt->style->left_margin; + ctxt->y = ctxt->style->top_margin; + cairo_show_page (cr); ctxt->column = 0; - gnome_print_showpage(ctxt->pc); - - gnome_print_beginpage (ctxt->pc, NULL); } static double e_contact_get_contact_size(EContact *contact, EContactPrintContext *ctxt) { + const char *file_as; gdouble height = 0; gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); gdouble column_width; - const char *file_as; gint field; column_width = (page_width + 18) / ctxt->style->num_columns - 18; @@ -293,74 +315,99 @@ e_contact_print_contact (EContact *contact, EContactPrintContext *ctxt) gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); gdouble column_width; char *file_as; + cairo_t *cr; int field; column_width = (page_width + 18) / ctxt->style->num_columns - 18; - - gnome_print_gsave(ctxt->pc); - - ctxt->y -= get_font_height (ctxt->style->headings_font) * .2; - ctxt->y -= get_font_height (ctxt->style->headings_font) * .2; + cr = gtk_print_context_get_cairo_context (ctxt->pc); + cairo_save(cr); + ctxt->y += get_font_height (ctxt->style->headings_font) * .2; + ctxt->y += get_font_height (ctxt->style->headings_font) * .2; file_as = e_contact_get (contact, E_CONTACT_FILE_AS); + if (ctxt->style->print_using_grey) - e_contact_rectangle(ctxt->pc, ctxt->x, ctxt->y + get_font_height (ctxt->style->headings_font) * .3, ctxt->x + column_width, ctxt->y - e_contact_text_height(ctxt, ctxt->style->headings_font, column_width - 4, file_as) - get_font_height (ctxt->style->headings_font) * .3, .85, .85, .85); - e_contact_output(ctxt, ctxt->style->headings_font, ctxt->x + 2, ctxt->y, column_width - 4, file_as); - ctxt->y -= e_contact_text_height(ctxt, ctxt->style->headings_font, column_width - 4, file_as); + e_contact_rectangle(ctxt->pc, + ctxt->x,ctxt->y + get_font_height (ctxt->style->headings_font) * .3, + column_width, + e_contact_text_height(ctxt, + ctxt->style->headings_font, + column_width - 4, file_as) + + get_font_height (ctxt->style->headings_font) * .3, + .85, .85, .85); + + + e_contact_output(ctxt, ctxt->style->headings_font, ctxt->x + 2, ctxt->y + 5, column_width + 4, file_as); + ctxt->y += e_contact_text_height(ctxt, ctxt->style->headings_font, column_width + 4, file_as); g_free (file_as); - ctxt->y -= get_font_height (ctxt->style->headings_font) * .2; - ctxt->y -= get_font_height (ctxt->style->headings_font) * .2; + ctxt->y += get_font_height (ctxt->style->headings_font) * .2; + ctxt->y += get_font_height (ctxt->style->headings_font) * .2; - for(field = E_CONTACT_FILE_AS; field != E_CONTACT_LAST_SIMPLE_STRING; field++) { + for(field = E_CONTACT_FILE_AS; field != E_CONTACT_LAST_SIMPLE_STRING;field++) + { char *string; string = e_contact_get(contact, field); - + if (string && *string) { double xoff = 0; - e_contact_output(ctxt, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, e_contact_pretty_name (field)); + + e_contact_output(ctxt, + ctxt->style->body_font, + ctxt->x + xoff, + ctxt->y + 5, + -1, + e_contact_pretty_name (field)); + xoff += get_font_width(ctxt, ctxt->style->body_font, e_contact_pretty_name (field)); e_contact_output(ctxt, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, -1, ": "); xoff += get_font_width(ctxt, ctxt->style->body_font, ": "); - e_contact_output(ctxt, ctxt->style->body_font, ctxt->x + xoff, ctxt->y, column_width - xoff, string); - ctxt->y -= e_contact_text_height(ctxt, ctxt->style->body_font, column_width - xoff, string); - ctxt->y -= .2 * get_font_height (ctxt->style->body_font); + + e_contact_output(ctxt, + ctxt->style->body_font, + ctxt->x + xoff, + ctxt->y + 5, + column_width - xoff, + string); + + ctxt->y += e_contact_text_height(ctxt, ctxt->style->body_font, column_width - xoff, string); + ctxt->y += .2 * get_font_height (ctxt->style->body_font); + } g_free(string); - } - - ctxt->y -= get_font_height (ctxt->style->headings_font) * .4; - gnome_print_grestore(ctxt->pc); + } + ctxt->y += get_font_height (ctxt->style->headings_font) * .4 + 8; + cairo_restore(cr); } static void e_contact_start_new_column (EContactPrintContext *ctxt) { - gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); + gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); gdouble column_offset; + column_offset = (page_width + 18) / ctxt->style->num_columns; ctxt->column ++; + if (ctxt->column >= ctxt->style->num_columns) { e_contact_start_new_page(ctxt); ctxt->column = 0; } - ctxt->x = (72 * ctxt->style->left_margin) + column_offset * ctxt->column; - ctxt->y = 72 * (ctxt->style->page_height - ctxt->style->top_margin); + ctxt->x = ctxt->style->left_margin + column_offset * ctxt->column; + ctxt->y = ctxt->style->top_margin + 12; } static void -complete_sequence(EBookView *book_view, EBookViewStatus status, EContactPrintContext *ctxt) +complete_sequence (EBookView *book_view, EBookViewStatus status, EContactPrintContext *ctxt) { GList *contacts = ctxt->contacts; - + cairo_t *cr; gdouble page_width = 72 * (ctxt->style->page_width - ctxt->style->left_margin - ctxt->style->right_margin); ctxt->first_contact = TRUE; ctxt->character = NULL; - ctxt->y = (ctxt->style->page_height - ctxt->style->top_margin) * 72; - ctxt->x = (ctxt->style->left_margin) * 72; - - gnome_print_beginpage (ctxt->pc, NULL); + ctxt->y = ctxt->style->page_height + ctxt->style->top_margin; + ctxt->x = (ctxt->style->left_margin); for(; contacts; contacts = contacts->next) { EContact *contact = contacts->data; @@ -368,49 +415,43 @@ complete_sequence(EBookView *book_view, EBookViewStatus status, EContactPrintCon gchar *letter_str = NULL; file_as = e_contact_get (contact, E_CONTACT_FILE_AS); - - if (file_as != NULL) { - letter_str = g_strndup (file_as, g_utf8_next_char (file_as) - (gchar *) file_as); - } - if ( file_as && (!ctxt->character || g_utf8_collate (ctxt->character, letter_str) != 0) ) { + + if (file_as != NULL) { + letter_str = g_strndup (file_as, g_utf8_next_char (file_as) - (gchar *) file_as); + } + if ( file_as && (!ctxt->character || g_utf8_collate (ctxt->character, letter_str) != 0) ) { g_free (ctxt->character); ctxt->character = g_strdup (letter_str); if (ctxt->style->sections_start_new_page && ! ctxt->first_contact) { e_contact_start_new_page(ctxt); - } - else if ((!ctxt->first_contact) && (ctxt->y - e_contact_get_letter_heading_height(ctxt) - e_contact_get_contact_size(contact, ctxt) < ctxt->style->bottom_margin * 72)) - e_contact_start_new_column(ctxt); + } + else if ((!ctxt->first_contact) && (ctxt->y > ctxt->style->page_height * 60 )) + e_contact_start_new_column(ctxt); if ( ctxt->style->letter_headings ) e_contact_print_letter_heading(ctxt, ctxt->character); ctxt->first_section = FALSE; } - else if ( (!ctxt->first_contact) && (ctxt->y - e_contact_get_contact_size(contact, ctxt) < ctxt->style->bottom_margin * 72)) { + + else if ( (!ctxt->first_contact) && (ctxt->y > ctxt->style->page_height * 60)) { e_contact_start_new_column(ctxt); if ( ctxt->style->letter_headings ) e_contact_print_letter_heading(ctxt, ctxt->character); } + g_free (letter_str); e_contact_print_contact(contact, ctxt); ctxt->first_contact = FALSE; } - gnome_print_showpage(ctxt->pc); - gnome_print_context_close(ctxt->pc); - gnome_print_job_close(ctxt->master); - g_free(ctxt->character); + if (book_view) g_object_unref(book_view); - if (ctxt->type == GNOME_PRINT_DIALOG_RESPONSE_PREVIEW) { - GtkWidget *preview; - preview = GTK_WIDGET(gnome_print_job_preview_new(ctxt->master, "Print Preview")); - gtk_widget_show_all(preview); - } else { - gnome_print_job_print(ctxt->master); - } - g_object_unref(ctxt->pc); + + g_object_unref(ctxt->pc); g_object_unref(ctxt->pl); - g_object_unref(ctxt->master); if (ctxt->book) g_object_unref(ctxt->book); + + g_free(ctxt->character); if (ctxt->query) e_book_query_unref (ctxt->query); g_list_foreach(ctxt->contacts, (GFunc) g_object_unref, NULL); @@ -464,21 +505,20 @@ book_view_loaded (EBook *book, EBookStatus status, EBookView *book_view, EContac G_CALLBACK(create_contact), ctxt); - g_signal_connect(book_view, - "sequence_complete", - G_CALLBACK(complete_sequence), - ctxt); - e_book_view_start (book_view); } static void e_contact_do_print_contacts (EBook *book, EBookQuery *query, EContactPrintContext *ctxt) { - e_book_async_get_book_view(book, query, NULL, -1, (EBookBookViewCallback) book_view_loaded, ctxt); -} + EBookView *bookview; + gboolean status; -static void + status = e_book_get_book_view (book, query, NULL, -1, &bookview, NULL); + book_view_loaded (book, 1, bookview, ctxt); +} + +static void e_contact_do_print (EBook *book, EBookQuery *query, EContactPrintContext *ctxt) { switch ( ctxt->style->type ) { @@ -543,7 +583,7 @@ static void get_font( char *data, PangoFontDescription **variable ) static void -e_contact_build_style(EContactPrintStyle *style, GnomePrintConfig *config) +e_contact_build_style(EContactPrintStyle *style, GtkPrintSettings *config) { xmlDocPtr styledoc; gchar *filename; @@ -673,14 +713,6 @@ e_contact_build_style(EContactPrintStyle *style, GnomePrintConfig *config) xmlFreeDoc(styledoc); } - /* - * get paper size and set it to the print style - */ - gnome_print_config_get_page_size(config, &page_width, &page_height); - gnome_print_convert_distance(&page_width, gnome_print_unit_get_default(), gnome_print_unit_get_by_name("Inches")); - gnome_print_convert_distance(&page_height, gnome_print_unit_get_default(), gnome_print_unit_get_by_name("Inches")); - style->page_height = page_height; - style->page_width = page_width; } static gint @@ -689,33 +721,40 @@ e_contact_print_close(GnomeDialog *dialog, gpointer data) return FALSE; } -static void +void e_contact_print_response(GtkWidget *dialog, gint response_id, gpointer data) { - EContactPrintContext *ctxt = g_new(EContactPrintContext, 1); - EContactPrintStyle *style = g_new(EContactPrintStyle, 1); - GnomePrintJob *master; - GnomePrintConfig *config; - GnomePrintContext *pc; + GtkPrintSettings *settings; + GtkPrintOperation *print; + GtkPrintOperationResult res; + GtkPaperSize *paper_size; + GtkPageSetup *page_setup; + GtkPrintPages print_pages; + GList *contact_list = NULL; + EBook *book = NULL; + EBookQuery *query = NULL; + EContact *contact = NULL; + gdouble font_size; gboolean uses_book = FALSE, uses_list = FALSE, uses_range = FALSE; - uses_range = GPOINTER_TO_INT (g_object_get_data(G_OBJECT (dialog), "uses_range")); + EContactPrintContext *ctxt = g_new0 (EContactPrintContext, 1); + EContactPrintStyle *style = g_new0 (EContactPrintStyle, 1); + ContactPrintItem *cpi = g_new0 (ContactPrintItem, 1); + + settings = gtk_print_unix_dialog_get_settings (GTK_PRINT_UNIX_DIALOG (dialog)); + uses_range = GPOINTER_TO_INT (g_object_get_data(G_OBJECT (dialog),"uses_range")); + if (uses_range) { - if (gnome_print_dialog_get_range (GNOME_PRINT_DIALOG (dialog)) & GNOME_PRINT_RANGE_ALL) + if (gtk_print_settings_get_print_pages (settings) == GTK_PRINT_PAGES_ALL) { uses_book = TRUE; - if (gnome_print_dialog_get_range (GNOME_PRINT_DIALOG (dialog)) & GNOME_PRINT_RANGE_SELECTION) + } + if (gtk_print_settings_get_print_pages (settings) == GTK_PRINT_PAGES_CURRENT) uses_list = TRUE; } else { uses_book = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), "uses_book")); uses_list = GPOINTER_TO_INT (g_object_get_data (G_OBJECT (dialog), "uses_list")); - } - EBook *book = NULL; - EBookQuery *query = NULL; - EContact *contact = NULL; - GList *contact_list = NULL; - gdouble font_size; - + } if (uses_book) { book = g_object_get_data(G_OBJECT(dialog), "book"); query = g_object_get_data(G_OBJECT(dialog), "query"); @@ -726,118 +765,57 @@ e_contact_print_response(GtkWidget *dialog, gint response_id, gpointer data) } else { contact = g_object_get_data(G_OBJECT(dialog), "contact"); + } + + page_setup = gtk_page_setup_new (); + paper_size = gtk_paper_size_new ("iso_a4"); /* FIXME paper size hardcoded */ + gtk_page_setup_set_paper_size (page_setup, paper_size); + print = gtk_print_operation_new (); + gtk_print_operation_set_default_page_setup (print, page_setup); + gtk_print_operation_set_n_pages (print, 1); + gtk_print_settings_set_print_pages (settings, GTK_PRINT_PAGES_ALL); + + /* style information */ + e_contact_build_style(style, settings); + style->page_height = gtk_page_setup_get_paper_height (page_setup, GTK_UNIT_INCH); + style->page_width = gtk_page_setup_get_paper_width (page_setup, GTK_UNIT_INCH); + ctxt->x = 0; + ctxt->y = 0; + ctxt->column = 0; + ctxt->style = style; + ctxt->first_section = TRUE; + ctxt->type = GTK_RESPONSE_OK; + font_size = 72 * ctxt->style->page_height / 27.0 / 2.0; + ctxt->letter_heading_font = find_font (pango_font_description_get_family (ctxt->style->headings_font), + get_font_height (ctxt->style->headings_font)*1.5); + ctxt->book = book; + ctxt->query = query; + cpi->uses_book = uses_book; + cpi->uses_list = uses_list; + cpi->settings = settings; + cpi->ctxt = ctxt; + cpi->contact= contact; + cpi->ctxt->contacts = NULL; + cpi->contact_list= contact_list; + cpi->book = book; + e_contact_do_print_contacts (book, query, ctxt); + + /* runs the print dialog , emitting signals */ + g_signal_connect (print, "draw_page",G_CALLBACK (contact_draw_page), cpi); + if (response_id == GTK_RESPONSE_APPLY) { + res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PREVIEW, NULL, NULL); } - switch( response_id ) { - case GNOME_PRINT_DIALOG_RESPONSE_PRINT: - config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG(dialog)); - master = gnome_print_job_new( config ); - pc = gnome_print_job_get_context( master ); - e_contact_build_style(style, config); - - ctxt->x = 0; - ctxt->y = 0; - ctxt->column = 0; - ctxt->style = style; - ctxt->master = master; - ctxt->first_section = TRUE; - ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_PRINT; - - font_size = 72 * ctxt->style->page_height / 27.0 / 2.0; - ctxt->letter_heading_font = find_font (pango_font_description_get_family(ctxt->style->headings_font), get_font_height(ctxt->style->headings_font)*1.5); - - ctxt->pc = pc; - ctxt->pl = gnome_print_pango_create_layout (pc); -#warning FIXME gnome_print_multipage_new_from_sizes -#if 0 - ctxt->pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc, - 72 * style->paper_width, - 72 * style->paper_height, - 72 * style->page_width, - 72 * style->page_height)); -#endif - - ctxt->book = book; - ctxt->query = query; - if (uses_book) { - ctxt->contacts = NULL; - e_contact_do_print(book, ctxt->query, ctxt); - } - else if (uses_list) { - ctxt->contacts = contact_list; - complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, ctxt); - } - else { - ctxt->contacts = g_list_append(NULL, contact); - complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, ctxt); - } - gtk_widget_destroy (dialog); - - break; - case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: - config = gnome_print_dialog_get_config (GNOME_PRINT_DIALOG(dialog)); - master = gnome_print_job_new( config ); - pc = gnome_print_job_get_context( master ); - e_contact_build_style(style, config); - - ctxt->x = 0; - ctxt->y = 0; - ctxt->column = 0; - ctxt->style = style; - ctxt->master = master; - ctxt->first_section = TRUE; - ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_PREVIEW; - - font_size = 72 * ctxt->style->page_height / 27.0 / 2.0; - ctxt->letter_heading_font = find_font (pango_font_description_get_family(ctxt->style->headings_font), get_font_height (ctxt->style->headings_font) * 1.5); - - ctxt->pc = pc; - ctxt->pl = gnome_print_pango_create_layout (pc); -#warning FIXME gnome_print_multipage_new_from_sizes -#if 0 - ctxt->pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc, - 72 * style->paper_width, - 72 * style->paper_height, - 72 * style->page_width, - 72 * style->page_height)); -#endif - ctxt->book = book; - ctxt->query = query; - - if (uses_book) { - ctxt->contacts = NULL; - g_object_ref(book); - e_contact_do_print(book, ctxt->query, ctxt); - } - else if (uses_list) { - ctxt->contacts = g_list_copy (contact_list); - g_list_foreach (ctxt->contacts, (GFunc)g_object_ref, NULL); - complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, ctxt); - } - else { - ctxt->contacts = g_list_append(NULL, contact); - g_object_ref(contact); - complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, ctxt); - } - gtk_widget_destroy (dialog); - break; - case GNOME_PRINT_DIALOG_RESPONSE_CANCEL: - if (uses_book) - g_object_unref(book); - else if (uses_list) - e_free_object_list (contact_list); - else - g_object_unref(contact); - - if (query) - e_book_query_unref (query); - - gtk_widget_destroy (dialog); - g_free(style); - g_free(ctxt); - break; - } + else + res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL); + g_object_unref (settings); + g_object_unref (print); + g_object_unref (paper_size); + g_object_unref (page_setup); + g_object_unref (cpi); + gtk_widget_destroy (dialog); } + GtkWidget * e_contact_print_dialog_new(EBook *book, char *query, GList *list) { @@ -845,10 +823,7 @@ e_contact_print_dialog_new(EBook *book, char *query, GList *list) GList *copied_list = NULL; GList *l; - - dialog = e_print_get_dialog(_("Print contacts"), GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES); - gnome_print_dialog_construct_range_any(GNOME_PRINT_DIALOG(dialog), GNOME_PRINT_RANGE_ALL | GNOME_PRINT_RANGE_SELECTION, - NULL, NULL, NULL); + dialog = e_print_get_dialog(_("Print contacts"), GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES); if (list != NULL) { copied_list = g_list_copy (list); @@ -859,86 +834,23 @@ e_contact_print_dialog_new(EBook *book, char *query, GList *list) g_object_set_data(G_OBJECT(dialog), "contact_list", copied_list); g_object_set_data(G_OBJECT(dialog), "book", book); g_object_set_data(G_OBJECT(dialog), "query", e_book_query_from_string (query)); - g_object_set_data(G_OBJECT(dialog), "uses_range", GINT_TO_POINTER (TRUE)); + g_object_set_data(G_OBJECT(dialog), "uses_range", GINT_TO_POINTER (TRUE)); + g_signal_connect(dialog, "response", G_CALLBACK(e_contact_print_response), NULL); g_signal_connect(dialog, "close", G_CALLBACK(e_contact_print_close), NULL); return dialog; -} - -void -e_contact_print_preview(EBook *book, char *query, GList *list) -{ - EContactPrintContext *ctxt = g_new(EContactPrintContext, 1); - EContactPrintStyle *style = g_new(EContactPrintStyle, 1); - GnomePrintJob *master; - GnomePrintContext *pc; - GnomePrintConfig *config; - gdouble font_size; - GList *copied_list = NULL; - GList *l; - gboolean uses_book = FALSE, uses_list = FALSE; - - config = e_print_load_config (); - master = gnome_print_job_new (config); - pc = gnome_print_job_get_context (master); - e_contact_build_style (style, config); - - if (list == NULL) { - uses_book = TRUE; - } - else { - uses_list = TRUE; - copied_list = g_list_copy (list); - for (l = copied_list; l; l = l->next) - l->data = e_contact_duplicate (E_CONTACT (l->data)); - } - - ctxt->x = 0; - ctxt->y = 0; - ctxt->column = 0; - ctxt->style = style; - ctxt->master = master; - ctxt->first_section = TRUE; - ctxt->type = GNOME_PRINT_DIALOG_RESPONSE_PREVIEW; - font_size = 72 * ctxt->style->page_height / 27.0 / 2.0; - ctxt->letter_heading_font = find_font (pango_font_description_get_family(ctxt->style->headings_font), get_font_height (ctxt->style->headings_font) * 1.5); - - ctxt->pc = pc; - ctxt->pl = gnome_print_pango_create_layout (pc); -#warning FIXME gnome_print_multipage_new_from_sizes -#if 0 - ctxt->pc = GNOME_PRINT_CONTEXT(gnome_print_multipage_new_from_sizes(pc, - 72 * style->paper_width, - 72 * style->paper_height, - 72 * style->page_width, - 72 * style->page_height)); -#endif - ctxt->book = book; - ctxt->query = e_book_query_from_string (query); - - if (uses_book) { - ctxt->contacts = NULL; - g_object_ref (book); - e_contact_do_print (book, ctxt->query, ctxt); - } - else if(uses_list) { - ctxt->contacts = g_list_copy (copied_list); - g_list_foreach (ctxt->contacts, (GFunc)g_object_ref, NULL); - complete_sequence (NULL, E_BOOK_VIEW_STATUS_OK, ctxt); - } } GtkWidget * e_contact_print_contact_dialog_new(EContact *contact) { GtkWidget *dialog; - - dialog = e_print_get_dialog(_("Print contact"), GNOME_PRINT_DIALOG_COPIES); - contact = e_contact_duplicate(contact); + dialog = e_print_get_dialog(_("Print contact"), GNOME_PRINT_DIALOG_COPIES); + contact = e_contact_duplicate(contact); g_object_set_data(G_OBJECT(dialog), "contact", contact); g_object_set_data(G_OBJECT(dialog), "uses_list", GINT_TO_POINTER (FALSE)); g_object_set_data(G_OBJECT(dialog), "uses_book", GINT_TO_POINTER (FALSE)); @@ -976,3 +888,27 @@ e_contact_print_contact_list_dialog_new(GList *list) "close", G_CALLBACK(e_contact_print_close), NULL); return dialog; } + +static void +contact_draw_page (GtkPrintOperation *print, GtkPrintContext *context, gint page_nr, ContactPrintItem *cpi) +{ + cairo_t *cr; + EBookView *view; + EBookViewStatus status; + + cpi->ctxt->pc = context; + g_object_ref (cpi->ctxt->pc); + cpi->ctxt->pl =gtk_print_context_create_pango_layout (context); + + if (cpi->uses_book) { + complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, cpi->ctxt); + } + + else if (cpi->uses_list) { + complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, cpi->ctxt); + } + else { + cpi->ctxt->contacts = g_list_append(NULL,cpi->contact); + complete_sequence(NULL, E_BOOK_VIEW_STATUS_OK, cpi->ctxt); + } +} diff --git a/calendar/ChangeLog b/calendar/ChangeLog index b2cbdcd91d..ea05f7c425 100644 --- a/calendar/ChangeLog +++ b/calendar/ChangeLog @@ -1,3 +1,23 @@ +2007-01-22 Srinivasa Ragavan <sragavan@novell.com> + + Committing GtkPrint migration from Ebby Wiselyn. + + * gui/print.c: (evo_calendar_print_cal_data_new), + (evo_calendar_print_data_new), + (evo_calendar_print_renderer_get_width), + (print_border_with_triangles), (print_border_rgb), (print_border), + (print_rectangle), (print_text), (print_text_size), + (print_text_size_bold), (titled_box), (print_month_small), + (bound_text), (print_day_background), (print_day_add_event), + (print_day_long_event), (print_day_event), (print_day_details), + (print_week_long_event), (print_week_day_event), + (print_week_event), (print_week_view_background), + (print_week_summary), (print_month_summary), (print_todo_details), + (print_day_view), (print_week_view), (print_month_view), + (print_year_view), (print_comp_item), (print_calendar), + (print_comp), (print_title), (print_table), (comp_draw_page), + (cal_draw_page), (table_draw_page): + 2007-01-08 Veerapuram Varadhan <vvaradhan@novell.com> Patch submitted by Nathan Owens <pianocomp81@yahoo.com> and diff --git a/calendar/gui/print.c b/calendar/gui/print.c index cc83f1aa0d..b1f23d7cc2 100644 --- a/calendar/gui/print.c +++ b/calendar/gui/print.c @@ -33,11 +33,12 @@ #include <time.h> #include <glib.h> #include <gtk/gtkradiobutton.h> +#include <gtk/gtk.h> #include <libgnome/gnome-i18n.h> #include <libgnomeui/gnome-dialog.h> #include <libgnomeui/gnome-uidefs.h> #include <libgnomeui/gnome-stock-icons.h> -#include <libgnomeprint/gnome-print.h> +#include <libgnomeprint/gnome-print.h> #include <libgnomeprint/gnome-print-paper.h> #include <libgnomeprint/gnome-print-job.h> #include <libgnomeprintui/gnome-print-job-preview.h> @@ -50,6 +51,7 @@ #include <e-util/e-dialog-widgets.h> #include <e-util/e-print.h> #include <libecal/e-cal-time-util.h> +#include <libecal/e-cal-component.h> #include "calendar-commands.h" #include "calendar-config.h" #include "e-cal-model.h" @@ -61,43 +63,99 @@ #include "print.h" #include <libgnomeprint/gnome-print-pango.h> +#include <glade/glade-xml.h> +#include <gtk/gtkprintunixdialog.h> +#include <gtk/gtkwindow.h> +#include <gtk/gtkdialog.h> +#include <gtk/gtkpagesetupunixdialog.h> +#include <gtk/gtkprinter.h> + typedef struct EvoCalendarPrintRenderer EvoCalendarPrintRenderer; +typedef struct PrintCompItem PrintCompItem; +typedef struct PrintTableItem PrintTableItem; +typedef struct PrintCalItem PrintCalItem; struct EvoCalendarPrintRenderer { - GnomePrintContext *pc; + GtkPrintContext *pc; /* keep one of these around: */ PangoLayout *pl; }; -static EvoCalendarPrintRenderer * -evo_calendar_print_data_new (GnomePrintContext *pc); +struct PrintCompItem +{ + EvoCalendarPrintRenderer *pr; + struct ECal *client; + struct ECalComponent *comp; + double r,l,b,t; +}; + +struct PrintCalItem +{ + EvoCalendarPrintRenderer *pr; + struct GnomeCalendar *gcal; + PrintView default_view; + double r,l,b,t; + time_t date; +}; + +struct PrintTableItem +{ + struct EPrintable *printable; + double left_margin,bottom_margin,paper_width,paper_height; + GtkPrintContext *context; +}; + +static PrintCompItem * +evo_calendar_print_data_new (GtkPrintContext *pc, PrintCompItem *pci); static void evo_calendar_print_data_free (EvoCalendarPrintRenderer *pr); +static void +comp_draw_page (GtkPrintOperation *print, + GtkPrintContext *context, + gint page_nr, + PrintCompItem *pci); +static void +cal_draw_page (GtkPrintOperation *print, + GtkPrintContext *context, + gint page_nr, + PrintCalItem *pcali); +static void +table_draw_page (GtkPrintOperation *print, + GtkPrintContext *context, + gint page_nr1, + PrintTableItem *pti); + static double evo_calendar_print_renderer_get_width (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, const char *text); - -static EvoCalendarPrintRenderer * -evo_calendar_print_data_new (GnomePrintContext *pc) +static PrintCalItem * +evo_calendar_print_cal_data_new (GtkPrintContext *pc, PrintCalItem *pcali) { - EvoCalendarPrintRenderer *pr; - g_return_val_if_fail (pc, NULL); + + pcali->pr = g_new0 (EvoCalendarPrintRenderer, 1); + pcali->pr->pc = pc; + pcali->pr->pl = gtk_print_context_create_pango_layout (pc); + + return pcali; +} +static PrintCompItem * +evo_calendar_print_data_new (GtkPrintContext *pc,PrintCompItem *pci) +{ + g_return_val_if_fail (pc, NULL); + + pci->pr = g_new0 (EvoCalendarPrintRenderer, 1); + pci->pr->pc = pc; + pci->pr->pl = gtk_print_context_create_pango_layout (pc); - pr = g_new0 (EvoCalendarPrintRenderer, 1); - - pr->pc = pc; /* ref/unref this? the old code doesn't */ - - pr->pl = gnome_print_pango_create_layout (pc); - - return pr; + return pci; } static void @@ -122,7 +180,6 @@ evo_calendar_print_renderer_get_width (EvoCalendarPrintRenderer *pr, pango_layout_set_font_description (pr->pl, font); pango_layout_set_text (pr->pl, text, -1); pango_layout_set_indent (pr->pl, 0); - pango_layout_get_size (pr->pl, &w, &h); return w/(double)PANGO_SCALE; @@ -370,50 +427,66 @@ enum align_box { left_triangle_width, right_triangle_width = width from edge of rectangle to point of triangle, or -ve for no triangle. */ static void -print_border_with_triangles (GnomePrintContext *pc, +print_border_with_triangles (GtkPrintContext *pc, double l, double r, double t, double b, double width, double red, double green, double blue, double left_triangle_width, double right_triangle_width) { - gnome_print_gsave (pc); + cairo_t *cr; + + cr = gtk_print_context_get_cairo_context (pc); + cairo_save (cr); /* Fill in the interior of the rectangle, if desired. */ if (red >= -EPSILON && green >= -EPSILON && blue >= -EPSILON) { - gnome_print_moveto (pc, l, t); + + cairo_move_to (cr, l, t); + if (left_triangle_width > 0.0) - gnome_print_lineto (pc, l - left_triangle_width, - (t + b) / 2); - gnome_print_lineto (pc, l, b); - gnome_print_lineto (pc, r, b); + cairo_line_to (cr, l - left_triangle_width, + (t + b) / 2); + + cairo_line_to (cr, l, b); + cairo_line_to (cr, r, b); + if (right_triangle_width > 0.0) - gnome_print_lineto (pc, r + right_triangle_width, - (t + b) / 2); - gnome_print_lineto (pc, r, t); - gnome_print_closepath (pc); - gnome_print_setrgbcolor (pc, red, green, blue); - gnome_print_fill (pc); + cairo_line_to (cr, r + right_triangle_width, (t + b) / 2); + + cairo_line_to (cr, r, t); + cairo_close_path (cr); + cairo_set_source_rgb (cr, red, green, blue); + cairo_fill (cr); + cairo_restore (cr); + cairo_save (cr); } /* Draw the outline, if desired. */ if (width >= -EPSILON) { - gnome_print_moveto (pc, l, t); + + cr = gtk_print_context_get_cairo_context (pc); + cairo_move_to (cr, l, t); + if (left_triangle_width > 0.0) - gnome_print_lineto (pc, l - left_triangle_width, + cairo_line_to (cr, l - left_triangle_width, (t + b) / 2); - gnome_print_lineto (pc, l, b); - gnome_print_lineto (pc, r, b); + + cairo_line_to (cr, l, b); + cairo_line_to (cr, r, b); + if (right_triangle_width > 0.0) - gnome_print_lineto (pc, r + right_triangle_width, + cairo_line_to (cr, r + right_triangle_width, (t + b) / 2); - gnome_print_lineto (pc, r, t); - gnome_print_closepath (pc); - gnome_print_setrgbcolor (pc, 0, 0, 0); - gnome_print_setlinewidth (pc, width); - gnome_print_stroke (pc); + + cairo_line_to (cr, r, t); + cairo_close_path (cr); + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_set_line_width (cr, width); + cairo_stroke (cr); + } - gnome_print_grestore (pc); + cairo_restore (cr); } @@ -421,7 +494,7 @@ print_border_with_triangles (GnomePrintContext *pc, width = width of border, -ve means no border. fillcolor = shade of fill, -ve means no fill. */ static void -print_border_rgb (GnomePrintContext *pc, +print_border_rgb (GtkPrintContext *pc, double l, double r, double t, double b, double width, double red, double green, double blue) { @@ -429,7 +502,7 @@ print_border_rgb (GnomePrintContext *pc, } static void -print_border (GnomePrintContext *pc, +print_border (GtkPrintContext *pc, double l, double r, double t, double b, double width, double fillcolor) { @@ -437,25 +510,26 @@ print_border (GnomePrintContext *pc, } static void -print_rectangle (GnomePrintContext *pc, +print_rectangle (GtkPrintContext *pc, double l, double r, double t, double b, double red, double green, double blue) { - gnome_print_gsave (pc); - - gnome_print_moveto (pc, l, t); - gnome_print_lineto (pc, l, b); - gnome_print_lineto (pc, r, b); - gnome_print_lineto (pc, r, t); - gnome_print_closepath (pc); - gnome_print_setrgbcolor (pc, red, green, blue); - gnome_print_fill (pc); - - gnome_print_grestore (pc); + cairo_t *cr; + + cr = gtk_print_context_get_cairo_context (pc); + cairo_save (cr); + + cairo_move_to (cr, l, t); + cairo_line_to (cr, l, b); + cairo_line_to (cr, r, b); + cairo_line_to (cr, r, t); + cairo_close_path (cr); + cairo_set_source_rgb (cr, red, green, blue); + cairo_fill (cr); + + cairo_restore (cr); } - - /* Prints 1 line of aligned text in a box. It is centered vertically, and the horizontal alignment can be either ALIGN_LEFT, ALIGN_RIGHT, or ALIGN_CENTER. */ @@ -465,7 +539,10 @@ print_text (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, const char { double w, x; int pw, ph; - gnome_print_gsave (pr->pc); + cairo_t *cr; + + cr = gtk_print_context_get_cairo_context (pr->pc); + cairo_save (cr); pango_layout_set_font_description (pr->pl, font); pango_layout_set_text (pr->pl, text, -1); @@ -491,20 +568,18 @@ print_text (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, const char x = MAX (l, x); /* Set a clipping rectangle. */ - gnome_print_moveto (pr->pc, l, t); - gnome_print_lineto (pr->pc, r, t); - gnome_print_lineto (pr->pc, r, b); - gnome_print_lineto (pr->pc, l, b); - gnome_print_closepath (pr->pc); - gnome_print_clip (pr->pc); + cairo_move_to (cr, l, t); + cairo_rectangle (cr, l, t, r, b); + cairo_clip (cr); - gnome_print_newpath (pr->pc); - gnome_print_setrgbcolor (pr->pc, 0, 0, 0); + cairo_new_path (cr); + cairo_set_source_rgb (cr, 0, 0, 0); - gnome_print_moveto (pr->pc, x, t); - gnome_print_pango_layout (pr->pc, pr->pl); + cairo_move_to (cr, x, t); + pango_cairo_show_layout (cr, pr->pl); - gnome_print_grestore (pr->pc); + cairo_stroke(cr); + cairo_restore (cr); return w; } @@ -516,8 +591,13 @@ print_text_size(EvoCalendarPrintRenderer *pr, const char *text, { PangoFontDescription *font; double w; - - font = get_font_for_size (pr, t - b, GNOME_FONT_BOOK, FALSE); + + if(t > b) + font = get_font_for_size (pr,t - b, GNOME_FONT_BOOK, FALSE); + else + { + font = get_font_for_size (pr, b - t , GNOME_FONT_BOOK, FALSE); + } w = print_text(pr, font, text, align, l, r, t, b); pango_font_description_free (font); @@ -532,7 +612,11 @@ print_text_size_bold(EvoCalendarPrintRenderer *pr, const char *text, PangoFontDescription *font; double w; - font = get_font_for_size (pr, t - b, GNOME_FONT_BOLD, FALSE); + if (t > b) + font = get_font_for_size (pr, t - b , GNOME_FONT_BOLD, FALSE); + else + font = get_font_for_size (pr, b - t, GNOME_FONT_BOLD, FALSE); + w = print_text(pr, font, text, align, l, r, t, b); pango_font_description_free (font); @@ -547,20 +631,17 @@ titled_box (EvoCalendarPrintRenderer *pr, const char *text, PangoFontDescription double size; size = get_font_size (font); - if (align & ALIGN_BORDER) { - print_border (pr->pc, *l, *r, *t, *t - size * 1.4, + print_border (pr->pc, *l, *r, *t, *t + size * 1.4, linewidth, 0.9); - print_border (pr->pc, *l, *r, *t - size * 1.4, *b, + print_border (pr->pc, *l, *r, *t + size * 1.4, *b, linewidth, -1.0); - *l += 2; *r -= 2; *b += 2; } - - print_text (pr, font, text, align, *l, *r, *t, *t - size * 1.4); - *t -= size * 1.4; + print_text (pr, font, text, align, *l, *r, *t, *t + size * 1.4); + *t += size * 1.4; } enum datefmt { @@ -630,7 +711,6 @@ instance_cb (ECalComponent *comp, time_t instance_start, time_t instance_end, gp return FALSE; } - /* print out the month small, embolden any days with events. */ @@ -651,29 +731,38 @@ print_month_small (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t mon double font_size, max_font_size; double header_size, col_width, row_height, text_xpad, w; double cell_top, cell_bottom, cell_left, cell_right, text_right; + /* Translators: These are workday abbreviations, e.g. Su=Sunday and Th=Thursday */ char *daynames[] = { N_("Su"), N_("Mo"), N_("Tu"), N_("We"), N_("Th"), N_("Fr"), N_("Sa") }; + cairo_t *cr; /* Print the title, e.g. 'June 2001', in the top 16% of the area. */ format_date (month, titleflags, buf, 100); - header_size = (top - bottom) * 0.16; + + if(top < bottom) + header_size = (bottom - top) * 0.16; + else + header_size = (top - bottom) * 0.16; + font = get_font_for_size (pr, header_size, GNOME_FONT_BOLD, FALSE); if (bordertitle) { - print_border (pr->pc, left, right, top, top - header_size, + print_border (pr->pc, left, right, top, top + header_size, 1.0, 0.9); } print_text (pr, font, buf, ALIGN_CENTER, left, right, - top, top - header_size); + top, top + header_size); pango_font_description_free (font); - top -= header_size; - + top += header_size; col_width = (right - left) / 7; /* The top row with the day abbreviations gets an extra bit of vertical space around it. */ - row_height = (top - bottom) / 7.4; + if (bottom > top ) + row_height = (bottom - top) / 7.4; + else + row_height = (top - bottom ) / 7.4; /* First we need to calculate a reasonable font size. We start with a rough guess of just under the height of each row. */ @@ -683,8 +772,8 @@ print_month_small (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t mon twice as high as they are wide, but we need to fit two characters into each cell, so we don't want to go over col_width. */ max_font_size = col_width * 0.65; - /* Why calculate this if we're not using it? */ + /* Why calculate this if we're not using it? */ font_size = row_height; /* get month days */ @@ -700,7 +789,8 @@ print_month_small (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t mon w = evo_calendar_print_renderer_get_width (pr, font_bold, "23"); text_xpad = (col_width - w) / 2; - gnome_print_setrgbcolor (pr->pc, 0, 0, 0); + cr = gtk_print_context_get_cairo_context (pr->pc); + cairo_set_source_rgb (cr, 0, 0, 0); /* Print the abbreviated day names across the top in bold. */ week_start_day = calendar_config_get_week_start_day (); @@ -708,17 +798,17 @@ print_month_small (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t mon for (x = 0; x < 7; x++) { print_text (pr, font_bold, _(daynames[weekday]), ALIGN_CENTER, left + x * col_width, left + (x + 1) * col_width, - top, top - row_height * 1.4); + top, top + row_height * 1.4); weekday = (weekday + 1) % 7; } - top -= row_height * 1.4; + top += row_height * 1.4; now = time_month_begin_with_zone (month, zone); for (y = 0; y < 6; y++) { - cell_top = top - y * row_height; - cell_bottom = cell_top - row_height; + cell_top = top + y * row_height; + cell_bottom = cell_top + row_height; for (x = 0; x < 7; x++) { @@ -733,7 +823,6 @@ print_month_small (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t mon day = days[y * 7 + x]; if (day != 0) { gboolean found = FALSE; - sprintf (buf, "%d", day); /* this is a slow messy way to do this ... but easy ... */ @@ -744,12 +833,12 @@ print_month_small (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t mon font = found ? font_bold : font_normal; next = time_add_day_with_zone (now, 1, zone); - if ((now >= greystart && now < greyend) + if ((now >= greystart && now < greyend) || (greystart >= now && greystart < next)) { print_border (pr->pc, cell_left, cell_right, cell_top, cell_bottom, - -1.0, 0.75); + -1.0, 0.75); } print_text (pr, font, buf, ALIGN_RIGHT, cell_left, text_right, @@ -766,36 +855,34 @@ print_month_small (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t mon /* wraps text into the print context, not taking up more than its allowed space */ static double -bound_text(EvoCalendarPrintRenderer *pr, PangoFontDescription *font, const char *text, +bound_text (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, const char *text, double left, double right, double top, double bottom, double indent) { /* Let Pango do all the work: */ - int w, h; - - gnome_print_gsave (pr->pc); + int w=0, h=0; + cairo_t *cr; + + cr = gtk_print_context_get_cairo_context (pr->pc); + cairo_save (cr); /* Set a clipping rectangle. */ - gnome_print_moveto (pr->pc, left, top); - gnome_print_lineto (pr->pc, right, top); - gnome_print_lineto (pr->pc, right, bottom); - gnome_print_lineto (pr->pc, left, bottom); - gnome_print_closepath (pr->pc); - gnome_print_clip (pr->pc); - - gnome_print_newpath (pr->pc); + cairo_move_to (cr, left, top); + cairo_rectangle (cr, left, top, right, bottom); + cairo_clip (cr); + cairo_new_path (cr); pango_layout_set_font_description (pr->pl, font); pango_layout_set_text (pr->pl, text, -1); pango_layout_set_indent (pr->pl, indent * PANGO_SCALE); pango_layout_set_width (pr->pl, (right-left)*PANGO_SCALE); - gnome_print_moveto (pr->pc, left, top); - gnome_print_pango_layout (pr->pc, pr->pl); - - gnome_print_grestore (pr->pc); - - pango_layout_get_size (pr->pl, &w, &h); - return top - (double)h/(double)PANGO_SCALE; + cairo_move_to (cr, left, top); + pango_cairo_show_layout (cr, pr->pl); + cairo_stroke (cr); + + cairo_restore (cr); + pango_layout_get_size (pr->pl, &w, &h); + return top + ((double)h/(double)PANGO_SCALE); } @@ -814,22 +901,29 @@ print_day_background (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, gboolean use_24_hour; int i, hour, row; double hour_minute_x; - + cairo_t *cr; + /* Fill the time column in light-gray. */ print_border (pr->pc, left, left + width, top, bottom, -1.0, 0.9); /* Draw the border around the entire view. */ - gnome_print_setrgbcolor (pr->pc, 0, 0, 0); - print_border (pr->pc, left, right, top, bottom, 1.0, -1.0); + cr = gtk_print_context_get_cairo_context (pr->pc); - /* Draw the vertical line on the right of the time column. */ - gnome_print_setlinewidth (pr->pc, 0.0); - gnome_print_moveto (pr->pc, left + width, bottom); - gnome_print_lineto (pr->pc, left + width, top); - gnome_print_stroke (pr->pc); + cairo_set_source_rgb (cr, 0, 0, 0); + print_border (pr->pc, left, right, top, bottom, 1.0, -1.0); + /* Draw the vertical line on the right of the time column. */ + cr = gtk_print_context_get_cairo_context (pr->pc); + cairo_set_line_width (cr, 0.0); + cairo_move_to (cr, left + width, bottom); + cairo_line_to (cr, left + width, top); + cairo_stroke (cr); + /* Calculate the row height. */ - yinc = (top - bottom) / (pdi->end_hour - pdi->start_hour); + if (top > bottom) + yinc = (top - bottom) / (pdi->end_hour - pdi->start_hour); + else + yinc = (bottom - top) / (pdi->end_hour - pdi->start_hour); /* Get the 2 fonts we need. */ font_size = yinc * 0.6; @@ -847,8 +941,9 @@ print_day_background (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, row = 0; hour_minute_x = left + width * 0.58; for (i = pdi->start_hour; i < pdi->end_hour; i++) { - y = top - yinc * (row + 1); - gnome_print_setrgbcolor (pr->pc, 0, 0, 0); + y = top + yinc * (row + 1) ; + cr = gtk_print_context_get_cairo_context (pr->pc); + cairo_set_source_rgb (cr, 0, 0, 0); if (use_24_hour) { hour = i; @@ -868,24 +963,26 @@ print_day_background (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, sprintf (buf, "%d", hour); print_text (pr, font_hour, buf, ALIGN_RIGHT, left, hour_minute_x, - y + yinc - 4, y + yinc - 4 - hour_font_size); + y - yinc + yinc / 2, y - yinc + yinc / 2 + hour_font_size); print_text (pr, font_minute, minute, ALIGN_LEFT, hour_minute_x, left + width - 3, - y + yinc - 3, y + yinc - 3 - minute_font_size); - - /* Draw the horizontal line between hours, across the entire + y - yinc + yinc / 2, y - yinc + yinc / 2 + minute_font_size); + + /* Draw the horizontal line between hours, across the entire width of the day view. */ - gnome_print_moveto (pr->pc, left, y); - gnome_print_lineto (pr->pc, right, y); - gnome_print_stroke (pr->pc); - + cr = gtk_print_context_get_cairo_context (pr->pc); + cairo_move_to (cr, left, y); + cairo_line_to (cr, right, y); + cairo_set_line_width (cr, 1); + cairo_stroke (cr); + /* Draw the horizontal line for the 1/2-hours, across the entire width except for part of the time column. */ - gnome_print_moveto (pr->pc, left + width * 0.6, y + yinc / 2); - gnome_print_lineto (pr->pc, right, y + yinc / 2); - gnome_print_stroke (pr->pc); - - row++; + cairo_move_to (cr, left + width * 0.6, y - yinc / 2); + cairo_line_to (cr, right, y - yinc / 2); + cairo_set_line_width (cr, 1); + cairo_stroke (cr); + row ++; } pango_font_description_free (font_hour); @@ -956,7 +1053,6 @@ print_day_add_event (ECalModelComponent *comp_data, event.end_minute = 24 * 60; } - g_array_append_val (events[day], event); return day; } @@ -1027,8 +1123,8 @@ print_day_long_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, x1 = left + 10; x2 = right - 10; - y1 = top - event->start_row_or_col * row_height - 4; - y2 = y1 - row_height + 4; + y1 = top + event->start_row_or_col * row_height + 4; + y2 = y1 + row_height-7; red = green = blue = 0.95; e_cal_model_get_rgb_color_for_component (model, event->comp_data, &red, &green, &blue); print_border_with_triangles (pr->pc, x1, x2, y1, y2, 0.5, red, green, blue, @@ -1114,11 +1210,10 @@ print_day_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, x1 = left + event->start_row_or_col * col_width; x2 = x1 + event->num_columns * col_width - DAY_VIEW_EVENT_X_PAD; - row_height = (top - bottom) / pdi->rows; - y1 = top - start_row * row_height; - y2 = top - (end_row + 1) * row_height; - -#if 0 + row_height = (bottom - top) / pdi->rows; + y1 = top + start_row * row_height; + y2 = top + (end_row + 1) * row_height; +#if 0 g_print ("Event: %g,%g %g,%g\n row_height: %g start_row: %i top: %g rows: %i\n", x1, y1, x2, y2, row_height, start_row, top, pdi->rows); #endif @@ -1129,7 +1224,7 @@ print_day_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, summary = icalcomponent_get_summary (event->comp_data->icalcomp); text = summary ? (char*) summary : ""; - + if (display_times) { date_tm.tm_year = 2001; @@ -1173,6 +1268,8 @@ print_day_details (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t whe struct pdinfo pdi; gint rows_in_top_display, i; double font_size, max_font_size; + cairo_t *cr; + ECalModel *model = gnome_calendar_get_calendar_model (gcal); start = time_day_begin_with_zone (whence, zone); @@ -1226,15 +1323,14 @@ print_day_details (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t whe e_day_view_layout_long_events (pdi.long_events, pdi.days_shown, pdi.day_starts, &rows_in_top_display); - /* Print the long events. */ + /*Print the long events. */ font = get_font_for_size (pr, 12, GNOME_FONT_BOOK, FALSE); for (i = 0; i < pdi.long_events->len; i++) { event = &g_array_index (pdi.long_events, EDayViewEvent, i); print_day_long_event (pr, font, left, right, top, bottom, DAY_VIEW_ROW_HEIGHT, event, &pdi, model); } - pango_font_description_free (font); - + /* We always leave space for DAY_VIEW_MIN_ROWS_IN_TOP_DISPLAY in the top display, but we may have more rows than that, in which case the main display area will be compressed. */ @@ -1242,38 +1338,44 @@ print_day_details (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t whe DAY_VIEW_MIN_ROWS_IN_TOP_DISPLAY); /* Draw the border around the long events. */ - gnome_print_setrgbcolor (pr->pc, 0, 0, 0); - print_border (pr->pc, left, right, - top, top - rows_in_top_display * DAY_VIEW_ROW_HEIGHT - 4, - 1.0, -1.0); + cr = gtk_print_context_get_cairo_context (pr->pc); + cairo_set_source_rgb (cr, 0, 0, 0); + print_border (pr->pc, left, right, + top, top + rows_in_top_display * DAY_VIEW_ROW_HEIGHT - 4, + 1.0, -1.0); + /* Adjust the area containing the main display. */ - top -= rows_in_top_display * DAY_VIEW_ROW_HEIGHT + 4; - + top += rows_in_top_display * DAY_VIEW_ROW_HEIGHT - 2; + /* Draw the borders, lines, and times down the left. */ print_day_background (pr, gcal, whence, &pdi, left, right, top, bottom); - /* Now adjust to get rid of the time column. */ left += DAY_VIEW_TIME_COLUMN_WIDTH; - - /* Lay out the short events, within the day. */ + + + /* lay out the short events, within the day. */ e_day_view_layout_day_events (pdi.events[0], DAY_VIEW_ROWS, DAY_VIEW_MINS_PER_ROW, pdi.cols_per_row); - /* Print the short events. */ - max_font_size = ((top - bottom) / pdi.rows) - 4; - font_size = MIN (DAY_NORMAL_FONT_SIZE, max_font_size); + /* print the short events. */ + if (top > bottom ) + max_font_size = ((top - bottom) / pdi.rows) - 4; + else + max_font_size = ((bottom - top ) / pdi.rows) - 4; + font_size = MIN(DAY_NORMAL_FONT_SIZE, max_font_size); font = get_font_for_size (pr, font_size, GNOME_FONT_BOOK, FALSE); + for (i = 0; i < pdi.events[0]->len; i++) { event = &g_array_index (pdi.events[0], EDayViewEvent, i); print_day_event (pr, font, left, right, top, bottom, event, &pdi, model); } - pango_font_description_free (font); - + /* Free everything. */ free_event_array (pdi.long_events); + pango_font_description_free (font); g_array_free (pdi.long_events, TRUE); free_event_array (pdi.events[0]); g_array_free (pdi.events[0], TRUE); @@ -1319,7 +1421,7 @@ print_week_long_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, if (event->end > psi->day_starts[span->start_day + span->num_days]) right_triangle_width = 4; - print_border_with_triangles (pr->pc, x1, x2, y1, y2, 0.5, red, green, blue, + print_border_with_triangles (pr->pc, x1, x2, y1, y2 + 4, 0.5, red, green, blue, left_triangle_width, right_triangle_width); @@ -1385,20 +1487,19 @@ print_week_day_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, e_time_format_time (&date_tm, psi->use_24_hour_format, FALSE, buffer, sizeof (buffer)); - - print_rectangle (pr->pc, x1, x2, y1, y2, red, green, blue); - x1 += print_text_size (pr, buffer, ALIGN_LEFT, x1, x2, y1, y2) + 4; - print_text_size (pr, text, ALIGN_LEFT, x1, x2, y1, y2); - + print_rectangle (pr->pc, x1, x2 + 6, y1, y2 + 4, red, green, blue); + x1 += print_text_size (pr, buffer, ALIGN_LEFT, x1, x2, y1, y2 + 3 ) + 4; + print_text_size (pr, text, ALIGN_LEFT, x1, x2, y1, y2 + 3); + date_tm.tm_hour = event->end_minute / 60; date_tm.tm_min = event->end_minute % 60; e_time_format_time (&date_tm, psi->use_24_hour_format, FALSE, buffer, sizeof (buffer)); - print_rectangle (pr->pc, x1, x2, y1, y2, red, green, blue); - x1 += print_text_size (pr, buffer, ALIGN_LEFT, x1, x2, y1, y2) + 4; - print_text_size (pr, text, ALIGN_LEFT, x1, x2, y1, y2); + print_rectangle (pr->pc, x1, x2 + 6, y1, y2 + 4, red, green, blue); + x1 += print_text_size (pr, buffer, ALIGN_LEFT, x1, x2, y1, y2 + 3) + 4; + print_text_size (pr, text, ALIGN_LEFT, x1, x2, y1, y2 + 3); } @@ -1457,11 +1558,12 @@ print_week_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, } x1 = left + start_x * cell_width + 6; - x2 = left + (end_x + 1) * cell_width - 6; - y1 = top - start_y * cell_height - - psi->header_row_height - - span->row * psi->row_height; - y2 = y1 - psi->row_height * 0.9; + x2 = left + (end_x + 1) * cell_width - 16; + y1 = top + start_y * cell_height + + psi->header_row_height + + span->row * psi->row_height; + y2 = y1 + psi->row_height * 0.5; + red = .9; green = .9; @@ -1471,12 +1573,12 @@ print_week_event (EvoCalendarPrintRenderer *pr, PangoFontDescription *font, psi->day_starts)) { print_week_day_event (pr, font, psi, x1, x2, y1, y2, - event, span, text, red, green, blue); + event, span, text, red, green, blue); } else { print_week_long_event (pr, font, psi, x1, x2, y1, y2, event, span, text, red, green, blue); - } + } } } } @@ -1489,10 +1591,11 @@ print_week_view_background (EvoCalendarPrintRenderer *pr, PangoFontDescription * double cell_width, double cell_height) { icaltimezone *zone = calendar_config_get_icaltimezone (); + struct tm tm; int day, day_x, day_y, day_h; double x1, x2, y1, y2, font_size, fillcolor; - struct tm tm; char *format_string, buffer[128]; + cairo_t *cr; font_size = get_font_size (font); @@ -1504,8 +1607,8 @@ print_week_view_background (EvoCalendarPrintRenderer *pr, PangoFontDescription * x1 = left + day_x * cell_width; x2 = left + (day_x + 1) * cell_width; - y1 = top - day_y * cell_height; - y2 = y1 - day_h * cell_height; + y1 = top + day_y * cell_height; + y2 = y1 + day_h * cell_height; tm = *convert_timet_to_struct_tm (psi->day_starts[day], zone); @@ -1523,13 +1626,16 @@ print_week_view_background (EvoCalendarPrintRenderer *pr, PangoFontDescription * else format_string = "%d"; } else { - gnome_print_moveto (pr->pc, x1 + 0.1 * cell_width, - y1 - psi->header_row_height + 3); - gnome_print_lineto (pr->pc, x2, - y1 - psi->header_row_height + 3); - gnome_print_setrgbcolor (pr->pc, 0, 0, 0); - gnome_print_setlinewidth (pr->pc, 0.5); - gnome_print_stroke (pr->pc); + cr = gtk_print_context_get_cairo_context (pr->pc); + + cairo_move_to (cr, x1 + 0.1 * cell_width, + y1 + psi->header_row_height - 4); + cairo_line_to (cr, x2, + y1 + psi->header_row_height - 4); + + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_set_line_width (cr, 0.5); + cairo_stroke (cr); /* strftime format %A = full weekday name, %d = day of month, %B = full month name. You can change the @@ -1540,8 +1646,9 @@ print_week_view_background (EvoCalendarPrintRenderer *pr, PangoFontDescription * } e_utf8_strftime (buffer, sizeof (buffer), format_string, &tm); - print_text_size (pr, buffer, ALIGN_RIGHT, - x1, x2 - 4, y1 - 2, y1 - 2 - font_size); + + print_text_size (pr, buffer, ALIGN_RIGHT, + x1, x2 - 4, y1 + 2, y1 + 2 + font_size); } } @@ -1652,11 +1759,12 @@ print_week_summary (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, /* Calculate the size of the cells. */ if (multi_week_view) { cell_width = (right - left) / (psi.compress_weekend ? 6 : 7); - cell_height = (top - bottom) / (weeks_shown * 2); + cell_height = (bottom - top) / (weeks_shown * 2); } else { cell_width = (right - left) / 2; - cell_height = (top - bottom) / 6; + cell_height = (bottom - top) / 6; } + /* Calculate the row height, using the normal font and with room for space or a rectangle around it. */ @@ -1670,11 +1778,9 @@ print_week_summary (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, / psi.row_height; font = get_font_for_size (pr, font_size, GNOME_FONT_BOOK, FALSE); - /* Draw the grid and the day names/numbers. */ print_week_view_background (pr, font, &psi, left, top, cell_width, cell_height); - /* Print the events. */ for (event_num = 0; event_num < psi.events->len; event_num++) { event = &g_array_index (psi.events, EWeekViewEvent, event_num); @@ -1781,7 +1887,7 @@ print_month_summary (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t w columns = compress_weekend ? 6 : 7; cell_width = (right - left) / columns; y1 = top; - y2 = top - font_size * 1.5; + y2 = top + font_size * 1.5; for (col = 0; col < columns; col++) { if (tm.tm_wday == 6 && compress_weekend) { @@ -1825,6 +1931,7 @@ print_todo_details (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, ETable *table; ECalModel *model; gint rows, row; + cairo_t *cr; /* We get the tasks directly from the TaskPad ETable. This means we get them filtered & sorted for free. */ @@ -1832,15 +1939,18 @@ print_todo_details (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, table = e_calendar_table_get_table (task_pad); model = e_calendar_table_get_model (task_pad); - font_summary = get_font_for_size (pr, 10, GNOME_FONT_BOOK, FALSE); + font_summary = get_font_for_size (pr, 12, GNOME_FONT_BOOK, FALSE); - gnome_print_setrgbcolor (pr->pc, 0, 0, 0); - gnome_print_setlinewidth (pr->pc, 0.0); + cr = gtk_print_context_get_cairo_context (pr->pc); + + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_set_line_width (cr, 0.0); + top +=2; titled_box (pr, _("Tasks"), font_summary, ALIGN_CENTER | ALIGN_BORDER, &left, &right, &top, &bottom, 1.0); - y = top - 3; + y = top; yend = bottom - 2; rows = e_table_model_row_count (E_TABLE_MODEL (model)); @@ -1866,34 +1976,36 @@ print_todo_details (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, x = left; xend = right - 2; - - if (y < bottom) + if (y > bottom) break; /* Print the box to put the tick in. */ - print_border (pr->pc, x + 2, x + 8, y - 3, y - 11, 0.1, -1.0); + print_border (pr->pc, x + 2, x + 8, y + 6, y + 15, 0.1, -1.0); /* If the task is complete, print a tick in the box. */ e_cal_component_get_completed (comp, &tt); if (tt) { e_cal_component_free_icaltimetype (tt); - gnome_print_setrgbcolor (pr->pc, 0, 0, 0); - gnome_print_setlinewidth (pr->pc, 1.0); - gnome_print_moveto (pr->pc, x + 3, y - 8); - gnome_print_lineto (pr->pc, x + 5, y - 10); - gnome_print_lineto (pr->pc, x + 7, y - 3.5); - gnome_print_stroke (pr->pc); + cr = gtk_print_context_get_cairo_context (pr->pc); + cairo_set_source_rgb (cr, 0, 0, 0); + cairo_move_to (cr, x + 3, y + 11); + cairo_line_to (cr, x + 5, y + 14); + cairo_line_to (cr, x + 7, y + 5.5); + cairo_set_line_width (cr, 1); + cairo_stroke (cr); } y = bound_text (pr, font_summary, summary.value, - x + 10, xend, y, yend, 0); + x + 14, xend, y+4, yend, 0); + - y += get_font_size (font_summary) - 12; - gnome_print_moveto (pr->pc, x, y); - gnome_print_lineto (pr->pc, xend, y); - gnome_print_stroke (pr->pc); - y -= 3; + y += get_font_size (font_summary)-5; + cr = gtk_print_context_get_cairo_context (pr->pc); + cairo_move_to (cr, x, y); + cairo_line_to (cr, xend, y); + cairo_set_line_width (cr, 1); + cairo_stroke (cr); g_object_unref (comp); } @@ -2007,53 +2119,60 @@ print_day_view (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t date, int i, days = 1; double todo, header, l; char buf[100]; + cairo_t *cr; for (i = 0; i < days; i++) { todo = (right - left) * 0.75 + left; - header = top - HEADER_HEIGHT; + /* header = top - HEADER_HEIGHT;*/ + header = HEADER_HEIGHT + top; - gnome_print_beginpage (pr->pc, NULL); + cr = gtk_print_context_get_cairo_context (pr->pc); /* Print the main view with all the events in. */ print_day_details (pr, gcal, date, left, todo - 2.0, header, bottom); - - /* Print the TaskPad down the right. */ + + /* Print the TaskPad down the right. */ print_todo_details (pr, gcal, 0, INT_MAX, todo, right, header, bottom); - + /* Print the filled border around the header. */ print_border (pr->pc, left, right, top, header + 2.0, 1.0, 0.9); - + /* Print the 2 mini calendar-months. */ - l = right - SMALL_MONTH_PAD - SMALL_MONTH_WIDTH * 2 - - SMALL_MONTH_SPACING; - print_month_small (pr, gcal, date, + l = right - SMALL_MONTH_PAD - SMALL_MONTH_WIDTH * 2 - SMALL_MONTH_SPACING; + + print_month_small (pr, gcal, date, l, l + SMALL_MONTH_WIDTH, - top - 4, header + 4, + top + 4, header + 4, DATE_MONTH | DATE_YEAR, date, date, FALSE); + l += SMALL_MONTH_SPACING + SMALL_MONTH_WIDTH; print_month_small (pr, gcal, time_add_month_with_zone (date, 1, zone), l, l + SMALL_MONTH_WIDTH, - top - 4, header + 4, + top + 4, header + 4, DATE_MONTH | DATE_YEAR, 0, 0, FALSE); - + + /* Print the date, e.g. '8th May, 2001'. */ format_date (date, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); + print_text_size_bold (pr, buf, ALIGN_LEFT, - left + 4, todo, top - 4, top - 4 - 24); + left + 4, todo, top + 4, top + 4 + 24); /* Print the day, e.g. 'Tuesday'. */ format_date (date, DATE_DAYNAME, buf, 100); + print_text_size_bold (pr, buf, ALIGN_LEFT, - left + 4, todo, top - 32, top - 32 - 18); + left + 4, todo, top + 32, top + 32 + 18); - gnome_print_showpage (pr->pc); + cr = gtk_print_context_get_cairo_context (pr->pc); + date = time_add_day_with_zone (date, 1, zone); - } + } } @@ -2068,13 +2187,11 @@ print_week_view (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t date, gint week_start_day; struct tm tm; - header = top - HEADER_HEIGHT; - - gnome_print_beginpage (pr->pc, NULL); - + header = HEADER_HEIGHT - top; tm = *convert_timet_to_struct_tm (date, zone); week_start_day = calendar_config_get_week_start_day (); when = time_week_begin_with_zone (date, week_start_day, zone); + /* If the week starts on a Sunday, we have to show the Saturday first, since the weekend is compressed. */ if (week_start_day == 0) { @@ -2087,20 +2204,21 @@ print_week_view (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t date, /* Print the main week view. */ print_week_summary (pr, gcal, when, FALSE, 1, 0, WEEK_NORMAL_FONT_SIZE, - left, right, header, bottom); - + left, right, header + 20, bottom); + + /* Print the border around the main view. */ - print_border (pr->pc, left, right, header, bottom, 1.0, -1.0); + print_border (pr->pc, left, right, header , bottom, 1.0, -1.0); /* Print the border around the header area. */ - print_border (pr->pc, left, right, top, header + 2.0, 1.0, 0.9); + print_border (pr->pc, left, right, top, header + 2.0 + 20, 1.0, 0.9); /* Print the 2 mini calendar-months. */ l = right - SMALL_MONTH_PAD - SMALL_MONTH_WIDTH * 2 - SMALL_MONTH_SPACING; print_month_small (pr, gcal, when, l, l + SMALL_MONTH_WIDTH, - top - 4, header + 4, + top + 4, header + 30, DATE_MONTH | DATE_YEAR, when, time_add_week_with_zone (when, 1, zone), FALSE); @@ -2108,22 +2226,20 @@ print_week_view (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t date, print_month_small (pr, gcal, time_add_month_with_zone (when, 1, zone), l, l + SMALL_MONTH_WIDTH, - top - 4, header + 4, + top + 4, header + 30, DATE_MONTH | DATE_YEAR, when, time_add_week_with_zone (when, 1, zone), FALSE); /* Print the start day of the week, e.g. '7th May 2001'. */ format_date (when, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); print_text_size_bold (pr, buf, ALIGN_LEFT, - left + 3, right, top - 4, top - 4 - 24); - + left + 3, right, top + 4, top + 4 + 24); + /* Print the end day of the week, e.g. '13th May 2001'. */ when = time_add_day_with_zone (when, 6, zone); format_date (when, DATE_DAY | DATE_MONTH | DATE_YEAR, buf, 100); print_text_size_bold (pr, buf, ALIGN_LEFT, - left + 3, right, top - 24 - 3, top - 24 - 3 - 24); - - gnome_print_showpage (pr->pc); + left + 3, right, top + 24 + 3, top + 24 + 3 + 24); } @@ -2135,9 +2251,7 @@ print_month_view (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t date double header; char buf[100]; - header = top - HEADER_HEIGHT; - - gnome_print_beginpage (pr->pc, NULL); + header = top + HEADER_HEIGHT; /* Print the main month view. */ print_month_summary (pr, gcal, date, left, right, header, bottom); @@ -2149,20 +2263,19 @@ print_month_view (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t date print_month_small (pr, gcal, time_add_month_with_zone (date, 1, zone), right - (right - left) / 7 + 2, right - 8, - top - 4, header, + top + 4, header, DATE_MONTH | DATE_YEAR, 0, 0, FALSE); print_month_small (pr, gcal, time_add_month_with_zone (date, -1, zone), left + 8, left + (right - left) / 7 - 2, - top - 4, header, + top + 4, header, DATE_MONTH | DATE_YEAR, 0, 0, FALSE); /* Print the month, e.g. 'May 2001'. */ format_date (date, DATE_MONTH | DATE_YEAR, buf, 100); print_text_size_bold (pr, buf, ALIGN_CENTER, - left + 3, right - 3, top - 3, top - 3 - 24); + left + 3, right - 3, top + 3, top + 3 + 24); - gnome_print_showpage (pr->pc); } @@ -2171,18 +2284,20 @@ print_year_view (EvoCalendarPrintRenderer *pr, GnomeCalendar *gcal, time_t date, double left, double right, double top, double bottom) { char buf[100]; + cairo_t *cr; - gnome_print_beginpage (pr->pc, NULL); + cr = gtk_print_context_get_cairo_context (pr->pc); - print_year_summary (pr, gcal, date, left, right, top - 50, bottom, + cairo_show_page (cr); + print_year_summary (pr, gcal, date, left, right, top + 50, bottom, TRUE); /* centered title */ format_date (date, DATE_YEAR, buf, 100); print_text_size_bold (pr, buf, ALIGN_CENTER, - left+3, right, top-3, top - 27); - - gnome_print_showpage (pr->pc); + left+3, right, top+3, top + 27); + cr=gtk_print_context_get_cairo_context (pr->pc); + cairo_show_page (cr); } static void @@ -2298,17 +2413,36 @@ print_date_label (EvoCalendarPrintRenderer *pr, ECalComponent *comp, ECal *clien } static void -print_comp_item (EvoCalendarPrintRenderer *pr, ECalComponent *comp, ECal *client, - double left, double right, double top, double bottom) +print_comp_item (PrintCompItem *pci) + { PangoFontDescription *font; + EvoCalendarPrintRenderer *pr; + ECal *client; + ECalComponent *comp; ECalComponentVType vtype; ECalComponentText text; GSList *desc, *l; + GSList *contact_list, *elem; + const char *title, *categories, *location; char *categories_string, *location_string, *summary_string; - GSList *contact_list, *elem; - gint header_size; + double header_size; + cairo_t *cr; + double left, right, top, bottom; + + /* PrintCompItem structure contains elements to be used + * with the Print Context , obtained in comp_draw_page + */ + comp = g_new0 (ECalComponent, 1); + client = g_new0 (ECal, 1); + pr = pci->pr; + client = pci->client; + comp = pci->comp; + left = pci->l; + right = pci->r; + top = pci->t; + bottom = pci->b; vtype = e_cal_component_get_vtype (comp); @@ -2322,25 +2456,26 @@ print_comp_item (EvoCalendarPrintRenderer *pr, ECalComponent *comp, ECal *client else return; - gnome_print_beginpage (pr->pc, NULL); - + cr = gtk_print_context_get_cairo_context (pr->pc); + /* Print the title in a box at the top of the page. */ font = get_font_for_size (pr, 18, GNOME_FONT_BOLD, FALSE); - header_size = 50; - print_border (pr->pc, left, right, top, top - header_size, + header_size = 40; + print_border (pr->pc, left, right, top, top+header_size, 1.0, 0.9); print_text (pr, font, title, ALIGN_CENTER, left, right, - top - header_size * 0.1, top - header_size); + top + 0.1, top +header_size - 0.1); pango_font_description_free (font); - top -= header_size + 10; - + top += header_size + 30; + /* Summary */ font = get_font_for_size (pr, 18, GNOME_FONT_BOLD, FALSE); e_cal_component_get_summary (comp, &text); summary_string = g_strdup_printf (_("Summary: %s"), text.value); top = bound_text (pr, font, summary_string, left, right, - top - 3, bottom, 0); + top, bottom, 0); + g_free (summary_string); /* Location */ @@ -2349,17 +2484,16 @@ print_comp_item (EvoCalendarPrintRenderer *pr, ECalComponent *comp, ECal *client location_string = g_strdup_printf (_("Location: %s"), location); top = bound_text (pr, font, location_string, left, right, - top - 3, bottom, 0); + top + 3, bottom, 0); g_free (location_string); } pango_font_description_free (font); - + /* Date information */ - print_date_label (pr, comp, client, left, right, top-3, top - 15); - top -= 20; - + print_date_label (pr, comp, client, left, right, top + 3, top + 15); + top += 20; font = get_font_for_size (pr, 12, GNOME_FONT_BOOK, FALSE); - + /* For a VTODO we print the Status, Priority, % Complete and URL. */ if (vtype == E_CAL_COMPONENT_TODO) { icalproperty_status status; @@ -2367,7 +2501,7 @@ print_comp_item (EvoCalendarPrintRenderer *pr, ECalComponent *comp, ECal *client int *percent; int *priority; const char *url; - + /* Status */ e_cal_component_get_status (comp, &status); if (status != ICAL_STATUS_NONE) { @@ -2436,11 +2570,10 @@ print_comp_item (EvoCalendarPrintRenderer *pr, ECalComponent *comp, ECal *client top = bound_text (pr, font, url_string, left, right, top, bottom, 0); top += get_font_size (font) - 6; - g_free (url_string); } } - + /* Categories */ e_cal_component_get_categories (comp, &categories); if (categories && categories[0]) { @@ -2448,10 +2581,10 @@ print_comp_item (EvoCalendarPrintRenderer *pr, ECalComponent *comp, ECal *client categories); top = bound_text (pr, font, categories_string, left, right, top, bottom, 0); - top += get_font_size (font) - 6; + top += get_font_size (font) - 6 ; g_free (categories_string); } - + /* Contacts */ e_cal_component_get_contact_list (comp, &contact_list); if (contact_list) { @@ -2468,362 +2601,326 @@ print_comp_item (EvoCalendarPrintRenderer *pr, ECalComponent *comp, ECal *client top = bound_text (pr, font, contacts->str, left, right, top, bottom, 0); top += get_font_size (font) - 6; - g_string_free (contacts, TRUE); } - - top -= 16; + top += 16; /* Description */ e_cal_component_get_description_list (comp, &desc); for (l = desc; l != NULL; l = l->next) { ECalComponentText *text = l->data; + if (top > bottom) { + top = 10; //FIXME + cairo_show_page (cr); + } + if (text->value != NULL) + top = bound_text (pr, font, text->value, left, right, top + 3, bottom, 0) + 30; - if (text->value != NULL) - top = bound_text (pr, font, text->value, left, right, top-3, bottom, 0); } + e_cal_component_free_text_list (desc); pango_font_description_free (font); - gnome_print_showpage (pr->pc); } void print_calendar (GnomeCalendar *gcal, gboolean preview, time_t date, PrintView default_view) { - GnomePrintConfig *print_config; - GnomePrintJob *gpm; - EvoCalendarPrintRenderer *pr; - double l, r, t, b; - guchar *old_orientation; - + GtkPrintSettings *settings; + GtkPrintOperationResult res; + GtkPrintOperation *print; + GtkPaperSize *paper_size; + GtkPageSetup *page_setup; + GtkWidget *gpd; + GtkWidget *range; + PrintCalItem *pcali; + int view; + double r, t, w, h; + g_return_if_fail (gcal != NULL); g_return_if_fail (GNOME_IS_CALENDAR (gcal)); - - print_config = e_print_load_config (); - - /* Don't save the orientation if we guessed it to be nice to the user */ - old_orientation = gnome_print_config_get (print_config, (const guchar *) GNOME_PRINT_KEY_PAGE_ORIENTATION); - if (default_view == PRINT_VIEW_MONTH) { - if (old_orientation && !strcmp ((char *) old_orientation, "R90")) { - g_free (old_orientation); - old_orientation = NULL; - } - - gnome_print_config_set (print_config, (const guchar *) GNOME_PRINT_KEY_PAGE_ORIENTATION, (const guchar *) "R90"); - } - - if (!preview) { - GtkWidget *gpd; - GtkWidget *range; - int view; - - gpd = e_print_get_dialog_with_config (_("Print"), GNOME_PRINT_DIALOG_COPIES | GNOME_PRINT_DIALOG_RANGE, print_config); - - view = (int) default_view; - range = range_selector_new (gpd, date, &view); - gnome_print_dialog_construct_range_custom (GNOME_PRINT_DIALOG (gpd), range); - - gtk_dialog_set_default_response (GTK_DIALOG (gpd), - GNOME_PRINT_DIALOG_RESPONSE_PRINT); - - /* Run dialog */ - - switch (gtk_dialog_run (GTK_DIALOG (gpd))) { - case GNOME_PRINT_DIALOG_RESPONSE_PRINT: - break; - - case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: - preview = TRUE; - break; - - case -1: - return; - - default: - gtk_widget_destroy (gpd); - return; - } - - e_dialog_get_values (gpd); - default_view = (PrintView) view; - - gtk_widget_destroy (gpd); - } - - gpm = gnome_print_job_new (print_config); - - pr = evo_calendar_print_data_new (gnome_print_job_get_context (gpm)); - - gnome_print_config_get_page_size (print_config, &r, &t); - - /* See top of source for an explanation of this */ - - /* gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_TOP, &temp_d); - * t -= temp_d; - * gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT, &temp_d); - * r -= temp_d; - * gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, &b); - * gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_LEFT, &l); - * b = l = TEMP_MARGIN; */ - b = t * TEMP_MARGIN; - l = r * TEMP_MARGIN; - t *= (1.0 - TEMP_MARGIN); - r *= (1.0 - TEMP_MARGIN); - - /* depending on the view, do a different output */ - switch (default_view) { - case PRINT_VIEW_DAY: - print_day_view (pr, gcal, date, l, r, t, b); - break; - case PRINT_VIEW_WEEK: - print_week_view (pr, gcal, date, l, r, t, b); - break; - case PRINT_VIEW_MONTH: - print_month_view (pr, gcal, date, l, r, t, b); - break; - case PRINT_VIEW_YEAR: - print_year_view (pr, gcal, date, l, r, t, b); - break; - default: - g_assert_not_reached (); - } - - evo_calendar_print_data_free (pr); - - gnome_print_job_close (gpm); - - if (preview) { - GtkWidget *gpmp; + view = (int) default_view; + range = range_selector_new (gpd, date, &view); + + pcali = g_new0 (PrintCalItem, 1); + pcali->gcal = g_new0 (GnomeCalendar, 1); + + print = gtk_print_operation_new (); + paper_size = gtk_paper_size_new ("iso_a4"); + page_setup = gtk_page_setup_new(); + gtk_page_setup_set_paper_size(page_setup, paper_size); + + settings = gtk_print_settings_new (); + settings = e_print_load_config (); + gpd = e_print_get_dialog_with_config (_("ebby"),GNOME_PRINT_DIALOG_RANGE | GNOME_PRINT_DIALOG_COPIES, settings ); + gtk_print_unix_dialog_add_custom_tab (GTK_PRINT_UNIX_DIALOG (gpd), range,gtk_label_new (_("range"))); + + t = gtk_paper_size_get_default_top_margin (paper_size, GTK_UNIT_POINTS); + r = gtk_paper_size_get_default_right_margin (paper_size, GTK_UNIT_POINTS); + w = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS); + h = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS); + + pcali->b = h * (1.0 - TEMP_MARGIN); + pcali->l = r * TEMP_MARGIN; + pcali->t = t * (1.0 - TEMP_MARGIN); + pcali->r = w * (1.0 - TEMP_MARGIN); + pcali->default_view = default_view; + pcali->gcal = gcal; + pcali->date = date; + + settings = gtk_print_unix_dialog_get_settings (GTK_PRINT_UNIX_DIALOG (gpd)); + gtk_print_operation_set_default_page_setup (print, page_setup); + gtk_print_operation_set_n_pages (print, 1); + + /* FIX ME ,Allow it to use the default settings for the first time */ + /* gtk_print_operation_set_print_settings (print, settings); */ - gpmp = gnome_print_job_preview_new (gpm, (const guchar *) _("Print Preview")); - gtk_widget_show (gpmp); - } else { - gnome_print_job_print (gpm); + /* Runs the print dialog, recursively, emitting signals */ + g_signal_connect (print, "draw_page", G_CALLBACK (cal_draw_page), pcali); + if (preview) + gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PREVIEW, NULL, NULL); + else + res = gtk_print_operation_run (print,GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL); + + /* Save the user configured settings back to the gconf */ + settings = gtk_print_operation_get_print_settings (print); + e_print_save_config (settings); + + if (res == GTK_PRINT_OPERATION_RESULT_APPLY) { + g_object_unref (settings); + g_object_unref (page_setup); + g_object_unref (paper_size); + g_object_unref (print); + g_object_unref (paper_size); + g_object_unref (page_setup); } - - /* Don't save the orientation if we guessed it to be nice to the user */ - if (old_orientation) { - gnome_print_config_set (print_config, (const guchar *) GNOME_PRINT_KEY_PAGE_ORIENTATION, old_orientation); - - e_print_save_config (print_config); - g_free (old_orientation); + else if (res == GTK_PRINT_OPERATION_RESULT_ERROR) { + /* FIX ME */ + } - g_object_unref (print_config); - g_object_unref (gpm); } - void print_comp (ECalComponent *comp, ECal *client, gboolean preview) { - GnomePrintConfig *print_config; - GnomePrintJob *gpm; - EvoCalendarPrintRenderer *pr; - double l, r, t, b; - - g_return_if_fail (comp != NULL); - g_return_if_fail (E_IS_CAL_COMPONENT (comp)); - - print_config = e_print_load_config (); - - if (!preview) { - GtkWidget *gpd; - - gpd = e_print_get_dialog_with_config (_("Print Item"), GNOME_PRINT_DIALOG_COPIES, print_config); - - gtk_dialog_set_default_response (GTK_DIALOG (gpd), - GNOME_PRINT_DIALOG_RESPONSE_PRINT); - - /* Run dialog */ - - switch (gtk_dialog_run (GTK_DIALOG (gpd))) { - case GNOME_PRINT_DIALOG_RESPONSE_PRINT: - break; - - case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: - preview = TRUE; - break; - - case -1: - return; - - default: - gtk_widget_destroy (gpd); - return; - } - - e_dialog_get_values (gpd); - gtk_widget_destroy (gpd); - } - - gpm = gnome_print_job_new (print_config); - - pr = evo_calendar_print_data_new (gnome_print_job_get_context (gpm)); - gnome_print_config_get_page_size (print_config, &r, &t); - - /* See top of source for an explanation of this */ - - /* gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_TOP, &temp_d); - * t -= temp_d; - * gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT, &temp_d); - * r -= temp_d; - * gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, &b); - * gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_LEFT, &l); - * b = l = TEMP_MARGIN; */ - - b = t * TEMP_MARGIN; - l = r * TEMP_MARGIN; - t *= (1.0 - TEMP_MARGIN); - r *= (1.0 - TEMP_MARGIN); - - print_comp_item (pr, comp, client, l, r, t, b); - gnome_print_job_close (gpm); - - evo_calendar_print_data_free (pr); - - if (preview) { - GtkWidget *gpmp; - - gpmp = gnome_print_job_preview_new (gpm, (const guchar *) _("Print Preview")); - gtk_widget_show (gpmp); - } else { - gnome_print_job_print (gpm); - } + GtkPrintOperation *print; + GtkPrintSettings *settings; + GtkPaperSize *paper_size; + PrintCompItem *pci; + GtkPrintOperationResult res; + GtkPageSetup *page_setup; + gdouble t, r, w,h; + GtkWidget *gpd; + + g_return_if_fail (comp != NULL); + g_return_if_fail (E_IS_CAL_COMPONENT (comp)); + + pci = g_new0 (PrintCompItem, 1); + + print = gtk_print_operation_new (); + paper_size = gtk_paper_size_new ("iso_a4"); + page_setup = gtk_page_setup_new(); + gtk_page_setup_set_paper_size(page_setup, paper_size); + + settings = gtk_print_settings_new (); + settings = e_print_load_config (); + gpd = e_print_get_dialog_with_config (_("Print Item"), GNOME_PRINT_DIALOG_COPIES, settings); + + /* Values using the print context , used in comp_draw_page */ + t = gtk_paper_size_get_default_top_margin (paper_size, GTK_UNIT_POINTS); + r = gtk_paper_size_get_default_right_margin (paper_size, GTK_UNIT_POINTS); + w = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS); + h = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS); + pci->b = h * (1.0 - TEMP_MARGIN); + pci->l = r * TEMP_MARGIN; + pci->t = t * (1.0 - TEMP_MARGIN); + pci->r = w * (1.0 - TEMP_MARGIN); + pci->comp = comp; + pci->client = client; + + gtk_print_operation_set_default_page_setup (print, page_setup); + gtk_print_operation_set_n_pages (print, 1); + + /* FIX ME ,Allow it to use the default settings for the first time */ + /* gtk_print_operation_set_print_settings (print, settings); */ - g_object_unref (print_config); - g_object_unref (gpm); + g_signal_connect (print, "draw_page", G_CALLBACK (comp_draw_page), pci); + + gtk_print_operation_set_print_settings (print, settings); + + /* Runs a dialog , emitting various signals based on user response */ + if (preview) + gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL); + else + res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG , NULL, NULL); + + /* Saves the user configuration in gconf */ + settings = gtk_print_operation_get_print_settings (print); + e_print_save_config (settings); + + if (res == GTK_PRINT_OPERATION_RESULT_APPLY) { + g_object_unref (settings); + g_object_unref (print); + g_object_unref (page_setup); + g_object_unref (paper_size); + } + else if ( res == GTK_PRINT_OPERATION_RESULT_ERROR) { + /* FIX ME */ + } } static void -print_title (EvoCalendarPrintRenderer *pr, const char *title, - double page_width, double page_height) +print_title (GtkPrintContext *context, const char *title, + double page_width, double page_height, double left_margin, double bottom_margin) { PangoFontDescription *font; + PangoLayout *pl; double w, x, y; + cairo_t *cr; - font = pango_font_description_from_string("Sans Bold 18"); - pango_layout_set_font_description (pr->pl, font); - pango_layout_set_text (pr->pl, title, -1); - w = pango_layout_get_width (pr->pl)/(double)PANGO_SCALE; - y = page_height; + cr = gtk_print_context_get_cairo_context (context); + cairo_save (cr); + pl = gtk_print_context_create_pango_layout (context); + font = pango_font_description_from_string("Sans Bold 18"); + pango_layout_set_font_description (pl, font); + pango_layout_set_text (pl, title, -1); + + w = pango_layout_get_width (pl)/(double)PANGO_SCALE; + y = page_height ; x = (page_width - w) / 2; - gnome_print_moveto (pr->pc, x, y); - gnome_print_setrgbcolor (pr->pc, 0, 0, 0); + cairo_move_to (cr, x, y ); + pango_cairo_show_layout (cr, pl); - gnome_print_pango_layout (pr->pc, pr->pl); + cairo_restore (cr); + pango_font_description_free (font); - pango_font_description_free (font); } void print_table (ETable *etable, const char *dialog_title, const char *print_header, gboolean preview) { EPrintable *printable; - GnomePrintConfig *print_config; - EvoCalendarPrintRenderer *pr; - GnomePrintJob *gpm; - double l, r, t, b, page_width, page_height, left_margin, bottom_margin; - - print_config = e_print_load_config (); - + GtkPrintOperationResult res; + GtkPrintSettings *settings; + GtkPrintOperation *print; + GtkPageSetup *page_setup; + GtkPaperSize *paper_size; + GtkWidget *gpd; + PrintTableItem *pti; + double w, h, t, r, l, b; + + pti = g_new0 (PrintTableItem, 1); + + print = gtk_print_operation_new (); + paper_size = gtk_paper_size_new ("iso_a4"); + page_setup = gtk_page_setup_new(); + gtk_page_setup_set_paper_size(page_setup, paper_size); + + w = gtk_paper_size_get_width (paper_size, GTK_UNIT_POINTS); + h = gtk_paper_size_get_height (paper_size, GTK_UNIT_POINTS); + t = gtk_paper_size_get_default_top_margin (paper_size, GTK_UNIT_POINTS); + r = gtk_paper_size_get_default_right_margin (paper_size, GTK_UNIT_POINTS); + + b =h * (1.0 - TEMP_MARGIN); + l =r * TEMP_MARGIN; + t =t * (1.0 - TEMP_MARGIN); + r =w * (1.0 - TEMP_MARGIN); + + pti->left_margin = l; + pti->bottom_margin = b; + pti->paper_width = r - l; + pti->paper_height= t + 10; + + settings = e_print_load_config (); + gpd = e_print_get_dialog_with_config (dialog_title, GNOME_PRINT_DIALOG_COPIES, settings); + settings = gtk_print_settings_new (); printable = e_table_get_printable (etable); + g_object_ref (printable); gtk_object_sink (GTK_OBJECT (printable)); e_printable_reset (printable); + pti->printable = printable; - if (!preview) { - GtkWidget *gpd; - - gpd = e_print_get_dialog_with_config (dialog_title, GNOME_PRINT_DIALOG_COPIES, print_config); - - gtk_dialog_set_default_response (GTK_DIALOG (gpd), - GNOME_PRINT_DIALOG_RESPONSE_PRINT); - - /* Run dialog */ + gtk_print_operation_set_default_page_setup (print, page_setup); + gtk_print_operation_set_n_pages (print, 1); - switch (gtk_dialog_run (GTK_DIALOG (gpd))) { - case GNOME_PRINT_DIALOG_RESPONSE_PRINT: - break; + /* FIX ME ,Allow it to use the default settings for the first time */ + /* gtk_print_operation_set_print_settings (print, settings); */ - case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: - preview = TRUE; - break; + /* runs the dialog emitting the signals based on user response */ + g_signal_connect (print, "draw_page", G_CALLBACK (table_draw_page), pti); + if (preview) + res = gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL); + else + gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PREVIEW, NULL, NULL); + - case -1: - return; + /* Saves the user configuration in gconf */ + settings = gtk_print_operation_get_print_settings (print); + e_print_save_config (settings); + + if (res == GTK_PRINT_OPERATION_RESULT_APPLY) { + g_object_unref (settings); + g_object_unref (print); + g_object_unref (page_setup); + g_object_unref (paper_size); + } + else if ( res == GTK_PRINT_OPERATION_RESULT_ERROR) { + /* FIX ME */ + } +} - default: - gtk_widget_destroy (gpd); - return; - } - e_dialog_get_values (gpd); +void comp_draw_page (GtkPrintOperation *print, GtkPrintContext *context, gint page_nr, PrintCompItem *pci) +{ + pci = evo_calendar_print_data_new (context, pci); + print_comp_item (pci); +} - gtk_widget_destroy (gpd); +void cal_draw_page (GtkPrintOperation *print1, GtkPrintContext *context, gint page_nr1, PrintCalItem *pcali) +{ + pcali = evo_calendar_print_cal_data_new (context, pcali); + + switch (pcali->default_view) { + case PRINT_VIEW_DAY: + print_day_view (pcali->pr, pcali->gcal, pcali->date, pcali->l, pcali->r, pcali->t, pcali->b); + break; + case PRINT_VIEW_WEEK: + print_week_view (pcali->pr, pcali->gcal, pcali->date, pcali->l, pcali->r, pcali->t, pcali->b); + break; + case PRINT_VIEW_MONTH: + print_month_view (pcali->pr, pcali->gcal, pcali->date, pcali->l, pcali->r, pcali->t, pcali->b); + break; + case PRINT_VIEW_YEAR: + print_year_view (pcali->pr, pcali->gcal, pcali->date, pcali->l, pcali->r, pcali->t, pcali->b); + break; + default: + g_assert_not_reached (); } + - gpm = gnome_print_job_new (print_config); - - pr = evo_calendar_print_data_new (gnome_print_job_get_context (gpm)); - - gnome_print_config_get_page_size (print_config, &r, &t); - - /* See top of source for an explanation of this */ - -#if 0 - gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_TOP, &temp_d); - t -= temp_d; - gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_RIGHT, &temp_d); - r -= temp_d; - gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_BOTTOM, &b); - gnome_print_config_get_double (print_config, GNOME_PRINT_KEY_PAGE_MARGIN_LEFT, &l); -#endif - - b = t * TEMP_MARGIN; - l = r * TEMP_MARGIN; - t *= (1.0 - TEMP_MARGIN); - r *= (1.0 - TEMP_MARGIN); - - page_width = r - l; - page_height = t - b; - left_margin = l; - bottom_margin = b; +} +void table_draw_page (GtkPrintOperation *print, GtkPrintContext *context, gint page_nr, PrintTableItem *pti) +{ + pti->context = context; + do { - gnome_print_beginpage (pr->pc, (const guchar *) "Tasks"); - gnome_print_gsave (pr->pc); - - gnome_print_translate (pr->pc, left_margin, bottom_margin); - - print_title (pr, print_header, page_width, page_height); + print_title (context,"Table", pti->paper_width, pti->paper_height, pti->left_margin, pti->bottom_margin); + + if (e_printable_data_left (pti->printable)) + e_printable_print_page (pti->printable, pti->context, + pti->paper_width, pti->paper_height + 24, TRUE); - if (e_printable_data_left (printable)) - e_printable_print_page (printable, pr->pc, - page_width, page_height - 24, TRUE); + } while (e_printable_data_left (pti->printable)); +} - gnome_print_grestore (pr->pc); - gnome_print_showpage (pr->pc); - } while (e_printable_data_left (printable)); - evo_calendar_print_data_free (pr); - gnome_print_job_close (gpm); - if (preview) { - GtkWidget *gpmp; - gpmp = gnome_print_job_preview_new (gpm, (const guchar *) _("Print Preview")); - gtk_widget_show (gpmp); - } else { - gnome_print_job_print (gpm); - } - g_object_unref (print_config); - g_object_unref (gpm); - g_object_unref (printable); -} diff --git a/configure.in b/configure.in index 9fe545dd2b..4c82c05171 100644 --- a/configure.in +++ b/configure.in @@ -1240,7 +1240,7 @@ EVO_SET_COMPILE_FLAGS(E_NAME, libgnomeui-2.0 libbonoboui-2.0 >= $BONOBOUI_REQUIR AC_SUBST(E_NAME_CFLAGS) AC_SUBST(E_NAME_LIBS) -EVO_SET_COMPILE_FLAGS(E_UTIL, gthread-2.0 gconf-2.0 libxml-2.0 libbonoboui-2.0 >= $BONOBOUI_REQUIRED libglade-2.0 libgnomeui-2.0 libgnome-2.0 libgnomecanvas-2.0 libgnomeprintui-2.2 libedataserver-$EDS_PACKAGE >= $EDS_REQUIRED libedataserverui-$EDS_PACKAGE >= $EDS_REQUIRED $mozilla_nspr $mono_package, $THREADS_CFLAGS $MANUAL_NSPR_CFLAGS, $THREADS_LIBS $MANUAL_NSPR_LIBS) +EVO_SET_COMPILE_FLAGS(E_UTIL, gthread-2.0 gconf-2.0 libxml-2.0 gtk+-unix-print-2.0 libbonoboui-2.0 >= $BONOBOUI_REQUIRED libglade-2.0 libgnomeui-2.0 libgnome-2.0 libgnomecanvas-2.0 libgnomeprintui-2.2 libedataserver-$EDS_PACKAGE >= $EDS_REQUIRED libedataserverui-$EDS_PACKAGE >= $EDS_REQUIRED $mozilla_nspr $mono_package, $THREADS_CFLAGS $MANUAL_NSPR_CFLAGS, $THREADS_LIBS $MANUAL_NSPR_LIBS) AC_SUBST(E_UTIL_CFLAGS) AC_SUBST(E_UTIL_LIBS) @@ -1290,7 +1290,7 @@ AC_SUBST(SHELL_LIBS) dnl --- evolution-addressbook flags -EVOLUTION_ADDRESSBOOK_DEPS="gconf-2.0 libbonoboui-2.0 >= $BONOBOUI_REQUIRED libglade-2.0 libgnomeui-2.0 libgnome-2.0 libgnomecanvas-2.0 gnome-vfs-2.0 libgnomeprintui-2.2 libgtkhtml-$GTKHTML_PACKAGE >= $GTKHTML_REQUIRED libebook-$EDS_PACKAGE >= $EDS_REQUIRED libedataserverui-$EDS_PACKAGE >= $EDS_REQUIRED camel-$EDS_PACKAGE" +EVOLUTION_ADDRESSBOOK_DEPS="gconf-2.0 libbonoboui-2.0 >= $BONOBOUI_REQUIRED libglade-2.0 libgnomeui-2.0 libgnome-2.0 libgnomecanvas-2.0 gtk+-unix-print-2.0 gnome-vfs-2.0 libgnomeprintui-2.2 libgtkhtml-$GTKHTML_PACKAGE >= $GTKHTML_REQUIRED libebook-$EDS_PACKAGE >= $EDS_REQUIRED libedataserverui-$EDS_PACKAGE >= $EDS_REQUIRED camel-$EDS_PACKAGE" EVO_SET_COMPILE_FLAGS(EVOLUTION_ADDRESSBOOK, $EVOLUTION_ADDRESSBOOK_DEPS) AC_SUBST(EVOLUTION_ADDRESSBOOK_CFLAGS) @@ -1328,7 +1328,7 @@ EVO_SET_COMPILE_FLAGS(LIBSOUP, $LIBSOUP >= $LIBSOUP_REQUIRED) AC_SUBST(LIBSOUP_CFLAGS) AC_SUBST(LIBSOUP_LIBS) -EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR, libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 libglade-2.0 gnome-vfs-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 gnome-vfs-module-2.0 libgtkhtml-$GTKHTML_PACKAGE >= $GTKHTML_REQUIRED libebook-$EDS_PACKAGE >= $EDS_REQUIRED libecal-$EDS_PACKAGE >= $EDS_REQUIRED libedataserverui-$EDS_PACKAGE >= $EDS_REQUIRED $HAL_REQUIREMENT $libnotify) +EVO_SET_COMPILE_FLAGS(EVOLUTION_CALENDAR, libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 libglade-2.0 gnome-vfs-2.0 gtk+-unix-print-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 gnome-vfs-module-2.0 libgtkhtml-$GTKHTML_PACKAGE >= $GTKHTML_REQUIRED libebook-$EDS_PACKAGE >= $EDS_REQUIRED libecal-$EDS_PACKAGE >= $EDS_REQUIRED libedataserverui-$EDS_PACKAGE >= $EDS_REQUIRED $HAL_REQUIREMENT $libnotify) AC_SUBST(EVOLUTION_CALENDAR_CFLAGS) AC_SUBST(EVOLUTION_CALENDAR_LIBS) @@ -1340,7 +1340,7 @@ fi dnl --- evolution-mail flags -EVO_SET_COMPILE_FLAGS(EVOLUTION_MAIL, camel-provider-$EDS_PACKAGE libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 >= $BONOBOUI_REQUIRED libglade-2.0 gnome-vfs-module-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libgtkhtml-$GTKHTML_PACKAGE >= $GTKHTML_REQUIRED libxml-2.0 bonobo-activation-2.0 gthread-2.0 gconf-2.0 $mozilla_nss libebook-$EDS_PACKAGE >= $EDS_REQUIRED libedataserverui-$EDS_PACKAGE >= $EDS_REQUIRED) +EVO_SET_COMPILE_FLAGS(EVOLUTION_MAIL, camel-provider-$EDS_PACKAGE libgnome-2.0 libgnomeui-2.0 libbonoboui-2.0 >= $BONOBOUI_REQUIRED libglade-2.0 gnome-vfs-module-2.0 libgnomeprint-2.2 libgnomeprintui-2.2 libgtkhtml-$GTKHTML_PACKAGE >= $GTKHTML_REQUIRED libxml-2.0 bonobo-activation-2.0 gthread-2.0 gconf-2.0 gtk+-unix-print-2.0 $mozilla_nss libebook-$EDS_PACKAGE >= $EDS_REQUIRED libedataserverui-$EDS_PACKAGE >= $EDS_REQUIRED) AC_SUBST(EVOLUTION_MAIL_CFLAGS) AC_SUBST(EVOLUTION_MAIL_LIBS) diff --git a/e-util/ChangeLog b/e-util/ChangeLog index 57bf7fd461..0485d7d500 100644 --- a/e-util/ChangeLog +++ b/e-util/ChangeLog @@ -1,3 +1,12 @@ +2007-01-22 Srinivasa Ragavan <sragavan@novell.com> + + ** GtkPrint API migration from Ebby Wiselyn. + + * e-print.c: (e_print_load_config), (e_print_save_config), + (print_dialog_response), (e_print_get_dialog), + (e_print_get_dialog_with_config): + * e-print.h: + 2006-11-28 Daniel Gryniewicz <dang@gentoo.org> ** Fix for bug #349966 diff --git a/e-util/e-print.c b/e-util/e-print.c index 63d7bf3e1e..33eecca14b 100644 --- a/e-util/e-print.c +++ b/e-util/e-print.c @@ -23,75 +23,174 @@ #include <string.h> #include <gconf/gconf-client.h> #include "e-print.h" - -#define PRINT_CONFIG_KEY "/apps/evolution/shell/print_config" - -GnomePrintConfig * +#include <gtk/gtk.h> +#include <gtk/gtkprintunixdialog.h> +#define PRINTER "/apps/evolution/shell/printer" +#define SCALE "/apps/evolution/shell/scale" +#define PRINT_PAGES "/apps/evolution/shell/print_pages" +#define PAGE_RANGES "/apps/evolution/shell/page_ranges" +#define PAGE_SET "/apps/evolution/shell/page_set" +#define COLLATE "/apps/evolution/shell/collate" +#define REVERSE "/apps/evolution/shell/reverse" +#define N_COPIES "/apps/evolution/shell/n_copies" +#define LPR_COMMANDLINE "/apps/evolution/shell/lpr_commandline" +#define OUTPUT_URI "/apps/evolution/shell/output_uri" +#define OUTPUT_FILE_FORMAT "/apps/evolution/shell/output_file_format" + +/* Loads the print settings that were saved previously */ + +GtkPrintSettings * e_print_load_config (void) { GConfClient *gconf; - GnomePrintConfig *config; - char *str; + GtkPrintSettings *settings; + gchar *printer_name; + gchar *collate; + gchar *n_copies; + gchar *print_pages; + gchar *page_set; + gchar *scale; + gchar *output_uri; + gchar *output_file_format; + gchar *reverse; + gchar *page_ranges; + gchar *lpr_commandline; + + settings = gtk_print_settings_new (); gconf = gconf_client_get_default (); - str = gconf_client_get_string (gconf, PRINT_CONFIG_KEY, NULL); - g_object_unref (gconf); + + printer_name = gconf_client_get_string (gconf, PRINTER, NULL); + gtk_print_settings_set (settings, "printer", printer_name); - if (!str) - return gnome_print_config_default (); + n_copies = gconf_client_get_string (gconf, N_COPIES, NULL); + gtk_print_settings_set (settings, "n-copies",n_copies); + + collate = gconf_client_get_string (gconf, COLLATE, NULL); + gtk_print_settings_set (settings, "collate", collate); - config = gnome_print_config_from_string (str, 0); + lpr_commandline = gconf_client_get_string (gconf, LPR_COMMANDLINE, NULL); + gtk_print_settings_set (settings, "lpr-commandline", lpr_commandline); - /* Its unlikely people will want to preserve this too often */ - gnome_print_config_set_int (config, GNOME_PRINT_KEY_NUM_COPIES, 1); - gnome_print_config_set_boolean (config, GNOME_PRINT_KEY_COLLATE, FALSE); + print_pages = gconf_client_get_string (gconf, PRINT_PAGES, NULL); + gtk_print_settings_set (settings, "print-pages", print_pages); + + page_set = gconf_client_get_string (gconf, PAGE_SET, NULL); + gtk_print_settings_set (settings, "page-set", page_set); - return config; + output_uri = gconf_client_get_string (gconf, OUTPUT_URI, NULL); + gtk_print_settings_set (settings, "output-uri", output_uri); + + output_file_format = gconf_client_get_string (gconf, OUTPUT_FILE_FORMAT, NULL); + gtk_print_settings_set (settings, "output-file-format",output_file_format); + + reverse = gconf_client_get_string (gconf, REVERSE, NULL); + gtk_print_settings_set (settings, "reverse", reverse); + + scale = gconf_client_get_string (gconf, SCALE, NULL); + gtk_print_settings_set (settings, "scale", scale); + + page_ranges = gconf_client_get_string (gconf, PAGE_RANGES, NULL); + gtk_print_settings_set (settings, "page-ranges", page_ranges); + + g_free (printer_name); + g_free (collate); + g_free (n_copies); + g_free (print_pages); + g_free (page_set); + g_free (scale); + g_free (output_uri); + g_free (output_file_format); + g_free (reverse); + g_free (page_ranges); + g_free (lpr_commandline); + g_object_unref (gconf); + return settings; } - +/* Saves the print settings */ + void -e_print_save_config (GnomePrintConfig *config) +e_print_save_config (GtkPrintSettings *settings) { GConfClient *gconf; - char *str; - - str = gnome_print_config_to_string (config, 0); + const gchar *printer_name; + const gchar *collate; + const gchar *n_copies; + const gchar *print_pages; + const gchar *page_set; + const gchar *scale; + const gchar *output_uri; + const gchar *output_file_format; + const gchar *reverse; + const gchar *page_ranges; + const gchar *lpr_commandline; gconf = gconf_client_get_default (); - gconf_client_set_string (gconf, PRINT_CONFIG_KEY, str, NULL); + printer_name = gtk_print_settings_get (settings, "printer"); + gconf_client_set_string (gconf, PRINTER, printer_name, NULL); + + scale = gtk_print_settings_get (settings, "scale"); + gconf_client_set_string (gconf, SCALE, scale, NULL); + + page_set = gtk_print_settings_get (settings, "page-set"); + gconf_client_set_string (gconf, PAGE_SET, page_set, NULL); + + print_pages = gtk_print_settings_get (settings, "print-pages"); + gconf_client_set_string (gconf, PRINT_PAGES, print_pages, NULL); + + lpr_commandline = gtk_print_settings_get (settings, "lpr-commandline"); + gconf_client_set_string (gconf, LPR_COMMANDLINE, lpr_commandline, NULL); + + collate = gtk_print_settings_get (settings, "collate"); + gconf_client_set_string (gconf, COLLATE, collate, NULL); + + output_uri = gtk_print_settings_get (settings, "output-uri"); + gconf_client_set_string (gconf, OUTPUT_URI, output_uri, NULL); + + output_file_format = gtk_print_settings_get (settings, "output-file-format"); + gconf_client_set_string (gconf, OUTPUT_FILE_FORMAT, output_file_format, NULL); + + reverse = gtk_print_settings_get (settings, "reverse"); + gconf_client_set_string (gconf, REVERSE, reverse, NULL); + + n_copies = gtk_print_settings_get (settings, "n_copies"); + gconf_client_set_string (gconf, N_COPIES, n_copies, NULL); + + page_ranges = gtk_print_settings_get (settings, "page-ranges"); + gconf_client_set_string (gconf, PAGE_RANGES, "page-ranges",NULL); + g_object_unref (gconf); } static void print_dialog_response(GtkWidget *widget, int resp, gpointer data) { - if (resp == GNOME_PRINT_DIALOG_RESPONSE_PRINT) - e_print_save_config (gnome_print_dialog_get_config (GNOME_PRINT_DIALOG (widget))); + if (resp == GTK_RESPONSE_OK) { + e_print_save_config (gtk_print_unix_dialog_get_settings(GTK_PRINT_UNIX_DIALOG (widget))); + } } +/* Creates a dialog with the print settings */ GtkWidget * e_print_get_dialog (const char *title, int flags) { - GnomePrintConfig *config; + GtkPrintSettings *settings; GtkWidget *dialog; - config = e_print_load_config (); - dialog = e_print_get_dialog_with_config (title, flags, config); - g_object_unref (config); - + settings = e_print_load_config (); + dialog = e_print_get_dialog_with_config (title, flags, settings); + g_object_unref (settings); return dialog; } GtkWidget * -e_print_get_dialog_with_config (const char *title, int flags, GnomePrintConfig *config) +e_print_get_dialog_with_config (const char *title, int flags, GtkPrintSettings *settings) { GtkWidget *dialog; - - dialog = g_object_new (GNOME_TYPE_PRINT_DIALOG, "print_config", config, NULL); - gnome_print_dialog_construct (GNOME_PRINT_DIALOG (dialog), title, flags); - - g_signal_connect(dialog, "response", G_CALLBACK(print_dialog_response), NULL); - + + dialog = gtk_print_unix_dialog_new (title, NULL); + gtk_print_unix_dialog_set_settings (GTK_PRINT_UNIX_DIALOG(dialog), settings); + g_signal_connect(dialog, "response", G_CALLBACK(print_dialog_response), NULL); return dialog; } diff --git a/e-util/e-print.h b/e-util/e-print.h index 738da0f418..c8ca551203 100644 --- a/e-util/e-print.h +++ b/e-util/e-print.h @@ -28,11 +28,11 @@ G_BEGIN_DECLS -GnomePrintConfig *e_print_load_config (void); -void e_print_save_config (GnomePrintConfig *config); +GtkPrintSettings *e_print_load_config (void); +void e_print_save_config (GtkPrintSettings *settings); GtkWidget *e_print_get_dialog (const char *title, int flags); -GtkWidget *e_print_get_dialog_with_config (const char *title, int flags, GnomePrintConfig *config); +GtkWidget *e_print_get_dialog_with_config (const char *title, int flags, GtkPrintSettings *settings); G_END_DECLS diff --git a/mail/ChangeLog b/mail/ChangeLog index 0e0d6ce4a1..0a0ca074e2 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,13 @@ +2007-01-22 Srinivasa Ragavan <sragavan@novell.com> + + ** GtkPrint migration patch from Ebby Wiselyn. + + * em-folder-view.c: (emfv_print_response), (em_folder_view_print): + * em-format-html-print.c: (efhp_finalise), (efhp_footer_cb), + (emfhp_complete), (mail_draw_page), (em_format_html_print_print), + (em_format_html_print_message), (em_format_html_print_raw_message): + * em-format-html-print.h: + 2007-01-17 Srinivasa Ragavan <sragavan@novell.com> ** Downstream fix from OpenSUSE diff --git a/mail/em-folder-view.c b/mail/em-folder-view.c index f7467b409c..a1f24b1c8c 100644 --- a/mail/em-folder-view.c +++ b/mail/em-folder-view.c @@ -83,7 +83,7 @@ #include "e-util/e-dialog-utils.h" #include "e-util/e-icon-factory.h" #include "e-util/e-print.h" -#include "e-util/e-profile-event.h" +#include "e-util/e-profile-event.h" #include "e-util/e-util-private.h" #include "filter/filter-rule.h" @@ -110,6 +110,7 @@ #include "mail-vfolder.h" #include "mail-component.h" #include "mail-tools.h" +#include <gtk/gtkprintunixdialog.h> #include "evolution-shell-component-utils.h" /* Pixmap stuff, sigh */ @@ -2115,7 +2116,7 @@ emfv_activate(EMFolderView *emfv, BonoboUIComponent *uic, int act) struct _print_data { EMFolderView *emfv; - GnomePrintConfig *config; + GtkPrintSettings *settings; int preview; CamelFolder *folder; char *uid; @@ -2125,28 +2126,32 @@ static void emfv_print_response(GtkWidget *w, int resp, struct _print_data *data) { EMFormatHTMLPrint *print; - + gboolean preview = FALSE; + switch (resp) { - case GNOME_PRINT_DIALOG_RESPONSE_PREVIEW: - data->preview = TRUE; - case GNOME_PRINT_DIALOG_RESPONSE_PRINT: - print = em_format_html_print_new(); - em_format_set_session((EMFormat *)print, ((EMFormat *)data->emfv->preview)->session); - em_format_html_print_message(print, (EMFormatHTML *)data->emfv->preview, data->config, data->folder, data->uid, data->preview); - g_object_unref(print); - break; + case GTK_RESPONSE_APPLY: + preview = TRUE; + case GTK_RESPONSE_OK: + print = em_format_html_print_new (); + print->preview = preview; + em_format_set_session ((EMFormat *)print, ((EMFormat *)data->emfv->preview)->session); + em_format_html_print_message (print, + (EMFormatHTML *)data->emfv->preview, + data->settings, + data->folder, + data->uid, + data->preview); + g_object_unref(print); + break; } + g_object_unref (data->emfv); + g_object_unref (data->settings); + camel_object_unref (data->folder); + g_free (data->uid); + g_free (data); +} - if (w) - gtk_widget_destroy(w); - g_object_unref(data->emfv); - e_print_save_config (data->config); - g_object_unref(data->config); - camel_object_unref(data->folder); - g_free(data->uid); - g_free(data); -} int em_folder_view_print(EMFolderView *emfv, int preview) { @@ -2165,7 +2170,7 @@ int em_folder_view_print(EMFolderView *emfv, int preview) data = g_malloc0(sizeof(*data)); data->emfv = emfv; g_object_ref(emfv); - data->config = e_print_load_config (); + data->settings = e_print_load_config (); data->preview = preview; data->folder = emfv->folder; camel_object_ref(data->folder); @@ -2173,14 +2178,17 @@ int em_folder_view_print(EMFolderView *emfv, int preview) message_list_free_uids(emfv->list, uids); if (preview) { - emfv_print_response(NULL, GNOME_PRINT_DIALOG_RESPONSE_PREVIEW, data); + GtkDialog *dialog = (GtkDialog *)e_print_get_dialog_with_config (_("Print Message"), + GNOME_PRINT_DIALOG_COPIES, data->settings); + gtk_dialog_set_default_response (dialog, GTK_RESPONSE_APPLY); + e_dialog_set_transient_for ((GtkWindow *) dialog, (GtkWidget *) emfv); + emfv_print_response(dialog, GTK_RESPONSE_APPLY, data); } else { - GtkDialog *dialog = (GtkDialog *)e_print_get_dialog_with_config (_("Print Message"), GNOME_PRINT_DIALOG_COPIES, data->config); - - gtk_dialog_set_default_response(dialog, GNOME_PRINT_DIALOG_RESPONSE_PRINT); + GtkDialog *dialog = (GtkDialog *)e_print_get_dialog_with_config (_("Print Message"), + GNOME_PRINT_DIALOG_COPIES, data->settings); + gtk_dialog_set_default_response (dialog, GTK_RESPONSE_OK); e_dialog_set_transient_for ((GtkWindow *) dialog, (GtkWidget *) emfv); - g_signal_connect(dialog, "response", G_CALLBACK(emfv_print_response), data); - gtk_widget_show((GtkWidget *)dialog); + emfv_print_response (dialog, GTK_RESPONSE_OK, data); } return 0; diff --git a/mail/em-format-html-print.c b/mail/em-format-html-print.c index df12ddf856..ce352c4739 100644 --- a/mail/em-format-html-print.c +++ b/mail/em-format-html-print.c @@ -37,6 +37,7 @@ #include "mail-ops.h" #include "mail-mt.h" #include "em-format-html-print.h" +#include <gtk/gtk.h> static void efhp_builtin_init(EMFormatHTMLPrintClass *efhc); @@ -65,8 +66,8 @@ efhp_finalise(GObject *o) EMFormatHTMLPrint *efhp = (EMFormatHTMLPrint *)o; gtk_widget_destroy(efhp->window); - if (efhp->config) - g_object_unref(efhp->config); + if (efhp->settings) + g_object_unref(efhp->settings); if (efhp->source) g_object_unref(efhp->source); @@ -119,28 +120,39 @@ struct footer_info { GnomeFont *local_font; gint page_num, pages; }; +typedef struct MailDraw MailDraw; +struct MailDraw { + EMFormatHTMLPrint *efhp; + struct footer_info info; + void *data; + gint res; + gdouble line; +}; + +static void mail_draw_page(GtkPrintOperation *print, GtkPrintContext *context, gint page_nr, MailDraw *mdi); static void -efhp_footer_cb(GtkHTML *html, GnomePrintContext *print_context, double x, double y, double width, double height, void *data) +efhp_footer_cb(GtkHTML *html, GtkPrintContext *print_context, double x, double y, double width, double height, void *data) { struct footer_info *info = data; - + cairo_t *cr; + /* do we want anything nicer here, like who its from, etc? */ if (info->local_font) { char *text = g_strdup_printf (_("Page %d of %d"), info->page_num, info->pages); /*gdouble tw = gnome_font_get_width_string (info->local_font, text);*/ /* FIXME: work out how to measure this */ gdouble tw = strlen(text) * 8; - - gnome_print_gsave(print_context); - gnome_print_newpath(print_context); - gnome_print_setrgbcolor(print_context, .0, .0, .0); - gnome_print_moveto(print_context, x + width - tw, y - gnome_font_get_ascender(info->local_font)); - gnome_print_setfont(print_context, info->local_font); - gnome_print_show(print_context, text); - gnome_print_grestore(print_context); - - g_free(text); + cr = gtk_print_context_get_cairo_context (print_context); + cairo_save (cr); + cairo_set_source_rgb (cr, .0, .0, .0); + cairo_move_to (cr, x + width - tw, y - gnome_font_get_ascender(info->local_font)); + cairo_set_font_face (cr, NULL); + cairo_set_font_size (cr, 6); + cairo_show_text (cr, text); + cairo_restore(cr); + cairo_show_page (cr); + g_free(text); info->page_num++; } } @@ -150,48 +162,73 @@ efhp_footer_cb(GtkHTML *html, GnomePrintContext *print_context, double x, double static void emfhp_complete(EMFormatHTMLPrint *efhp, void *data) { - GnomePrintContext *print_context; - GnomePrintJob *print_job; - gdouble line = 0.0; + GtkPaperSize *paper_size; + GtkPrintOperation *print; + GtkPrintSettings *settings; + GtkPageSetup *page_setup; + struct MailDraw *mdi; struct footer_info info; - int res = GNOME_PRINT_OK; - - print_job = gnome_print_job_new(efhp->config); - print_context = gnome_print_job_get_context(print_job); - - gtk_html_print_set_master(efhp->formathtml.html, print_job); - info.local_font = gnome_font_find_closest("Sans Regular", 10.0); - if (info.local_font) { - line = gnome_font_get_ascender(info.local_font) - gnome_font_get_descender(info.local_font); - info.page_num = 1; - info.pages = gtk_html_print_get_pages_num(efhp->formathtml.html, print_context, 0.0, line); - gtk_html_print_with_header_footer(efhp->formathtml.html, print_context, 0.0, line, NULL, efhp_footer_cb, &info); - gnome_font_unref(info.local_font); - } else { - gtk_html_print(efhp->formathtml.html, print_context); - } - gtk_html_print_set_master(efhp->formathtml.html, NULL); - - gnome_print_job_close(print_job); - if (efhp->preview) - gtk_widget_show(gnome_print_job_preview_new(print_job, _("Print Preview"))); + page_setup = gtk_page_setup_new (); + paper_size = gtk_paper_size_new ("iso_a4");/*FIXME paper size hard coded */ + print = gtk_print_operation_new (); + gtk_page_setup_set_paper_size (page_setup, paper_size); + + settings = e_print_load_config (); + /* running the dialog */ + gtk_print_operation_set_default_page_setup (print, page_setup); + gtk_print_operation_set_n_pages (print, 1); + + /*initialise the struct */ + mdi = g_new0 (MailDraw, 1); + mdi->efhp = efhp; + mdi->line = 0.0; + mdi->res = GNOME_PRINT_OK; + mdi->info = info; + + /* connect */ + g_signal_connect (print,"draw_page", G_CALLBACK (mail_draw_page), mdi); + if (!efhp->preview) + gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PRINT_DIALOG, NULL, NULL); else - res = gnome_print_job_print(print_job); + gtk_print_operation_run (print, GTK_PRINT_OPERATION_ACTION_PREVIEW, NULL, NULL); + g_object_unref (print); + g_object_unref (settings); + g_object_unref (paper_size); + g_object_unref (page_setup); + g_object_unref (efhp); +} - g_object_unref(print_job); - g_object_unref(efhp); +static void +mail_draw_page (GtkPrintOperation *print, GtkPrintContext *context, gint page_nr, MailDraw *mdi) +{ + mdi->info.local_font = gnome_font_find_closest("Sans Regular", 10.0); + if (mdi->info.local_font) { + mdi->line = gnome_font_get_ascender(mdi->info.local_font) - gnome_font_get_descender(mdi->info.local_font); + mdi->info.page_num = 1; + mdi->info.pages = gtk_html_print_page_get_pages_num(mdi->efhp->formathtml.html, context, 0.0, mdi->line ); + gtk_html_print_page_with_header_footer(mdi->efhp->formathtml.html, + context, + 0.0, + mdi->line, + NULL, + efhp_footer_cb, + &(mdi->info)); + } else { + gtk_html_print_page (mdi->efhp->formathtml.html, context); + } + g_object_unref(mdi->efhp); } -int em_format_html_print_print(EMFormatHTMLPrint *efhp, EMFormatHTML *source, struct _GnomePrintConfig *print_config, int preview) +int em_format_html_print_print(EMFormatHTMLPrint *efhp, EMFormatHTML *source, struct GtkPrintSettings *settings, int preview) { EMFormat *emfs = (EMFormat *)source; - efhp->config = print_config; - if (print_config) - g_object_ref(print_config); - efhp->preview = preview; + efhp->settings = settings; + if (settings) + g_object_ref(settings); + efhp->preview = preview; ((EMFormatHTML *)efhp)->load_http = source->load_http_now; g_signal_connect(efhp, "complete", G_CALLBACK(emfhp_complete), efhp); @@ -217,11 +254,12 @@ emfhp_got_message(struct _CamelFolder *folder, const char *uid, struct _CamelMim } } -int em_format_html_print_message(EMFormatHTMLPrint *efhp, EMFormatHTML *source, struct _GnomePrintConfig *print_config, struct _CamelFolder *folder, const char *uid, int preview) +int em_format_html_print_message(EMFormatHTMLPrint *efhp, EMFormatHTML *source, struct GtkPrintSettings *settings, struct _CamelFolder *folder, const char *uid, int preview) { - efhp->config = print_config; - if (print_config) - g_object_ref(print_config); + efhp->settings = settings; + + if (settings) + g_object_ref(settings); efhp->preview = preview; efhp->source = source; if (source) @@ -233,11 +271,12 @@ int em_format_html_print_message(EMFormatHTMLPrint *efhp, EMFormatHTML *source, return 0; /* damn async ... */ } -int em_format_html_print_raw_message(EMFormatHTMLPrint *efhp, struct _GnomePrintConfig *print_config, struct _CamelMimeMessage *msg, int preview) +int em_format_html_print_raw_message(EMFormatHTMLPrint *efhp, GtkPrintSettings *settings, struct _CamelMimeMessage *msg, int preview) { - efhp->config = print_config; - if (print_config) - g_object_ref(print_config); + efhp->settings = settings; + + if (settings) + g_object_ref(settings); efhp->source = NULL; efhp->preview = preview; g_object_ref(efhp); diff --git a/mail/em-format-html-print.h b/mail/em-format-html-print.h index b995780563..3cc605ba43 100644 --- a/mail/em-format-html-print.h +++ b/mail/em-format-html-print.h @@ -8,8 +8,7 @@ #include "mail/em-format-html.h" -struct _GnomePrintConfig; - +struct GtkPrintSettings; typedef struct _EMFormatHTMLPrint EMFormatHTMLPrint; typedef struct _EMFormatHTMLPrintClass EMFormatHTMLPrintClass; @@ -19,7 +18,7 @@ struct _EMFormatHTMLPrint { EMFormatHTML formathtml; struct _GtkWidget *window; /* used to realise the gtkhtml in a toplevel, i dont know why */ - struct _GnomePrintConfig *config; + struct _GtkPrintSettings *settings; struct _EMFormatHTML *source; /* used for print_message */ guint preview:1; @@ -33,8 +32,8 @@ GType em_format_html_print_get_type(void); EMFormatHTMLPrint *em_format_html_print_new(void); -int em_format_html_print_print(EMFormatHTMLPrint *efhp, EMFormatHTML *source, struct _GnomePrintConfig *print_config, int preview); -int em_format_html_print_message(EMFormatHTMLPrint *efhp, EMFormatHTML *source, struct _GnomePrintConfig *print_config, struct _CamelFolder *folder, const char *uid, int preview); -int em_format_html_print_raw_message(EMFormatHTMLPrint *efhp, struct _GnomePrintConfig *print_config, struct _CamelMimeMessage *msg, int preview); +int em_format_html_print_print(EMFormatHTMLPrint *efhp, EMFormatHTML *source, struct GtkPrintSettings *settings, int preview); +int em_format_html_print_message(EMFormatHTMLPrint *efhp, EMFormatHTML *source, struct GtkPrintSettings *settings, struct _CamelFolder *folder, const char *uid, int preview); +int em_format_html_print_raw_message(EMFormatHTMLPrint *efhp, struct _GtkPrintSettings *settings, struct _CamelMimeMessage *msg, int preview); #endif /* ! _EM_FORMAT_HTML_PRINT_H */ diff --git a/shell/ChangeLog b/shell/ChangeLog index a3a715ebec..5f747cbf04 100644 --- a/shell/ChangeLog +++ b/shell/ChangeLog @@ -1,3 +1,9 @@ +2007-01-22 Srinivasa Ragavan <sragavan@novell.com> + + ** Added schemas from GtkPrint API by Ebby Wiselyn. + + * apps_evolution_shell.schemas.in.in: + 2006-12-03 Harish Krishnaswamy <kharish@novell.com> * e-shell.c: (impl_dispose): Fix memory leak of iid. diff --git a/shell/apps_evolution_shell.schemas.in.in b/shell/apps_evolution_shell.schemas.in.in index 1a0ea854f3..96467f5de0 100644 --- a/shell/apps_evolution_shell.schemas.in.in +++ b/shell/apps_evolution_shell.schemas.in.in @@ -217,5 +217,289 @@ </locale> </schema> + + <schema> + <key>/schemas/apps/evolution/shell/printer</key> + <applyto>/apps/evolution/shell/printer</applyto> + <owner>evolution</owner> + <type>string</type> + <default>printer</default> + <locale name="C"> + <short></short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + <schema> + <key>/schemas/apps/evolution/shell/orientation</key> + <applyto>/apps/evolution/shell/orientation</applyto> + <owner>evolution</owner> + <type>int</type> + <default>2</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/paper_size</key> + <applyto>/apps/evolution/shell/paper_size</applyto> + <owner>evolution</owner> + <type>int</type> + <default>GTK_PAPER_NAME_A3</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/paper_width</key> + <applyto>/apps/evolution/shell/paper_width</applyto> + <owner>evolution</owner> + <type>double</type> + <default>5</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/paper_height</key> + <applyto>/apps/evolution/shell/paper_height</applyto> + <owner>evolution</owner> + <type>double</type> + <default>5</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/duplex</key> + <applyto>/apps/evolution/shell/duplex</applyto> + <owner>evolution</owner> + <type>int</type> + <default>1</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/quality</key> + <applyto>/apps/evolution/shell/quality</applyto> + <owner>evolution</owner> + <type>int</type> + <default>1</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/n_copies</key> + <applyto>/apps/evolution/shell/n_copies</applyto> + <owner>evolution</owner> + <type>int</type> + <default>10</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/number_up</key>_ + <applyto>/apps/evolution/shell/number_up</applyto> + <owner>evolution</owner> + <type>int</type> + <default>10</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/resolution</key> + <applyto>/apps/evolution/shell/resolution</applyto> + <owner>evolution</owner> + <type>int</type> + <default>50</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/scale</key> + <applyto>/apps/evolution/shell/scale</applyto> + <owner>evolution</owner> + <type>double</type> + <default>50.0</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/print_pages</key> + <applyto>/apps/evolution/shell/print_pages</applyto> + <owner>evolution</owner> + <type>int</type> + <default>3</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/page_ranges</key> + <applyto>/apps/evolution/shell/page_ranges</applyto> + <owner>evolution</owner> + <type>int</type> + <default>5</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/page_set</key> + <applyto>/apps/evolution/shell/page_set</applyto> + <owner>evolution</owner> + <type>int</type> + <default>5</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/default_source</key> + <applyto>/apps/evolution/shell/default_source</applyto> + <owner>evolution</owner> + <type>string</type> + <default>"/home/ebby/Desktop/"</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/media_type</key> + <applyto>/apps/evolution/shell/media_type</applyto> + <owner>evolution</owner> + <type>string</type> + <default>"iso_a3"</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/dither</key> + <applyto>/apps/evolution/shell/dither</applyto> + <owner>evolution</owner> + <type>string</type> + <default>"dither"</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/finishings</key> + <applyto>/apps/evolution/shell/finishings</applyto> + <owner>evolution</owner> + <type>string</type> + <default>"finish"</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + +
<schema> + <key>/schemas/apps/evolution/shell/output_bin</key> + <applyto>/apps/evolution/shell/output_bin</applyto> + <owner>evolution</owner> + <type>string</type> + <default>"/home/ebby/Desktop"</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/reverse</key> + <applyto>/apps/evolution/shell/reverse</applyto> + <owner>evolution</owner> + <type>bool</type> + <default>TRUE</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/collate</key> + <applyto>/apps/evolution/shell/collate</applyto> + <owner>evolution</owner> + <type>bool</type> + <default>TRUE</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + + + <schema> + <key>/schemas/apps/evolution/shell/use_color</key> + <applyto>/apps/evolution/shell/use_color</applyto> + <owner>evolution</owner> + <type>bool</type> + <default>TRUE</default> + <locale name="C"> + <short>Printer settings</short> + <long>A GNOME Print description of the current printer settings</long> + </locale> + </schema> + </schemalist> </gconfschemafile> diff --git a/widgets/table/ChangeLog b/widgets/table/ChangeLog index 16e42bb724..3a9d49da40 100644 --- a/widgets/table/ChangeLog +++ b/widgets/table/ChangeLog @@ -1,3 +1,24 @@ +2007-01-22 Srinivasa Ragavan <sragavan@novell.com> + + ** GtkPrint api migration from Ebby Wiselyn. + + * e-cell-checkbox.c: (ecc_print), (e_cell_checkbox_class_init): + * e-cell-pixbuf.c: (gnome_print_pixbuf), (pixbuf_print), + (pixbuf_print_height): + * e-cell-popup.c: (ecp_print), (ecp_print_height): + * e-cell-text.c: (ect_print), (ect_print_height): + * e-cell-toggle.c: (etog_print), (etog_print_height): + * e-cell.c: (e_cell_print), (e_cell_print_height): + * e-cell.h: + * e-table-group-container.c: (gp_draw_rect), + (e_table_group_container_print_page), + (e_table_group_container_height), + (e_table_group_container_will_fit): + * e-table-item.c: (eti_realize_cell_views), (eti_draw), + (eti_event), (eti_printed_row_height), (gp_draw_rect), + (e_table_item_print_page), (e_table_item_height), + (e_table_item_will_fit): + 2006-12-04 Matthew Barnes <mbarnes@redhat.com> Fixes bug #357970 diff --git a/widgets/table/e-cell-checkbox.c b/widgets/table/e-cell-checkbox.c index cdeb1814de..33135b5b71 100644 --- a/widgets/table/e-cell-checkbox.c +++ b/widgets/table/e-cell-checkbox.c @@ -39,8 +39,32 @@ static GdkPixbuf *checks [2]; static void +ecc_print (ECellView *ecell_view, GtkPrintContext *context, + int model_col, int view_col, int row, + double width, double height) +{ + cairo_t *cr; + cr = gtk_print_context_get_cairo_context (context); + const int value = GPOINTER_TO_INT ( + e_table_model_value_at (ecell_view->e_table_model, model_col, row)); + cairo_save (cr); + + if ( value == 1) { + + cairo_set_line_width (cr, 2); + cairo_move_to (cr, 3, 11); + cairo_line_to (cr, 7, 14); + cairo_line_to (cr, 11, 5); + cairo_stroke (cr); + } + cairo_restore (cr); +} + +static void e_cell_checkbox_class_init (GtkObjectClass *object_class) { + ECellClass *ecc = (ECellClass *) object_class; + ecc->print = ecc_print; checks [0] = gdk_pixbuf_new_from_xpm_data (check_empty_xpm); checks [1] = gdk_pixbuf_new_from_xpm_data (check_filled_xpm); } diff --git a/widgets/table/e-cell-pixbuf.c b/widgets/table/e-cell-pixbuf.c index a87ba5887d..38fb1ae59d 100644 --- a/widgets/table/e-cell-pixbuf.c +++ b/widgets/table/e-cell-pixbuf.c @@ -28,7 +28,7 @@ #include <libgnomecanvas/gnome-canvas.h> #include "e-util/e-i18n.h" - +#include <gtk/gtk.h> #include "e-cell-pixbuf.h" #define PARENT_TYPE E_CELL_TYPE @@ -51,20 +51,14 @@ enum { }; static int -gnome_print_pixbuf (GnomePrintContext *pc, GdkPixbuf *pixbuf) +gnome_print_pixbuf (GtkPrintContext *pc, GdkPixbuf *pixbuf) { - if (gdk_pixbuf_get_has_alpha (pixbuf)) - return gnome_print_rgbaimage (pc, - gdk_pixbuf_get_pixels (pixbuf), - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - gdk_pixbuf_get_rowstride (pixbuf)); - else - return gnome_print_rgbimage (pc, - gdk_pixbuf_get_pixels (pixbuf), - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - gdk_pixbuf_get_rowstride (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; } /* @@ -224,29 +218,28 @@ pixbuf_height (ECellView *ecell_view, int model_col, int view_col, int row) * ECell::print method */ static void -pixbuf_print (ECellView *ecell_view, GnomePrintContext *context, +pixbuf_print (ECellView *ecell_view, GtkPrintContext *context, int model_col, int view_col, int row, double width, double height) { GdkPixbuf *pixbuf; int scale; - + cairo_t *cr = gtk_print_context_get_cairo_context (context); + pixbuf = (GdkPixbuf *) e_table_model_value_at (ecell_view->e_table_model, model_col, row); if (pixbuf == NULL) return; - scale = gdk_pixbuf_get_height (pixbuf); - - gnome_print_gsave(context); - gnome_print_translate (context, 0, (height - scale) / 2); - gnome_print_scale (context, scale, scale); - gnome_print_pixbuf (context, pixbuf); - - gnome_print_grestore(context); + scale = gdk_pixbuf_get_height (pixbuf); + cairo_save (cr); + cairo_translate (cr, 0, (double)(height - scale) / (double)2); + gdk_cairo_set_source_pixbuf (cr, pixbuf, (double)scale, (double)scale); + cairo_paint (cr); + cairo_restore (cr); } static gdouble -pixbuf_print_height (ECellView *ecell_view, GnomePrintContext *context, +pixbuf_print_height (ECellView *ecell_view, GtkPrintContext *context, int model_col, int view_col, int row, double width) { diff --git a/widgets/table/e-cell-popup.c b/widgets/table/e-cell-popup.c index 613b11dae2..49a4c1e728 100644 --- a/widgets/table/e-cell-popup.c +++ b/widgets/table/e-cell-popup.c @@ -38,6 +38,7 @@ #include "e-cell-popup.h" #include "e-table-item.h" +#include <gtk/gtk.h> #define E_CELL_POPUP_ARROW_WIDTH 16 #define E_CELL_POPUP_ARROW_XPAD 3 @@ -86,14 +87,14 @@ static void ecp_leave_edit (ECellView *ecv, int row, void *edit_context); static void ecp_print (ECellView *ecv, - GnomePrintContext *context, + GtkPrintContext *context, int model_col, int view_col, int row, double width, double height); static gdouble ecp_print_height (ECellView *ecv, - GnomePrintContext *context, + GtkPrintContext *context, int model_col, int view_col, int row, @@ -402,7 +403,7 @@ ecp_leave_edit (ECellView *ecv, int model_col, int view_col, int row, static void -ecp_print (ECellView *ecv, GnomePrintContext *context, +ecp_print (ECellView *ecv, GtkPrintContext *context, int model_col, int view_col, int row, double width, double height) { ECellPopupView *ecp_view = (ECellPopupView *) ecv; @@ -413,7 +414,7 @@ ecp_print (ECellView *ecv, GnomePrintContext *context, static gdouble -ecp_print_height (ECellView *ecv, GnomePrintContext *context, +ecp_print_height (ECellView *ecv, GtkPrintContext *context, int model_col, int view_col, int row, double width) { diff --git a/widgets/table/e-cell-text.c b/widgets/table/e-cell-text.c index dfa0f4da19..88dd215636 100644 --- a/widgets/table/e-cell-text.c +++ b/widgets/table/e-cell-text.c @@ -60,7 +60,6 @@ #include "e-cell-text.h" #include "e-table-item.h" #include "e-table-tooltip.h" - #define d(x) #define DO_SELECTION 1 #define VIEW_TO_CELL(view) E_CELL_TEXT (((ECellView *)view)->ecell) @@ -1322,45 +1321,45 @@ get_font_size (PangoLayout *layout, PangoFontDescription *font, const char *text } 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) { - PangoFontDescription *font_des = get_font_description_for_size (16); + PangoFontDescription *font_des = get_font_description_for_size (12); PangoLayout *layout; PangoContext *pango_context; PangoFontMetrics *font_metrics; - char *string; ECellText *ect = E_CELL_TEXT(ecell_view->ecell); - double ty, ly, text_width, text_height; ECellTextView *ectView = (ECellTextView *)ecell_view; GtkWidget *canvas = GTK_WIDGET(ectView->canvas); PangoDirection dir; gboolean strikeout, underline; + cairo_t *cr; + char *string; + double ty, ly, text_width, text_height; + + cr = gtk_print_context_get_cairo_context (context); string = e_cell_text_get_text(ect, ecell_view->e_table_model, model_col, row); - layout = gnome_print_pango_create_layout (context); + + cairo_save (cr); + layout = gtk_print_context_create_pango_layout (context); + font_des = pango_font_description_from_string ("sans 12"); /* fix me font hardcoded */ pango_layout_set_font_description (layout, font_des); + pango_layout_set_text (layout, string, -1); get_font_size (layout, font_des, string, &text_width, &text_height); - gnome_print_gsave(context); - if (gnome_print_moveto(context, 2, 2) == -1) - /* FIXME */; - if (gnome_print_lineto(context, width - 2, 2) == -1) - /* FIXME */; - if (gnome_print_lineto(context, width - 2, height - 2) == -1) - /* FIXME */; - if (gnome_print_lineto(context, 2, height - 2) == -1) - /* FIXME */; - if (gnome_print_lineto(context, 2, 2) == -1) - /* FIXME */; - if (gnome_print_clip(context) == -1) - /* FIXME */; + + cairo_move_to(cr, 2, 2); + cairo_rectangle (cr, 2, 2, width + 2, height + 2); + cairo_clip(cr); pango_context = gtk_widget_get_pango_context (canvas); font_metrics = pango_context_get_metrics (pango_context, - canvas->style->font_desc, pango_context_get_language(pango_context)); - ty = (double)(text_height - pango_font_metrics_get_ascent (font_metrics) - pango_font_metrics_get_descent (font_metrics)) / 2.0 /(double)PANGO_SCALE; + canvas->style->font_desc, pango_context_get_language(pango_context)); + ty = (double)(text_height + - pango_font_metrics_get_ascent (font_metrics) + - pango_font_metrics_get_descent (font_metrics)) / 2.0 /(double)PANGO_SCALE; strikeout = ect->strikeout_column >= 0 && row >= 0 && e_table_model_value_at (ecell_view->e_table_model, ect->strikeout_column, row); @@ -1368,47 +1367,50 @@ ect_print (ECellView *ecell_view, GnomePrintContext *context, e_table_model_value_at(ecell_view->e_table_model, ect->underline_column, row); dir = pango_find_base_dir (string, strlen(string)); + if (underline) { ly = ty + (double)pango_font_metrics_get_underline_position (font_metrics)/(double)PANGO_SCALE; - gnome_print_newpath (context); + cairo_new_path (cr); if (dir == PANGO_DIRECTION_RTL) { - gnome_print_moveto (context, width - 2, ly + text_height - 4); - gnome_print_lineto (context, MAX (width - 2 - text_width, 2), ly + text_height - 4); + cairo_move_to (cr, width - 2, ly + text_height + 6); + cairo_line_to (cr, MAX (width - 2 - text_width, 2), ly + text_height + 6); } else { - gnome_print_moveto (context, 2, ly + text_height - 4); - gnome_print_lineto (context, MIN (2 + text_width, width - 2), ly + text_height - 4); + cairo_move_to (cr, 2, ly + text_height + 6); + cairo_line_to (cr, MIN (2 + text_width, width - 2), ly + text_height + 6); } - gnome_print_setlinewidth (context, (double)pango_font_metrics_get_underline_thickness (font_metrics)/(double)PANGO_SCALE); - gnome_print_stroke (context); + cairo_set_line_width (cr, (double)pango_font_metrics_get_underline_thickness (font_metrics)/(double)PANGO_SCALE); + cairo_stroke (cr); } if (strikeout) { ly = ty + (double)pango_font_metrics_get_strikethrough_position (font_metrics)/(double)PANGO_SCALE; - gnome_print_newpath (context); + cairo_new_path (cr); if (dir == PANGO_DIRECTION_RTL) { - gnome_print_moveto (context, width - 2, ly + text_height - 4); - gnome_print_lineto (context, MAX (width - 2 - text_width, 2), ly + text_height - 4); + cairo_move_to (cr, width - 2, ly + text_height + 6); + cairo_line_to (cr, MAX (width - 2 - text_width, 2), ly + text_height + 6); } else { - gnome_print_moveto (context, 2, ly + text_height - 4); - gnome_print_lineto (context, MIN (2 + text_width, width - 2), ly + text_height - 4); + cairo_move_to (cr, 2, ly + text_height + 6); + cairo_line_to (cr, MIN (2 + text_width, width - 2), ly + text_height + 6); } - gnome_print_setlinewidth (context, (double)pango_font_metrics_get_strikethrough_thickness (font_metrics)/(double)PANGO_SCALE); - gnome_print_stroke (context); - } + cairo_set_line_width (cr,(double)pango_font_metrics_get_strikethrough_thickness (font_metrics)/(double)PANGO_SCALE); + + cairo_stroke (cr); + } + + cairo_move_to(cr, 2, text_height- 5); + pango_layout_set_width (layout, (width - 4)*PANGO_SCALE); + pango_cairo_show_layout(cr, layout); + cairo_restore (cr); - gnome_print_moveto(context, 2, text_height + 2); - pango_layout_set_width (layout, (width - 4)*PANGO_SCALE); - gnome_print_pango_layout(context, layout); pango_font_description_free (font_des); g_object_unref (layout); - gnome_print_grestore(context); e_cell_text_free_text(ect, string); } 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-toggle.c b/widgets/table/e-cell-toggle.c index 971ca1f98e..dda87efcae 100644 --- a/widgets/table/e-cell-toggle.c +++ b/widgets/table/e-cell-toggle.c @@ -48,23 +48,6 @@ static ECellClass *parent_class; #define CACHE_SEQ_COUNT 6 -static int -gnome_print_pixbuf (GnomePrintContext *pc, GdkPixbuf *pixbuf) -{ - if (gdk_pixbuf_get_has_alpha (pixbuf)) - return gnome_print_rgbaimage (pc, - gdk_pixbuf_get_pixels (pixbuf), - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - gdk_pixbuf_get_rowstride (pixbuf)); - else - return gnome_print_rgbimage (pc, - gdk_pixbuf_get_pixels (pixbuf), - gdk_pixbuf_get_width (pixbuf), - gdk_pixbuf_get_height (pixbuf), - gdk_pixbuf_get_rowstride (pixbuf)); -} - /* * ECell::realize method */ @@ -145,7 +128,7 @@ check_cache (ECellToggleView *toggle_view, int image_seq, int cache_seq) gdk_pixmap_new (toggle_view->canvas->layout.bin_window, width, height, gtk_widget_get_visual (GTK_WIDGET (toggle_view->canvas))->depth); - + switch (cache_seq % 3) { case 0: color = GTK_WIDGET (toggle_view->canvas)->style->bg [GTK_STATE_SELECTED]; @@ -195,7 +178,7 @@ etog_draw (ECellView *ecell_view, GdkDrawable *drawable, GdkPixbuf *image; int x, y, width, height; int cache_seq; - + const int value = GPOINTER_TO_INT ( e_table_model_value_at (ecell_view->e_table_model, model_col, row)); @@ -272,7 +255,7 @@ etog_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, return FALSE; #endif - switch (event->type){ + switch (event->type){ case GDK_KEY_PRESS: if (event->key.keyval != GDK_space) return FALSE; @@ -280,7 +263,7 @@ etog_event (ECellView *ecell_view, GdkEvent *event, int model_col, int view_col, case GDK_BUTTON_PRESS: if (!e_table_model_is_cell_editable(ecell_view->e_table_model, model_col, row)) return FALSE; - + etog_set_value (toggle_view, model_col, view_col, row, value + 1); return TRUE; @@ -304,34 +287,41 @@ etog_height (ECellView *ecell_view, int model_col, int view_col, int row) * ECell::print method */ static void -etog_print (ECellView *ecell_view, GnomePrintContext *context, +etog_print (ECellView *ecell_view, GtkPrintContext *context, int model_col, int view_col, int row, double width, double height) { ECellToggle *toggle = E_CELL_TOGGLE(ecell_view->ecell); GdkPixbuf *image; + double image_width, image_height; const int value = GPOINTER_TO_INT ( e_table_model_value_at (ecell_view->e_table_model, model_col, row)); - if (value >= toggle->n_states){ + cairo_t *cr; + if (value >= toggle->n_states){ g_warning ("Value from the table model is %d, the states we support are [0..%d)\n", value, toggle->n_states); return; } - gnome_print_gsave(context); - - image = toggle->images[value]; - - gnome_print_translate (context, 0, (height - toggle->height) / 2); - gnome_print_scale (context, toggle->height, toggle->height); - gnome_print_pixbuf (context, image); - - gnome_print_grestore(context); + cr = gtk_print_context_get_cairo_context (context); + cairo_save(cr); + image = toggle->images[value]; + cairo_translate (cr, 0 , 0); + image = gdk_pixbuf_add_alpha (image, TRUE, 255, 255, 255); + image_width = (double)gdk_pixbuf_get_width (image); + image_height = (double)gdk_pixbuf_get_height (image); + cairo_rectangle (cr, image_width / 7, image_height / 3, + image_width - image_width / 4, + image_width - image_height / 7); + cairo_clip (cr); + gdk_cairo_set_source_pixbuf (cr, image, 0, image_height / 4); + cairo_paint (cr); + cairo_restore(cr); } static gdouble -etog_print_height (ECellView *ecell_view, GnomePrintContext *context, +etog_print_height (ECellView *ecell_view, GtkPrintContext *context, int model_col, int view_col, int row, double width) { @@ -414,7 +404,7 @@ e_cell_toggle_class_init (GtkObjectClass *object_class) parent_class = g_type_class_ref (PARENT_TYPE); gal_a11y_e_cell_registry_add_cell_type (NULL, - E_CELL_TOGGLE_TYPE, + E_CELL_TOGGLE_TYPE, gal_a11y_e_cell_toggle_new); } diff --git a/widgets/table/e-cell.c b/widgets/table/e-cell.c index b27badc348..0679cffd53 100644 --- a/widgets/table/e-cell.c +++ b/widgets/table/e-cell.c @@ -1,4 +1,4 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ + /*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ /* * e-cell.c - base class for cell renderers in e-table * Copyright 1999, 2000, 2001, Ximian, Inc. @@ -23,7 +23,7 @@ */ #include <config.h> - +#include <gtk/gtk.h> #include "e-util/e-util.h" #include "e-cell.h" @@ -280,7 +280,7 @@ e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable, /** * e_cell_print: * @ecell_view: the ECellView to redraw - * @context: The GnomePrintContext where we output our printed data. + * @context: The GtkPrintContext where we output our printed data. * @model_col: the column in the model being drawn. * @view_col: the column in the view being drawn (what the model maps to). * @row: the row being drawn @@ -290,7 +290,7 @@ e_cell_draw (ECellView *ecell_view, GdkDrawable *drawable, * FIXME: */ void -e_cell_print (ECellView *ecell_view, GnomePrintContext *context, +e_cell_print (ECellView *ecell_view, GtkPrintContext *context, int model_col, int view_col, int row, double width, double height) { @@ -304,7 +304,7 @@ e_cell_print (ECellView *ecell_view, GnomePrintContext *context, * FIXME: */ gdouble -e_cell_print_height (ECellView *ecell_view, GnomePrintContext *context, +e_cell_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 fabe7bf372..526d8995e7 100644 --- a/widgets/table/e-cell.h +++ b/widgets/table/e-cell.h @@ -26,6 +26,7 @@ #define _E_CELL_H_ #include <gdk/gdktypes.h> +#include <gtk/gtk.h> #include <libgnomeprint/gnome-print.h> #include <libgnomeprint/gnome-font.h> #include <table/e-table-model.h> @@ -107,10 +108,10 @@ typedef struct { void *(*save_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *context); void (*load_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *context, void *save_state); void (*free_state) (ECellView *ecell_view, int model_col, int view_col, int row, void *save_state); - void (*print) (ECellView *ecell_view, GnomePrintContext *context, + void (*print) (ECellView *ecell_view, GtkPrintContext *context, int model_col, int view_col, int row, gdouble width, gdouble height); - gdouble (*print_height) (ECellView *ecell_view, GnomePrintContext *context, + gdouble (*print_height) (ECellView *ecell_view,GtkPrintContext *context, int model_col, int view_col, int row, gdouble width); int (*max_width) (ECellView *ecell_view, int model_col, int view_col); int (*max_width_by_row) (ECellView *ecell_view, int model_col, int view_col, int row); @@ -149,14 +150,14 @@ void e_cell_draw (ECellView *ecell_view, int x2, int y2); void e_cell_print (ECellView *ecell_view, - GnomePrintContext *context, + GtkPrintContext *context, int model_col, int view_col, int row, double width, double height); gdouble e_cell_print_height (ECellView *ecell_view, - GnomePrintContext *context, + GtkPrintContext *context, int model_col, int view_col, int row, diff --git a/widgets/table/e-table-group-container.c b/widgets/table/e-table-group-container.c index 86a8036450..f2060db1ad 100644 --- a/widgets/table/e-table-group-container.c +++ b/widgets/table/e-table-group-container.c @@ -1063,7 +1063,7 @@ etgc_init (GtkObject *object) { ETableGroupContainer *container = E_TABLE_GROUP_CONTAINER(object); container->children = FALSE; - + e_canvas_item_set_reflow_callback (GNOME_CANVAS_ITEM(object), etgc_reflow); container->alternating_row_colors = 1; @@ -1110,32 +1110,18 @@ typedef struct { EPrintable *child_printable; } ETGCPrintContext; -#if 0 -#define CHECK(x) if((x) == -1) return -1; -static gint -gp_draw_rect (GnomePrintContext *context, gdouble x, gdouble y, gdouble width, gdouble height, gdouble r, gdouble g, gdouble b) -{ - 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); -} -#endif #define CHECK(x) if((x) == -1) return -1; static gint -gp_draw_rect (GnomePrintContext *context, gdouble x, gdouble y, gdouble width, gdouble height) +gp_draw_rect (GtkPrintContext *context, double x, double y, double width, double 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); + cairo_t *cr; + cr = gtk_print_context_get_cairo_context (context); + cairo_move_to (cr, x, y); + cairo_rectangle (cr, x, y, x + width, y + height); + cairo_fill (cr); } #define TEXT_HEIGHT (12) @@ -1143,12 +1129,13 @@ gp_draw_rect (GnomePrintContext *context, gdouble x, gdouble y, gdouble width, g static void e_table_group_container_print_page (EPrintable *ep, - GnomePrintContext *context, + GtkPrintContext *context, gdouble width, gdouble height, gboolean quantize, ETGCPrintContext *groupcontext) -{ +{ + cairo_t *cr; gdouble yd = height; gdouble child_height; ETableGroupContainerChildNode *child_node; @@ -1159,6 +1146,8 @@ e_table_group_container_print_page (EPrintable *ep, child_printable = groupcontext->child_printable; child = groupcontext->child; + yd = 6.5 * 72; + height = 5 * 72; if (child_printable) { if (child) @@ -1179,50 +1168,21 @@ e_table_group_container_print_page (EPrintable *ep, } while (1) { - child_height = e_printable_height(child_printable, context, width - 36, yd - TEXT_AREA_HEIGHT, quantize); - - if (gnome_print_gsave(context) == -1) - /* FIXME */; - if (gnome_print_moveto(context, 0, yd - child_height - TEXT_AREA_HEIGHT) == -1) - /* FIXME */; - if (gnome_print_lineto(context, 36, yd - child_height - TEXT_AREA_HEIGHT) == -1) - /* FIXME */; - if (gnome_print_lineto(context, 36, yd - TEXT_AREA_HEIGHT) == -1) - /* FIXME */; - if (gnome_print_lineto(context, width, yd - TEXT_AREA_HEIGHT) == -1) - /* FIXME */; - if (gnome_print_lineto(context, width, yd) == -1) - /* FIXME */; - if (gnome_print_lineto(context, 0, yd) == -1) - /* FIXME */; - if (gnome_print_lineto(context, 0, yd - child_height - TEXT_AREA_HEIGHT) == -1) - /* FIXME */; - if (gnome_print_setrgbcolor(context, .7, .7, .7) == -1) - /* FIXME */; - if (gnome_print_fill(context) == -1) - /* FIXME */; - if (gnome_print_grestore(context) == -1) - /* FIXME */; - - if (gnome_print_gsave(context) == -1) - /* FIXME */; - if (gnome_print_moveto(context, 0, yd - TEXT_AREA_HEIGHT) == -1) - /* FIXME */; - if (gnome_print_lineto(context, width, yd - TEXT_AREA_HEIGHT) == -1) - /* FIXME */; - if (gnome_print_lineto(context, width, yd) == -1) - /* FIXME */; - if (gnome_print_lineto(context, 0, yd) == -1) - /* FIXME */; - if (gnome_print_lineto(context, 0, yd - TEXT_AREA_HEIGHT) == -1) - /* FIXME */; - if (gnome_print_clip(context) == -1) - /* FIXME */; - - if (gnome_print_moveto(context, 2, yd - (TEXT_AREA_HEIGHT + gnome_font_get_ascender(font) - gnome_font_get_descender(font)) / 2) == -1) - /* FIXME */; - if (gnome_print_setfont(context, font)) - /* FIXME */; + 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); if (groupcontext->etgc->ecol->text) string = g_strdup_printf ("%s : %s (%d item%s)", groupcontext->etgc->ecol->text, @@ -1234,63 +1194,38 @@ e_table_group_container_print_page (EPrintable *ep, child_node->string, (gint) child_node->count, child_node->count == 1 ? "" : "s"); - if (gnome_print_show(context, string)) - /* FIXME */; - g_free(string); - if (gnome_print_grestore(context) == -1) - /* FIXME */; - - if (gnome_print_gsave(context) == -1) - /* FIXME */; - if (gnome_print_translate(context, 36, yd - TEXT_AREA_HEIGHT - child_height) == -1) - /* FIXME */; - if (gnome_print_moveto(context, 0, 0) == -1) - /* FIXME */; - if (gnome_print_lineto(context, width - 36, 0) == -1) - /* FIXME */; - if (gnome_print_lineto(context, width - 36, child_height) == -1) - /* FIXME */; - if (gnome_print_lineto(context, 0, child_height) == -1) - /* FIXME */; - if (gnome_print_lineto(context, 0, 0) == -1) - /* FIXME */; - if (gnome_print_clip(context) == -1) - /* FIXME */; - e_printable_print_page(child_printable, context, width - 36, child_height, quantize); - if (gnome_print_grestore(context) == -1) - /* FIXME */; - - gp_draw_rect(context, 0, yd - child_height - TEXT_AREA_HEIGHT + 1, width, 1); - gp_draw_rect(context, width - 1, yd, 1, yd - child_height - TEXT_AREA_HEIGHT); - gp_draw_rect(context, 0, yd, 1, yd - child_height - TEXT_AREA_HEIGHT); - - yd -= child_height + TEXT_AREA_HEIGHT; + 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); + + 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; - child = child->next; + child = child->next; if (!child) { child_printable = NULL; break; } - child_node = child->data; + child_node = child->data; if (child_printable) g_object_unref (child_printable); - child_printable = e_table_group_get_printable(child_node->child); + child_printable = e_table_group_get_printable(child_node->child); if (child_printable) g_object_ref (child_printable); - e_printable_reset(child_printable); + e_printable_reset(child_printable); } - - gp_draw_rect(context, 0, height, width, 1); - if (groupcontext->child_printable) g_object_unref (groupcontext->child_printable); groupcontext->child_printable = child_printable; groupcontext->child = child; - } static gboolean @@ -1313,7 +1248,7 @@ e_table_group_container_reset (EPrintable *ep, static gdouble e_table_group_container_height (EPrintable *ep, - GnomePrintContext *context, + GtkPrintContext *context, gdouble width, gdouble max_height, gboolean quantize, @@ -1350,14 +1285,14 @@ e_table_group_container_height (EPrintable *ep, while (1) { child_height = e_printable_height(child_printable, context, width - 36, yd - (yd == -1 ? 0 : TEXT_AREA_HEIGHT), quantize); - height += child_height + TEXT_AREA_HEIGHT; + height -= child_height + TEXT_AREA_HEIGHT; if (yd != -1) { if (!e_printable_will_fit(child_printable, context, width - 36, yd - (yd == -1 ? 0 : TEXT_AREA_HEIGHT), quantize)) { break; } - yd -= child_height + TEXT_AREA_HEIGHT; + yd += child_height + TEXT_AREA_HEIGHT; } child = child->next; @@ -1381,7 +1316,7 @@ e_table_group_container_height (EPrintable *ep, static gboolean e_table_group_container_will_fit (EPrintable *ep, - GnomePrintContext *context, + GtkPrintContext *context, gdouble width, gdouble max_height, gboolean quantize, @@ -1424,7 +1359,7 @@ e_table_group_container_will_fit (EPrintable *ep, break; } - yd -= child_height + TEXT_AREA_HEIGHT; + yd += child_height + TEXT_AREA_HEIGHT; } child = child->next; diff --git a/widgets/table/e-table-item.c b/widgets/table/e-table-item.c index c095b84c05..0936c03f31 100644 --- a/widgets/table/e-table-item.c +++ b/widgets/table/e-table-item.c @@ -98,7 +98,7 @@ enum { PROP_LENGTH_THRESHOLD, PROP_CURSOR_ROW, PROP_UNIFORM_ROW_HEIGHT, - + PROP_MINIMUM_WIDTH, PROP_WIDTH, PROP_HEIGHT @@ -334,7 +334,7 @@ eti_free_save_state (ETableItem *eti) * we might want to avoid realizing each e-cell. */ static void -eti_realize_cell_views (ETableItem *eti) +eti_realize_cell_views ( ETableItem *eti) { int i; @@ -1939,7 +1939,6 @@ eti_draw (GnomeCanvasItem *item, GdkDrawable *drawable, int x, int y, int width, height = ETI_ROW_HEIGHT (eti, row); xd = x_offset; -/* printf ("paint: %d %d\n", yd, yd + height); */ selected = e_selection_model_is_row_selected(E_SELECTION_MODEL (eti->selection), view_to_model_row(eti,row)); @@ -2084,7 +2083,7 @@ find_cell (ETableItem *eti, double x, double y, int *view_col_res, int *view_row int col, row; int height_extra = eti->horizontal_draw_grid ? 1 : 0; - + /* FIXME: this routine is inneficient, fix later */ if (eti->grabbed_col >= 0 && eti->grabbed_row >= 0) { @@ -2447,6 +2446,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e) } #endif + if (!find_cell (eti, e->button.x, e->button.y, &col, &row, &x1, &y1)) return TRUE; @@ -2654,6 +2654,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e) break; } + g_signal_emit (eti, eti_signals [KEY_PRESS], 0, model_to_view_row(eti, cursor_row), cursor_col, e, &return_val); if ((!return_val) && @@ -2686,6 +2687,7 @@ eti_event (GnomeCanvasItem *item, GdkEvent *e) if ((e->key.state & GDK_MOD1_MASK) && ((e->key.keyval == GDK_Down ) || (e->key.keyval == GDK_KP_Down))) { gint view_col = model_to_view_col(eti, cursor_col); + if ((view_col >= 0) && (view_col < eti->cols)) if (eti_e_cell_event (eti, eti->cell_views [view_col], e, ((GdkEventKey *)e)->time, cursor_col, view_col, model_to_view_row(eti, cursor_row), E_CELL_CURSOR)) return TRUE; @@ -3450,7 +3452,7 @@ e_table_item_calculate_print_widths (ETableHeader *eth, gdouble width) } static gdouble -eti_printed_row_height (ETableItem *eti, gdouble *widths, GnomePrintContext *context, gint row) +eti_printed_row_height (ETableItem *eti, gdouble *widths, GtkPrintContext *context, gint row) { int col; int cols = eti->cols; @@ -3468,106 +3470,106 @@ eti_printed_row_height (ETableItem *eti, gdouble *widths, GnomePrintContext *con #define CHECK(x) if((x) == -1) return -1; static gint -gp_draw_rect (GnomePrintContext *context, gdouble x, gdouble y, gdouble width, gdouble height) +gp_draw_rect (GtkPrintContext *context, double x, double y, double width, double 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); + cairo_t *cr; + cr = gtk_print_context_get_cairo_context (context); + cairo_save (cr); + cairo_rectangle (cr, x, y, width, height); + cairo_set_line_width (cr, 0.5); + cairo_stroke (cr); + cairo_restore (cr); + return 0; } static void e_table_item_print_page (EPrintable *ep, - GnomePrintContext *context, - gdouble width, - gdouble height, + GtkPrintContext *context, + double width, + double height, gboolean quantize, ETableItemPrintContext *itemcontext) { ETableItem *eti = itemcontext->item; const int rows = eti->rows; const int cols = eti->cols; + gdouble max_height; int rows_printed = itemcontext->rows_printed; + int row, col, next_page = 0; + double yd = height; + cairo_t *cr; gdouble *widths; - int row, col; - gdouble yd = height; - + + cr = gtk_print_context_get_cairo_context (context); + max_height = gtk_print_context_get_height (context); widths = e_table_item_calculate_print_widths (itemcontext->item->header, width); /* * Draw cells */ + if (eti->horizontal_draw_grid){ gp_draw_rect(context, 0, yd, width, 1); } - yd--; - - for (row = rows_printed; row < rows; row++){ + yd++; + + for (row = rows_printed; row < rows ; row++){ gdouble xd = 1, row_height; - row_height = eti_printed_row_height(eti, widths, context, row); + if (quantize) { - if (yd - row_height - 1 < 0 && row != rows_printed) { + if (yd + row_height + 1 > max_height && row != rows_printed) { + next_page = 1; break; } } else { - if (yd < 0) { + if (yd > max_height) { + next_page = 1; break; - } - } - + } + } + for (col = 0; col < cols; col++){ ECellView *ecell_view = eti->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, view_to_model_col(eti, col), col, row, - widths[col] - 1, row_height); - - if (gnome_print_grestore(context) == -1) - /* FIXME */; + cairo_save(cr); + cairo_translate(cr, xd, yd); + cairo_rectangle (cr, 0, 0, widths[col] - 1, row_height); + cairo_clip(cr); + + e_cell_print (ecell_view, context, + view_to_model_col(eti, col), + col, + row, + widths[col] - 1, + row_height + 2 ); + + cairo_restore (cr); xd += widths[col]; } - yd -= row_height; - + + yd += row_height; if (eti->horizontal_draw_grid){ gp_draw_rect(context, 0, yd, width, 1); } - yd--; - } + yd ++; + } itemcontext->rows_printed = row; - if (eti->vertical_draw_grid){ gdouble xd = 0; - for (col = 0; col < cols; col++){ - gp_draw_rect(context, xd, height, 1, height - yd); - + gp_draw_rect(context, xd, height, 1, yd - height); xd += widths[col]; } - gp_draw_rect(context, xd, height, 1, height - yd); + gp_draw_rect(context, xd, height, 1, yd - height); } + if (next_page) { + cairo_show_page (cr); + next_page = 0; + } + g_free (widths); } @@ -3591,7 +3593,7 @@ e_table_item_reset (EPrintable *ep, static gdouble e_table_item_height (EPrintable *ep, - GnomePrintContext *context, + GtkPrintContext *context, gdouble width, gdouble max_height, gboolean quantize, @@ -3641,7 +3643,7 @@ e_table_item_height (EPrintable *ep, static gboolean e_table_item_will_fit (EPrintable *ep, - GnomePrintContext *context, + GtkPrintContext *context, gdouble width, gdouble max_height, gboolean quantize, |