aboutsummaryrefslogtreecommitdiffstats
path: root/mail
diff options
context:
space:
mode:
authorSrinivasa Ragavan <sragavan@novell.com>2007-01-23 00:41:31 +0800
committerSrinivasa Ragavan <sragavan@src.gnome.org>2007-01-23 00:41:31 +0800
commit2a1d77a838cd309647088f13b81afce46d5ae90e (patch)
tree9f26bb2f33a3b9fa5f24578515939692abe2171f /mail
parent0b9195cb2c24add072671f82d1d1498b78a8b217 (diff)
downloadgsoc2013-evolution-2a1d77a838cd309647088f13b81afce46d5ae90e.tar
gsoc2013-evolution-2a1d77a838cd309647088f13b81afce46d5ae90e.tar.gz
gsoc2013-evolution-2a1d77a838cd309647088f13b81afce46d5ae90e.tar.bz2
gsoc2013-evolution-2a1d77a838cd309647088f13b81afce46d5ae90e.tar.lz
gsoc2013-evolution-2a1d77a838cd309647088f13b81afce46d5ae90e.tar.xz
gsoc2013-evolution-2a1d77a838cd309647088f13b81afce46d5ae90e.tar.zst
gsoc2013-evolution-2a1d77a838cd309647088f13b81afce46d5ae90e.zip
** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22
2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. 2006-01-22 Srinivasa Ragavan <sragavan@novell.com> ** Committing Ebby Wiselyn's patch for GtkPrint API migration. svn path=/trunk/; revision=33134
Diffstat (limited to 'mail')
-rw-r--r--mail/ChangeLog10
-rw-r--r--mail/em-folder-view.c62
-rw-r--r--mail/em-format-html-print.c147
-rw-r--r--mail/em-format-html-print.h11
4 files changed, 143 insertions, 87 deletions
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 */