diff options
author | Radek Doulik <rodo@src.gnome.org> | 2002-01-30 03:37:29 +0800 |
---|---|---|
committer | Radek Doulik <rodo@src.gnome.org> | 2002-01-30 03:37:29 +0800 |
commit | 2488e2dfc18e22e5839fcd234d9b2b625f4cedfd (patch) | |
tree | 7ba10fd580734e3d48fb28413e3e147df54a4f4e /mail/mail-callbacks.c | |
parent | ac9c64ee1a3da02cf815b2f2d1157cbd79d152d9 (diff) | |
download | gsoc2013-evolution-2488e2dfc18e22e5839fcd234d9b2b625f4cedfd.tar.gz gsoc2013-evolution-2488e2dfc18e22e5839fcd234d9b2b625f4cedfd.tar.zst gsoc2013-evolution-2488e2dfc18e22e5839fcd234d9b2b625f4cedfd.zip |
(do_mail_print): get rid of static global variables, as they are
not thread safe (thanks to clahey for pointing this out)
svn path=/trunk/; revision=15508
Diffstat (limited to 'mail/mail-callbacks.c')
-rw-r--r-- | mail/mail-callbacks.c | 57 |
1 files changed, 36 insertions, 21 deletions
diff --git a/mail/mail-callbacks.c b/mail/mail-callbacks.c index 3d504c3a5c..2ee006cdbb 100644 --- a/mail/mail-callbacks.c +++ b/mail/mail-callbacks.c @@ -2378,42 +2378,62 @@ providers_config (BonoboUIComponent *uih, void *user_data, const char *path) } } -static void +/* static void header_print_cb (GtkHTML *html, GnomePrintContext *print_context, double x, double y, double width, double height, gpointer user_data) { - /* printf ("header_print_cb %f,%f x %f,%f\n", x, y, width, height); + printf ("header_print_cb %f,%f x %f,%f\n", x, y, width, height); gnome_print_newpath (print_context); gnome_print_setlinewidth (print_context, 12.0); gnome_print_setrgbcolor (print_context, 1.0, 0.0, 0.0); gnome_print_moveto (print_context, x, y); gnome_print_lineto (print_context, x+width, y-height); - gnome_print_strokepath (print_context); */ -} + gnome_print_strokepath (print_context); +} */ -static GnomeFont *local_font = NULL; -static gint page_num, pages; +struct footer_info { + GnomeFont *local_font; + gint page_num, pages; +}; static void footer_print_cb (GtkHTML *html, GnomePrintContext *print_context, double x, double y, double width, double height, gpointer user_data) { - if (local_font) { - gchar *text = g_strdup_printf (_("Page %d of %d"), page_num, pages); - gdouble tw = gnome_font_get_width_string (local_font, text); + struct footer_info *info = (struct footer_info *) user_data; + + if (info->local_font) { + gchar *text = g_strdup_printf (_("Page %d of %d"), info->page_num, info->pages); + gdouble tw = gnome_font_get_width_string (info->local_font, text); 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 (local_font)); - gnome_print_setfont (print_context, local_font); + 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); g_free (text); - page_num++; + info->page_num++; } } +static struct footer_info * +footer_info_new (GtkHTML *html, GnomePrintContext *pc, gdouble *line) +{ + struct footer_info *info; + + info = g_new (struct footer_info, 1); + info->local_font = gnome_font_new_closest ("Helvetica", GNOME_FONT_BOOK, FALSE, 10); + 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 (html, pc, 0.0, *line); + + return info; +} + static void do_mail_print (FolderBrowser *fb, gboolean preview) { @@ -2425,6 +2445,7 @@ do_mail_print (FolderBrowser *fb, gboolean preview) gdouble line = 0.0; int copies = 1; int collate = FALSE; + struct footer_info *info; if (!preview) { dialog = GNOME_PRINT_DIALOG (gnome_print_dialog_new (_("Print Message"), @@ -2469,15 +2490,9 @@ do_mail_print (FolderBrowser *fb, gboolean preview) mail_display_render (fb->mail_display, html); gtk_html_print_set_master (html, print_master); - if (!local_font) { - local_font = gnome_font_new_closest ("Helvetica", GNOME_FONT_BOOK, FALSE, 10); - } - if (local_font) { - line = gnome_font_get_ascender (local_font) + gnome_font_get_descender (local_font); - } - page_num = 1; - pages = gtk_html_print_get_pages_num (html, print_context, 0.0, line); - gtk_html_print_with_header_footer (html, print_context, 0.0, line, NULL, footer_print_cb, NULL); + info = footer_info_new (html, print_context, &line); + gtk_html_print_with_header_footer (html, print_context, 0.0, line, NULL, footer_print_cb, info); + g_free (info); fb->mail_display->printing = FALSE; |