From 624146d0d722e91857fb32f68ab6eabfd1db7aa8 Mon Sep 17 00:00:00 2001 From: Vivek Jain Date: Thu, 19 May 2005 13:48:21 +0000 Subject: Plugin to provide "print" option to composer. Files added: 2005-05-19 Vivek Jain Plugin to provide "print" option to composer. Files added: * print-message.c * Makefile.am * org-gnome-print-message.eplug.xml * org-gnome-print-message.xml svn path=/trunk/; revision=29388 --- plugins/print-message/ChangeLog | 9 ++ plugins/print-message/Makefile.am | 16 ++++ .../org-gnome-print-message.eplug.xml | 31 ++++++ plugins/print-message/org-gnome-print-message.xml | 17 ++++ plugins/print-message/print-message.c | 106 +++++++++++++++++++++ 5 files changed, 179 insertions(+) create mode 100644 plugins/print-message/ChangeLog create mode 100644 plugins/print-message/Makefile.am create mode 100644 plugins/print-message/org-gnome-print-message.eplug.xml create mode 100644 plugins/print-message/org-gnome-print-message.xml create mode 100644 plugins/print-message/print-message.c (limited to 'plugins') diff --git a/plugins/print-message/ChangeLog b/plugins/print-message/ChangeLog new file mode 100644 index 0000000000..c393c49b2b --- /dev/null +++ b/plugins/print-message/ChangeLog @@ -0,0 +1,9 @@ +2005-05-19 Vivek Jain + + Plugin to provide "print" option to composer. Files added: + + * print-message.c + * Makefile.am + * org-gnome-print-message.eplug.xml + * org-gnome-print-message.xml + diff --git a/plugins/print-message/Makefile.am b/plugins/print-message/Makefile.am new file mode 100644 index 0000000000..f039acd514 --- /dev/null +++ b/plugins/print-message/Makefile.am @@ -0,0 +1,16 @@ +INCLUDES = \ + -I$(top_srcdir) \ + $(EVOLUTION_MAIL_CFLAGS) + +@EVO_PLUGIN_RULE@ + +plugin_DATA = org-gnome-print-message.eplug org-gnome-print-message.xml +plugin_LTLIBRARIES = liborg-gnome-print-message.la + +liborg_gnome_print_message_la_SOURCES = print-message.c +liborg_gnome_print_message_la_LDFLAGS = -module -avoid-version + +EXTRA_DIST = \ + org-gnome-compose-print-message.eplug.xml\ + org-gnome-compose-print-message.xml +CLEANFILES = $(BUILT_SOURCES) diff --git a/plugins/print-message/org-gnome-print-message.eplug.xml b/plugins/print-message/org-gnome-print-message.eplug.xml new file mode 100644 index 0000000000..8a21072b52 --- /dev/null +++ b/plugins/print-message/org-gnome-print-message.eplug.xml @@ -0,0 +1,31 @@ + + + + <_description>Gives an option to print mail from composer + + + + + + + + + + + + + diff --git a/plugins/print-message/org-gnome-print-message.xml b/plugins/print-message/org-gnome-print-message.xml new file mode 100644 index 0000000000..49d6f2cfe0 --- /dev/null +++ b/plugins/print-message/org-gnome-print-message.xml @@ -0,0 +1,17 @@ + + + + + + + + + + + + + + + diff --git a/plugins/print-message/print-message.c b/plugins/print-message/print-message.c new file mode 100644 index 0000000000..aac3217eab --- /dev/null +++ b/plugins/print-message/print-message.c @@ -0,0 +1,106 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- + * + * Authors: Vivek Jain + * + * Copyright 2004 Novell, Inc. (www.novell.com) + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA. + * + */ + + +#include +#include +#include +#include +#include +#include +#include "mail/em-format-html-display.h" +#include "mail/em-format-html-print.h" +#include +#include +#include +#include "mail/em-menu.h" +#include "mail/em-utils.h" +#include "e-util/e-print.h" +#include "composer/e-msg-composer.h" + +void org_gnome_compose_print_message (EPlugin *ep, EMMenuTargetWidget *t); + +struct _print_data { + GnomePrintConfig *config; + CamelMimeMessage *msg; + int preview; +}; + +static void +print_response (GtkWidget *w, int resp, struct _print_data *data) +{ + EMFormatHTMLPrint *print; + + 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_html_print_raw_message(print, data->config, data->msg, data->preview); + g_object_unref(print); + break; + } + + if (w) + gtk_widget_destroy(w); + + e_print_save_config (data->config); + g_object_unref(data->config); + g_free(data); + +} + +void +org_gnome_print_message (EPlugin *ep, EMMenuTargetWidget *t) +{ + + EMsgComposer *composer = (EMsgComposer *)t->target.widget; + struct _print_data *data; + + data = g_malloc0(sizeof(*data)); + data->config = e_print_load_config (); + data->preview = 0; + + data->msg = e_msg_composer_get_message (composer, 1); + 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); + e_dialog_set_transient_for ((GtkWindow *) dialog, (GtkWidget *) composer); + g_signal_connect(dialog, "response", G_CALLBACK(print_response), data); + gtk_widget_show((GtkWidget *)dialog); + +} + +void +org_gnome_print_preview (EPlugin *ep, EMMenuTargetWidget *t) +{ + EMsgComposer *composer = (EMsgComposer *)t->target.widget; + struct _print_data *data; + + data = g_malloc0(sizeof(*data)); + data->config = e_print_load_config (); + data->preview = 0; + + data->msg = e_msg_composer_get_message (composer, 1); + + print_response(NULL, GNOME_PRINT_DIALOG_RESPONSE_PREVIEW, data); +} + + -- cgit v1.2.3